// constructors /// <summary> /// Initializes a new instance of the <see cref="GsaslGssapiImplementation" /> class. /// </summary> /// <param name="serverName">Name of the server.</param> /// <param name="username">The username.</param> /// <param name="evidence">The evidence.</param> public GsaslGssapiImplementation(string serverName, string username, MongoIdentityEvidence evidence) : base("GSSAPI", new byte[0]) { _authorizationId = username; _evidence = evidence; _servicePrincipalName = "mongodb/" + serverName; }
// constructors /// <summary> /// Initializes a new instance of the <see cref="GsaslGssapiImplementation" /> class. /// </summary> /// <param name="hostName">Name of the host.</param> /// <param name="username">The username.</param> /// <param name="evidence">The evidence.</param> public GsaslGssapiImplementation(string hostName, string username, MongoIdentityEvidence evidence) : base("GSSAPI", new byte[0]) { _userPrincipalName = username; _evidence = evidence; _hostname = hostName; _service = "mongodb"; }
// constructors /// <summary> /// Initializes a new instance of the <see cref="GsaslGssapiImplementation" /> class. /// </summary> /// <param name="serviceName">Name of the service.</param> /// <param name="hostName">Name of the host.</param> /// <param name="username">The username.</param> /// <param name="hostRealm">The realm.</param> /// <param name="evidence">The evidence.</param> public GsaslGssapiImplementation(string serviceName, string hostName, string hostRealm, string username, MongoIdentityEvidence evidence) : base("GSSAPI", new byte[0]) { _authorizationId = username; _hostRealm = hostRealm; _evidence = evidence; _hostname = hostName; _service = serviceName; }
// constructors /// <summary> /// Initializes a new instance of the <see cref="WindowsGssapiImplementation" /> class. /// </summary> /// <param name="serviceName">Name of the service.</param> /// <param name="hostName">Name of the host.</param> /// <param name="hostRealm">The domain.</param> /// <param name="username">The username.</param> /// <param name="evidence">The evidence.</param> public WindowsGssapiImplementation(string serviceName, string hostName, string hostRealm, string username, MongoIdentityEvidence evidence) { _authorizationId = username; _evidence = evidence; _servicePrincipalName = string.Format("{0}/{1}", serviceName, hostName); if (!string.IsNullOrEmpty(hostRealm)) { _servicePrincipalName += "@" + hostRealm; } }
public static SecurityCredential Acquire(SspiPackage package, string username, MongoIdentityEvidence evidence) { long timestamp; var credential = new SecurityCredential(); RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { uint result; var passwordEvidence = evidence as PasswordEvidence; if (passwordEvidence == null) { result = Win32.AcquireCredentialsHandle( null, package.ToString(), SecurityCredentialUse.Outbound, IntPtr.Zero, IntPtr.Zero, 0, IntPtr.Zero, ref credential._sspiHandle, out timestamp); } else { using(var authIdentity = new AuthIdentity(username, passwordEvidence.SecurePassword)) { // TODO: make this secure by using SecurePassword result = Win32.AcquireCredentialsHandle( null, package.ToString(), SecurityCredentialUse.Outbound, IntPtr.Zero, authIdentity, 0, IntPtr.Zero, ref credential._sspiHandle, out timestamp); } } if (result != Win32.SEC_E_OK) { credential.SetHandleAsInvalid(); throw Win32.CreateException(result, "Unable to acquire credential."); } } return credential; }
// constructors /// <summary> /// Initializes a new instance of the <see cref="WindowsGssapiImplementation" /> class. /// </summary> /// <param name="serviceName">Name of the service.</param> /// <param name="hostName">Name of the host.</param> /// <param name="username">The username.</param> /// <param name="evidence">The evidence.</param> public WindowsGssapiImplementation(string serviceName, string hostName, string username, MongoIdentityEvidence evidence) { _authorizationId = username; _evidence = evidence; _servicePrincipalName = string.Format("{0}/{1}", serviceName, hostName); }
// constructors /// <summary> /// Initializes a new instance of the <see cref="WindowsGssapiImplementation" /> class. /// </summary> /// <param name="hostName">Name of the host.</param> /// <param name="username">The username.</param> /// <param name="evidence">The evidence.</param> public WindowsGssapiImplementation(string hostName, string username, MongoIdentityEvidence evidence) { _authorizationId = username; _evidence = evidence; _servicePrincipalName = "mongodb/" + hostName; }
public static SecurityCredential Acquire(SspiPackage package, string username, MongoIdentityEvidence evidence) { long timestamp; var credential = new SecurityCredential(); RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { uint result; var passwordEvidence = evidence as PasswordEvidence; if (passwordEvidence == null) { result = Win32.AcquireCredentialsHandle( null, package.ToString(), SecurityCredentialUse.Outbound, IntPtr.Zero, IntPtr.Zero, 0, IntPtr.Zero, ref credential._sspiHandle, out timestamp); } else { using (var authIdentity = new AuthIdentity(username, passwordEvidence.SecurePassword)) { // TODO: make this secure by using SecurePassword result = Win32.AcquireCredentialsHandle( null, package.ToString(), SecurityCredentialUse.Outbound, IntPtr.Zero, authIdentity, 0, IntPtr.Zero, ref credential._sspiHandle, out timestamp); } } if (result != Win32.SEC_E_OK) { credential.SetHandleAsInvalid(); throw Win32.CreateException(result, "Unable to acquire credential."); } } return(credential); }