Search in sources :

Example 26 with ApiOperation

use of com.wordnik.swagger.annotations.ApiOperation in project oxAuth by GluuFederation.

the class UmaConfigurationWS method getConfiguration.

@GET
@Produces({ UmaConstants.JSON_MEDIA_TYPE })
@ApiOperation(value = "Provides configuration data as json document. It contains options and endpoints supported by the authorization server.", response = UmaConfiguration.class)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Failed to build Uma configuration json object.") })
public Response getConfiguration() {
    try {
        final String baseEndpointUri = appConfiguration.getBaseEndpoint();
        final UmaConfiguration c = new UmaConfiguration();
        c.setVersion("1.0");
        c.setIssuer(appConfiguration.getIssuer());
        c.setPatProfilesSupported(new String[] { TokenType.BEARER.getName() });
        c.setAatProfilesSupported(new String[] { TokenType.BEARER.getName() });
        c.setRptProfilesSupported(new String[] { RptProfiles.BEARER.getIdentifyingUri() });
        c.setPatGrantTypesSupported(new String[] { GrantType.AUTHORIZATION_CODE.getValue(), GrantType.IMPLICIT.getValue(), GrantType.CLIENT_CREDENTIALS.getValue() });
        c.setAatGrantTypesSupported(new String[] { GrantType.AUTHORIZATION_CODE.getValue(), GrantType.IMPLICIT.getValue(), GrantType.CLIENT_CREDENTIALS.getValue() });
        c.setClaimTokenProfilesSupported(new String[] { "openid" });
        c.setUmaProfilesSupported(new String[0]);
        c.setDynamicClientEndpoint(baseEndpointUri + "/oxauth/register");
        c.setTokenEndpoint(baseEndpointUri + "/oxauth/token");
        c.setAuthorizationEndpoint(baseEndpointUri + "/requester/perm");
        c.setRequestingPartyClaimsEndpoint("");
        c.setIntrospectionEndpoint(baseEndpointUri + "/rpt/status");
        c.setResourceSetRegistrationEndpoint(baseEndpointUri + "/host/rsrc/resource_set");
        c.setPermissionRegistrationEndpoint(baseEndpointUri + "/host/rsrc_pr");
        c.setRptEndpoint(baseEndpointUri + "/requester/rpt");
        c.setGatEndpoint(baseEndpointUri + "/requester/gat");
        c.setScopeEndpoint(baseEndpointUri + UMA_SCOPES_SUFFIX);
        c.setRptAsJwt(appConfiguration.getUmaRptAsJwt());
        // convert manually to avoid possible conflicts between resteasy providers, e.g. jettison, jackson
        final String entity = ServerUtil.asPrettyJson(c);
        log.trace("Uma configuration: {}", entity);
        return Response.ok(entity).build();
    } catch (Throwable ex) {
        log.error(ex.getMessage(), ex);
        throw new WebApplicationException(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorResponseFactory.getUmaJsonErrorResponse(UmaErrorResponseType.SERVER_ERROR)).build());
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) UmaConfiguration(org.xdi.oxauth.model.uma.UmaConfiguration) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) ApiResponses(com.wordnik.swagger.annotations.ApiResponses)

Example 27 with ApiOperation

use of com.wordnik.swagger.annotations.ApiOperation in project oxAuth by GluuFederation.

the class U2fConfigurationWS method getConfiguration.

@GET
@Produces({ "application/json" })
@ApiOperation(value = "Provides configuration data as json document. It contains options and endpoints supported by the FIDO U2F server.", response = U2fConfiguration.class)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Failed to build FIDO U2F configuration json object.") })
public Response getConfiguration() {
    try {
        final String baseEndpointUri = appConfiguration.getBaseEndpoint();
        final U2fConfiguration conf = new U2fConfiguration();
        conf.setVersion("2.0");
        conf.setIssuer(appConfiguration.getIssuer());
        conf.setRegistrationEndpoint(baseEndpointUri + "/fido/u2f/registration");
        conf.setAuthenticationEndpoint(baseEndpointUri + "/fido/u2f/authentication");
        // convert manually to avoid possible conflicts between resteasy
        // providers, e.g. jettison, jackson
        final String entity = ServerUtil.asPrettyJson(conf);
        log.trace("FIDO U2F configuration: {}", entity);
        return Response.ok(entity).build();
    } catch (Throwable ex) {
        log.error(ex.getMessage(), ex);
        throw new WebApplicationException(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorResponseFactory.getUmaJsonErrorResponse(U2fErrorResponseType.SERVER_ERROR)).build());
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) U2fConfiguration(org.xdi.oxauth.model.fido.u2f.U2fConfiguration) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) ApiResponses(com.wordnik.swagger.annotations.ApiResponses)

Example 28 with ApiOperation

use of com.wordnik.swagger.annotations.ApiOperation in project oxAuth by GluuFederation.

the class CreateRptWS method getGat.

@Path("gat")
@POST
@Produces({ UmaConstants.JSON_MEDIA_TYPE })
@ApiOperation(value = "The endpoint at which the requester asks the AM to issue an GAT", produces = UmaConstants.JSON_MEDIA_TYPE, notes = "The endpoint at which the requester asks the AM to issue an GAT")
@ApiResponses(value = { @ApiResponse(code = 401, message = "Unauthorized") })
public Response getGat(@HeaderParam("Authorization") String authorization, @HeaderParam("Host") String amHost, GatRequest request, @Context HttpServletRequest httpRequest) {
    try {
        umaValidationService.assertHasAuthorizationScope(authorization);
        String validatedAmHost = umaValidationService.validateAmHost(amHost);
        UmaRPT rpt = rptManager.createRPT(authorization, validatedAmHost, true);
        authorizeGat(request, rpt, authorization, httpRequest);
        String rptResponse = rpt.getCode();
        final Boolean umaRptAsJwt = appConfiguration.getUmaRptAsJwt();
        if (umaRptAsJwt != null && umaRptAsJwt) {
            rptResponse = createJwr(rpt, authorization, request.getScopes()).asString();
        }
        return Response.status(Response.Status.CREATED).entity(ServerUtil.asJson(new RPTResponse(rptResponse))).build();
    } catch (Exception ex) {
        log.error("Exception happened", ex);
        if (ex instanceof WebApplicationException) {
            throw (WebApplicationException) ex;
        }
        throw new WebApplicationException(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorResponseFactory.getUmaJsonErrorResponse(UmaErrorResponseType.SERVER_ERROR)).build());
    }
}
Also used : UmaRPT(org.xdi.oxauth.model.common.uma.UmaRPT) WebApplicationException(javax.ws.rs.WebApplicationException) RPTResponse(org.xdi.oxauth.model.uma.RPTResponse) WebApplicationException(javax.ws.rs.WebApplicationException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) ApiResponses(com.wordnik.swagger.annotations.ApiResponses)

Example 29 with ApiOperation

use of com.wordnik.swagger.annotations.ApiOperation in project oxAuth by GluuFederation.

the class CreateRptWS method getRpt.

@Path("rpt")
@POST
@Produces({ UmaConstants.JSON_MEDIA_TYPE })
@ApiOperation(value = "The endpoint at which the requester asks the AM to issue an RPT", produces = UmaConstants.JSON_MEDIA_TYPE, notes = "The endpoint at which the requester asks the AM to issue an RPT")
@ApiResponses(value = { @ApiResponse(code = 401, message = "Unauthorized") })
public Response getRpt(@HeaderParam("Authorization") String authorization, @HeaderParam("Host") String amHost) {
    try {
        umaValidationService.assertHasAuthorizationScope(authorization);
        String validatedAmHost = umaValidationService.validateAmHost(amHost);
        UmaRPT rpt = rptManager.createRPT(authorization, validatedAmHost, false);
        String rptResponse = rpt.getCode();
        final Boolean umaRptAsJwt = appConfiguration.getUmaRptAsJwt();
        if (umaRptAsJwt != null && umaRptAsJwt) {
            rptResponse = createJwr(rpt, authorization, Lists.<String>newArrayList()).asString();
        }
        return Response.status(Response.Status.CREATED).entity(ServerUtil.asJson(new RPTResponse(rptResponse))).build();
    } catch (Exception ex) {
        log.error("Exception happened", ex);
        if (ex instanceof WebApplicationException) {
            throw (WebApplicationException) ex;
        }
        throw new WebApplicationException(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorResponseFactory.getUmaJsonErrorResponse(UmaErrorResponseType.SERVER_ERROR)).build());
    }
}
Also used : UmaRPT(org.xdi.oxauth.model.common.uma.UmaRPT) WebApplicationException(javax.ws.rs.WebApplicationException) RPTResponse(org.xdi.oxauth.model.uma.RPTResponse) WebApplicationException(javax.ws.rs.WebApplicationException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) ApiResponses(com.wordnik.swagger.annotations.ApiResponses)

Example 30 with ApiOperation

use of com.wordnik.swagger.annotations.ApiOperation in project oxAuth by GluuFederation.

the class PermissionRegistrationWS method registerResourceSetPermission.

@POST
@Consumes({ UmaConstants.JSON_MEDIA_TYPE })
@Produces({ UmaConstants.JSON_MEDIA_TYPE })
@ApiOperation(value = "Registers permission using the POST method", consumes = UmaConstants.JSON_MEDIA_TYPE, produces = UmaConstants.JSON_MEDIA_TYPE, notes = "The resource server uses the POST method at the endpoint. The body of the HTTP request message contains a JSON object providing the requested permission, using a format derived from the scope description format specified in [OAuth-resource-reg], as follows. The object has the following properties:")
@ApiResponses(value = { @ApiResponse(code = 401, message = "Unauthorized"), @ApiResponse(code = 400, message = "Bad Request") })
public Response registerResourceSetPermission(@Context HttpServletRequest request, @HeaderParam("Authorization") String authorization, @HeaderParam("Host") String amHost, @ApiParam(value = "The identifier for a resource set to which this client is seeking access. The identifier MUST correspond to a resource set that was previously registered.", required = true) UmaPermission resourceSetPermissionRequest) {
    try {
        umaValidationService.assertHasProtectionScope(authorization);
        String validatedAmHost = umaValidationService.validateAmHost(amHost);
        umaValidationService.validateResourceSet(resourceSetPermissionRequest);
        final ResourceSetPermission resourceSetPermissions = resourceSetPermissionManager.createResourceSetPermission(validatedAmHost, resourceSetPermissionRequest, umaRsPermissionService.rptExpirationDate());
        resourceSetPermissionManager.addResourceSetPermission(resourceSetPermissions, tokenService.getClientDn(authorization));
        return Response.status(Response.Status.CREATED).entity(new PermissionTicket(resourceSetPermissions.getTicket())).build();
    } catch (Exception ex) {
        if (ex instanceof WebApplicationException) {
            throw (WebApplicationException) ex;
        }
        log.error("Exception happened", ex);
        throw new WebApplicationException(Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(errorResponseFactory.getUmaJsonErrorResponse(UmaErrorResponseType.SERVER_ERROR)).build());
    }
}
Also used : PermissionTicket(org.xdi.oxauth.model.uma.PermissionTicket) WebApplicationException(javax.ws.rs.WebApplicationException) ResourceSetPermission(org.xdi.oxauth.model.uma.persistence.ResourceSetPermission) WebApplicationException(javax.ws.rs.WebApplicationException) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) ApiResponses(com.wordnik.swagger.annotations.ApiResponses)

Aggregations

ApiOperation (com.wordnik.swagger.annotations.ApiOperation)61 Produces (javax.ws.rs.Produces)49 Response (javax.ws.rs.core.Response)36 DefaultValue (javax.ws.rs.DefaultValue)35 HeaderParam (javax.ws.rs.HeaderParam)35 ListResponse (org.gluu.oxtrust.model.scim2.ListResponse)34 URI (java.net.URI)31 Path (javax.ws.rs.Path)30 Consumes (javax.ws.rs.Consumes)21 ProtectedApi (org.gluu.oxtrust.service.filter.ProtectedApi)21 InvalidAttributeValueException (javax.management.InvalidAttributeValueException)19 SCIMException (org.gluu.oxtrust.model.exception.SCIMException)19 ListViewResponse (org.gluu.persist.model.ListViewResponse)19 GET (javax.ws.rs.GET)17 POST (javax.ws.rs.POST)17 RefAdjusted (org.gluu.oxtrust.service.scim2.interceptor.RefAdjusted)17 DuplicateEntryException (org.gluu.site.ldap.exception.DuplicateEntryException)15 EntryPersistenceException (org.gluu.site.ldap.persistence.exception.EntryPersistenceException)15 ApiResponses (com.wordnik.swagger.annotations.ApiResponses)14 VirtualListViewResponse (org.xdi.ldap.model.VirtualListViewResponse)14