use of org.restlet.data.ChallengeScheme in project OpenAM by OpenRock.
the class RestletHeaderAccessTokenVerifier method getChallengeResponse.
/**
* Returns the authentication response sent by a client to an origin server
* instead of org.restlet.engine.adapter.HttpRequest.
*
* @return The authentication response sent by a client to an origin server.
*/
public ChallengeResponse getChallengeResponse(Request request) {
if (request instanceof HttpRequest) {
// Extract the header value
final Series<Header> headers = ((HttpRequest) request).getHttpCall().getRequestHeaders();
final String authorization = headers.getValues(HeaderConstants.HEADER_AUTHORIZATION);
if (authorization != null) {
int space = authorization.indexOf(' ');
if (space != -1) {
String scheme = authorization.substring(0, space);
if (scheme.equalsIgnoreCase("Bearer")) {
ChallengeResponse result = new ChallengeResponse(new ChallengeScheme("HTTP_" + scheme, scheme));
result.setRawValue(authorization.substring(space + 1));
request.setChallengeResponse(result);
return result;
}
}
}
}
return request.getChallengeResponse();
}
Aggregations