use of org.forgerock.oauth2.core.AccessToken in project OpenAM by OpenRock.
the class OAuth2AuditAccessTokenContextProvider method getUserIdFromAccessTokenFromRequest.
private String getUserIdFromAccessTokenFromRequest(Request request) {
String userId = null;
AccessToken accessToken = retrieveAccessTokenFromRequest(request);
if (accessToken != null) {
userId = getUserIdFromToken(accessToken);
}
return userId;
}
use of org.forgerock.oauth2.core.AccessToken in project OpenAM by OpenRock.
the class OAuth2AuditAccessTokenContextProvider method getTrackingIdFromAccessTokenFromAuthorizationHeader.
private String getTrackingIdFromAccessTokenFromAuthorizationHeader(Request request) {
String trackingId = null;
AccessToken accessToken = retrieveAccessTokenFromChallengeResponse(request);
if (accessToken != null) {
trackingId = getTrackingIdFromToken(accessToken);
}
return trackingId;
}
use of org.forgerock.oauth2.core.AccessToken in project OpenAM by OpenRock.
the class AuthorizationRequestEndpoint method getAuthorisationApiToken.
protected AccessToken getAuthorisationApiToken() throws ServerException {
Request req = getRequest();
ChallengeResponse challengeResponse = req.getChallengeResponse();
try {
return oauth2TokenStore.readAccessToken(requestFactory.create(req), challengeResponse.getRawValue());
} catch (InvalidGrantException e) {
throw new ServerException("Unable to verify client identity.");
} catch (NotFoundException e) {
throw new ServerException(e.getMessage());
}
}
use of org.forgerock.oauth2.core.AccessToken in project OpenAM by OpenRock.
the class ConnectClientRegistration method getClient.
/**
* Handles GET requests to the OpenId Connect client registration endpoint for retrieving OpenId Connect client
* registrations.
*
* @return The representation of the client registration details.
* @throws OAuth2RestletException If an error occurs whilst retrieving the client registration.
*/
@Get
public Representation getClient() throws OAuth2RestletException {
final OAuth2Request request = requestFactory.create(getRequest());
final String clientId = request.getParameter(OAuth2Constants.OAuth2Client.CLIENT_ID);
final String accessToken = getRequest().getChallengeResponse().getRawValue();
try {
final JsonValue registration = clientRegistrationService.getRegistration(clientId, accessToken, request);
return jacksonRepresentationFactory.create(registration.asMap());
} catch (OAuth2Exception e) {
throw new OAuth2RestletException(e.getStatusCode(), e.getError(), e.getMessage(), null);
}
}
use of org.forgerock.oauth2.core.AccessToken in project OpenAM by OpenRock.
the class TokenEndpointResourceTest method testToken.
@Test
public void testToken() throws Exception {
//Given
Context context = new Context();
Request request = new Request();
Response response = new Response(request);
tokenEndpointResource.init(context, request, response);
doReturn(new AccessToken(null, OAUTH_ACCESS_TOKEN, null)).when(accessTokenService).requestAccessToken(any(OAuth2Request.class));
//When
tokenEndpointResource.token(new EmptyRepresentation());
//Then
verify(hook).afterTokenHandling(any(OAuth2Request.class), eq(request), eq(response));
}
Aggregations