Search in sources :

Example 6 with UmaMetadata

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;
}
Also used : UmaMetadata(io.jans.as.model.uma.UmaMetadata) UmaMetadataService(io.jans.as.client.uma.UmaMetadataService) UmaClientFactory(io.jans.as.client.uma.UmaClientFactory)

Example 7 with UmaMetadata

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.");
    }
}
Also used : UmaMetadata(io.jans.as.model.uma.UmaMetadata) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 8 with UmaMetadata

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);
    }
}
Also used : UmaMetadata(io.jans.as.model.uma.UmaMetadata)

Example 9 with UmaMetadata

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);
}
Also used : UmaMetadata(io.jans.as.model.uma.UmaMetadata) Parameters(org.testng.annotations.Parameters) BaseTest(io.jans.as.server.BaseTest) Test(org.testng.annotations.Test)

Example 10 with UmaMetadata

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;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) Utils(io.jans.ca.server.Utils) Collectors(java.util.stream.Collectors) Injector(com.google.inject.Injector) HttpException(io.jans.ca.server.HttpException) UmaMetadata(io.jans.as.model.uma.UmaMetadata) RpGetClaimsGatheringUrlParams(io.jans.ca.common.params.RpGetClaimsGatheringUrlParams) ErrorResponseCode(io.jans.ca.common.ErrorResponseCode) IOpResponse(io.jans.ca.common.response.IOpResponse) List(java.util.List) Lists(com.google.common.collect.Lists) ExpiredObjectType(io.jans.ca.common.ExpiredObjectType) Map(java.util.Map) RpGetClaimsGatheringUrlResponse(io.jans.ca.common.response.RpGetClaimsGatheringUrlResponse) Command(io.jans.ca.common.Command) Rp(io.jans.ca.server.service.Rp) UmaMetadata(io.jans.as.model.uma.UmaMetadata) RpGetClaimsGatheringUrlResponse(io.jans.ca.common.response.RpGetClaimsGatheringUrlResponse) Rp(io.jans.ca.server.service.Rp)

Aggregations

UmaMetadata (io.jans.as.model.uma.UmaMetadata)12 HttpException (io.jans.ca.server.HttpException)6 Rp (io.jans.ca.server.service.Rp)4 Parameters (org.testng.annotations.Parameters)3 Test (org.testng.annotations.Test)3 Lists (com.google.common.collect.Lists)2 Injector (com.google.inject.Injector)2 UmaMetadataService (io.jans.as.client.uma.UmaMetadataService)2 UmaResourceService (io.jans.as.client.uma.UmaResourceService)2 Command (io.jans.ca.common.Command)2 ErrorResponseCode (io.jans.ca.common.ErrorResponseCode)2 IOpResponse (io.jans.ca.common.response.IOpResponse)2 Utils (io.jans.ca.server.Utils)2 IOException (java.io.IOException)2 List (java.util.List)2 Preconditions (com.google.common.base.Preconditions)1 Strings (com.google.common.base.Strings)1 Sets (com.google.common.collect.Sets)1 BaseTest (io.jans.as.client.BaseTest)1 RegisterClient (io.jans.as.client.RegisterClient)1