Search in sources :

Example 1 with UmaMetadata

use of org.xdi.oxauth.model.uma.UmaMetadata in project oxTrust by GluuFederation.

the class AppInitializer method initUmaMetadataConfiguration.

@Produces
@ApplicationScoped
@Named("umaMetadataConfiguration")
public UmaMetadata initUmaMetadataConfiguration() throws OxIntializationException {
    String umaConfigurationEndpoint = getUmaConfigurationEndpoint();
    if (StringHelper.isEmpty(umaConfigurationEndpoint)) {
        return null;
    }
    UmaMetadataService metaDataConfigurationService = UmaClientFactory.instance().createMetadataService(umaConfigurationEndpoint);
    UmaMetadata metadataConfiguration = metaDataConfigurationService.getMetadata();
    if (metadataConfiguration == null) {
        throw new OxIntializationException("UMA meta data configuration is invalid!");
    }
    return metadataConfiguration;
}
Also used : UmaMetadata(org.xdi.oxauth.model.uma.UmaMetadata) OxIntializationException(org.xdi.exception.OxIntializationException) UmaMetadataService(org.xdi.oxauth.client.uma.UmaMetadataService) Named(javax.inject.Named) Produces(javax.enterprise.inject.Produces) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Example 2 with UmaMetadata

use of org.xdi.oxauth.model.uma.UmaMetadata in project oxTrust by GluuFederation.

the class UmaAuthorizationClient method getAuthorizedRpt.

private String getAuthorizedRpt(String asUri, String ticket) throws OxTrustAuthorizationException {
    try {
        // Get metadata configuration
        UmaMetadata umaMetadata = UmaClientFactory.instance().createMetadataService(asUri).getMetadata();
        if (umaMetadata == null) {
            throw new OxTrustAuthorizationException(String.format("Failed to load valid UMA metadata configuration from: %s", asUri));
        }
        TokenRequest tokenRequest = getAuthorizationTokenRequest(umaMetadata);
        // No need for claims token. See comments on issue https://github.com/GluuFederation/SCIM-Client/issues/22
        UmaTokenService tokenService = UmaClientFactory.instance().createTokenService(umaMetadata);
        // ClaimTokenFormatType.ID_TOKEN.getValue()
        UmaTokenResponse rptResponse = tokenService.requestJwtAuthorizationRpt(ClientAssertionType.JWT_BEARER.toString(), tokenRequest.getClientAssertion(), GrantType.OXAUTH_UMA_TICKET.getValue(), ticket, null, null, null, null, null);
        if (rptResponse == null) {
            throw new OxTrustAuthorizationException("UMA RPT token response is invalid");
        }
        if (StringUtils.isBlank(rptResponse.getAccessToken())) {
            throw new OxTrustAuthorizationException("UMA RPT is invalid");
        }
        this.rpt = rptResponse.getAccessToken();
        return rpt;
    } catch (Exception ex) {
        throw new OxTrustAuthorizationException(ex.getMessage(), ex);
    }
}
Also used : UmaMetadata(org.xdi.oxauth.model.uma.UmaMetadata) UmaTokenResponse(org.xdi.oxauth.model.uma.UmaTokenResponse) UmaTokenService(org.xdi.oxauth.client.uma.UmaTokenService) TokenRequest(org.xdi.oxauth.client.TokenRequest)

Aggregations

UmaMetadata (org.xdi.oxauth.model.uma.UmaMetadata)2 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Produces (javax.enterprise.inject.Produces)1 Named (javax.inject.Named)1 OxIntializationException (org.xdi.exception.OxIntializationException)1 TokenRequest (org.xdi.oxauth.client.TokenRequest)1 UmaMetadataService (org.xdi.oxauth.client.uma.UmaMetadataService)1 UmaTokenService (org.xdi.oxauth.client.uma.UmaTokenService)1 UmaTokenResponse (org.xdi.oxauth.model.uma.UmaTokenResponse)1