Code example for PasswordAuthentication

0
     * @return the PasswordAuthentication instance 
     */ 
    protected PasswordAuthentication getPasswordAuthentication() {
        if ( m_auth == null ) {
            m_auth = new PasswordAuthentication(
                        m_username, m_password.toCharArray());
        } 
        return m_auth;
    } 
 
    // ------------------------------------------------------------------------ 
     
    /** 
     * Creates a new PasswordAuthenticator for the given name and password and 
     * sets it as the default Authenticator for use within Java networking. 
     */ 
    public static void setAuthentication(String username, String password) {
        Authenticator.setDefault(new PasswordAuthenticator(username,password));
    } 
     
} // end of class PasswordAuthenticator