Ejemplo n.º 1
0
    private void authCramMD5() throws MessagingException {
      String b64Nonce = executeSimpleCommand("AUTH CRAM-MD5").replace("+ ", "");

      String b64CRAM = Authentication.computeCramMd5(mUsername, mPassword, b64Nonce);
      try {
        executeSimpleCommand(b64CRAM, true);
      } catch (Pop3ErrorResponse e) {
        throw new AuthenticationFailedException(
            "POP3 CRAM-MD5 authentication failed: " + e.getMessage(), e);
      }
    }
Ejemplo n.º 2
0
  private void saslAuthCramMD5(String username, String password)
      throws MessagingException, AuthenticationFailedException, IOException {

    List<String> respList = executeSimpleCommand("AUTH CRAM-MD5");
    if (respList.size() != 1) {
      throw new AuthenticationFailedException("Unable to negotiate CRAM-MD5");
    }

    String b64Nonce = respList.get(0);
    String b64CRAMString = Authentication.computeCramMd5(mUsername, mPassword, b64Nonce);

    try {
      executeSimpleCommand(b64CRAMString, true);
    } catch (MessagingException me) {
      throw new AuthenticationFailedException("Unable to negotiate MD5 CRAM");
    }
  }