Package org.apache.commons.httpclient.auth

Examples of org.apache.commons.httpclient.auth.AuthState


        // Clean up existing authentication headers
        if (!cleanAuthHeaders(method, PROXY_AUTH_RESP)) {
            // User defined authentication header(s) present
            return;
        }
        AuthState authstate = method.getProxyAuthState();
        AuthScheme authscheme = authstate.getAuthScheme();
        if (authscheme == null) {
            return;
        }
        if (authstate.isAuthRequested() || !authscheme.isConnectionBased()) {
            AuthScope authscope = new AuthScope(
                conn.getProxyHost(), conn.getProxyPort(),
                authscheme.getRealm(),
                authscheme.getSchemeName())
            if (LOG.isDebugEnabled()) {
View Full Code Here


            }
            applyConnectionParams(this.connectMethod);                   
            this.connectMethod.execute(state, this.conn);
            code = this.connectMethod.getStatusCode();
            boolean retry = false;
            AuthState authstate = this.connectMethod.getProxyAuthState();
            authstate.setAuthRequested(code == HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED);
            if (authstate.isAuthRequested()) {
                if (processAuthenticationResponse(this.connectMethod)) {
                    retry = true;
                }
            }
            if (!retry) {
View Full Code Here

    }

    private boolean processClaimsAuthChallenge(HttpMethod method)
            throws MalformedChallengeException, AuthenticationException, IOException
    {
        AuthState authstate = method.getHostAuthState();
        if (authstate.getAuthScheme() == null) {
            authstate.setAuthScheme(new ClaimsAuthScheme());
        }
        ClaimsAuthScheme claims = (ClaimsAuthScheme)authstate.getAuthScheme();

        AuthScope authscope = new AuthScope(
            method.getHostConfiguration().getHost(),
            method.getHostConfiguration().getPort(),
            claims.getRealm(),
            claims.getSchemeName());

        CredentialsProvider cp = (CredentialsProvider)method.getParams().getParameter(
             CredentialsProvider.PROVIDER);
        Credentials creds = (cp == null) ?
            state.getCredentials(AuthScope.ANY) :
            cp.getCredentials(claims, authscope.getHost(), authscope.getPort(), false);
           
        if (adfsLogin(method.getURI().getScheme()
            + "://" + method.getURI().getAuthority(), creds)) {
          claims.setComplete();
          return true;
        }

        this.state.setCredentials(authscope, creds);
        if (method.getStatusCode() == HttpStatus.SC_FORBIDDEN) {
            claims.originalUri = method.getURI();
            method.setRequestHeader(new Header("User-Agent", "Mozilla/4.0"));
            Header xforms = method.getResponseHeader("X-Forms_Based_Auth_Required");
            if (xforms == null) {
                throw new MalformedChallengeException("Status 403 Forbidden received from" +
                    "server, but X-Forms_Based_Auth_Required header missing - not claims " +
                    "based authentication");
            }
            URI xform = new URI(xforms.getValue().split(", ")[0]);
            hostConfiguration.setHost(xform);
            method.setURI(xform);
        } else if (method.getStatusCode() == HttpStatus.SC_MOVED_TEMPORARILY) {
            Header cookie = method.getResponseHeader("Set-Cookie");
            if (cookie != null && cookie.getValue().startsWith("FedAuth")) {
                method.removeRequestHeader("Authorization");
                method.setURI(claims.originalUri);
                hostConfiguration.setHost(claims.originalUri);
                claims.setComplete();
                authstate.setAuthScheme(null);
            }
        }
        return true;
    }
View Full Code Here

  private static final String PROXY_NTLM_VALUE = "NTLM"; //$NON-NLS-1$

  public static boolean detectNTLMProxy(HttpMethodBase method) {
    if (method == null)
      return false;
    AuthState authState = method.getProxyAuthState();
    if (authState == null)
      return false;
    AuthScheme authScheme = authState.getAuthScheme();
    if (authScheme == null)
      return false;
    String schemeName = authScheme.getSchemeName();
    if (schemeName == null)
      return false;
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.auth.AuthState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.