当前位置: 首页>>代码示例>>Java>>正文


Java AuthType.EXTERNAL属性代码示例

本文整理汇总了Java中com.fsck.k9.mail.AuthType.EXTERNAL属性的典型用法代码示例。如果您正苦于以下问题:Java AuthType.EXTERNAL属性的具体用法?Java AuthType.EXTERNAL怎么用?Java AuthType.EXTERNAL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在com.fsck.k9.mail.AuthType的用法示例。


在下文中一共展示了AuthType.EXTERNAL属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateViewFromAuthType

/**
 * 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);
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:23,代码来源:AccountSetupIncoming.java

示例2: onNext

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);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:26,代码来源:AccountSetupOutgoing.java

示例3: onManualSetup

private void onManualSetup() {
    String email = mEmailView.getText().toString();
    String[] emailParts = splitEmail(email);
    String user = email;
    String domain = emailParts[1];

    String password = null;
    String clientCertificateAlias = null;
    AuthType authenticationType;
    if (mClientCertificateCheckBox.isChecked()) {
        authenticationType = AuthType.EXTERNAL;
        clientCertificateAlias = mClientCertificateSpinner.getAlias();
    } else {
        authenticationType = AuthType.PLAIN;
        password = mPasswordView.getText().toString();
    }

    if (mAccount == null) {
        mAccount = Preferences.getPreferences(this).newAccount();
    }
    mAccount.setName(getOwnerName());
    mAccount.setEmail(email);

    // set default uris
    // NOTE: they will be changed again in AccountSetupAccountType!
    ServerSettings storeServer = new ServerSettings(ServerSettings.Type.IMAP, "mail." + domain, -1,
            ConnectionSecurity.SSL_TLS_REQUIRED, authenticationType, user, password, clientCertificateAlias);
    ServerSettings transportServer = new ServerSettings(ServerSettings.Type.SMTP, "mail." + domain, -1,
            ConnectionSecurity.SSL_TLS_REQUIRED, authenticationType, user, password, clientCertificateAlias);
    String storeUri = RemoteStore.createStoreUri(storeServer);
    String transportUri = TransportUris.createTransportUri(transportServer);
    mAccount.setStoreUri(storeUri);
    mAccount.setTransportUri(transportUri);

    setupFolderNames(domain);

    AccountSetupAccountType.actionSelectAccountType(this, mAccount, false);

    finish();
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:40,代码来源:AccountSetupBasics.java

示例4: get

public static AuthTypeAdapter get(Context context) {
    AuthType[] authTypes = new AuthType[]{AuthType.PLAIN, AuthType.CRAM_MD5, AuthType.EXTERNAL};
    AuthTypeHolder[] holders = new AuthTypeHolder[authTypes.length];
    for (int i = 0; i < authTypes.length; i++) {
        holders[i] = new AuthTypeHolder(authTypes[i], context.getResources());
    }
    AuthTypeAdapter authTypesAdapter = new AuthTypeAdapter(context,
            android.R.layout.simple_spinner_item, holders);
    authTypesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    return authTypesAdapter;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:11,代码来源:AuthTypeAdapter.java

示例5: createUri_withEXTERNAL_shouldProduceExternalAuthUri

@Test
public void createUri_withEXTERNAL_shouldProduceExternalAuthUri() {
    ServerSettings settings = new ServerSettings(Type.POP3, "server", 12345, ConnectionSecurity.NONE,
            AuthType.EXTERNAL, "user", "password", "clientCert");

    String uri = Pop3Store.createUri(settings);

    assertEquals(uri, "pop3://EXTERNAL:user:[email protected]:12345");
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:9,代码来源:Pop3StoreTest.java

示例6: validateFields

/**
 * This is invoked only when the user makes changes to a widget, not when
 * widgets are changed programmatically.  (The logic is simpler when you know
 * that this is the last thing called after an input change.)
 */
private void validateFields() {
    AuthType authType = getSelectedAuthType();
    boolean isAuthTypeExternal = (AuthType.EXTERNAL == authType);

    ConnectionSecurity connectionSecurity = getSelectedSecurity();
    boolean hasConnectionSecurity = (connectionSecurity != ConnectionSecurity.NONE);

    if (isAuthTypeExternal && !hasConnectionSecurity) {

        // Notify user of an invalid combination of AuthType.EXTERNAL & ConnectionSecurity.NONE
        String toastText = getString(R.string.account_setup_incoming_invalid_setting_combo_notice,
                getString(R.string.account_setup_incoming_auth_type_label),
                AuthType.EXTERNAL.toString(),
                getString(R.string.account_setup_incoming_security_label),
                ConnectionSecurity.NONE.toString());
        Toast.makeText(this, toastText, Toast.LENGTH_LONG).show();

        // Reset the views back to their previous settings without recursing through here again
        OnItemSelectedListener onItemSelectedListener = mAuthTypeView.getOnItemSelectedListener();
        mAuthTypeView.setOnItemSelectedListener(null);
        mAuthTypeView.setSelection(mCurrentAuthTypeViewPosition, false);
        mAuthTypeView.setOnItemSelectedListener(onItemSelectedListener);
        updateViewFromAuthType();

        onItemSelectedListener = mSecurityTypeView.getOnItemSelectedListener();
        mSecurityTypeView.setOnItemSelectedListener(null);
        mSecurityTypeView.setSelection(mCurrentSecurityTypeViewPosition, false);
        mSecurityTypeView.setOnItemSelectedListener(onItemSelectedListener);
        updateAuthPlainTextFromSecurityType(getSelectedSecurity());

        mPortView.removeTextChangedListener(validationTextWatcher);
        mPortView.setText(mCurrentPortViewSetting);
        mPortView.addTextChangedListener(validationTextWatcher);

        authType = getSelectedAuthType();
        isAuthTypeExternal = (AuthType.EXTERNAL == authType);

        connectionSecurity = getSelectedSecurity();
        hasConnectionSecurity = (connectionSecurity != ConnectionSecurity.NONE);
    } else {
        mCurrentAuthTypeViewPosition = mAuthTypeView.getSelectedItemPosition();
        mCurrentSecurityTypeViewPosition = mSecurityTypeView.getSelectedItemPosition();
        mCurrentPortViewSetting = mPortView.getText().toString();
    }

    boolean hasValidCertificateAlias = mClientCertificateSpinner.getAlias() != null;
    boolean hasValidUserName = Utility.requiredFieldValid(mUsernameView);

    boolean hasValidPasswordSettings = hasValidUserName
            && !isAuthTypeExternal
            && Utility.requiredFieldValid(mPasswordView);

    boolean hasValidExternalAuthSettings = hasValidUserName
            && isAuthTypeExternal
            && hasConnectionSecurity
            && hasValidCertificateAlias;

    mNextButton.setEnabled(Utility.domainFieldValid(mServerView)
            && Utility.requiredFieldValid(mPortView)
            && (hasValidPasswordSettings || hasValidExternalAuthSettings));
    Utility.setCompoundDrawablesAlpha(mNextButton, mNextButton.isEnabled() ? 255 : 128);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:67,代码来源:AccountSetupIncoming.java

示例7: onActivityResult

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        if (Intent.ACTION_EDIT.equals(getIntent().getAction())) {
            boolean isPushCapable = false;
            try {
                Store store = mAccount.getRemoteStore();
                isPushCapable = store.isPushCapable();
            } catch (Exception e) {
                Timber.e(e, "Could not get remote store");
            }
            if (isPushCapable && mAccount.getFolderPushMode() != FolderMode.NONE) {
                MailService.actionRestartPushers(this, null);
            }
            mAccount.save(Preferences.getPreferences(this));
            finish();
        } else {
            /*
             * Set the username and password for the outgoing settings to the username and
             * password the user just set for incoming.
             */
            try {
                String username = mUsernameView.getText().toString();

                String password = null;
                String clientCertificateAlias = null;
                AuthType authType = getSelectedAuthType();
                if (AuthType.EXTERNAL == authType) {
                    clientCertificateAlias = mClientCertificateSpinner.getAlias();
                } else {
                    password = mPasswordView.getText().toString();
                }

                URI oldUri = new URI(mAccount.getTransportUri());
                ServerSettings transportServer = new ServerSettings(Type.SMTP, oldUri.getHost(), oldUri.getPort(),
                        ConnectionSecurity.SSL_TLS_REQUIRED, authType, username, password, clientCertificateAlias);
                String transportUri = TransportUris.createTransportUri(transportServer);
                mAccount.setTransportUri(transportUri);
            } catch (URISyntaxException use) {
                /*
                 * If we can't set up the URL we just continue. It's only for
                 * convenience.
                 */
            }

            AccountSetupOutgoing.actionOutgoingSettings(this, mAccount, mMakeDefault);
            finish();
        }
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:50,代码来源:AccountSetupIncoming.java

示例8: onNext

protected void onNext() {
    try {
        ConnectionSecurity connectionSecurity = getSelectedSecurity();

        String username = mUsernameView.getText().toString();
        String password = null;
        String clientCertificateAlias = null;

        AuthType authType = getSelectedAuthType();
        if (authType == AuthType.EXTERNAL) {
            clientCertificateAlias = mClientCertificateSpinner.getAlias();
        } else {
            password = mPasswordView.getText().toString();
        }
        String host = mServerView.getText().toString();
        int port = Integer.parseInt(mPortView.getText().toString());

        Map<String, String> extra = null;
        if (Type.IMAP == mStoreType) {
            extra = new HashMap<String, String>();
            extra.put(ImapStoreSettings.AUTODETECT_NAMESPACE_KEY,
                    Boolean.toString(mImapAutoDetectNamespaceView.isChecked()));
            extra.put(ImapStoreSettings.PATH_PREFIX_KEY,
                    mImapPathPrefixView.getText().toString());
        } else if (Type.WebDAV == mStoreType) {
            extra = new HashMap<String, String>();
            extra.put(WebDavStoreSettings.PATH_KEY,
                    mWebdavPathPrefixView.getText().toString());
            extra.put(WebDavStoreSettings.AUTH_PATH_KEY,
                    mWebdavAuthPathView.getText().toString());
            extra.put(WebDavStoreSettings.MAILBOX_PATH_KEY,
                    mWebdavMailboxPathView.getText().toString());
        } else if (Type.EWS == mStoreType) {
            extra = new HashMap<>();
            extra.put(EwsStoreSettings.EXCHANGE_VERSION_KEY, getSelectedExchangeVersion().name());
            extra.put(EwsStoreSettings.PATH_KEY, mExchangePathView.getText().toString());
        }

        mAccount.deleteCertificate(host, port, CheckDirection.INCOMING);
        ServerSettings settings = new ServerSettings(mStoreType, host, port,
                connectionSecurity, authType, username, password, clientCertificateAlias, extra);

        mAccount.setStoreUri(RemoteStore.createStoreUri(settings));

        mAccount.setCompression(NetworkType.MOBILE, mCompressionMobile.isChecked());
        mAccount.setCompression(NetworkType.WIFI, mCompressionWifi.isChecked());
        mAccount.setCompression(NetworkType.OTHER, mCompressionOther.isChecked());
        mAccount.setSubscribedFoldersOnly(mSubscribedFoldersOnly.isChecked());

        AccountSetupCheckSettings.actionCheckSettings(this, mAccount, CheckDirection.INCOMING);
    } catch (Exception e) {
        failure(e);
    }

}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:55,代码来源:AccountSetupIncoming.java

示例9: validateFields

/**
 * This is invoked only when the user makes changes to a widget, not when
 * widgets are changed programmatically.  (The logic is simpler when you know
 * that this is the last thing called after an input change.)
 */
private void validateFields() {
    AuthType authType = getSelectedAuthType();
    boolean isAuthTypeExternal = (AuthType.EXTERNAL == authType);

    ConnectionSecurity connectionSecurity = getSelectedSecurity();
    boolean hasConnectionSecurity = (connectionSecurity != ConnectionSecurity.NONE);

    if (isAuthTypeExternal && !hasConnectionSecurity) {

        // Notify user of an invalid combination of AuthType.EXTERNAL & ConnectionSecurity.NONE
        String toastText = getString(R.string.account_setup_outgoing_invalid_setting_combo_notice,
                getString(R.string.account_setup_incoming_auth_type_label),
                AuthType.EXTERNAL.toString(),
                getString(R.string.account_setup_incoming_security_label),
                ConnectionSecurity.NONE.toString());
        Toast.makeText(this, toastText, Toast.LENGTH_LONG).show();

        // Reset the views back to their previous settings without recursing through here again
        OnItemSelectedListener onItemSelectedListener = mAuthTypeView.getOnItemSelectedListener();
        mAuthTypeView.setOnItemSelectedListener(null);
        mAuthTypeView.setSelection(mCurrentAuthTypeViewPosition, false);
        mAuthTypeView.setOnItemSelectedListener(onItemSelectedListener);
        updateViewFromAuthType();

        onItemSelectedListener = mSecurityTypeView.getOnItemSelectedListener();
        mSecurityTypeView.setOnItemSelectedListener(null);
        mSecurityTypeView.setSelection(mCurrentSecurityTypeViewPosition, false);
        mSecurityTypeView.setOnItemSelectedListener(onItemSelectedListener);
        updateAuthPlainTextFromSecurityType(getSelectedSecurity());

        mPortView.removeTextChangedListener(validationTextWatcher);
        mPortView.setText(mCurrentPortViewSetting);
        mPortView.addTextChangedListener(validationTextWatcher);

        authType = getSelectedAuthType();
        isAuthTypeExternal = (AuthType.EXTERNAL == authType);

        connectionSecurity = getSelectedSecurity();
        hasConnectionSecurity = (connectionSecurity != ConnectionSecurity.NONE);
    } else {
        mCurrentAuthTypeViewPosition = mAuthTypeView.getSelectedItemPosition();
        mCurrentSecurityTypeViewPosition = mSecurityTypeView.getSelectedItemPosition();
        mCurrentPortViewSetting = mPortView.getText().toString();
    }

    boolean hasValidCertificateAlias = mClientCertificateSpinner.getAlias() != null;
    boolean hasValidUserName = Utility.requiredFieldValid(mUsernameView);

    boolean hasValidPasswordSettings = hasValidUserName
            && !isAuthTypeExternal
            && Utility.requiredFieldValid(mPasswordView);

    boolean hasValidExternalAuthSettings = hasValidUserName
            && isAuthTypeExternal
            && hasConnectionSecurity
            && hasValidCertificateAlias;

    mNextButton
            .setEnabled(Utility.domainFieldValid(mServerView)
                    && Utility.requiredFieldValid(mPortView)
                    && (!mRequireLoginView.isChecked()
                            || hasValidPasswordSettings || hasValidExternalAuthSettings));
    Utility.setCompoundDrawablesAlpha(mNextButton, mNextButton.isEnabled() ? 255 : 128);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:69,代码来源:AccountSetupOutgoing.java

示例10: create

/**
 * Creates an ImapStore URI with the supplied settings.
 *
 * @param server
 *         The {@link ServerSettings} object that holds the server settings.
 *
 * @return An ImapStore URI that holds the same information as the {@code server} parameter.
 *
 * @see com.fsck.k9.mail.store.StoreConfig#getStoreUri()
 * @see EwsStore#decodeUri(String)
 */
public static String create(ServerSettings server) {
    String userEnc = encodeUtf8(server.username);
    String passwordEnc = (server.password != null) ? encodeUtf8(server.password) : "";
    String clientCertificateAliasEnc = (server.clientCertificateAlias != null) ?
            encodeUtf8(server.clientCertificateAlias) : "";

    String scheme;
    switch (server.connectionSecurity) {
        case SSL_TLS_REQUIRED:
            scheme = "ews+ssl+";
            break;
        case STARTTLS_REQUIRED:
            scheme = "ews+tls+";
            break;
        default:
        case NONE:
            scheme = "ews";
            break;
    }

    AuthType authType = server.authenticationType;
    String userInfo;
    if (authType == AuthType.EXTERNAL) {
        userInfo = authType.name() + ":" + userEnc + ":" + clientCertificateAliasEnc;
    } else {
        userInfo = authType.name() + ":" + userEnc + ":" + passwordEnc;
    }
    try {
        Map<String, String> extra = server.getExtra();
        String path;
        String exchangeVersion;
        if (extra != null) {
            exchangeVersion = extra.get(EwsStoreSettings.EXCHANGE_VERSION_KEY);
            path = "/"+exchangeVersion+"/"+extra.get(EwsStoreSettings.PATH_KEY);
        } else {
            exchangeVersion = ExchangeVersion.Exchange2010_SP2.name();
            path = "/"+exchangeVersion+"/";
        }
        return new URI(scheme, userInfo, server.host, server.port, path, null, null).toString();
    } catch (URISyntaxException e) {
        throw new IllegalArgumentException("Can't create EwsStore URI", e);
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:54,代码来源:EwsStoreUriCreator.java

示例11: create

/**
 * Creates an ImapStore URI with the supplied settings.
 *
 * @param server
 *         The {@link ServerSettings} object that holds the server settings.
 *
 * @return An ImapStore URI that holds the same information as the {@code server} parameter.
 *
 * @see com.fsck.k9.mail.store.StoreConfig#getStoreUri()
 * @see ImapStore#decodeUri(String)
 */
public static String create(ServerSettings server) {
    String userEnc = encodeUtf8(server.username);
    String passwordEnc = (server.password != null) ? encodeUtf8(server.password) : "";
    String clientCertificateAliasEnc = (server.clientCertificateAlias != null) ?
            encodeUtf8(server.clientCertificateAlias) : "";

    String scheme;
    switch (server.connectionSecurity) {
        case SSL_TLS_REQUIRED:
            scheme = "imap+ssl+";
            break;
        case STARTTLS_REQUIRED:
            scheme = "imap+tls+";
            break;
        default:
        case NONE:
            scheme = "imap";
            break;
    }

    AuthType authType = server.authenticationType;
    String userInfo;
    if (authType == AuthType.EXTERNAL) {
        userInfo = authType.name() + ":" + userEnc + ":" + clientCertificateAliasEnc;
    } else {
        userInfo = authType.name() + ":" + userEnc + ":" + passwordEnc;
    }
    try {
        Map<String, String> extra = server.getExtra();
        String path;
        if (extra != null) {
            boolean autoDetectNamespace = Boolean.TRUE.toString().equals(
                    extra.get(ImapStoreSettings.AUTODETECT_NAMESPACE_KEY));
            String pathPrefix = (autoDetectNamespace) ?
                    null : extra.get(ImapStoreSettings.PATH_PREFIX_KEY);
            path = "/" + (autoDetectNamespace ? "1" : "0") + "|" +
                    ((pathPrefix == null) ? "" : pathPrefix);
        } else {
            path = "/1|";
        }
        return new URI(scheme, userInfo, server.host, server.port, path, null, null).toString();
    } catch (URISyntaxException e) {
        throw new IllegalArgumentException("Can't create ImapStore URI", e);
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:56,代码来源:ImapStoreUriCreator.java


注:本文中的com.fsck.k9.mail.AuthType.EXTERNAL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。