本文整理了Java中com.fsck.k9.mail.filter.Base64.encode()
方法的一些代码示例,展示了Base64.encode()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Base64.encode()
方法的具体详情如下:
包路径:com.fsck.k9.mail.filter.Base64
类名称:Base64
方法名:encode
[英]Encodes an Object using the base64 algorithm. This method is provided in order to satisfy the requirements of the Encoder interface, and will throw an EncoderException if the supplied object is not of type byte[].
[中]使用base64算法对对象进行编码。提供此方法是为了满足编码器接口的要求,如果提供的对象不是byte[]类型,则将抛出EncoderException。
代码示例来源:origin: k9mail/k-9
public String toIdentityString() {
StringBuilder refString = new StringBuilder();
refString.append(IDENTITY_VERSION_1);
refString.append(IDENTITY_SEPARATOR);
refString.append(Base64.encode(accountUuid));
refString.append(IDENTITY_SEPARATOR);
refString.append(Base64.encode(folderServerId));
refString.append(IDENTITY_SEPARATOR);
refString.append(Base64.encode(uid));
if (flag != null) {
refString.append(IDENTITY_SEPARATOR);
refString.append(flag.name());
}
return refString.toString();
}
代码示例来源:origin: k9mail/k-9
private void saslAuthExternal() throws MessagingException, IOException {
executeCommand("AUTH EXTERNAL %s", Base64.encode(username));
}
代码示例来源:origin: k9mail/k-9
public static String encode(String s) {
if (s == null) {
return null;
}
byte[] encoded = new Base64().encode(s.getBytes());
return new String(encoded);
}
代码示例来源:origin: k9mail/k-9
/**
* Encodes an Object using the base64 algorithm. This method is provided in order to satisfy the requirements of the
* Encoder interface, and will throw an EncoderException if the supplied object is not of type byte[].
*
* @param pObject
* Object to encode
* @return An object (of type byte[]) containing the base64 encoded data which corresponds to the byte[] supplied.
* @throws EncoderException
* if the parameter supplied is not of type byte[]
*/
public Object encode(Object pObject) throws EncoderException {
if (!(pObject instanceof byte[])) {
throw new EncoderException("Parameter supplied to Base64 encode is not a byte[]");
}
return encode((byte[]) pObject);
}
代码示例来源:origin: k9mail/k-9
authString = "Basic " + Base64.encode(username + ":" + password);
代码示例来源:origin: k9mail/k-9
/**
* Closes this output stream, flushing any remaining bytes that must be encoded. The
* underlying stream is flushed but not closed.
*/
@Override
public void close() throws IOException {
// Notify encoder of EOF (-1).
if (doEncode) {
base64.encode(singleByte, 0, -1);
} else {
base64.decode(singleByte, 0, -1);
}
flush();
}
代码示例来源:origin: k9mail/k-9
/**
* Writes <code>len</code> bytes from the specified
* <code>b</code> array starting at <code>offset</code> to
* this output stream.
*
* @param b source byte array
* @param offset where to start reading the bytes
* @param len maximum number of bytes to write
*
* @throws IOException if an I/O error occurs.
* @throws NullPointerException if the byte array parameter is null
* @throws IndexOutOfBoundsException if offset, len or buffer size are invalid
*/
@Override
public void write(byte b[], int offset, int len) throws IOException {
if (b == null) {
throw new NullPointerException();
} else if (offset < 0 || len < 0 || offset + len < 0) {
throw new IndexOutOfBoundsException();
} else if (offset > b.length || offset + len > b.length) {
throw new IndexOutOfBoundsException();
} else if (len > 0) {
if (doEncode) {
base64.encode(b, offset, len);
} else {
base64.decode(b, offset, len);
}
flush(false);
}
}
代码示例来源:origin: k9mail/k-9
private void saslAuthLogin() throws MessagingException, IOException {
try {
executeCommand("AUTH LOGIN");
executeSensitiveCommand(Base64.encode(username));
executeSensitiveCommand(Base64.encode(password));
} catch (NegativeSmtpReplyException exception) {
if (exception.getReplyCode() == SMTP_AUTHENTICATION_FAILURE_ERROR_CODE) {
throw new AuthenticationFailedException("AUTH LOGIN failed (" + exception.getMessage() + ")");
} else {
throw exception;
}
}
}
代码示例来源:origin: k9mail/k-9
b64.encode(binaryData, 0, binaryData.length);
b64.encode(binaryData, 0, -1); // Notify encoder of EOF.
代码示例来源:origin: k9mail/k-9
private void authExternal() throws MessagingException {
try {
executeSimpleCommand(
String.format("AUTH EXTERNAL %s",
Base64.encode(settings.getUsername())), 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);
}
}
代码示例来源:origin: k9mail/k-9
private void saslAuthPlain() throws MessagingException, IOException {
String data = Base64.encode("\000" + username + "\000" + password);
try {
executeSensitiveCommand("AUTH PLAIN %s", data);
} catch (NegativeSmtpReplyException exception) {
if (exception.getReplyCode() == SMTP_AUTHENTICATION_FAILURE_ERROR_CODE) {
throw new AuthenticationFailedException("AUTH PLAIN failed ("
+ exception.getMessage() + ")");
} else {
throw exception;
}
}
}
代码示例来源:origin: k9mail/k-9
private List<ImapResponse> saslAuthExternal() throws IOException, MessagingException {
try {
String command = Commands.AUTHENTICATE_EXTERNAL + " " + Base64.encode(settings.getUsername());
return executeSimpleCommand(command, false);
} catch (NegativeImapResponseException 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(e.getMessage());
}
}
代码示例来源:origin: k9mail/k-9
URI newUri = new URI(uri.getScheme(), newUserInfo, uri.getHost(), uri.getPort(), uri.getPath(),
uri.getQuery(), uri.getFragment());
String newTransportUriStr = Base64.encode(newUri.toString());
migrationsHelper.writeValue(db, uuid + ".transportUri", newTransportUriStr);
URI newUri = new URI(uri.getScheme(), newUserInfo, uri.getHost(), uri.getPort(), uri.getPath(),
uri.getQuery(), uri.getFragment());
String newStoreUriStr = Base64.encode(newUri.toString());
migrationsHelper.writeValue(db, uuid + ".storeUri", newStoreUriStr);
代码示例来源:origin: k9mail/k-9
@Test
public void checkSettings_withInitialUnauthorizedResponse_shouldPerformBasicAuthentication() throws Exception {
configureHttpResponses(UNAUTHORIZED_401_RESPONSE, OK_200_RESPONSE);
webDavStore.checkSettings();
List<HttpGeneric> requests = requestCaptor.getAllValues();
assertEquals(2, requests.size());
assertEquals("GET", requests.get(0).getMethod());
assertEquals("GET", requests.get(1).getMethod());
assertEquals("Basic " + Base64.encode("user:password"),
requests.get(1).getHeaders("Authorization")[0].getValue());
}
代码示例来源:origin: k9mail/k-9
BackendManager backendManager = DI.get(BackendManager.class);
String storeUri = backendManager.createStoreUri(incoming);
putString(editor, accountKeyPrefix + AccountPreferenceSerializer.STORE_URI_KEY, Base64.encode(storeUri));
putString(editor, accountKeyPrefix + AccountPreferenceSerializer.TRANSPORT_URI_KEY, Base64.encode(transportUri));
代码示例来源:origin: k9mail/k-9
@Test
public void open_withCramMd5AuthExtension() throws Exception {
MockSmtpServer server = new MockSmtpServer();
server.output("220 localhost Simple Mail Transfer Service Ready");
server.expect("EHLO [127.0.0.1]");
server.output("250-localhost Hello client.localhost");
server.output("250 AUTH CRAM-MD5");
server.expect("AUTH CRAM-MD5");
server.output(Base64.encode("<24609.1047914046@localhost>"));
server.expect("dXNlciA3NmYxNWEzZmYwYTNiOGI1NzcxZmNhODZlNTcyMDk2Zg==");
server.output("235 2.7.0 Authentication successful");
SmtpTransport transport = startServerAndCreateSmtpTransport(server, AuthType.CRAM_MD5, ConnectionSecurity.NONE);
transport.open();
server.verifyConnectionStillOpen();
server.verifyInteractionCompleted();
}
代码示例来源:origin: k9mail/k-9
@Test
public void open_withAutomaticAuthAndNoTransportSecurityAndAuthCramMd5Extension_shouldUseAuthCramMd5()
throws Exception {
MockSmtpServer server = new MockSmtpServer();
server.output("220 localhost Simple Mail Transfer Service Ready");
server.expect("EHLO [127.0.0.1]");
server.output("250-localhost Hello client.localhost");
server.output("250 AUTH CRAM-MD5");
server.expect("AUTH CRAM-MD5");
server.output(Base64.encode("<24609.1047914046@localhost>"));
server.expect("dXNlciA3NmYxNWEzZmYwYTNiOGI1NzcxZmNhODZlNTcyMDk2Zg==");
server.output("235 2.7.0 Authentication successful");
SmtpTransport transport = startServerAndCreateSmtpTransport(server, AuthType.AUTOMATIC,
ConnectionSecurity.NONE);
transport.open();
server.verifyConnectionStillOpen();
server.verifyInteractionCompleted();
}
内容来源于网络,如有侵权,请联系作者删除!