@Override public void setChallengeResponse(ChallengeResponse response) { super.setChallengeResponse(response); this.securityAdded = true; }
/** * 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); }
/** * Sets the authentication response sent by a client to an origin server. * * @param challengeResponse * The authentication response sent by a client to an origin * server. * @see Request#setChallengeResponse(ChallengeResponse) */ public void setChallengeResponse(ChallengeResponse challengeResponse) { getRequest().setChallengeResponse(challengeResponse); }
@Test public void test() { String url ="http://localhost:8190/project/user/status"; Client client = new Client(Protocol.HTTP); ChallengeResponse challengeResponse = new ChallengeResponse(ChallengeScheme.HTTP_BASIC,"user", "f399b0a660f684b2c5a6b4c054f22d89"); Request request = new Request(Method.GET, url); request.setChallengeResponse(challengeResponse); Response response = client.handle(request); System.out.println("request"+response.getStatus().getCode()); System.out.println("request test::"+response.getEntityAsText()); }
@Override public void handle(Request request, Response response) { if (authenticationEnabled) { // Do not add Authentication info from redirection request since // authentication has already been done. request.getHeaders().removeAll("Authorization"); request.setChallengeResponse(null); } super.handle(request, response); }
@Override public void handle(Request request, Response response) { if (authenticationEnabled) { // Do not add Authentication info from redirection request since // authentication has already been done. request.getHeaders().removeAll("Authorization"); request.setChallengeResponse(null); } super.handle(request, response); }
@Override public void handle(Request request, Response response) { if (authenticationEnabled) { // Do not add Authentication info from redirection request since // authentication has already been done. request.getHeaders().removeAll("Authorization"); request.setChallengeResponse(null); } super.handle(request, response); }
protected void setupAuth(Request request) { if (authType == AUTH_TYPE_BASIC) { ChallengeScheme scheme = ChallengeScheme.HTTP_BASIC; ChallengeResponse authentication = new ChallengeResponse(scheme, userName, password); request.setChallengeResponse(authentication); } else if (authType == AUTH_TYPE_SECRET) { Series<Parameter> additionnalHeaders = new Form(); Map<String, String> securityHeaders = PortalSSOAuthenticationProvider.getHeaders(secretToken, userName); for (String hn : securityHeaders.keySet()) { additionnalHeaders.add(hn, securityHeaders.get(hn)); } request.getAttributes().put("org.restlet.http.headers", additionnalHeaders); } }
@Override public void handle(Request request, Response response) { if (authenticationEnabled) { // Do not add Authentication info from redirection request since // authentication has already been done. request.getHeaders().removeAll("Authorization"); request.setChallengeResponse(null); } super.handle(request, response); }
@Override public void handle(Request request, Response response) { if (authenticationEnabled) { // Do not add Authentication info from redirection request since // authentication has already been done. request.getHeaders().removeAll("Authorization"); request.setChallengeResponse(null); } super.handle(request, response); }
/** * Processes the logout request. * * @param request * The current request. * @param response * The current response. */ protected int logout(final Request request, final Response response) { // Clears the credentials request.setChallengeResponse(null); final CookieSetting credentialsCookie = this.getCredentialsCookie(request, response); credentialsCookie.setMaxAge(0); this.log.debug("calling attemptRedirect after logout"); // Attempt to redirect this.attemptRedirect(request, response, null); return Filter.STOP; }
/** * Restores credentials from the cookie named {@link #getCookieName()} if available. The usual * processing is the followed. */ @Override protected boolean authenticate(final Request request, final Response response) { // Restore credentials from the cookie final Cookie credentialsCookie = request.getCookies().getFirst(this.getCookieName()); if(credentialsCookie != null) { ChallengeResponse credentials = this.parseCredentials(credentialsCookie.getValue()); if(credentials == null) { response.getCookieSettings().removeAll(this.getCookieName()); } else { request.setChallengeResponse(credentials); } } this.log.debug("Calling super.authenticate"); return super.authenticate(request, response); }
@Override protected int beforeHandle(Request request, Response response) { Cookie cookie = request.getCookies().getFirst("Credentials"); if (cookie != null) { // Extract the challenge response from the cookie String[] credentials = cookie.getValue().split("="); if (credentials.length == 2) { String identifier = credentials[0]; String secret = credentials[1]; request.setChallengeResponse(new ChallengeResponse( ChallengeScheme.HTTP_COOKIE, identifier, secret)); } } else if (Method.POST.equals(request.getMethod()) && request.getResourceRef().getQueryAsForm().getFirst("login") != null) { // Intercepting a login form Form credentials = new Form(request.getEntity()); String identifier = credentials.getFirstValue("identifier"); String secret = credentials.getFirstValue("secret"); request.setChallengeResponse(new ChallengeResponse( ChallengeScheme.HTTP_COOKIE, identifier, secret)); // Continue call processing to return the target representation if // authentication is successful or a new login page request.setMethod(Method.GET); } return super.beforeHandle(request, response); }
@Override protected int beforeHandle(Request request, Response response) { Cookie cookie = request.getCookies().getFirst("Credentials"); if (cookie != null) { // Extract the challenge response from the cookie String[] credentials = cookie.getValue().split("="); if (credentials.length == 2) { String identifier = credentials[0]; String secret = credentials[1]; request.setChallengeResponse(new ChallengeResponse( ChallengeScheme.HTTP_COOKIE, identifier, secret)); } } else if (Method.POST.equals(request.getMethod()) && request.getResourceRef().getQueryAsForm().getFirst("login") != null) { // Intercepting a login form Form credentials = new Form(request.getEntity()); String identifier = credentials.getFirstValue("identifier"); String secret = credentials.getFirstValue("secret"); request.setChallengeResponse(new ChallengeResponse( ChallengeScheme.HTTP_COOKIE, identifier, secret)); // Continue call processing to return the target representation if // authentication is successful or a new login page request.setMethod(Method.GET); } return super.beforeHandle(request, response); }
public static void main(String[] args) throws Exception { // Prepare the request Request request = new Request(Method.GET, "http://s3.amazonaws.com/quotes/nelson"); request.setChallengeResponse(new ChallengeResponse( ChallengeScheme.HTTP_AWS_S3, "44CF9590006BF252F707", "OtxrzxIsfpFjA7SwPzILwy8Bw21TLhquhboDYROV")); // Add some extra headers Series<Header> extraHeaders = new Series<Header>(Header.class); extraHeaders.add("X-Amz-Meta-Author", "foo@bar.com"); extraHeaders.add("X-Amz-Magic", "abracadabra"); // For the test we hard coded a special date header. Normally you don't // need this as the // HTTP client connector will automatically provide an accurate Date // header and use it // for authentication. // extraHeaders.add("X-Amz-Date", "Thu, 17 Nov 2005 18:49:58 GMT"); request.getAttributes().put(HeaderConstants.ATTRIBUTE_HEADERS, extraHeaders); // Handle it using an HTTP client connector Client client = new Client(Protocol.HTTP); Response response = client.handle(request); // Write the response entity on the console Representation output = response.getEntity(); output.write(System.out); }
/** * Processes the login request. * * @param request * The current request. * @param response * The current response. */ protected void login(final Request request, final Response response) { // Login detected final Form form = new Form(request.getEntity()); final Parameter identifier = form.getFirst(this.getIdentifierFormName()); final Parameter secret = form.getFirst(this.getSecretFormName()); // Set credentials final ChallengeResponse cr = new ChallengeResponse(this.getScheme(), identifier != null ? identifier.getValue() : null, secret != null ? secret.getValue() : null); request.setChallengeResponse(cr); this.log.info("calling attemptRedirect after login"); // Attempt to redirect this.attemptRedirect(request, response, form); }
ChallengeScheme.HTTP_OAUTH_BEARER); cr.setRawValue(token.getAccessToken()); request.setChallengeResponse(cr);
request.setChallengeResponse( new ChallengeResponse( ChallengeScheme.HTTP_BASIC, user.getName(), user.getSecret() ) );
request.setChallengeResponse( new ChallengeResponse( ChallengeScheme.HTTP_BASIC, user.getName(), user.getSecret() ) );