public void setAuthenticationToken ( Authentication authentication ) { if ( logger . isDebugEnabled ( ) ) { logger . debug ( "New authentication token: " + authentication ) ; } HttpComponentsHttpInvokerRequestExecutor executor = ( HttpComponentsHttpInvokerRequestExecutor ) getHttpInvokerRequestExecutor ( ) ; DefaultHttpClient httpClient = ( DefaultHttpClient ) executor . getHttpClient ( ) ; BasicCredentialsProvider provider = new BasicCredentialsProvider ( ) ; httpClient . setCredentialsProvider ( provider ) ; httpClient . addRequestInterceptor ( new PreemptiveAuthInterceptor ( ) ) ; UsernamePasswordCredentials usernamePasswordCredentials ; if ( authentication != null ) { usernamePasswordCredentials = new UsernamePasswordCredentials ( authentication . getName ( ) , authentication . getCredentials ( ) . toString ( ) ) ; } else { usernamePasswordCredentials = null ; } provider . setCredentials ( AuthScope . ANY , usernamePasswordCredentials ) ; }
Handle a change in the current authentication token . This method will fail fast if the executor isn t a CommonsHttpInvokerRequestExecutor .