use of org.forgerock.oauth2.core.exceptions.ServerException in project OpenAM by OpenRock.
the class ClaimsParameterValidatorTest method shouldValidateClaimsParameter.
@Test
public void shouldValidateClaimsParameter() throws NotFoundException, BadRequestException, RedirectUriMismatchException, InvalidScopeException, InvalidRequestException, InvalidClientException, ServerException, UnsupportedResponseTypeException {
//given
OAuth2Request mockRequest = mock(OAuth2Request.class);
OAuth2ProviderSettings mockProviderSettings = mock(OAuth2ProviderSettings.class);
String responseTypes = "code token id_token";
given(mockProviderSettingsFactory.get(mockRequest)).willReturn(mockProviderSettings);
given(mockProviderSettings.getClaimsParameterSupported()).willReturn(true);
given(mockRequest.getParameter(OAuth2Constants.Custom.CLAIMS)).willReturn(validClaimsString);
given(mockRequest.getParameter(OAuth2Constants.Params.RESPONSE_TYPE)).willReturn(responseTypes);
//when
claimsParameterValidator.validateRequest(mockRequest);
//then
}
use of org.forgerock.oauth2.core.exceptions.ServerException in project OpenAM by OpenRock.
the class SubjectTypeValidatorTest method shouldValidateRequest.
@Test
public void shouldValidateRequest() throws InvalidClientException, NotFoundException, ServerException {
//given
OAuth2ProviderSettings mockProviderSettings = mock(OAuth2ProviderSettings.class);
OAuth2Request mockRequest = mock(OAuth2Request.class);
OpenIdConnectClientRegistration mockClientRegistration = mock(OpenIdConnectClientRegistration.class);
Set<String> subjectTypesSupported = new HashSet<String>();
subjectTypesSupported.add("public");
given(mockProviderSettingsFactory.get(mockRequest)).willReturn(mockProviderSettings);
given(mockProviderSettings.getSupportedSubjectTypes()).willReturn(subjectTypesSupported);
given(mockRequest.getParameter(OAuth2Constants.Params.CLIENT_ID)).willReturn("CLIENT_ID");
given(mockClientRegistrationStore.get("CLIENT_ID", mockRequest)).willReturn(mockClientRegistration);
given(mockClientRegistration.getSubjectType()).willReturn("public");
//when
subjectTypeValidator.validateRequest(mockRequest);
//then
}
use of org.forgerock.oauth2.core.exceptions.ServerException in project OpenAM by OpenRock.
the class SubjectTypeValidatorTest method shouldFailSubjectTypeNotSupported.
@Test(expectedExceptions = InvalidClientException.class)
public void shouldFailSubjectTypeNotSupported() throws InvalidClientException, NotFoundException, ServerException {
//given
OAuth2ProviderSettings mockProviderSettings = mock(OAuth2ProviderSettings.class);
OAuth2Request mockRequest = mock(OAuth2Request.class);
OpenIdConnectClientRegistration mockClientRegistration = mock(OpenIdConnectClientRegistration.class);
Set<String> subjectTypesSupported = new HashSet<String>();
subjectTypesSupported.add("public");
given(mockProviderSettingsFactory.get(mockRequest)).willReturn(mockProviderSettings);
given(mockProviderSettings.getSupportedSubjectTypes()).willReturn(subjectTypesSupported);
given(mockRequest.getParameter(OAuth2Constants.Params.CLIENT_ID)).willReturn("CLIENT_ID");
given(mockClientRegistrationStore.get("CLIENT_ID", mockRequest)).willReturn(mockClientRegistration);
given(mockClientRegistration.getSubjectType()).willReturn("pairwise");
//when
subjectTypeValidator.validateRequest(mockRequest);
//then
}
use of org.forgerock.oauth2.core.exceptions.ServerException in project OpenAM by OpenRock.
the class OpenAMResourceSetStore method create.
@Override
public void create(OAuth2Request request, ResourceSetDescription resourceSetDescription) throws ServerException, BadRequestException, NotFoundException {
resourceSetDescription.setId(idGenerator.generateTokenId(null));
String policyEndpoint = oauth2UrisFactory.get(request).getResourceSetRegistrationPolicyEndpoint(resourceSetDescription.getId());
resourceSetDescription.setPolicyUri(policyEndpoint);
resourceSetDescription.setRealm(realm);
try {
delegate.create(resourceSetDescription);
} catch (org.forgerock.openam.sm.datalayer.store.ServerException e) {
throw new ServerException(e);
}
}
use of org.forgerock.oauth2.core.exceptions.ServerException in project OpenAM by OpenRock.
the class OpenAMResourceSetStore method update.
@Override
public void update(ResourceSetDescription resourceSetDescription) throws NotFoundException, ServerException {
try {
if (!realm.equals(resourceSetDescription.getRealm())) {
throw new ServerException("Could not read token with id, " + resourceSetDescription.getId() + ", in realm, " + realm);
}
read(resourceSetDescription.getId(), resourceSetDescription.getResourceOwnerId());
delegate.update(resourceSetDescription);
} catch (org.forgerock.openam.sm.datalayer.store.NotFoundException e) {
throw new NotFoundException("Resource set does not exist with id " + resourceSetDescription.getId());
} catch (org.forgerock.openam.sm.datalayer.store.ServerException e) {
throw new ServerException(e);
}
}
Aggregations