[mini]Add test for PtrToStruct<T>
[mono.git] / mcs / class / corlib / System.Security.Principal / WindowsIdentity.cs
index f05857016ea232a7f622d175dd32e9a6159544c1..a36af1be59ec9ee899b61c8e938998a63906a2c8 100644 (file)
@@ -33,15 +33,15 @@ using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 using System.Runtime.Serialization;
 using System.Security.Permissions;
+using System.Security.Claims;
+using Microsoft.Win32.SafeHandles;
 
 namespace System.Security.Principal {
 
        [Serializable]
        [ComVisible (true)]
        public class WindowsIdentity :
-#if NET_4_5
        System.Security.Claims.ClaimsIdentity,
-#endif
        IIdentity, IDeserializationCallback, ISerializable, IDisposable {
                private IntPtr _token;
                private string _type;
@@ -52,6 +52,9 @@ namespace System.Security.Principal {
 
                static private IntPtr invalidWindows = IntPtr.Zero;
 
+               [NonSerialized]
+               public new const string DefaultIssuer = "AD AUTHORITY";
+
                [SecurityPermission (SecurityAction.Demand, ControlPrincipal=true)]
                public WindowsIdentity (IntPtr userToken) 
                        : this (userToken, null, WindowsAccountType.Normal, false)
@@ -112,6 +115,15 @@ namespace System.Security.Principal {
                        _info = info;
                }
 
+               internal WindowsIdentity (ClaimsIdentity claimsIdentity, IntPtr userToken)
+                       : base (claimsIdentity)
+               {
+                       if (userToken != IntPtr.Zero && userToken.ToInt64() > 0)
+                       {
+                               SetToken (userToken);
+                       }
+               }
+
                [ComVisible (false)]
                public void Dispose ()
                {
@@ -171,8 +183,20 @@ namespace System.Security.Principal {
                        return new WindowsImpersonationContext (userToken);
                }
 
-               // properties
+               [SecuritySafeCritical]
+               public static void RunImpersonated (SafeAccessTokenHandle safeAccessTokenHandle, Action action)
+               {
+                       throw new NotImplementedException ();
+               }
 
+               [SecuritySafeCritical]
+               public static T RunImpersonated<T> (SafeAccessTokenHandle safeAccessTokenHandle, Func<T> func)
+               {
+                       throw new NotImplementedException ();
+               }
+
+               // properties
+               sealed override
                public string AuthenticationType {
                        get { return _type; }
                }
@@ -182,7 +206,8 @@ namespace System.Security.Principal {
                        get { return (_account == WindowsAccountType.Anonymous); }
                }
 
-               public virtual bool IsAuthenticated
+               override
+               public bool IsAuthenticated
                {
                        get { return _authenticated; }
                }
@@ -197,7 +222,8 @@ namespace System.Security.Principal {
                        get { return (_account == WindowsAccountType.System); }
                }
 
-               public virtual string Name
+               override
+               public string Name
                {
                        get {
                                if (_name == null) {
@@ -266,6 +292,16 @@ namespace System.Security.Principal {
                        info.AddValue ("m_isAuthenticated", _authenticated);
                }
 
+               internal ClaimsIdentity CloneAsBase ()
+               {
+                       return base.Clone();
+               }
+
+               internal IntPtr GetTokenInternal ()
+               {
+                       return _token;
+               }
+
                private void SetToken (IntPtr token) 
                {
                        if (Environment.IsUnix) {
@@ -289,6 +325,10 @@ namespace System.Security.Principal {
                        }
                }
 
+               public SafeAccessTokenHandle AccessToken {
+                       get { throw new NotImplementedException (); }
+               }
+
                // see mono/mono/metadata/security.c for implementation
 
                // Many people use reflection to get a user's roles - so many