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

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

本文整理了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

  1. /**
  2. * Encodes binary data using the base64 algorithm but does not chunk the output.
  3. *
  4. * @param binaryData
  5. * binary data to encode
  6. * @return Base64 characters
  7. */
  8. public static byte[] encodeBase64(byte[] binaryData) {
  9. return encodeBase64(binaryData, false);
  10. }

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

  1. /**
  2. * Encodes binary data using the base64 algorithm and chunks the encoded output into 76 character blocks
  3. *
  4. * @param binaryData
  5. * binary data to encode
  6. * @return Base64 characters chunked in 76 character blocks
  7. */
  8. public static byte[] encodeBase64Chunked(byte[] binaryData) {
  9. return encodeBase64(binaryData, true);
  10. }

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

  1. /**
  2. * Encodes a byte[] containing binary data, into a byte[] containing characters in the Base64 alphabet.
  3. *
  4. * @param pArray
  5. * a byte array containing binary data
  6. * @return A byte array containing only Base64 character data
  7. */
  8. public byte[] encode(byte[] pArray) {
  9. return encodeBase64(pArray, false);
  10. }

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

  1. public static String computeXoauth(String username, String authToken) throws UnsupportedEncodingException {
  2. String formattedAuthenticationString = String.format(XOAUTH_FORMAT, username, authToken);
  3. byte[] base64encodedAuthenticationString =
  4. Base64.encodeBase64(formattedAuthenticationString.getBytes());
  5. return new String(base64encodedAuthenticationString, US_ASCII);
  6. }
  7. }

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

  1. /**
  2. * Encode to a byte64-encoded integer according to crypto
  3. * standards such as W3C's XML-Signature
  4. *
  5. * @param bigInt a BigInteger
  6. * @return A byte array containing base64 character data
  7. * @throws NullPointerException if null is passed in
  8. */
  9. public static byte[] encodeInteger(BigInteger bigInt) {
  10. if (bigInt == null) {
  11. throw new NullPointerException("encodeInteger called with null parameter");
  12. }
  13. return encodeBase64(toIntegerBytes(bigInt), false);
  14. }

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

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

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

  1. private List<ImapResponse> saslAuthPlain() throws IOException, MessagingException {
  2. String command = Commands.AUTHENTICATE_PLAIN;
  3. String tag = sendCommand(command, false);
  4. readContinuationResponse(tag);
  5. String credentials = "\000" + settings.getUsername() + "\000" + settings.getPassword();
  6. byte[] encodedCredentials = Base64.encodeBase64(credentials.getBytes());
  7. outputStream.write(encodedCredentials);
  8. outputStream.write('\r');
  9. outputStream.write('\n');
  10. outputStream.flush();
  11. try {
  12. return responseParser.readStatusResponse(tag, command, getLogId(), null);
  13. } catch (NegativeImapResponseException e) {
  14. throw handleAuthenticationFailure(e);
  15. }
  16. }

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

  1. private void authPlain() throws MessagingException {
  2. executeSimpleCommand("AUTH PLAIN");
  3. try {
  4. byte[] encodedBytes = Base64.encodeBase64(("\000" + settings.getUsername()
  5. + "\000" + settings.getPassword()).getBytes());
  6. executeSimpleCommand(new String(encodedBytes), true);
  7. } catch (Pop3ErrorResponse e) {
  8. throw new AuthenticationFailedException(
  9. "POP3 SASL auth PLAIN authentication failed: "
  10. + e.getMessage(), e);
  11. }
  12. }

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

  1. @Test
  2. public void open_withAuthTypePlainAndPlainAuthCapability_performsPlainAuth() throws Exception {
  3. settings.setAuthType(AuthType.PLAIN);
  4. MockPop3Server server = new MockPop3Server();
  5. server.output("+OK POP3 server greeting");
  6. server.expect("AUTH");
  7. server.output("+OK Listing of supported mechanisms follows");
  8. server.output("PLAIN");
  9. server.output("CRAM-MD5");
  10. server.output("EXTERNAL");
  11. server.output(".");
  12. server.expect("CAPA");
  13. server.output("+OK Listing of supported mechanisms follows");
  14. server.output("PLAIN");
  15. server.output("CRAM-MD5");
  16. server.output("EXTERNAL");
  17. server.output(".");
  18. server.expect("AUTH PLAIN");
  19. server.output("+OK");
  20. server.expect(new String(Base64.encodeBase64(("\000"+username+"\000"+password).getBytes())));
  21. server.output("+OK");
  22. startServerAndCreateOpenConnection(server);
  23. server.verifyConnectionStillOpen();
  24. server.verifyInteractionCompleted();
  25. }

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

  1. @Test
  2. public void open_withAuthTypePlainAndPlainAuthCapabilityAndInvalidPasswordResponse_throwsException() throws Exception {
  3. settings.setAuthType(AuthType.PLAIN);
  4. MockPop3Server server = new MockPop3Server();
  5. server.output("+OK POP3 server greeting");
  6. server.expect("AUTH");
  7. server.output("+OK Listing of supported mechanisms follows");
  8. server.output("PLAIN");
  9. server.output("CRAM-MD5");
  10. server.output("EXTERNAL");
  11. server.output(".");
  12. server.expect("CAPA");
  13. server.output("+OK Listing of supported mechanisms follows");
  14. server.output("PLAIN");
  15. server.output("CRAM-MD5");
  16. server.output("EXTERNAL");
  17. server.output(".");
  18. server.expect("AUTH PLAIN");
  19. server.output("+OK");
  20. server.expect(new String(Base64.encodeBase64(("\000"+username+"\000"+password).getBytes())));
  21. server.output("-ERR");
  22. try {
  23. startServerAndCreateOpenConnection(server);
  24. fail("Expected auth failure");
  25. } catch (AuthenticationFailedException ignored) {}
  26. server.verifyInteractionCompleted();
  27. }

相关文章