com.fsck.k9.mail.filter.Base64.encodeBase64()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(213)

本文整理了Java中com.fsck.k9.mail.filter.Base64.encodeBase64()方法的一些代码示例,展示了Base64.encodeBase64()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Base64.encodeBase64()方法的具体详情如下:
包路径:com.fsck.k9.mail.filter.Base64
类名称:Base64
方法名:encodeBase64

Base64.encodeBase64介绍

[英]Encodes binary data using the base64 algorithm but does not chunk the output.
[中]使用base64算法对二进制数据进行编码,但不分块输出。

代码示例

代码示例来源:origin: k9mail/k-9

/**
 * Encodes binary data using the base64 algorithm but does not chunk the output.
 *
 * @param binaryData
 *            binary data to encode
 * @return Base64 characters
 */
public static byte[] encodeBase64(byte[] binaryData) {
  return encodeBase64(binaryData, false);
}

代码示例来源:origin: k9mail/k-9

/**
 * Encodes binary data using the base64 algorithm and chunks the encoded output into 76 character blocks
 *
 * @param binaryData
 *            binary data to encode
 * @return Base64 characters chunked in 76 character blocks
 */
public static byte[] encodeBase64Chunked(byte[] binaryData) {
  return encodeBase64(binaryData, true);
}

代码示例来源:origin: k9mail/k-9

/**
 * Encodes a byte[] containing binary data, into a byte[] containing characters in the Base64 alphabet.
 *
 * @param pArray
 *            a byte array containing binary data
 * @return A byte array containing only Base64 character data
 */
public byte[] encode(byte[] pArray) {
  return encodeBase64(pArray, false);
}

代码示例来源:origin: k9mail/k-9

public static String computeXoauth(String username, String authToken) throws UnsupportedEncodingException {
    String formattedAuthenticationString = String.format(XOAUTH_FORMAT, username, authToken);
    byte[] base64encodedAuthenticationString =
        Base64.encodeBase64(formattedAuthenticationString.getBytes());

    return new String(base64encodedAuthenticationString, US_ASCII);
  }
}

代码示例来源:origin: k9mail/k-9

/**
 * Encode to a byte64-encoded integer according to crypto
 * standards such as W3C's XML-Signature
 *
 * @param bigInt a BigInteger
 * @return A byte array containing base64 character data
 * @throws NullPointerException if null is passed in
 */
public static byte[] encodeInteger(BigInteger bigInt) {
  if (bigInt == null) {
    throw new NullPointerException("encodeInteger called with null parameter");
  }
  return encodeBase64(toIntegerBytes(bigInt), false);
}

代码示例来源:origin: k9mail/k-9

return Base64.encodeBase64(plainCRAM.getBytes());

代码示例来源:origin: k9mail/k-9

private List<ImapResponse> saslAuthPlain() throws IOException, MessagingException {
  String command = Commands.AUTHENTICATE_PLAIN;
  String tag = sendCommand(command, false);
  readContinuationResponse(tag);
  String credentials = "\000" + settings.getUsername() + "\000" + settings.getPassword();
  byte[] encodedCredentials = Base64.encodeBase64(credentials.getBytes());
  outputStream.write(encodedCredentials);
  outputStream.write('\r');
  outputStream.write('\n');
  outputStream.flush();
  try {
    return responseParser.readStatusResponse(tag, command, getLogId(), null);
  } catch (NegativeImapResponseException e) {
    throw handleAuthenticationFailure(e);
  }
}

代码示例来源:origin: k9mail/k-9

private void authPlain() throws MessagingException {
  executeSimpleCommand("AUTH PLAIN");
  try {
    byte[] encodedBytes = Base64.encodeBase64(("\000" + settings.getUsername()
        + "\000" + settings.getPassword()).getBytes());
    executeSimpleCommand(new String(encodedBytes), true);
  } catch (Pop3ErrorResponse e) {
    throw new AuthenticationFailedException(
        "POP3 SASL auth PLAIN authentication failed: "
            + e.getMessage(), e);
  }
}

代码示例来源:origin: k9mail/k-9

@Test
public void open_withAuthTypePlainAndPlainAuthCapability_performsPlainAuth() throws Exception {
  settings.setAuthType(AuthType.PLAIN);
  MockPop3Server server = new MockPop3Server();
  server.output("+OK POP3 server greeting");
  server.expect("AUTH");
  server.output("+OK Listing of supported mechanisms follows");
  server.output("PLAIN");
  server.output("CRAM-MD5");
  server.output("EXTERNAL");
  server.output(".");
  server.expect("CAPA");
  server.output("+OK Listing of supported mechanisms follows");
  server.output("PLAIN");
  server.output("CRAM-MD5");
  server.output("EXTERNAL");
  server.output(".");
  server.expect("AUTH PLAIN");
  server.output("+OK");
  server.expect(new String(Base64.encodeBase64(("\000"+username+"\000"+password).getBytes())));
  server.output("+OK");
  startServerAndCreateOpenConnection(server);
  server.verifyConnectionStillOpen();
  server.verifyInteractionCompleted();
}

代码示例来源:origin: k9mail/k-9

@Test
public void open_withAuthTypePlainAndPlainAuthCapabilityAndInvalidPasswordResponse_throwsException() throws Exception {
  settings.setAuthType(AuthType.PLAIN);
  MockPop3Server server = new MockPop3Server();
  server.output("+OK POP3 server greeting");
  server.expect("AUTH");
  server.output("+OK Listing of supported mechanisms follows");
  server.output("PLAIN");
  server.output("CRAM-MD5");
  server.output("EXTERNAL");
  server.output(".");
  server.expect("CAPA");
  server.output("+OK Listing of supported mechanisms follows");
  server.output("PLAIN");
  server.output("CRAM-MD5");
  server.output("EXTERNAL");
  server.output(".");
  server.expect("AUTH PLAIN");
  server.output("+OK");
  server.expect(new String(Base64.encodeBase64(("\000"+username+"\000"+password).getBytes())));
  server.output("-ERR");
  try {
    startServerAndCreateOpenConnection(server);
    fail("Expected auth failure");
  } catch (AuthenticationFailedException ignored) {}
  server.verifyInteractionCompleted();
}

相关文章