use of org.gluu.oxauth.model.uma.UmaMetadata in project oxTrust by GluuFederation.
the class UmaPermissionService method initUmaMetadataConfiguration.
@Produces
@ApplicationScoped
@Named("umaMetadataConfiguration")
public UmaMetadata initUmaMetadataConfiguration() throws OxIntializationException {
String umaConfigurationEndpoint = getUmaConfigurationEndpoint();
if (StringHelper.isEmpty(umaConfigurationEndpoint)) {
return null;
}
log.info("##### Getting UMA metadata ...");
UmaMetadataService metaDataConfigurationService;
if (this.clientHttpEngine == null) {
metaDataConfigurationService = UmaClientFactory.instance().createMetadataService(umaConfigurationEndpoint);
} else {
metaDataConfigurationService = UmaClientFactory.instance().createMetadataService(umaConfigurationEndpoint, this.clientHttpEngine);
}
UmaMetadata metadataConfiguration = null;
int max_attempts = 10;
for (int attempt = 1; attempt <= max_attempts; attempt++) {
try {
metadataConfiguration = metaDataConfigurationService.getMetadata();
} catch (javax.ws.rs.ServiceUnavailableException ex) {
if ((attempt == max_attempts) || (ex.getResponse().getStatus() != javax.ws.rs.core.Response.Status.SERVICE_UNAVAILABLE.getStatusCode())) {
throw ex;
}
try {
java.lang.Thread.sleep(3000);
} catch (InterruptedException ex2) {
throw ex;
}
log.info("##### Attempting to load UMA metadata ... {}", attempt);
}
}
log.info("##### Getting UMA metadata ... DONE");
if (metadataConfiguration == null) {
throw new OxIntializationException("UMA meta data configuration is invalid!");
}
return metadataConfiguration;
}
use of org.gluu.oxauth.model.uma.UmaMetadata 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);
}
}
use of org.gluu.oxauth.model.uma.UmaMetadata in project oxAuth by GluuFederation.
the class ScopeHttpTest method scopePresence.
@Test
@Parameters({ "umaMetaDataUrl" })
public void scopePresence(final String umaMetaDataUrl) {
final UmaMetadata metadata = UmaClientFactory.instance().createMetadataService(umaMetaDataUrl).getMetadata();
final UmaScopeService scopeService = UmaClientFactory.instance().createScopeService(metadata.getScopeEndpoint());
final UmaScopeDescription modifyScope = scopeService.getScope("modify");
UmaTestUtil.assert_(modifyScope);
}
use of org.gluu.oxauth.model.uma.UmaMetadata in project oxAuth by GluuFederation.
the class MetaDataFlowHttpTest method testGetUmaMetaDataConfiguration.
/**
* Test for getting meta data configuration
*/
@Test
@Parameters({ "umaMetaDataUrl" })
public void testGetUmaMetaDataConfiguration(final String umaMetaDataUrl) throws Exception {
showTitle("testGetUmaMetaDataConfiguration");
UmaMetadataService metaDataConfigurationService = UmaClientFactory.instance().createMetadataService(umaMetaDataUrl, clientEngine(true));
// Get meta data
UmaMetadata c = null;
try {
c = metaDataConfigurationService.getMetadata();
} catch (ClientErrorException ex) {
System.err.println(ex.getResponse().readEntity(String.class));
throw ex;
}
UmaTestUtil.assert_(c);
}
use of org.gluu.oxauth.model.uma.UmaMetadata in project oxAuth by GluuFederation.
the class UmaMetadataWS method getConfiguration.
@GET
@Produces({ UmaConstants.JSON_MEDIA_TYPE })
public Response getConfiguration() {
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 (Throwable ex) {
log.error(ex.getMessage(), ex);
throw errorResponseFactory.createWebApplicationException(Response.Status.INTERNAL_SERVER_ERROR, UmaErrorResponseType.SERVER_ERROR, "Internal error.");
}
}
Aggregations