forked from dotnet/corefx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving System.Security.Permissions Types from WPF
* moved wpf types * added new types to ref * addressed comments * addressing comments * addressed more comments * addressed comment * updated ref * added typeforwardedfrom and addressed comment * updated publickeytoken * added tests, addressed comments * added mediapermissionattribute test
- Loading branch information
Showing
10 changed files
with
389 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/System.Security.Permissions/src/System/Security/Permissions/MediaPermission.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
namespace System.Security.Permissions | ||
{ | ||
public enum MediaPermissionAudio | ||
{ | ||
NoAudio, | ||
SiteOfOriginAudio, | ||
SafeAudio, | ||
AllAudio | ||
} | ||
public enum MediaPermissionVideo | ||
{ | ||
NoVideo, | ||
SiteOfOriginVideo, | ||
SafeVideo, | ||
AllVideo, | ||
} | ||
public enum MediaPermissionImage | ||
{ | ||
NoImage, | ||
SiteOfOriginImage, | ||
SafeImage, | ||
AllImage, | ||
} | ||
sealed public class MediaPermission : CodeAccessPermission, IUnrestrictedPermission | ||
{ | ||
public MediaPermission() { } | ||
public MediaPermission(PermissionState state) { } | ||
public MediaPermission(MediaPermissionAudio permissionAudio) { } | ||
public MediaPermission(MediaPermissionVideo permissionVideo) { } | ||
public MediaPermission(MediaPermissionImage permissionImage) { } | ||
public MediaPermission(MediaPermissionAudio permissionAudio, | ||
MediaPermissionVideo permissionVideo, | ||
MediaPermissionImage permissionImage) | ||
{ } | ||
public bool IsUnrestricted() { return true; } | ||
public override bool IsSubsetOf(IPermission target) { return true; } | ||
public override IPermission Intersect(IPermission target) { return new MediaPermission(); } | ||
public override IPermission Union(IPermission target) { return new MediaPermission(); } | ||
public override IPermission Copy() { return new MediaPermission(); } | ||
public override SecurityElement ToXml() { return default(SecurityElement); } | ||
public override void FromXml(SecurityElement securityElement) { } | ||
public MediaPermissionAudio Audio { get { return MediaPermissionAudio.AllAudio; } } | ||
public MediaPermissionVideo Video { get { return MediaPermissionVideo.AllVideo; } } | ||
public MediaPermissionImage Image { get { return MediaPermissionImage.AllImage; } } | ||
} | ||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Assembly, AllowMultiple = true, Inherited = false)] | ||
sealed public class MediaPermissionAttribute : CodeAccessSecurityAttribute | ||
{ | ||
public MediaPermissionAttribute(SecurityAction action) : base(action) { } | ||
public override IPermission CreatePermission() { return new MediaPermission(); } | ||
public MediaPermissionAudio Audio { get { return MediaPermissionAudio.AllAudio; } set { } } | ||
public MediaPermissionVideo Video { get { return MediaPermissionVideo.AllVideo; } set { } } | ||
public MediaPermissionImage Image { get { return MediaPermissionImage.AllImage; } set { } } | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/System.Security.Permissions/src/System/Security/Permissions/WebBrowserPermission.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
namespace System.Security.Permissions | ||
{ | ||
public enum WebBrowserPermissionLevel | ||
{ | ||
None, | ||
Safe, | ||
Unrestricted | ||
} | ||
sealed public class WebBrowserPermission : CodeAccessPermission, IUnrestrictedPermission | ||
{ | ||
public WebBrowserPermission() { } | ||
public WebBrowserPermission(PermissionState state) { } | ||
public WebBrowserPermission(WebBrowserPermissionLevel webBrowserPermissionLevel) { } | ||
public bool IsUnrestricted() { return true; } | ||
public override bool IsSubsetOf(IPermission target) { return true; } | ||
public override IPermission Intersect(IPermission target) { return new WebBrowserPermission(); } | ||
public override IPermission Union(IPermission target) { return new WebBrowserPermission(); } | ||
public override IPermission Copy() { return new WebBrowserPermission(); } | ||
public override SecurityElement ToXml() { return default(SecurityElement); } | ||
public override void FromXml(SecurityElement securityElement) { } | ||
public WebBrowserPermissionLevel Level { get { return WebBrowserPermissionLevel.Unrestricted; } set { } } | ||
} | ||
|
||
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Assembly, AllowMultiple = true, Inherited = false)] | ||
sealed public class WebBrowserPermissionAttribute : CodeAccessSecurityAttribute | ||
{ | ||
public WebBrowserPermissionAttribute(SecurityAction action) : base(action) { } | ||
public override IPermission CreatePermission() { return new WebBrowserPermission(); } | ||
public WebBrowserPermissionLevel Level { get { return WebBrowserPermissionLevel.Unrestricted; } set { } } | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
src/System.Security.Permissions/src/System/Xaml/Permissions/XamlAccessLevel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Reflection; | ||
using System.Security; | ||
|
||
namespace System.Xaml.Permissions | ||
{ | ||
public class XamlAccessLevel | ||
{ | ||
private XamlAccessLevel(string assemblyName, string typeName) | ||
{ | ||
AssemblyNameString = assemblyName; | ||
PrivateAccessToTypeName = typeName; | ||
} | ||
|
||
public static XamlAccessLevel AssemblyAccessTo(Assembly assembly) | ||
{ | ||
return new XamlAccessLevel(assembly.FullName, null); | ||
} | ||
|
||
public static XamlAccessLevel AssemblyAccessTo(AssemblyName assemblyName) | ||
{ | ||
return new XamlAccessLevel(assemblyName.FullName, null); | ||
} | ||
|
||
public static XamlAccessLevel PrivateAccessTo(Type type) | ||
{ | ||
return new XamlAccessLevel(type.Assembly.FullName, type.FullName); | ||
} | ||
|
||
public static XamlAccessLevel PrivateAccessTo(string assemblyQualifiedTypeName) | ||
{ | ||
int nameBoundary = assemblyQualifiedTypeName.IndexOf(','); | ||
string typeName = assemblyQualifiedTypeName.Substring(0, nameBoundary).Trim(); | ||
string assemblyFullName = assemblyQualifiedTypeName.Substring(nameBoundary + 1).Trim(); | ||
AssemblyName assemblyName = new AssemblyName(assemblyFullName); | ||
return new XamlAccessLevel(assemblyName.FullName, typeName); | ||
} | ||
|
||
public AssemblyName AssemblyAccessToAssemblyName | ||
{ | ||
get { return new AssemblyName(AssemblyNameString); } | ||
} | ||
|
||
public string PrivateAccessToTypeName { get; private set; } | ||
|
||
internal string AssemblyNameString { get; private set; } | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/System.Security.Permissions/src/System/Xaml/Permissions/XamlLoadPermission.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Runtime.InteropServices; | ||
using System.Security; | ||
using System.Security.Permissions; | ||
|
||
namespace System.Xaml.Permissions | ||
{ | ||
public sealed class XamlLoadPermission : CodeAccessPermission, IUnrestrictedPermission | ||
{ | ||
public XamlLoadPermission(PermissionState state) { } | ||
public XamlLoadPermission(XamlAccessLevel allowedAccess) { } | ||
public XamlLoadPermission(IEnumerable<XamlAccessLevel> allowedAccess) { } | ||
[ComVisible(false)] | ||
public override bool Equals(object obj) { return ReferenceEquals(this, obj); } | ||
[ComVisible(false)] | ||
public override int GetHashCode() { return base.GetHashCode(); } | ||
public IList<XamlAccessLevel> AllowedAccess { get; private set; } = new ReadOnlyCollection<XamlAccessLevel>(Array.Empty<XamlAccessLevel>()); | ||
public override IPermission Copy() { return new XamlLoadPermission(PermissionState.Unrestricted); } | ||
public override void FromXml(SecurityElement elem) { } | ||
public bool Includes(XamlAccessLevel requestedAccess) { return true; } | ||
public override IPermission Intersect(IPermission target) { return new XamlLoadPermission(PermissionState.Unrestricted); } | ||
public override bool IsSubsetOf(IPermission target) { return true; } | ||
public override SecurityElement ToXml() { return default(SecurityElement); } | ||
public override IPermission Union(IPermission other) { return new XamlLoadPermission(PermissionState.Unrestricted); } | ||
public bool IsUnrestricted() { return true; } | ||
} | ||
} |
Oops, something went wrong.