diff options
15 files changed, 11 insertions, 391 deletions
diff --git a/src/mscorlib/mscorlib.shared.sources.props b/src/mscorlib/mscorlib.shared.sources.props index 422d78d601..4713826ffd 100644 --- a/src/mscorlib/mscorlib.shared.sources.props +++ b/src/mscorlib/mscorlib.shared.sources.props @@ -1048,12 +1048,8 @@ <InteropTceadaptergenSources Include="$(BclSourcesRoot)\System\Runtime\InteropServices\TCEAdapterGen\TCEAdapterGenerator.cs" /> </ItemGroup> <ItemGroup> - <SecurityPrincipalSources Include="$(BclSourcesRoot)\System\Security\Principal\GenericIdentity.cs" /> - <SecurityPrincipalSources Include="$(BclSourcesRoot)\System\Security\Principal\GenericPrincipal.cs" /> <SecurityPrincipalSources Include="$(BclSourcesRoot)\System\Security\Principal\IIdentity.cs" /> <SecurityPrincipalSources Include="$(BclSourcesRoot)\System\Security\Principal\IPrincipal.cs" /> - <SecurityPrincipalSources Include="$(BclSourcesRoot)\System\Security\Principal\PrincipalPolicy.cs" /> - <SecurityPrincipalSources Include="$(BclSourcesRoot)\System\Security\Principal\TokenAccessLevels.cs" /> <SecurityPrincipalSources Include="$(BclSourcesRoot)\System\Security\Principal\TokenImpersonationLevel.cs" /> </ItemGroup> <ItemGroup> diff --git a/src/mscorlib/src/Microsoft/Win32/Win32Native.cs b/src/mscorlib/src/Microsoft/Win32/Win32Native.cs index fd0791cef2..54b0afe0aa 100644 --- a/src/mscorlib/src/Microsoft/Win32/Win32Native.cs +++ b/src/mscorlib/src/Microsoft/Win32/Win32Native.cs @@ -90,7 +90,9 @@ namespace Microsoft.Win32 { using System; using System.Security; +#if FEATURE_IMPERSONATION using System.Security.Principal; +#endif using System.Text; using System.Configuration.Assemblies; using System.Runtime.Remoting; @@ -2330,7 +2332,7 @@ namespace Microsoft.Win32 { [ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)] internal static extern int LsaFreeReturnBuffer(IntPtr handle); -#if FEATURE_IMPERSONATION || FEATURE_CORECLR +#if FEATURE_IMPERSONATION [DllImport (ADVAPI32, CharSet=CharSet.Unicode, SetLastError=true)] internal static extern bool OpenProcessToken ( @@ -2339,17 +2341,6 @@ namespace Microsoft.Win32 { [Out] out SafeAccessTokenHandle TokenHandle); #endif -#if FEATURE_CORECLR - [DllImport (ADVAPI32, CharSet=CharSet.Unicode, SetLastError=true)] - [return: MarshalAs(UnmanagedType.Bool)] - internal static extern - bool OpenThreadToken ( - [In] IntPtr ThreadHandle, - [In] TokenAccessLevels DesiredAccess, - [In, MarshalAs(UnmanagedType.Bool)] bool OpenAsSelf, - [Out] out SafeAccessTokenHandle TokenHandle); -#endif - [DllImport( ADVAPI32, EntryPoint="SetNamedSecurityInfoW", diff --git a/src/mscorlib/src/System/AppDomain.cs b/src/mscorlib/src/System/AppDomain.cs index bb21e531cf..8f876768bb 100644 --- a/src/mscorlib/src/System/AppDomain.cs +++ b/src/mscorlib/src/System/AppDomain.cs @@ -29,7 +29,9 @@ namespace System { #endif using System.Security; using System.Security.Permissions; +#if FEATURE_IMPERSONATION using System.Security.Principal; +#endif using System.Security.Policy; using System.Security.Util; using System.Collections; diff --git a/src/mscorlib/src/System/Globalization/CompareInfo.cs b/src/mscorlib/src/System/Globalization/CompareInfo.cs index 69bc5a567d..05eb061f62 100644 --- a/src/mscorlib/src/System/Globalization/CompareInfo.cs +++ b/src/mscorlib/src/System/Globalization/CompareInfo.cs @@ -32,7 +32,6 @@ namespace System.Globalization { using System.Security.Permissions; using Microsoft.Win32; using System.Security; - using System.Security.Principal; using System.Diagnostics.Contracts; // diff --git a/src/mscorlib/src/System/Globalization/CultureData.cs b/src/mscorlib/src/System/Globalization/CultureData.cs index c8c5255bfe..eee49e3c05 100644 --- a/src/mscorlib/src/System/Globalization/CultureData.cs +++ b/src/mscorlib/src/System/Globalization/CultureData.cs @@ -19,7 +19,6 @@ namespace System.Globalization using System.Runtime.Versioning; using System.Diagnostics.Contracts; using System.Security; - using System.Security.Principal; // // List of culture data diff --git a/src/mscorlib/src/System/Globalization/GlobalizationAssembly.cs b/src/mscorlib/src/System/Globalization/GlobalizationAssembly.cs index a5deed71a0..51d785b8cf 100644 --- a/src/mscorlib/src/System/Globalization/GlobalizationAssembly.cs +++ b/src/mscorlib/src/System/Globalization/GlobalizationAssembly.cs @@ -10,7 +10,6 @@ namespace System.Globalization { using System.Collections.Generic; using System.Threading; using System.Security; - using System.Security.Principal; using System.Security.Permissions; using System.Runtime.CompilerServices; using System.Runtime.ConstrainedExecution; diff --git a/src/mscorlib/src/System/IAppDomain.cs b/src/mscorlib/src/System/IAppDomain.cs index 14c2d6ffdb..bd8b876577 100644 --- a/src/mscorlib/src/System/IAppDomain.cs +++ b/src/mscorlib/src/System/IAppDomain.cs @@ -19,7 +19,9 @@ namespace System { using SecurityManager = System.Security.SecurityManager; using System.Security.Permissions; using IEvidenceFactory = System.Security.IEvidenceFactory; +#if FEATURE_IMPERSONATION using System.Security.Principal; +#endif using System.Security.Policy; using System.Security; using System.Security.Util; diff --git a/src/mscorlib/src/System/Security/FrameSecurityDescriptor.cs b/src/mscorlib/src/System/Security/FrameSecurityDescriptor.cs index a590e78c1a..8f25bda617 100644 --- a/src/mscorlib/src/System/Security/FrameSecurityDescriptor.cs +++ b/src/mscorlib/src/System/Security/FrameSecurityDescriptor.cs @@ -15,7 +15,6 @@ namespace System.Security { using System.Diagnostics.Contracts; #if !FEATURE_PAL using Microsoft.Win32.SafeHandles; - using System.Security.Principal; #endif //FrameSecurityDescriptor.cs // diff --git a/src/mscorlib/src/System/Security/Principal/GenericIdentity.cs b/src/mscorlib/src/System/Security/Principal/GenericIdentity.cs deleted file mode 100644 index 0cc80f296c..0000000000 --- a/src/mscorlib/src/System/Security/Principal/GenericIdentity.cs +++ /dev/null @@ -1,162 +0,0 @@ -// 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. - -// - -// -// -// A generic identity -// - -namespace System.Security.Principal -{ - using System; - using System.Diagnostics.Contracts; - -// Claims feature is not available in Silverlight -#if !FEATURE_CORECLR - using System.Security.Claims; - using System.Collections.Generic; - using System.Runtime.Serialization; -#endif - - [Serializable] - [System.Runtime.InteropServices.ComVisible(true)] - -#if!FEATURE_CORECLR - public class GenericIdentity : ClaimsIdentity { -#else - public class GenericIdentity : IIdentity { -#endif - - private string m_name; - private string m_type; - -#if !FEATURE_CORECLR - [SecuritySafeCritical] -#endif - public GenericIdentity (string name) { - if (name == null) - throw new ArgumentNullException("name"); - Contract.EndContractBlock(); - - m_name = name; - m_type = ""; - -#if !FEATURE_CORECLR - AddNameClaim(); -#endif - } - -#if !FEATURE_CORECLR - [SecuritySafeCritical] -#endif - public GenericIdentity (string name, string type) { - if (name == null) - throw new ArgumentNullException("name"); - if (type == null) - throw new ArgumentNullException("type"); - Contract.EndContractBlock(); - - m_name = name; - m_type = type; - -#if !FEATURE_CORECLR - AddNameClaim(); -#endif - } - -#if !FEATURE_CORECLR - GenericIdentity() - : base() - { } -#endif - -#if !FEATURE_CORECLR - - protected GenericIdentity(GenericIdentity identity) - : base(identity) - { - m_name = identity.m_name; - m_type = identity.m_type; - } - - /// <summary> - /// Returns a new instance of <see cref="GenericIdentity"/> with values copied from this object. - /// </summary> - public override ClaimsIdentity Clone() - { - return new GenericIdentity(this); - } - - public override IEnumerable<Claim> Claims - { - get - { - return base.Claims; - } - } - -#endif - -#if !FEATURE_CORECLR - public override string Name { -#else - public virtual string Name { -#endif - get { - return m_name; - } - } - -#if !FEATURE_CORECLR - public override string AuthenticationType { -#else - public virtual string AuthenticationType { -#endif - get { - return m_type; - } - } - -#if !FEATURE_CORECLR - public override bool IsAuthenticated { -#else - public virtual bool IsAuthenticated { -#endif - get { - return !m_name.Equals(""); - } - } - -#if !FEATURE_CORECLR - [OnDeserialized()] - private void OnDeserializedMethod(StreamingContext context) - { - // GenericIdentities that have been deserialized from a .net 4.0 runtime, will not have any claims. - // In this case add a name claim, otherwise assume it was deserialized. - bool claimFound = false; - foreach (Claim c in base.Claims) - { - claimFound = true; - break; - } - - if (!claimFound) - { - AddNameClaim(); - } - } - - [SecuritySafeCritical] - private void AddNameClaim() - { - if (m_name != null) - { - base.AddClaim(new Claim(base.NameClaimType, m_name, ClaimValueTypes.String, ClaimsIdentity.DefaultIssuer, ClaimsIdentity.DefaultIssuer, this)); - } - } -#endif // #if !FEATURE_CORECLR - } -} diff --git a/src/mscorlib/src/System/Security/Principal/GenericPrincipal.cs b/src/mscorlib/src/System/Security/Principal/GenericPrincipal.cs deleted file mode 100644 index 582ae536b3..0000000000 --- a/src/mscorlib/src/System/Security/Principal/GenericPrincipal.cs +++ /dev/null @@ -1,144 +0,0 @@ -// 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.Principal -{ - using System; - using System.Diagnostics.Contracts; - -#if !FEATURE_CORECLR - using System.Collections.Generic; - using System.Runtime.Serialization; - using System.Security.Claims; -#endif - - [Serializable] - [System.Runtime.InteropServices.ComVisible(true)] - -#if !FEATURE_CORECLR - public class GenericPrincipal : ClaimsPrincipal { -#else - public class GenericPrincipal : IPrincipal { -#endif - private IIdentity m_identity; - private string[] m_roles; - - public GenericPrincipal(IIdentity identity, string[] roles) { - if (identity == null) - throw new ArgumentNullException("identity"); - Contract.EndContractBlock(); - - m_identity = identity; - if (roles != null) { - m_roles = new string[roles.Length]; - for (int i = 0; i < roles.Length; ++i) { - m_roles[i] = roles[i]; - } - } - else { - m_roles = null; - } - -#if !FEATURE_CORECLR - AddIdentityWithRoles(m_identity, m_roles); - } - - [OnDeserialized()] - private void OnDeserializedMethod(StreamingContext context) - { - // Here it the matrix of possible serializations - // - // Version From | Version To | ClaimsIdentities | Roles - // ============ ========== ================ ======================================================== - // 4.0 4.5 None We always need to add a ClaimsIdentity, if Roles add them - // - // 4.5 4.5 Yes There should be a ClaimsIdentity, DebugAssert if this is not the case - // If there are roles, attach them to the first ClaimsIdentity. - // If there is no non-null ClaimsIdentity, add one. However, this is unusual and may be an issue. - - ClaimsIdentity firstNonNullIdentity = null; - foreach (var identity in base.Identities) - { - if (identity != null) - { - firstNonNullIdentity = identity; - break; - } - } - - if (m_roles != null && m_roles.Length > 0 && firstNonNullIdentity != null) - { - firstNonNullIdentity.ExternalClaims.Add(new RoleClaimProvider(ClaimsIdentity.DefaultIssuer, m_roles, firstNonNullIdentity).Claims); - } - else if (firstNonNullIdentity == null) - { - AddIdentityWithRoles(m_identity, m_roles); - } - } - - /// <summary> - /// helper method to add roles - /// </summary> - [SecuritySafeCritical] - void AddIdentityWithRoles(IIdentity identity, string[] roles) - { - ClaimsIdentity claimsIdentity = identity as ClaimsIdentity; - - if (claimsIdentity != null) - { - claimsIdentity = claimsIdentity.Clone(); - } - else - { - claimsIdentity = new ClaimsIdentity(identity); - } - - // if roles are not null then we need to add a provider - if (roles != null && roles.Length > 0) - { - claimsIdentity.ExternalClaims.Add(new RoleClaimProvider(ClaimsIdentity.DefaultIssuer, roles, claimsIdentity).Claims); - } - - base.AddIdentity(claimsIdentity); - } -#else - } -#endif - - -#if !FEATURE_CORECLR - public override IIdentity Identity { -#else - public virtual IIdentity Identity { -#endif - get { return m_identity; } - } - -#if !FEATURE_CORECLR - public override bool IsInRole(string role) { -#else - public virtual bool IsInRole (string role) { -#endif - if (role == null || m_roles == null) - return false; - - for (int i = 0; i < m_roles.Length; ++i) { - if (m_roles[i] != null && String.Compare(m_roles[i], role, StringComparison.OrdinalIgnoreCase) == 0) - return true; - } - -#if !FEATURE_CORECLR - // it may be the case a ClaimsIdentity was passed in as the IIdentity which may have contained claims, they need to be checked. - return base.IsInRole(role); -#else - return false; -#endif - } - } -} diff --git a/src/mscorlib/src/System/Security/Principal/PrincipalPolicy.cs b/src/mscorlib/src/System/Security/Principal/PrincipalPolicy.cs deleted file mode 100644 index 5391c36114..0000000000 --- a/src/mscorlib/src/System/Security/Principal/PrincipalPolicy.cs +++ /dev/null @@ -1,23 +0,0 @@ -// 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. - -// - -// -// -// Enum describing what type of principal to create by default (assuming no -// principal has been set on the AppDomain). -// - -namespace System.Security.Principal -{ - [Serializable] -[System.Runtime.InteropServices.ComVisible(true)] - public enum PrincipalPolicy { - // Note: it's important that the default policy has the value 0. - UnauthenticatedPrincipal = 0, - NoPrincipal = 1, - WindowsPrincipal = 2, - } -} diff --git a/src/mscorlib/src/System/Security/Principal/TokenAccessLevels.cs b/src/mscorlib/src/System/Security/Principal/TokenAccessLevels.cs deleted file mode 100644 index fb94a6276f..0000000000 --- a/src/mscorlib/src/System/Security/Principal/TokenAccessLevels.cs +++ /dev/null @@ -1,41 +0,0 @@ -// 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.Principal -{ - - [Serializable] - [Flags] - [System.Runtime.InteropServices.ComVisible(true)] - public enum TokenAccessLevels { - AssignPrimary = 0x00000001, - Duplicate = 0x00000002, - Impersonate = 0x00000004, - Query = 0x00000008, - QuerySource = 0x00000010, - AdjustPrivileges = 0x00000020, - AdjustGroups = 0x00000040, - AdjustDefault = 0x00000080, - AdjustSessionId = 0x00000100, - - Read = 0x00020000 | Query, - - Write = 0x00020000 | AdjustPrivileges | AdjustGroups | AdjustDefault, - - AllAccess = 0x000F0000 | - AssignPrimary | - Duplicate | - Impersonate | - Query | - QuerySource | - AdjustPrivileges | - AdjustGroups | - AdjustDefault | - AdjustSessionId, - - MaximumAllowed = 0x02000000 - } -} diff --git a/src/mscorlib/src/System/Security/SecurityContext.cs b/src/mscorlib/src/System/Security/SecurityContext.cs index 4b482b6c09..e422a312df 100644 --- a/src/mscorlib/src/System/Security/SecurityContext.cs +++ b/src/mscorlib/src/System/Security/SecurityContext.cs @@ -17,7 +17,9 @@ namespace System.Security using Microsoft.Win32.SafeHandles; using System.Threading; using System.Runtime.Remoting; +#if FEATURE_IMPERSONATION using System.Security.Principal; +#endif using System.Collections; using System.Runtime.Serialization; using System.Security.Permissions; diff --git a/src/mscorlib/src/System/Threading/ExecutionContext.cs b/src/mscorlib/src/System/Threading/ExecutionContext.cs index fb96d933f5..34cf0ae0cf 100644 --- a/src/mscorlib/src/System/Threading/ExecutionContext.cs +++ b/src/mscorlib/src/System/Threading/ExecutionContext.cs @@ -14,7 +14,9 @@ namespace System.Threading using System; using System.Security; using System.Runtime.Remoting; +#if FEATURE_IMPERSONATION using System.Security.Principal; +#endif using System.Collections; using System.Collections.Generic; using System.Reflection; diff --git a/src/mscorlib/src/System/Threading/Mutex.cs b/src/mscorlib/src/System/Threading/Mutex.cs index 6095a0036c..b656b6bc01 100644 --- a/src/mscorlib/src/System/Threading/Mutex.cs +++ b/src/mscorlib/src/System/Threading/Mutex.cs @@ -23,7 +23,6 @@ namespace System.Threading using System.Runtime.InteropServices; using System.Runtime.ConstrainedExecution; using System.Runtime.Versioning; - using System.Security.Principal; using System.Security; using System.Diagnostics.Contracts; |