本文整理汇总了Java中com.fsck.k9.mail.AuthType类的典型用法代码示例。如果您正苦于以下问题:Java AuthType类的具体用法?Java AuthType怎么用?Java AuthType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AuthType类属于com.fsck.k9.mail包,在下文中一共展示了AuthType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: withAuthTypePlainAndNoPlainAuthCapabilityAndLoginFailure_throwsException
import com.fsck.k9.mail.AuthType; //导入依赖的package包/类
@Test
public void withAuthTypePlainAndNoPlainAuthCapabilityAndLoginFailure_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("CRAM-MD5");
server.output("EXTERNAL");
server.output(".");
server.expect("CAPA");
server.output("+OK Listing of supported mechanisms follows");
server.output("CRAM-MD5");
server.output("EXTERNAL");
server.output(".");
server.expect("USER user");
server.output("+OK");
server.expect("PASS password");
server.output("+OK");
startServerAndCreateConnection(server);
server.verifyInteractionCompleted();
}
示例2: updateViewFromAuthType
import com.fsck.k9.mail.AuthType; //导入依赖的package包/类
/**
* Shows/hides password field and client certificate spinner
*/
private void updateViewFromAuthType() {
AuthType authType = getSelectedAuthType();
boolean isAuthTypeExternal = (AuthType.EXTERNAL == authType);
if (isAuthTypeExternal) {
// hide password fields, show client certificate fields
mPasswordView.setVisibility(View.GONE);
mPasswordLabelView.setVisibility(View.GONE);
mClientCertificateLabelView.setVisibility(View.VISIBLE);
mClientCertificateSpinner.setVisibility(View.VISIBLE);
} else {
// show password fields, hide client certificate fields
mPasswordView.setVisibility(View.VISIBLE);
mPasswordLabelView.setVisibility(View.VISIBLE);
mClientCertificateLabelView.setVisibility(View.GONE);
mClientCertificateSpinner.setVisibility(View.GONE);
}
}
示例3: onNext
import com.fsck.k9.mail.AuthType; //导入依赖的package包/类
protected void onNext() {
ConnectionSecurity securityType = getSelectedSecurity();
String uri;
String username = null;
String password = null;
String clientCertificateAlias = null;
AuthType authType = null;
if (mRequireLoginView.isChecked()) {
username = mUsernameView.getText().toString();
authType = getSelectedAuthType();
if (AuthType.EXTERNAL == authType) {
clientCertificateAlias = mClientCertificateSpinner.getAlias();
} else {
password = mPasswordView.getText().toString();
}
}
String newHost = mServerView.getText().toString();
int newPort = Integer.parseInt(mPortView.getText().toString());
ServerSettings server = new ServerSettings(Type.SMTP, newHost, newPort, securityType, authType, username, password, clientCertificateAlias);
uri = TransportUris.createTransportUri(server);
mAccount.deleteCertificate(newHost, newPort, CheckDirection.OUTGOING);
mAccount.setTransportUri(uri);
AccountSetupCheckSettings.actionCheckSettings(this, mAccount, CheckDirection.OUTGOING);
}
示例4: parseSettings_account_cram_md5
import com.fsck.k9.mail.AuthType; //导入依赖的package包/类
@Test
public void parseSettings_account_cram_md5() throws SettingsImportExportException {
String validUUID = UUID.randomUUID().toString();
InputStream inputStream = new StringInputStream("<k9settings format=\"1\" version=\"1\">" +
"<accounts><account uuid=\"" + validUUID + "\"><name>Account</name>" +
"<incoming-server><authentication-type>CRAM_MD5</authentication-type></incoming-server>" +
"</account></accounts></k9settings>");
List<String> accountUuids = new ArrayList<>();
accountUuids.add(validUUID);
SettingsImporter.Imported results = SettingsImporter.parseSettings(inputStream, true, accountUuids, false);
assertEquals("Account", results.accounts.get(validUUID).name);
assertEquals(validUUID, results.accounts.get(validUUID).uuid);
assertEquals(AuthType.CRAM_MD5, results.accounts.get(validUUID).incoming.authenticationType);
}
示例5: setup
import com.fsck.k9.mail.AuthType; //导入依赖的package包/类
@Before
public void setup() {
Utils.deleteExistingAccounts(preferences);
Account account = Preferences.getPreferences(
shadowApplication.getApplicationContext()).newAccount();
String storeUri = ImapStore.createStoreUri(new ServerSettings(
Type.IMAP, "hotmail.com",
Type.IMAP.defaultPort, ConnectionSecurity.NONE,
AuthType.PLAIN, "test",
"password",
null));
account.setStoreUri(storeUri);
Intent intent = new Intent();
intent.putExtra("account", account.getUuid());
controller = Robolectric.buildActivity(AccountSetupIncoming.class)
.withIntent(intent)
.create().resume();
}
示例6: setup
import com.fsck.k9.mail.AuthType; //导入依赖的package包/类
@Before
public void setup() {
Utils.deleteExistingAccounts(preferences);
account = Preferences.getPreferences(
shadowApplication.getApplicationContext()).newAccount();
String storeUri = ImapStore.createStoreUri(new ServerSettings(
Type.IMAP, "hotmail.com",
Type.IMAP.defaultPort, ConnectionSecurity.NONE,
AuthType.PLAIN, "test",
"password",
null));
account.setStoreUri(storeUri);
account.setEmail("[email protected]");
Intent intent = new Intent();
intent.putExtra("account", account.getUuid());
controller = Robolectric.buildActivity(AccountSetupAccountType.class)
.withIntent(intent)
.create().resume();
}
示例7: open_withAuthPlainExtension
import com.fsck.k9.mail.AuthType; //导入依赖的package包/类
@Test
public void open_withAuthPlainExtension() throws Exception {
MockSmtpServer server = new MockSmtpServer();
server.output("220 localhost Simple Mail Transfer Service Ready");
server.expect("EHLO localhost");
server.output("250-localhost Hello client.localhost");
server.output("250 AUTH PLAIN LOGIN");
server.expect("AUTH PLAIN AHVzZXIAcGFzc3dvcmQ=");
server.output("235 2.7.0 Authentication successful");
SmtpTransport transport = startServerAndCreateSmtpTransport(server, AuthType.PLAIN, ConnectionSecurity.NONE);
transport.open();
server.verifyConnectionStillOpen();
server.verifyInteractionCompleted();
}
示例8: open_withAuthLoginExtension
import com.fsck.k9.mail.AuthType; //导入依赖的package包/类
@Test
public void open_withAuthLoginExtension() throws Exception {
MockSmtpServer server = new MockSmtpServer();
server.output("220 localhost Simple Mail Transfer Service Ready");
server.expect("EHLO localhost");
server.output("250-localhost Hello client.localhost");
server.output("250 AUTH LOGIN");
server.expect("AUTH LOGIN");
server.output("250 OK");
server.expect("dXNlcg==");
server.output("250 OK");
server.expect("cGFzc3dvcmQ=");
server.output("235 2.7.0 Authentication successful");
SmtpTransport transport = startServerAndCreateSmtpTransport(server, AuthType.PLAIN, ConnectionSecurity.NONE);
transport.open();
server.verifyConnectionStillOpen();
server.verifyInteractionCompleted();
}
示例9: open_withoutLoginAndPlainAuthExtensions_shouldThrow
import com.fsck.k9.mail.AuthType; //导入依赖的package包/类
@Test
public void open_withoutLoginAndPlainAuthExtensions_shouldThrow() throws Exception {
MockSmtpServer server = new MockSmtpServer();
server.output("220 localhost Simple Mail Transfer Service Ready");
server.expect("EHLO localhost");
server.output("250-localhost Hello client.localhost");
server.output("250 AUTH");
server.expect("QUIT");
server.output("221 BYE");
SmtpTransport transport = startServerAndCreateSmtpTransport(server, AuthType.PLAIN, ConnectionSecurity.NONE);
try {
transport.open();
fail("Exception expected");
} catch (MessagingException e) {
assertEquals("Authentication methods SASL PLAIN and LOGIN are unavailable.", e.getMessage());
}
server.verifyConnectionStillOpen();
server.verifyInteractionCompleted();
}
示例10: withTLS_connectsToSocket
import com.fsck.k9.mail.AuthType; //导入依赖的package包/类
@Test
public void withTLS_connectsToSocket() throws Exception {
String response = INITIAL_RESPONSE +
AUTH_HANDLE_RESPONSE +
CAPA_RESPONSE +
AUTH_PLAIN_AUTHENTICATED_RESPONSE;
when(mockSocket.getInputStream()).thenReturn(new ByteArrayInputStream(response.getBytes()));
setSettingsForMockSocket();
settings.setAuthType(AuthType.PLAIN);
new Pop3Connection(settings, mockTrustedSocketFactory);
assertEquals(AUTH +
CAPA +
AUTH_PLAIN_WITH_LOGIN, new String(outputStream.toByteArray()));
}
示例11: open_withXoauth2Extension_shouldInvalidateAndRetryOn400Response
import com.fsck.k9.mail.AuthType; //导入依赖的package包/类
@Test
public void open_withXoauth2Extension_shouldInvalidateAndRetryOn400Response() throws Exception {
MockSmtpServer server = new MockSmtpServer();
server.output("220 localhost Simple Mail Transfer Service Ready");
server.expect("EHLO localhost");
server.output("250-localhost Hello client.localhost");
server.output("250 AUTH XOAUTH2");
server.expect("AUTH XOAUTH2 dXNlcj11c2VyAWF1dGg9QmVhcmVyIG9sZFRva2VuAQE=");
server.output("334 "+ XOAuth2ChallengeParserTest.STATUS_400_RESPONSE);
server.expect("");
server.output("535-5.7.1 Username and Password not accepted. Learn more at");
server.output("535 5.7.1 http://support.google.com/mail/bin/answer.py?answer=14257 hx9sm5317360pbc.68");
server.expect("AUTH XOAUTH2 dXNlcj11c2VyAWF1dGg9QmVhcmVyIG5ld1Rva2VuAQE=");
server.output("235 2.7.0 Authentication successful");
SmtpTransport transport = startServerAndCreateSmtpTransport(server, AuthType.XOAUTH2, ConnectionSecurity.NONE);
transport.open();
InOrder inOrder = inOrder(oAuth2TokenProvider);
inOrder.verify(oAuth2TokenProvider).getToken(eq(USERNAME), anyInt());
inOrder.verify(oAuth2TokenProvider).invalidateToken(USERNAME);
inOrder.verify(oAuth2TokenProvider).getToken(eq(USERNAME), anyInt());
server.verifyConnectionStillOpen();
server.verifyInteractionCompleted();
}
示例12: open_withXoauth2Extension_shouldInvalidateAndRetryOnInvalidJsonResponse
import com.fsck.k9.mail.AuthType; //导入依赖的package包/类
@Test
public void open_withXoauth2Extension_shouldInvalidateAndRetryOnInvalidJsonResponse() throws Exception {
MockSmtpServer server = new MockSmtpServer();
server.output("220 localhost Simple Mail Transfer Service Ready");
server.expect("EHLO localhost");
server.output("250-localhost Hello client.localhost");
server.output("250 AUTH XOAUTH2");
server.expect("AUTH XOAUTH2 dXNlcj11c2VyAWF1dGg9QmVhcmVyIG9sZFRva2VuAQE=");
server.output("334 "+ XOAuth2ChallengeParserTest.INVALID_RESPONSE);
server.expect("");
server.output("535-5.7.1 Username and Password not accepted. Learn more at");
server.output("535 5.7.1 http://support.google.com/mail/bin/answer.py?answer=14257 hx9sm5317360pbc.68");
server.expect("AUTH XOAUTH2 dXNlcj11c2VyAWF1dGg9QmVhcmVyIG5ld1Rva2VuAQE=");
server.output("235 2.7.0 Authentication successful");
SmtpTransport transport = startServerAndCreateSmtpTransport(server, AuthType.XOAUTH2, ConnectionSecurity.NONE);
transport.open();
InOrder inOrder = inOrder(oAuth2TokenProvider);
inOrder.verify(oAuth2TokenProvider).getToken(eq(USERNAME), anyInt());
inOrder.verify(oAuth2TokenProvider).invalidateToken(USERNAME);
inOrder.verify(oAuth2TokenProvider).getToken(eq(USERNAME), anyInt());
server.verifyConnectionStillOpen();
server.verifyInteractionCompleted();
}
示例13: open_withXoauth2Extension_shouldInvalidateAndRetryOnMissingStatusJsonResponse
import com.fsck.k9.mail.AuthType; //导入依赖的package包/类
@Test
public void open_withXoauth2Extension_shouldInvalidateAndRetryOnMissingStatusJsonResponse() throws Exception {
MockSmtpServer server = new MockSmtpServer();
server.output("220 localhost Simple Mail Transfer Service Ready");
server.expect("EHLO localhost");
server.output("250-localhost Hello client.localhost");
server.output("250 AUTH XOAUTH2");
server.expect("AUTH XOAUTH2 dXNlcj11c2VyAWF1dGg9QmVhcmVyIG9sZFRva2VuAQE=");
server.output("334 "+ XOAuth2ChallengeParserTest.MISSING_STATUS_RESPONSE);
server.expect("");
server.output("535-5.7.1 Username and Password not accepted. Learn more at");
server.output("535 5.7.1 http://support.google.com/mail/bin/answer.py?answer=14257 hx9sm5317360pbc.68");
server.expect("AUTH XOAUTH2 dXNlcj11c2VyAWF1dGg9QmVhcmVyIG5ld1Rva2VuAQE=");
server.output("235 2.7.0 Authentication successful");
SmtpTransport transport = startServerAndCreateSmtpTransport(server, AuthType.XOAUTH2, ConnectionSecurity.NONE);
transport.open();
InOrder inOrder = inOrder(oAuth2TokenProvider);
inOrder.verify(oAuth2TokenProvider).getToken(eq(USERNAME), anyInt());
inOrder.verify(oAuth2TokenProvider).invalidateToken(USERNAME);
inOrder.verify(oAuth2TokenProvider).getToken(eq(USERNAME), anyInt());
server.verifyConnectionStillOpen();
server.verifyInteractionCompleted();
}
示例14: open_withXoauth2Extension_shouldThrowOnFailure_fetchingToken
import com.fsck.k9.mail.AuthType; //导入依赖的package包/类
@Test
public void open_withXoauth2Extension_shouldThrowOnFailure_fetchingToken() throws Exception {
MockSmtpServer server = new MockSmtpServer();
server.output("220 localhost Simple Mail Transfer Service Ready");
server.expect("EHLO localhost");
server.output("250-localhost Hello client.localhost");
server.output("250 AUTH XOAUTH2");
server.expect("QUIT");
server.output("221 BYE");
when(oAuth2TokenProvider.getToken(anyString(), anyInt())).thenThrow(new AuthenticationFailedException("Failed to fetch token"));
SmtpTransport transport = startServerAndCreateSmtpTransport(server, AuthType.XOAUTH2, ConnectionSecurity.NONE);
try {
transport.open();
fail("Exception expected");
} catch (AuthenticationFailedException e) {
assertEquals("Failed to fetch token", e.getMessage());
}
server.verifyConnectionClosed();
server.verifyInteractionCompleted();
}
示例15: open_withoutXoauth2Extension_shouldThrow
import com.fsck.k9.mail.AuthType; //导入依赖的package包/类
@Test
public void open_withoutXoauth2Extension_shouldThrow() throws Exception {
MockSmtpServer server = new MockSmtpServer();
server.output("220 localhost Simple Mail Transfer Service Ready");
server.expect("EHLO localhost");
server.output("250-localhost Hello client.localhost");
server.output("250 AUTH PLAIN LOGIN");
server.expect("QUIT");
server.output("221 BYE");
SmtpTransport transport = startServerAndCreateSmtpTransport(server, AuthType.XOAUTH2, ConnectionSecurity.NONE);
try {
transport.open();
fail("Exception expected");
} catch (MessagingException e) {
assertEquals("Authentication method XOAUTH2 is unavailable.", e.getMessage());
}
server.verifyConnectionClosed();
server.verifyInteractionCompleted();
}