Search in sources :

Example 1 with UmaTokenService

use of org.gluu.oxauth.client.uma.UmaTokenService in project oxTrust by GluuFederation.

the class BaseApiTest method getAuthorizedRpt.

private void getAuthorizedRpt(String asUri, String ticket) {
    try {
        UmaMetadata umaMetadata = UmaClientFactory.instance().createMetadataService(asUri).getMetadata();
        if (umaMetadata == null) {
            throw new IllegalArgumentException(String.format("Failed to load valid UMA metadata configuration from: %s", asUri));
        }
        TokenRequest tokenRequest = getAuthorizationTokenRequest(umaMetadata);
        UmaTokenService tokenService = UmaClientFactory.instance().createTokenService(umaMetadata);
        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 IllegalArgumentException("UMA RPT token response is invalid");
        }
        if (StringUtils.isBlank(rptResponse.getAccessToken())) {
            throw new IllegalArgumentException("UMA RPT is invalid");
        }
        this.rpt = rptResponse.getAccessToken();
        System.out.println("RPT IS:" + this.rpt);
    } catch (Exception ex) {
        throw new IllegalArgumentException(ex.getMessage(), ex);
    }
}
Also used : UmaMetadata(org.gluu.oxauth.model.uma.UmaMetadata) UmaTokenResponse(org.gluu.oxauth.model.uma.UmaTokenResponse) UmaTokenService(org.gluu.oxauth.client.uma.UmaTokenService) TokenRequest(org.gluu.oxauth.client.TokenRequest) KeyStoreException(java.security.KeyStoreException) IOException(java.io.IOException) KeyManagementException(java.security.KeyManagementException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException)

Aggregations

IOException (java.io.IOException)1 KeyManagementException (java.security.KeyManagementException)1 KeyStoreException (java.security.KeyStoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 TokenRequest (org.gluu.oxauth.client.TokenRequest)1 UmaTokenService (org.gluu.oxauth.client.uma.UmaTokenService)1 UmaMetadata (org.gluu.oxauth.model.uma.UmaMetadata)1 UmaTokenResponse (org.gluu.oxauth.model.uma.UmaTokenResponse)1