// Token: 0x060000F5 RID: 245 RVA: 0x00006328 File Offset: 0x00004528
 public static string ToStringParameterValue(ImapAuthenticationMechanism authMechanism)
 {
     return(authMechanism.ToString());
 }
Ejemplo n.º 2
0
 // Token: 0x06000020 RID: 32 RVA: 0x00002DC0 File Offset: 0x00000FC0
 internal Stream GetCommandParameterStream(string targetHost, string responseLine, out Exception failureException)
 {
     failureException = null;
     if (this.CommandType == ImapCommandType.Append)
     {
         return(this.CommandParameters[2] as Stream);
     }
     if (this.CommandType == ImapCommandType.Authenticate)
     {
         byte[]       inputBuffer = null;
         MemoryStream result      = null;
         ImapAuthenticationMechanism imapAuthenticationMechanism = (ImapAuthenticationMechanism)this.CommandParameters[0];
         string                text     = (string)this.CommandParameters[1];
         SecureString          password = (SecureString)this.CommandParameters[2];
         AuthenticationContext authenticationContext = (AuthenticationContext)this.CommandParameters[3];
         string                text2 = null;
         if (responseLine != null && responseLine.Length > 2)
         {
             inputBuffer = Encoding.ASCII.GetBytes(responseLine.Substring(2));
         }
         byte[] buffer = null;
         ImapAuthenticationMechanism imapAuthenticationMechanism2 = imapAuthenticationMechanism;
         if (imapAuthenticationMechanism2 != ImapAuthenticationMechanism.Basic)
         {
             if (imapAuthenticationMechanism2 == ImapAuthenticationMechanism.Ntlm)
             {
                 SecurityStatus securityStatus;
                 if (authenticationContext == null)
                 {
                     authenticationContext     = new AuthenticationContext();
                     this.CommandParameters[3] = authenticationContext;
                     string spn = "IMAP/" + targetHost;
                     securityStatus = authenticationContext.InitializeForOutboundNegotiate(AuthenticationMechanism.Ntlm, spn, text, password);
                     if (securityStatus != SecurityStatus.OK)
                     {
                         failureException = new ImapAuthenticationException(targetHost, imapAuthenticationMechanism.ToString(), RetryPolicy.Backoff);
                         return(null);
                     }
                 }
                 securityStatus = authenticationContext.NegotiateSecurityContext(inputBuffer, out buffer);
                 SecurityStatus securityStatus2 = securityStatus;
                 if (securityStatus2 != SecurityStatus.OK && securityStatus2 != SecurityStatus.ContinueNeeded)
                 {
                     failureException = new ImapAuthenticationException(targetHost, imapAuthenticationMechanism.ToString(), RetryPolicy.Backoff);
                     return(null);
                 }
                 result = new MemoryStream(buffer);
             }
             else
             {
                 failureException = new ImapUnsupportedAuthenticationException(targetHost, imapAuthenticationMechanism.ToString(), RetryPolicy.Backoff);
             }
         }
         else
         {
             SecurityStatus securityStatus;
             if (authenticationContext == null)
             {
                 authenticationContext     = new AuthenticationContext();
                 this.CommandParameters[3] = authenticationContext;
                 Match match = ImapCommand.UserNameWithAuthorizationId.Match(text);
                 if (match != null && match.Success && match.Groups.Count == 3)
                 {
                     text2 = match.Groups[1].Value;
                     text  = match.Groups[2].Value;
                 }
                 securityStatus = authenticationContext.InitializeForOutboundNegotiate(AuthenticationMechanism.Plain, null, text, password);
                 if (securityStatus != SecurityStatus.OK)
                 {
                     failureException = new ImapAuthenticationException(targetHost, imapAuthenticationMechanism.ToString(), RetryPolicy.Backoff);
                     return(null);
                 }
                 if (text2 != null)
                 {
                     authenticationContext.AuthorizationIdentity = Encoding.ASCII.GetBytes(text2);
                 }
             }
             securityStatus = authenticationContext.NegotiateSecurityContext(inputBuffer, out buffer);
             SecurityStatus securityStatus3 = securityStatus;
             if (securityStatus3 != SecurityStatus.OK)
             {
                 failureException = new ImapAuthenticationException(targetHost, imapAuthenticationMechanism.ToString(), RetryPolicy.Backoff);
                 return(null);
             }
             result = new MemoryStream(buffer);
         }
         return(result);
     }
     return(null);
 }