예제 #1
0
 private void saslAuthLogin(String username, String password)
     throws MessagingException, AuthenticationFailedException, IOException {
   try {
     executeSimpleCommand("AUTH LOGIN");
     executeSimpleCommand(new String(Base64.encodeBase64(username.getBytes())), true);
     executeSimpleCommand(new String(Base64.encodeBase64(password.getBytes())), true);
   } catch (MessagingException me) {
     if (me.getMessage().length() > 1 && me.getMessage().charAt(1) == '3') {
       throw new AuthenticationFailedException("AUTH LOGIN failed (" + me.getMessage() + ")");
     }
     throw me;
   }
 }
 private void authPlain() throws MessagingException {
   executeSimpleCommand("AUTH PLAIN");
   try {
     byte[] encodedBytes =
         Base64.encodeBase64(("\000" + mUsername + "\000" + mPassword).getBytes());
     executeSimpleCommand(new String(encodedBytes), true);
   } catch (Pop3ErrorResponse e) {
     throw new AuthenticationFailedException(
         "POP3 SASL auth PLAIN authentication failed: " + e.getMessage(), e);
   }
 }
 private void authExternal() throws MessagingException {
   try {
     executeSimpleCommand(String.format("AUTH EXTERNAL %s", Base64.encode(mUsername)), false);
   } catch (Pop3ErrorResponse e) {
     /*
      * Provide notification to the user of a problem authenticating
      * using client certificates. We don't use an
      * AuthenticationFailedException because that would trigger a
      * "Username or password incorrect" notification in
      * AccountSetupCheckSettings.
      */
     throw new CertificateValidationException(
         "POP3 client certificate authentication failed: " + e.getMessage(), e);
   }
 }