Search in sources :

Example 46 with ApiOperation

use of com.wordnik.swagger.annotations.ApiOperation in project symmetric-ds by JumpMind.

the class RestService method postRegisterNode.

@ApiOperation(value = "Register the specified node for the specified engine")
@RequestMapping(value = "/engine/{engine}/registernode", method = RequestMethod.POST)
@ResponseStatus(HttpStatus.OK)
@ResponseBody
public final RegistrationInfo postRegisterNode(@PathVariable("engine") String engineName, @RequestParam(value = "externalId") String externalId, @RequestParam(value = "nodeGroupId") String nodeGroupId, @RequestParam(value = "databaseType") String databaseType, @RequestParam(value = "databaseVersion") String databaseVersion, @RequestParam(value = "hostName") String hostName) {
    ISymmetricEngine engine = getSymmetricEngine(engineName);
    IRegistrationService registrationService = engine.getRegistrationService();
    INodeService nodeService = engine.getNodeService();
    RegistrationInfo regInfo = new org.jumpmind.symmetric.web.rest.model.RegistrationInfo();
    try {
        org.jumpmind.symmetric.model.Node processedNode = registrationService.registerPullOnlyNode(externalId, nodeGroupId, databaseType, databaseVersion);
        regInfo.setRegistered(processedNode.isSyncEnabled());
        if (regInfo.isRegistered()) {
            regInfo.setNodeId(processedNode.getNodeId());
            NodeSecurity nodeSecurity = nodeService.findNodeSecurity(processedNode.getNodeId());
            regInfo.setNodePassword(nodeSecurity.getNodePassword());
            org.jumpmind.symmetric.model.Node modelNode = nodeService.findIdentity();
            regInfo.setSyncUrl(modelNode.getSyncUrl());
            // do an initial heartbeat
            Heartbeat heartbeat = new Heartbeat();
            heartbeat.setNodeId(regInfo.getNodeId());
            heartbeat.setHostName(hostName);
            Date now = new Date();
            heartbeat.setCreateTime(now);
            heartbeat.setLastRestartTime(now);
            heartbeat.setHeartbeatTime(now);
            this.heartbeatImpl(engine, heartbeat);
        }
    // TODO: Catch a RegistrationRedirectException and redirect.
    } catch (IOException e) {
        throw new IoException(e);
    }
    return regInfo;
}
Also used : RegistrationInfo(org.jumpmind.symmetric.web.rest.model.RegistrationInfo) NodeSecurity(org.jumpmind.symmetric.model.NodeSecurity) IRegistrationService(org.jumpmind.symmetric.service.IRegistrationService) ISymmetricEngine(org.jumpmind.symmetric.ISymmetricEngine) IOException(java.io.IOException) Date(java.util.Date) INodeService(org.jumpmind.symmetric.service.INodeService) Heartbeat(org.jumpmind.symmetric.web.rest.model.Heartbeat) IoException(org.jumpmind.exception.IoException) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 47 with ApiOperation

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

the class TrustRelationshipWebService method delete.

@DELETE
@Path("/delete/{inum}")
@Produces(MediaType.TEXT_PLAIN)
@ApiOperation(value = "delete TrustRelationship", notes = "Delete GluuSAMLTrustRelationship.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 500, message = "Server error") })
public void delete(@PathParam("inum") @NotNull String inum, @Context HttpServletResponse response) {
    logger.trace("Delete Trust Relationship");
    try {
        GluuSAMLTrustRelationship trustRelationship = trustService.getRelationshipByInum(inum);
        trustService.removeTrustRelationship(trustRelationship);
    } catch (Exception e) {
        logger.error("delete() Exception", e);
        try {
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "INTERNAL SERVER ERROR");
        } catch (Exception ex) {
        }
    }
}
Also used : GluuSAMLTrustRelationship(org.gluu.oxtrust.model.GluuSAMLTrustRelationship) CertificateEncodingException(java.security.cert.CertificateEncodingException) BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException) IOException(java.io.IOException) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) ApiResponses(com.wordnik.swagger.annotations.ApiResponses)

Example 48 with ApiOperation

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

the class TrustRelationshipWebService method setCertificate.

@POST
@Path("/set_certificate/{inum}")
@Consumes({ MediaType.TEXT_PLAIN })
@Produces(MediaType.TEXT_PLAIN)
@ApiOperation(value = "set certificate for TrustRelationship", notes = "Find TrustRelationship by inum and set certificate.")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK"), @ApiResponse(code = 500, message = "Server error") })
public void setCertificate(@PathParam("inum") String trustRelationshipInum, String certificate, @Context HttpServletResponse response) {
    try {
        GluuSAMLTrustRelationship trustRelationship = trustService.getRelationshipByInum(trustRelationshipInum);
        if (StringHelper.isEmpty(certificate)) {
            logger.error("Failed to update TR certificate - certificate is empty");
            return;
        }
        updateTRCertificate(trustRelationship, certificate);
    } catch (Exception e) {
        logger.error("Failed to update certificate", e);
        try {
            response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "INTERNAL SERVER ERROR");
        } catch (Exception ex) {
        }
    }
}
Also used : GluuSAMLTrustRelationship(org.gluu.oxtrust.model.GluuSAMLTrustRelationship) CertificateEncodingException(java.security.cert.CertificateEncodingException) BaseMappingException(org.gluu.persist.exception.mapping.BaseMappingException) IOException(java.io.IOException) Path(javax.ws.rs.Path) 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)

Example 49 with ApiOperation

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

the class ScimConfigurationWS method getConfiguration.

@GET
@Produces({ MediaType.APPLICATION_JSON })
@ApiOperation(value = "Provides metadata as json document. It contains options and endpoints supported by the SCIM server.", response = ScimConfiguration.class)
@ApiResponses(value = { @ApiResponse(code = 500, message = "Failed to build SCIM configuration json object.") })
public Response getConfiguration() {
    try {
        final List<ScimConfiguration> cl = new ArrayList<ScimConfiguration>();
        // SCIM 2.0
        final ScimConfiguration c2 = new ScimConfiguration();
        c2.setVersion("2.0");
        c2.setAuthorizationSupported(new String[] { "uma" });
        c2.setUserEndpoint(userService.getEndpointUrl());
        c2.setUserSearchEndpoint(userService.getEndpointUrl() + "/" + BaseScimWebService.SEARCH_SUFFIX);
        c2.setGroupEndpoint(groupService.getEndpointUrl());
        c2.setBulkEndpoint(bulkService.getEndpointUrl());
        c2.setServiceProviderEndpoint(serviceProviderService.getEndpointUrl());
        c2.setResourceTypesEndpoint(resourceTypeService.getEndpointUrl());
        cl.add(c2);
        // Convert manually to avoid possible conflicts between resteasy providers, e.g. jettison, jackson
        final String entity = jsonService.objectToPerttyJson(cl);
        log.trace("SCIM 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("Failed to generate SCIM configuration").build());
    }
}
Also used : WebApplicationException(javax.ws.rs.WebApplicationException) ArrayList(java.util.ArrayList) ScimConfiguration(org.gluu.oxtrust.model.scim.ScimConfiguration) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) ApiResponses(com.wordnik.swagger.annotations.ApiResponses)

Example 50 with ApiOperation

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

the class FidoDeviceWebService method deleteDevice.

@Path("{id}")
@DELETE
@Produces({ MEDIA_TYPE_SCIM_JSON + UTF8_CHARSET_FRAGMENT, MediaType.APPLICATION_JSON + UTF8_CHARSET_FRAGMENT })
@HeaderParam("Accept")
@DefaultValue(MEDIA_TYPE_SCIM_JSON)
@ProtectedApi
@ApiOperation(value = "Delete device")
public Response deleteDevice(@PathParam("id") String id) {
    Response response;
    try {
        log.debug("Executing web service method. deleteDevice");
        // No need to check id being non-null. fidoDeviceService will give null if null is provided
        GluuCustomFidoDevice device = fidoDeviceService.getGluuCustomFidoDeviceById(null, id);
        if (device != null) {
            fidoDeviceService.removeGluuCustomFidoDevice(device);
            response = Response.noContent().build();
        } else
            response = getErrorResponse(Response.Status.NOT_FOUND, ErrorScimType.INVALID_VALUE, "Resource " + id + " not found");
    } catch (Exception e) {
        log.error("Failure at deleteDevice method", e);
        response = getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, "Unexpected error: " + e.getMessage());
    }
    return response;
}
Also used : ListResponse(org.gluu.oxtrust.model.scim2.ListResponse) Response(javax.ws.rs.core.Response) ListViewResponse(org.gluu.persist.model.ListViewResponse) GluuCustomFidoDevice(org.gluu.oxtrust.model.fido.GluuCustomFidoDevice) SCIMException(org.gluu.oxtrust.model.exception.SCIMException) InvalidAttributeValueException(javax.management.InvalidAttributeValueException) Path(javax.ws.rs.Path) DefaultValue(javax.ws.rs.DefaultValue) DELETE(javax.ws.rs.DELETE) HeaderParam(javax.ws.rs.HeaderParam) Produces(javax.ws.rs.Produces) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi)

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