/** * Sets the authentication response sent by a client to an origin server. * * @param response * The authentication response sent by a client to an origin * server. */ @Override public void setChallengeResponse(ChallengeResponse response) { getWrappedRequest().setChallengeResponse(response); }
private Request makeRequest(Reference uri, MediaType accepts) { Request request = new Request(); logger.debug("Making new request for " + uri + " -- " + uri.getTargetRef()); request.setResourceRef(uri.getTargetRef()); if (accepts != null) { request.getClientInfo().getAcceptedMediaTypes().add( new Preference<MediaType>(accepts)); } if (baseURI.isParent(uri) && username != null) { logger.debug("Authenticating as " + username); ChallengeResponse challengeResponse = new ChallengeResponse(ChallengeScheme.HTTP_BASIC, username, password); request.setChallengeResponse(challengeResponse); } else { logger.warn("Not supplying credentials for out-of-site URI " + uri); } return request; }
public Response sendRequest( Method method, String url, Representation representation ) { this.logger.debug( "Method: " + method.getName() + " url: " + url ); Request request = new Request(); request.setResourceRef( url ); request.setMethod( method ); if ( !Method.GET.equals( method ) && !Method.DELETE.equals( method ) ) { request.setEntity( representation ); } request.setChallengeResponse( this.challenge ); return this.restClient.handle( request ); }
public Response sendMessage( final Request request, final Matcher<Response> matchers ) throws IOException { checkNotNull( request ); // check the text context to see if this is a secure test if ( testContext.isSecureTest() ) { // ChallengeScheme scheme = new ChallengeScheme( "HTTP_NxBasic", "NxBasic", "Nexus Basic" ); ChallengeResponse authentication = new ChallengeResponse( ChallengeScheme.HTTP_BASIC, testContext.getUsername(), testContext.getPassword() ); request.setChallengeResponse( authentication ); } LOG.debug( "sendMessage: " + request.getMethod().getName() + " " + request.getResourceRef().toString() ); Response response = client.handle( request ); if ( matchers != null ) { try { assertThat( response, matchers ); } catch ( AssertionError e ) { releaseResponse( response ); throw e; } } return response; }
request.setChallengeResponse(authentication);
context.getUsername(), context.getPassword() ); request.setChallengeResponse( authentication );