當前位置: 首頁>>代碼示例>>Java>>正文


Java PasswordAuthentication.getPassword方法代碼示例

本文整理匯總了Java中java.net.PasswordAuthentication.getPassword方法的典型用法代碼示例。如果您正苦於以下問題:Java PasswordAuthentication.getPassword方法的具體用法?Java PasswordAuthentication.getPassword怎麽用?Java PasswordAuthentication.getPassword使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.net.PasswordAuthentication的用法示例。


在下文中一共展示了PasswordAuthentication.getPassword方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: handleKenaiAuthorization

import java.net.PasswordAuthentication; //導入方法依賴的package包/類
private boolean handleKenaiAuthorization(SvnKenaiAccessor support, String url) {
    PasswordAuthentication pa = support.getPasswordAuthentication(url, true);
    if(pa == null) {
        return false;
    }

    String user = pa.getUserName();
    char[] password = pa.getPassword();
    
    adapter.setUsername(user != null ? user : "");
    if (connectionType != ConnectionType.javahl) {
        adapter.setPassword(password != null ? new String(password) : "");
    }

    return true;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:SvnClientExceptionHandler.java

示例2: getAnswer

import java.net.PasswordAuthentication; //導入方法依賴的package包/類
private void getAnswer() {
    if (!answered) {
        answered = true;
        PasswordAuthentication passAuth =
                Authenticator.requestPasswordAuthentication(
                hci.host, hci.addr, hci.port, hci.protocol,
                hci.prompt, hci.scheme, hci.url, hci.authType);
        /**
         * To be compatible with existing callback handler implementations,
         * when the underlying Authenticator is canceled, username and
         * password are assigned null. No exception is thrown.
         */
        if (passAuth != null) {
            username = passAuth.getUserName();
            password = passAuth.getPassword();
        }
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:19,代碼來源:NegotiateCallbackHandler.java

示例3: init

import java.net.PasswordAuthentication; //導入方法依賴的package包/類
private void init (PasswordAuthentication pw) {
    this.pw = pw;
    if (pw != null) {
        String s = pw.getUserName();
        int i = s.indexOf ('\\');
        if (i == -1) {
            username = s;
            ntdomain = defaultDomain;
        } else {
            ntdomain = s.substring (0, i).toUpperCase();
            username = s.substring (i+1);
        }
        password = new String (pw.getPassword());
    } else {
        /* credentials will be acquired from OS */
        username = null;
        ntdomain = null;
        password = null;
    }
    init0();
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:22,代碼來源:NTLMAuthentication.java

示例4: getAnswer

import java.net.PasswordAuthentication; //導入方法依賴的package包/類
private void getAnswer() {
    if (!answered) {
        answered = true;
        PasswordAuthentication passAuth =
                Authenticator.requestPasswordAuthentication(
                hci.authenticator,
                hci.host, hci.addr, hci.port, hci.protocol,
                hci.prompt, hci.scheme, hci.url, hci.authType);
        /**
         * To be compatible with existing callback handler implementations,
         * when the underlying Authenticator is canceled, username and
         * password are assigned null. No exception is thrown.
         */
        if (passAuth != null) {
            username = passAuth.getUserName();
            password = passAuth.getPassword();
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:NegotiateCallbackHandler.java

示例5: getClient

import java.net.PasswordAuthentication; //導入方法依賴的package包/類
public SvnClient getClient(SVNUrl repositoryUrl, SvnProgressSupport progressSupport) throws SVNClientException {
    Parameters.notNull("repositoryUrl", repositoryUrl); //NOI18N
    String username = ""; // NOI18N
    char[] password = null;

    SvnKenaiAccessor kenaiSupport = SvnKenaiAccessor.getInstance();
    if(kenaiSupport.isKenai(repositoryUrl.toString())) {
        PasswordAuthentication pa = kenaiSupport.getPasswordAuthentication(repositoryUrl.toString(), false);
        if(pa != null) {
            username = pa.getUserName();
            password = pa.getPassword();
        }
    } else {
        RepositoryConnection rc = SvnModuleConfig.getDefault().getRepositoryConnection(repositoryUrl.toString());
        if(rc != null) {
            username = rc.getUsername();
            password = rc.getPassword();
        } else if(!Utilities.isWindows()) {
            PasswordFile pf = PasswordFile.findFileForUrl(repositoryUrl);
            if(pf != null) {
                username = pf.getUsername();
                String psswdString = pf.getPassword();
                password = psswdString != null ? psswdString.toCharArray() : null;
            }
        }
    }
    return getClient(repositoryUrl, username, password, progressSupport);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:29,代碼來源:Subversion.java

示例6: getKenaiAuthData

import java.net.PasswordAuthentication; //導入方法依賴的package包/類
private void getKenaiAuthData(SvnKenaiAccessor support) {
    final String urlString = url.toString();
    
    PasswordAuthentication pa = support.getPasswordAuthentication(urlString, true);
    if(pa == null) {
        throw new RuntimeException(new InterruptedException(org.openide.util.NbBundle.getMessage(SvnClientExceptionHandler.class, "MSG_ActionCanceledByUser"))); //NOI18N
    }
    String user = pa.getUserName();
    char[] psswd = pa.getPassword();

    username = user != null ? user : "";
    password = psswd;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:SvnClientCallback.java

示例7: authenticate

import java.net.PasswordAuthentication; //導入方法依賴的package包/類
@Override
public boolean authenticate(String errroMsg) {
    PasswordAuthentication pa = TeamAccessorUtils.getPasswordAuthentication(kenaiProject.getWebLocation().toString(), true);
    if(pa == null) {
        return false;
    }
    
    String user = pa.getUserName();
    char[] password = pa.getPassword();

    setTaskRepository(user, password);

    return true;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:KenaiRepository.java

示例8: getKenaiPassword

import java.net.PasswordAuthentication; //導入方法依賴的package包/類
private static char[] getKenaiPassword(TeamProject kenaiProject) {
    PasswordAuthentication pa = TeamAccessorUtils.getPasswordAuthentication(kenaiProject.getWebLocation().toString(), false);
    if(pa != null) {
        return pa.getPassword();
    }
    return new char[0];                                                     // NOI18N
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,代碼來源:KenaiRepository.java

示例9: propertyChange

import java.net.PasswordAuthentication; //導入方法依賴的package包/類
@Override
public void propertyChange(PropertyChangeEvent evt) {
    if(evt.getPropertyName().equals(TeamAccessor.PROP_LOGIN)) {

        // XXX move to spi?
        // get kenai credentials
        String user;
        char[] psswd;
        PasswordAuthentication pa = 
                TeamAccessorUtils.getPasswordAuthentication(kenaiProject.getWebLocation().toString(), false); // do not force login
        if(pa != null) {
            user = pa.getUserName();
            psswd = pa.getPassword();
        } else {
            user = "";                                                      // NOI18N
            psswd = new char[0];                                            // NOI18N
        }

        setTaskRepository(user, psswd);

        synchronized(KenaiRepository.this) {
            if(evt.getNewValue() != null) {
                if(myIssues != null) {
                    // XXX this is a mess - setting the controller and the query
                    KenaiQueryController c = (KenaiQueryController) myIssues.getController();
                    String url = getMyIssuesQueryUrl();
                    c.populate(url);
                    myIssues.setUrlParameters(url);
                }
            } 
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:34,代碼來源:KenaiRepository.java

示例10: handle

import java.net.PasswordAuthentication; //導入方法依賴的package包/類
@Override
public ChallengeResponse handle(ChallengeRequest challengeRequest) {

    LOG.entering(CLASS_NAME, "handle", new String[]{challengeRequest.getLocation(),
                                                    challengeRequest.getAuthenticationParameters()});

    if (challengeRequest.getLocation() != null) {



        // Start by using this generic Basic handler
        LoginHandler loginHandler = getLoginHandler();

        // Try to delegate to a realm-specific login handler if we can
        String realm = RealmUtils.getRealm(challengeRequest);
        if ( realm != null && loginHandlersByRealm.get(realm) != null) {
            loginHandler = loginHandlersByRealm.get(realm);
        }
        LOG.finest("BasicChallengeHandler.getResponse: login handler = " + loginHandler);
        if (loginHandler != null) {
            PasswordAuthentication creds = loginHandler.getCredentials();
            if (creds != null && creds.getUserName() != null && creds.getPassword() != null) {
                return BasicChallengeResponseFactory.create(creds, this);
            }
        }
    }
    return null;
}
 
開發者ID:Datatellit,項目名稱:xlight_android_native,代碼行數:29,代碼來源:DefaultBasicChallengeHandler.java

示例11: getCredentials

import java.net.PasswordAuthentication; //導入方法依賴的package包/類
public Credentials getCredentials(final AuthScope authscope) {
    Args.notNull(authscope, "Auth scope");
    final Credentials localcreds = internal.getCredentials(authscope);
    if (localcreds != null) {
        return localcreds;
    }
    if (authscope.getHost() != null) {
        PasswordAuthentication systemcreds = getSystemCreds(
                authscope, Authenticator.RequestorType.SERVER);
        if (systemcreds == null) {
            systemcreds = getSystemCreds(
                    authscope, Authenticator.RequestorType.PROXY);
        }
        if (systemcreds != null) {
            final String domain = System.getProperty("http.auth.ntlm.domain");
            if (domain != null) {
                return new NTCredentials(
                        systemcreds.getUserName(),
                        new String(systemcreds.getPassword()),
                        null, domain);
            } else {
                if (AuthSchemes.NTLM.equalsIgnoreCase(authscope.getScheme())) {
                    // Domian may be specified in a fully qualified user name
                    return new NTCredentials(
                            systemcreds.getUserName(),
                            new String(systemcreds.getPassword()),
                            null, null);
                } else {
                    return new UsernamePasswordCredentials(
                            systemcreds.getUserName(),
                            new String(systemcreds.getPassword()));
                }
            }
        }
    }
    return null;
}
 
開發者ID:mozilla-mobile,項目名稱:FirefoxData-android,代碼行數:38,代碼來源:SystemDefaultCredentialsProvider.java


注:本文中的java.net.PasswordAuthentication.getPassword方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。