コード例 #1
0
        internal static unsafe SecurityCredentials CreateFromNative(NativeTypes.FABRIC_SECURITY_CREDENTIALS *nativeCredentials)
        {
            SecurityCredentials managedCredentials = null;

            switch (nativeCredentials->Kind)
            {
            case NativeTypes.FABRIC_SECURITY_CREDENTIAL_KIND.FABRIC_SECURITY_CREDENTIAL_KIND_CLAIMS:
                managedCredentials = ClaimsCredentials.CreateFromNative((NativeTypes.FABRIC_CLAIMS_CREDENTIALS *)nativeCredentials->Value);
                break;

            case NativeTypes.FABRIC_SECURITY_CREDENTIAL_KIND.FABRIC_SECURITY_CREDENTIAL_KIND_WINDOWS:
                managedCredentials = WindowsCredentials.CreateFromNative((NativeTypes.FABRIC_WINDOWS_CREDENTIALS *)nativeCredentials->Value);
                break;

            case NativeTypes.FABRIC_SECURITY_CREDENTIAL_KIND.FABRIC_SECURITY_CREDENTIAL_KIND_X509:
                managedCredentials = X509Credentials.CreateFromNative((NativeTypes.FABRIC_X509_CREDENTIALS *)nativeCredentials->Value);
                break;

            case NativeTypes.FABRIC_SECURITY_CREDENTIAL_KIND.FABRIC_SECURITY_CREDENTIAL_KIND_NONE:
                managedCredentials = NoneSecurityCredentials.CreateFromNative();
                break;

            default:
                AppTrace.TraceSource.WriteError("SecurityCredentials.FromNative", "Unknown credential type: {0}", nativeCredentials->Kind);
                ReleaseAssert.Failfast("Unknown credential type: {0}", nativeCredentials->Kind);
                break;
            }

            return(managedCredentials);
        }
コード例 #2
0
        internal static unsafe WindowsCredentials CreateFromNative(NativeTypes.FABRIC_WINDOWS_CREDENTIALS *nativeCredentials)
        {
            WindowsCredentials managedCredentials = new WindowsCredentials();

            managedCredentials.ProtectionLevel = CreateFromNative(nativeCredentials->ProtectionLevel);

            managedCredentials.RemoteSpn = NativeTypes.FromNativeString(nativeCredentials->RemoteSpn);

            var remoteIdentities = new ItemList <string>();

            for (int i = 0; i < nativeCredentials->RemoteIdentityCount; i++)
            {
                IntPtr location = nativeCredentials->RemoteIdentities + (i * IntPtr.Size);
                IntPtr value    = *((IntPtr *)location);
                remoteIdentities.Add(NativeTypes.FromNativeString(value));
            }
            managedCredentials.RemoteIdentities = remoteIdentities;

            return(managedCredentials);
        }
コード例 #3
0
 public NativeWindowsCredentialConverter(WindowsCredentials windowsCredentials)
 {
     this.windowsCredentials = windowsCredentials;
 }