Example usage for org.apache.commons.httpclient.auth AuthScope ANY_SCHEME

List of usage examples for org.apache.commons.httpclient.auth AuthScope ANY_SCHEME

Introduction

In this page you can find the example usage for org.apache.commons.httpclient.auth AuthScope ANY_SCHEME.

Prototype

String ANY_SCHEME

To view the source code for org.apache.commons.httpclient.auth AuthScope ANY_SCHEME.

Click Source Link

Usage

From source file:com.twinsoft.convertigo.engine.HttpStateEvent.java

private Credentials getCredentials() {
    Credentials credentials = null;//from  w  ww  .  j  ava  2 s. c  o  m
    if (httpState != null) {
        if (host != null) {
            AuthScope authScope = new AuthScope(host, AuthScope.ANY_PORT, realm, AuthScope.ANY_SCHEME);
            credentials = httpState.getCredentials(authScope);
        }
    }
    return credentials;
}

From source file:be.fedict.trust.Credential.java

/**
 * Any scheme is allowed./*from ww w  . java  2 s  . c  o m*/
 * 
 * @param host
 * @param port
 * @param realm
 * @param username
 * @param password
 */
public Credential(String host, int port, String realm, String username, String password) {
    this(host, port, realm, AuthScope.ANY_SCHEME, username, password);
}

From source file:com.legstar.http.client.CicsHttpTest.java

/**
 * Try to create a state.//from   www. j  a v  a 2s.  c o  m
 */
public void testCreateHttpState() {
    CicsHttp cicsHttp = new CicsHttp(getName(), getEndpoint());
    HttpState state = cicsHttp.createHttpState("mainframe", 3080, "P390", "TRUC", null);
    AuthScope as = new AuthScope("mainframe", 3080, null, AuthScope.ANY_SCHEME);
    assertEquals("P390:TRUC", state.getCredentials(as).toString());
}

From source file:it.drwolf.ridire.session.async.JobDBDataUpdater.java

private void create() {
    Protocol.registerProtocol("https", new Protocol("https", new EasySSLProtocolSocketFactory(), 8443));
    this.httpClient = new HttpClient();
    this.httpClient.getParams().setAuthenticationPreemptive(true);
    Credentials defaultcreds = new UsernamePasswordCredentials("admin", this.entityManager
            .find(CommandParameter.class, CommandParameter.HERITRIX_ADMINPW_KEY).getCommandValue());
    this.httpClient.getState().setCredentials(
            new AuthScope(AuthScope.ANY_SCHEME, AuthScope.ANY_PORT, AuthScope.ANY_REALM), defaultcreds);
    this.engineUri = this.entityManager.find(Parameter.class, Parameter.ENGINE_URI.getKey()).getValue();
    Logger httpClientlogger = Logger.getLogger(this.httpClient.getClass());
    httpClientlogger.setLevel(Level.ERROR);
    Logger authChallengeProcessorLogger = Logger.getLogger(AuthChallengeProcessor.class);
    authChallengeProcessorLogger.setLevel(Level.ERROR);
    Logger httpMethodBaseLogger = Logger.getLogger(HttpMethodBase.class);
    httpMethodBaseLogger.setLevel(Level.ERROR);
    this.jobsDir = this.entityManager.find(Parameter.class, Parameter.JOBS_DIR.getKey()).getValue();
}

From source file:com.gargoylesoftware.htmlunit.DefaultCredentialsProvider.java

/**
 * Adds credentials for the specified username/password on the specified host/port for the
 * specified realm. The credentials may be for any authentication scheme, including NTLM,
 * digest and basic HTTP authentication.
 * @param username the username for the new credentials
 * @param password the password for the new credentials
 * @param host the host to which to the new credentials apply (<tt>null</tt> if applicable to any host)
 * @param port the port to which to the new credentials apply (negative if applicable to any port)
 * @param realm the realm to which to the new credentials apply (<tt>null</tt> if applicable to any realm)
 *//* w  w w .j av a  2  s.c  o  m*/
public void addCredentials(final String username, final String password, final String host, final int port,
        final String realm) {
    final AuthScopeProxy scope = new AuthScopeProxy(host, port, realm, AuthScope.ANY_SCHEME);
    final Credentials c = new UsernamePasswordCredentialsExt(username, password);
    credentials_.put(scope, c);
    clearAnswered(); // don't need to be precise, will cause in worst case one extra request
}

From source file:edu.ucsd.xmlrpc.xmlrpc.client.XmlRpcCommonsTransport.java

protected void setCredentials(XmlRpcHttpClientConfig pConfig) throws XmlRpcClientException {
    String userName = pConfig.getBasicUserName();
    if (userName != null) {
        String enc = pConfig.getBasicEncoding();
        if (enc == null) {
            enc = XmlRpcStreamConfig.UTF8_ENCODING;
        }//from  w w w  . j av  a 2 s  .  c  o  m
        client.getParams().setParameter(HttpMethodParams.CREDENTIAL_CHARSET, enc);
        Credentials creds = new UsernamePasswordCredentials(userName, pConfig.getBasicPassword());
        AuthScope scope = new AuthScope(null, AuthScope.ANY_PORT, null, AuthScope.ANY_SCHEME);
        client.getState().setCredentials(scope, creds);
        client.getParams().setAuthenticationPreemptive(true);
    }
}

From source file:it.drwolf.ridire.session.async.JobMapperMonitor.java

private void create() {
    int transactionTimeoutSeconds = 240;
    try {//  www  . j a  v a  2s . c o  m
        ((javax.transaction.UserTransaction) org.jboss.seam.transaction.Transaction.instance())
                .setTransactionTimeout(transactionTimeoutSeconds);
    } catch (SystemException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    Protocol.registerProtocol("https", new Protocol("https", new EasySSLProtocolSocketFactory(), 8443));
    this.httpClient = new HttpClient();
    this.httpClient.getParams().setAuthenticationPreemptive(true);
    this.mainUserTx = (UserTransaction) org.jboss.seam.Component
            .getInstance("org.jboss.seam.transaction.transaction", ScopeType.APPLICATION);
    Credentials defaultcreds = null;
    int jobsToBeProcessed = 4;
    try {
        this.mainUserTx.setTransactionTimeout(10 * 10 * 60);
        // 10 mins
        this.mainUserTx.begin();
        this.eventEntityManager.joinTransaction();
        defaultcreds = new UsernamePasswordCredentials("admin", this.eventEntityManager
                .find(CommandParameter.class, CommandParameter.HERITRIX_ADMINPW_KEY).getCommandValue());
        jobsToBeProcessed = Integer.parseInt(this.eventEntityManager
                .find(Parameter.class, Parameter.JOBS_TO_BE_PROCESSED.getKey()).getValue());
        JobMapperMonitor.JOBSDIR = this.eventEntityManager.find(Parameter.class, Parameter.JOBS_DIR.getKey())
                .getValue();
        this.flagBearer.setHostname(
                this.eventEntityManager.find(Parameter.class, Parameter.HOSTNAME.getKey()).getValue());
        this.eventEntityManager.flush();
        this.mainUserTx.commit();
    } catch (Exception e) {
        e.printStackTrace();
    }
    this.httpClient.getState().setCredentials(
            new AuthScope(AuthScope.ANY_SCHEME, AuthScope.ANY_PORT, AuthScope.ANY_REALM), defaultcreds);
    Logger httpClientlogger = Logger.getLogger(this.httpClient.getClass());
    httpClientlogger.setLevel(Level.ERROR);
    Logger authChallengeProcessorLogger = Logger.getLogger(AuthChallengeProcessor.class);
    authChallengeProcessorLogger.setLevel(Level.ERROR);
    Logger httpMethodBaseLogger = Logger.getLogger(HttpMethodBase.class);
    httpMethodBaseLogger.setLevel(Level.ERROR);
    this.highPoolThreadFactory = new PoolThreadFactory(JobMapperMonitor.THREADS_PRIORITY);
    this.threadPool = new ThreadPoolExecutor(jobsToBeProcessed, jobsToBeProcessed, 100, TimeUnit.SECONDS,
            new LinkedBlockingQueue<Runnable>(), this.highPoolThreadFactory);
}

From source file:com.gargoylesoftware.htmlunit.DefaultCredentialsProvider.java

/**
 * Adds proxy credentials for the specified username/password on the specified host/port.
 * @param username the username for the new credentials
 * @param password the password for the new credentials
 * @param host the host to which to the new credentials apply (<tt>null</tt> if applicable to any host)
 * @param port the port to which to the new credentials apply (negative if applicable to any port)
 *//*from  w  w  w  . j av a 2  s  .c om*/
public void addProxyCredentials(final String username, final String password, final String host,
        final int port) {
    final AuthScopeProxy scope = new AuthScopeProxy(host, port, AuthScope.ANY_REALM, AuthScope.ANY_SCHEME);
    final Credentials c = new UsernamePasswordCredentialsExt(username, password);
    proxyCredentials_.put(scope, c);
    clearAnswered(); // don't need to be precise, will cause in worst case one extra request
}

From source file:com.gargoylesoftware.htmlunit.DefaultCredentialsProvider.java

/**
 * Adds NTLM credentials for the specified username/password on the specified host/port.
 * @param username the username for the new credentials; should not include the domain to authenticate with;
 *        for example: <tt>"user"</tt> is correct whereas <tt>"DOMAIN\\user"</tt> is not
 * @param password the password for the new credentials
 * @param host the host to which to the new credentials apply (<tt>null</tt> if applicable to any host)
 * @param port the port to which to the new credentials apply (negative if applicable to any port)
 * @param clientHost the host the authentication request is originating from; essentially, the computer name for
 *        this machine./*from w  w  w.  j  a  v  a2  s. co m*/
 * @param clientDomain the domain to authenticate within
 */
public void addNTLMCredentials(final String username, final String password, final String host, final int port,
        final String clientHost, final String clientDomain) {
    final AuthScopeProxy scope = new AuthScopeProxy(host, port, AuthScope.ANY_REALM, AuthScope.ANY_SCHEME);
    final Credentials c = new NTCredentialsExt(username, password, clientHost, clientDomain);
    credentials_.put(scope, c);
    clearAnswered(); // don't need to be precise, will cause in worst case one extra request
}

From source file:com.intuit.tank.httpclient3.TankHttpClient3.java

@Override
public void addAuth(AuthCredentials creds) {
    String host = (StringUtils.isBlank(creds.getHost()) || "*".equals(creds.getHost())) ? AuthScope.ANY_HOST
            : creds.getHost();//w  w  w .  j  av  a2s.co m
    String realm = (StringUtils.isBlank(creds.getRealm()) || "*".equals(creds.getRealm())) ? AuthScope.ANY_REALM
            : creds.getRealm();
    int port = NumberUtils.toInt(creds.getPortString(), AuthScope.ANY_PORT);
    String scheme = creds.getScheme() != null ? creds.getScheme().getRepresentation() : AuthScope.ANY_SCHEME;

    Credentials defaultcreds = new UsernamePasswordCredentials(creds.getUserName(), creds.getPassword());
    httpclient.getState().setCredentials(new AuthScope(host, port, realm, scheme), defaultcreds);
}