Code example for DefaultHttpClient

Methods: getCredentialsProvider

     * Login to the ADP site 
     * @return  true if login is successful, false otherwise 
    private boolean login() { 
        httpClient = new DefaultHttpClient();
        httpClient.getCredentialsProvider().setCredentials(new AuthScope(null, -1),
                new UsernamePasswordCredentials(loginName, password));
        return signon(httpClient);
     * Sign on to the ADP eTime site. Return true if signon was successful, false otherwise. Sign on is done through 
     * hitting a series of ADP pages with basic authentication set. Sets the progress bar on the main page. 
     * @param httpClient the http client to be used to sign on. 
     * @return  true if signon was successful, false otherwise. 
    public boolean signon(DefaultHttpClient httpClient) {
        String page;
        page = ETimeUtils.getHtmlPage(httpClient, LOGIN_URL);
        if (page == null || page.contains(LOGIN_FAILED)) {
            return false; 
        page = ETimeUtils.getHtmlPage(httpClient, LOGIN_URL_STEP2);
        return !(page == null || page.contains(LOGIN_FAILED));