Search in sources :

Example 1 with UmaTokenService

use of org.xdi.oxauth.client.uma.UmaTokenService 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

TokenRequest (org.xdi.oxauth.client.TokenRequest)1 UmaTokenService (org.xdi.oxauth.client.uma.UmaTokenService)1 UmaMetadata (org.xdi.oxauth.model.uma.UmaMetadata)1 UmaTokenResponse (org.xdi.oxauth.model.uma.UmaTokenResponse)1