Search in sources :

Example 1 with BasicAuth

use of org.apache.activemq.artemis.rest.queue.push.xml.BasicAuth in project activemq-artemis by apache.

the class UriStrategy method initAuthentication.

protected void initAuthentication() {
    if (registration.getAuthenticationMechanism() != null) {
        if (registration.getAuthenticationMechanism().getType() instanceof BasicAuth) {
            BasicAuth basic = (BasicAuth) registration.getAuthenticationMechanism().getType();
            UsernamePasswordCredentials creds = new UsernamePasswordCredentials(basic.getUsername(), basic.getPassword());
            AuthScope authScope = new AuthScope(AuthScope.ANY);
            ((DefaultHttpClient) client).getCredentialsProvider().setCredentials(authScope, creds);
            localContext = new BasicHttpContext();
            // Generate BASIC scheme object and stick it to the local execution context
            BasicScheme basicAuth = new BasicScheme();
            localContext.setAttribute("preemptive-auth", basicAuth);
            // Add as the first request interceptor
            ((DefaultHttpClient) client).addRequestInterceptor(new PreemptiveAuth(), 0);
            executor.setHttpContext(localContext);
        }
    }
}
Also used : BasicScheme(org.apache.http.impl.auth.BasicScheme) BasicAuth(org.apache.activemq.artemis.rest.queue.push.xml.BasicAuth) BasicHttpContext(org.apache.http.protocol.BasicHttpContext) AuthScope(org.apache.http.auth.AuthScope) DefaultHttpClient(org.apache.http.impl.client.DefaultHttpClient) UsernamePasswordCredentials(org.apache.http.auth.UsernamePasswordCredentials)

Aggregations

BasicAuth (org.apache.activemq.artemis.rest.queue.push.xml.BasicAuth)1 AuthScope (org.apache.http.auth.AuthScope)1 UsernamePasswordCredentials (org.apache.http.auth.UsernamePasswordCredentials)1 BasicScheme (org.apache.http.impl.auth.BasicScheme)1 DefaultHttpClient (org.apache.http.impl.client.DefaultHttpClient)1 BasicHttpContext (org.apache.http.protocol.BasicHttpContext)1