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;
}
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);
}
}
Aggregations