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); }
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); }
public NativeWindowsCredentialConverter(WindowsCredentials windowsCredentials) { this.windowsCredentials = windowsCredentials; }