use of io.jans.as.model.uma.UmaMetadata in project jans by JanssenProject.
the class OpClientFactoryMockImpl method createUmaClientFactory.
public synchronized UmaClientFactory createUmaClientFactory() {
Optional<UmaClientFactory> umaClientFactoryOpt = Optional.ofNullable((UmaClientFactory) opClientCache.getIfPresent("umaClientFactory"));
Optional<UmaMetadataService> umaMetadataServiceOpt = Optional.ofNullable((UmaMetadataService) opClientCache.getIfPresent("UmaMetadataService"));
UmaClientFactory umaClientFactory = null;
if (!umaClientFactoryOpt.isPresent() || !umaMetadataServiceOpt.isPresent()) {
umaClientFactory = mock(UmaClientFactory.class);
UmaMetadataService umaMetadataService = mock(UmaMetadataService.class);
UmaMetadata umaMetadata = new UmaMetadata();
when(umaClientFactory.createMetadataService(any(), any())).thenReturn(umaMetadataService);
when(umaMetadataService.getMetadata()).thenReturn(umaMetadata);
opClientCache.put("umaClientFactory", umaClientFactory);
opClientCache.put("UmaMetadataService", umaMetadataService);
} else {
umaClientFactory = (UmaClientFactory) opClientCache.getIfPresent("umaClientFactory");
}
return umaClientFactory;
}
use of io.jans.as.model.uma.UmaMetadata in project jans by JanssenProject.
the class UmaMetadataWS method getConfiguration.
@GET
@Produces({ UmaConstants.JSON_MEDIA_TYPE })
public Response getConfiguration() {
errorResponseFactory.validateComponentEnabled(ComponentType.UMA);
try {
final String baseEndpointUri = appConfiguration.getBaseEndpoint();
final UmaMetadata c = new UmaMetadata();
c.setIssuer(appConfiguration.getIssuer());
c.setGrantTypesSupported(new String[] { GrantType.AUTHORIZATION_CODE.getValue(), GrantType.IMPLICIT.getValue(), GrantType.CLIENT_CREDENTIALS.getValue(), GrantType.OXAUTH_UMA_TICKET.getValue() });
c.setResponseTypesSupported(new String[] { ResponseType.CODE.getValue(), ResponseType.ID_TOKEN.getValue(), ResponseType.TOKEN.getValue() });
c.setTokenEndpointAuthMethodsSupported(appConfiguration.getTokenEndpointAuthMethodsSupported().toArray(new String[appConfiguration.getTokenEndpointAuthMethodsSupported().size()]));
c.setTokenEndpointAuthSigningAlgValuesSupported(appConfiguration.getTokenEndpointAuthSigningAlgValuesSupported().toArray(new String[appConfiguration.getTokenEndpointAuthSigningAlgValuesSupported().size()]));
c.setUiLocalesSupported(appConfiguration.getUiLocalesSupported().toArray(new String[appConfiguration.getUiLocalesSupported().size()]));
c.setOpTosUri(appConfiguration.getOpTosUri());
c.setOpPolicyUri(appConfiguration.getOpPolicyUri());
c.setJwksUri(appConfiguration.getJwksUri());
c.setServiceDocumentation(appConfiguration.getServiceDocumentation());
c.setUmaProfilesSupported(new String[0]);
c.setRegistrationEndpoint(appConfiguration.getRegistrationEndpoint());
c.setTokenEndpoint(appConfiguration.getTokenEndpoint());
c.setAuthorizationEndpoint(appConfiguration.getAuthorizationEndpoint());
c.setIntrospectionEndpoint(baseEndpointUri + "/rpt/status");
c.setResourceRegistrationEndpoint(baseEndpointUri + "/host/rsrc/resource_set");
c.setPermissionEndpoint(baseEndpointUri + "/host/rsrc_pr");
c.setScopeEndpoint(baseEndpointUri + UMA_SCOPES_SUFFIX);
c.setClaimsInteractionEndpoint(baseEndpointUri + UMA_CLAIMS_GATHERING_PATH);
// convert manually to avoid possible conflicts between resteasy providers, e.g. jettison, jackson
final String entity = ServerUtil.asPrettyJson(c);
log.trace("Uma metadata: {}", entity);
return Response.ok(entity).build();
} catch (Exception ex) {
log.error(ex.getMessage(), ex);
throw errorResponseFactory.createWebApplicationException(Response.Status.INTERNAL_SERVER_ERROR, UmaErrorResponseType.SERVER_ERROR, "Internal error.");
}
}
use of io.jans.as.model.uma.UmaMetadata in project jans by JanssenProject.
the class ObtainPatProvider method obtainPat.
private void obtainPat() {
try {
UmaMetadata umaMetadata = serviceProvider.getUmaMetadata();
patToken = requestPat(umaMetadata.getTokenEndpoint(), configuration.getUmaPatClientId(), configuration.getUmaPatClientSecret());
LOG.trace("New PAT obtained.");
} catch (Exception e) {
LOG.error("Failed to obtain PAT. " + e.getMessage(), e);
throw new RuntimeException(e);
}
}
use of io.jans.as.model.uma.UmaMetadata in project jans by JanssenProject.
the class UmaConfigurationWSTest method configurationPresence.
@Parameters({ "umaConfigurationPath" })
@Test
public void configurationPresence(final String umaConfigurationPath) throws Exception {
final UmaMetadata c = TUma.requestConfiguration(url, umaConfigurationPath);
UmaTestUtil.assertIt(c);
}
use of io.jans.as.model.uma.UmaMetadata in project jans by JanssenProject.
the class RpGetGetClaimsGatheringUrlOperation method execute.
@Override
public IOpResponse execute(RpGetClaimsGatheringUrlParams params) throws Exception {
validate(params);
final UmaMetadata metadata = getDiscoveryService().getUmaDiscoveryByRpId(params.getRpId());
final Rp rp = getRp();
final String state = StringUtils.isNotBlank(params.getState()) ? getStateService().putState(getStateService().encodeExpiredObject(params.getState(), ExpiredObjectType.STATE)) : getStateService().generateState();
String url = metadata.getClaimsInteractionEndpoint() + "?client_id=" + rp.getClientId() + "&ticket=" + params.getTicket() + "&claims_redirect_uri=" + params.getClaimsRedirectUri() + "&state=" + state;
if (params.getCustomParameters() != null && !params.getCustomParameters().isEmpty()) {
List<String> paramsList = Lists.newArrayList("rp_id", "client_id", "ticket", "state", "claims_redirect_uri");
Map<String, String> customParameterMap = params.getCustomParameters().entrySet().stream().filter(map -> !paramsList.contains(map.getKey())).collect(Collectors.toMap(map -> map.getKey(), map -> map.getValue()));
if (!customParameterMap.isEmpty()) {
url += "&" + Utils.mapAsStringWithEncodedValues(customParameterMap);
}
}
final RpGetClaimsGatheringUrlResponse r = new RpGetClaimsGatheringUrlResponse();
r.setUrl(url);
r.setState(state);
return r;
}
Aggregations