use of org.forgerock.oauth2.restlet.OAuth2RestletException in project OpenAM by OpenRock.
the class EndSessionTest method shouldAttemptEndSessionAndFailMismatchRedirect.
@Test
public void shouldAttemptEndSessionAndFailMismatchRedirect() throws Exception {
// given
String requestedUri = "http://www.example.com";
String registeredUri = "http://www.google.com";
when(oAuth2Request.getParameter(OAuth2Constants.Params.POST_LOGOUT_REDIRECT_URI)).thenReturn(requestedUri);
when(client.getPostLogoutRedirectUris()).thenReturn(Collections.singleton(new URI(registeredUri)));
// when
OAuth2RestletException exception = null;
try {
endSession.endSession();
} catch (OAuth2RestletException e) {
exception = e;
}
// then
verify(openIDConnectEndSession, times(1)).endSession(any(String.class));
assertThat(exception).isNotNull();
assertThat(exception.getError()).isEqualTo("redirect_uri_mismatch");
}
use of org.forgerock.oauth2.restlet.OAuth2RestletException in project OpenAM by OpenRock.
the class OpenIDConnectConfiguration method getConfiguration.
/**
* Handles GET requests to the OpenId Connect .well-known endpoint for retrieving the OpenId Connect provider
* configuration.
*
* @return The representation of the OpenId Connect provider configuration.
* @throws OAuth2RestletException If an error occurs whilst retrieving the OpenId Connect provider configuration.
*/
@Get
public Representation getConfiguration() throws OAuth2RestletException {
try {
final OAuth2Request request = requestFactory.create(getRequest());
final JsonValue configuration = providerConfiguration.getConfiguration(request);
return new JsonRepresentation(configuration.asMap());
} catch (OAuth2Exception e) {
throw new OAuth2RestletException(e.getStatusCode(), e.getError(), e.getMessage(), null);
}
}
use of org.forgerock.oauth2.restlet.OAuth2RestletException in project OpenAM by OpenRock.
the class OpenIDConnectDiscovery method discovery.
/**
* Handles GET requests to the OpenId Connect discovery endpoint.
*
* @return The representation of the OpenId Connect discovery.
* @throws OAuth2RestletException If an error occurs whilst performing the discovery.
*/
@Get
public Representation discovery() throws OAuth2RestletException {
final OAuth2Request request = requestFactory.create(getRequest());
final String resource = request.getParameter("resource");
final String rel = request.getParameter("rel");
final String realm = request.getParameter("realm");
try {
final String deploymentUrl = baseUrlProviderFactory.get(realm).getRootURL(ServletUtils.getRequest(getRequest()));
final Map<String, Object> response = providerDiscovery.discover(resource, rel, deploymentUrl, request);
return new JsonRepresentation(response);
} catch (OAuth2Exception e) {
throw new OAuth2RestletException(e.getStatusCode(), e.getError(), e.getMessage(), null);
}
}
use of org.forgerock.oauth2.restlet.OAuth2RestletException 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);
}
}
Aggregations