Search in sources :

Example 96 with ApiResponses

use of io.swagger.v3.oas.models.responses.ApiResponses in project oxTrust by GluuFederation.

the class SmtpConfigurationWebResource method updateSmtpConfiguration.

@PUT
@Operation(summary = "Update smtp configuration", description = "Update smtp configuration")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = SmtpConfiguration.class)), description = Constants.RESULT_SUCCESS), @ApiResponse(responseCode = "404", description = "Not found"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response updateSmtpConfiguration(SmtpConfiguration smtpConfiguration) {
    try {
        Preconditions.checkNotNull(smtpConfiguration, "Attempt to update null smtpConfiguration");
        configurationService.encryptedSmtpPassword(smtpConfiguration);
        GluuConfiguration configurationUpdate = configurationService.getConfiguration();
        configurationUpdate.setSmtpConfiguration(smtpConfiguration);
        configurationService.updateConfiguration(configurationUpdate);
        return Response.ok(configurationService.getConfiguration().getSmtpConfiguration()).build();
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : GluuConfiguration(org.gluu.oxtrust.model.GluuConfiguration) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 97 with ApiResponses

use of io.swagger.v3.oas.models.responses.ApiResponses in project oxTrust by GluuFederation.

the class SmtpConfigurationWebResource method testSmtpConfiguration.

@GET
@Path(ApiConstants.TEST)
@Operation(summary = "Test smtp configuration", description = "Test smtp configuration")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = SmtpConfiguration.class)), description = Constants.RESULT_SUCCESS), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { READ_ACCESS })
public Response testSmtpConfiguration() {
    try {
        SmtpConfiguration smtpConfiguration = configurationService.getConfiguration().getSmtpConfiguration();
        String password = encryptionService.decrypt(smtpConfiguration.getPassword());
        smtpConfiguration.setPasswordDecrypted(password);
        boolean result = mailService.sendMail(smtpConfiguration, smtpConfiguration.getFromEmailAddress(), smtpConfiguration.getFromName(), smtpConfiguration.getFromEmailAddress(), null, "SMTP Configuration verification", "Mail to test smtp configuration", "Mail to test smtp configuration");
        return Response.ok(result ? true : false).build();
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : SmtpConfiguration(org.gluu.model.SmtpConfiguration) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 98 with ApiResponses

use of io.swagger.v3.oas.models.responses.ApiResponses in project oxTrust by GluuFederation.

the class UmaScopeWebResource method updateUmaScope.

@PUT
@Operation(summary = "Update UMA scope", description = "Update uma scope")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Scope.class)), description = Constants.RESULT_SUCCESS), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response updateUmaScope(Scope umaScopeDescription) {
    String inum = umaScopeDescription.getInum();
    log(logger, "Update uma scope " + inum);
    try {
        Objects.requireNonNull(inum, "inum should not be null");
        Objects.requireNonNull(umaScopeDescription, "Attempt to update null uma scope");
        Scope existingScope = scopeDescriptionService.getUmaScopeByInum(inum);
        if (existingScope != null) {
            umaScopeDescription.setDn(scopeDescriptionService.getDnForScope(inum));
            scopeDescriptionService.updateUmaScope(umaScopeDescription);
            return Response.ok(scopeDescriptionService.getUmaScopeByInum(inum)).build();
        } else {
            return Response.status(Response.Status.NOT_FOUND).build();
        }
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : Scope(org.oxauth.persistence.model.Scope) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 99 with ApiResponses

use of io.swagger.v3.oas.models.responses.ApiResponses in project oxTrust by GluuFederation.

the class UmaScopeWebResource method getUmaScopeByInum.

@GET
@Path(ApiConstants.INUM_PARAM_PATH)
@Operation(summary = "Get UMA scope by inum", description = "Get a uma scope by inum")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Scope.class)), description = Constants.RESULT_SUCCESS), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { READ_ACCESS })
public Response getUmaScopeByInum(@PathParam(ApiConstants.INUM) @NotNull String inum) {
    log(logger, "Get uma scope " + inum);
    try {
        Objects.requireNonNull(inum, "inum should not be null");
        Scope scope = scopeDescriptionService.getUmaScopeByInum(inum);
        if (scope != null) {
            return Response.ok(scope).build();
        } else {
            return Response.status(Response.Status.NOT_FOUND).build();
        }
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : Scope(org.oxauth.persistence.model.Scope) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 100 with ApiResponses

use of io.swagger.v3.oas.models.responses.ApiResponses in project oxTrust by GluuFederation.

the class ClientWebResource method getClientScope.

@GET
@Path(ApiConstants.INUM_PARAM_PATH + ApiConstants.SCOPES)
@Operation(summary = "Get assigned OIDC client scopes", description = "Get OIDC scopes assign to OIDC client")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Scope[].class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error"), @ApiResponse(responseCode = "404", description = "Not Found") })
@ProtectedApi(scopes = { READ_ACCESS })
public Response getClientScope(@PathParam(ApiConstants.INUM) @NotNull String inum) {
    log(logger, "Get client scopes");
    try {
        Objects.requireNonNull(inum);
        OxAuthClient client = clientService.getClientByInum(inum);
        if (client != null) {
            List<String> scopesDn = client.getOxAuthScopes();
            List<Scope> scopes = new ArrayList<Scope>();
            if (scopesDn != null) {
                for (String scopeDn : scopesDn) {
                    scopes.add(scopeService.getScopeByDn(scopeDn));
                }
                return Response.ok(scopes).build();
            } else {
                return Response.ok(scopes).build();
            }
        } else {
            return Response.status(Response.Status.NOT_FOUND).build();
        }
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : Scope(org.oxauth.persistence.model.Scope) OxAuthClient(org.gluu.oxtrust.model.OxAuthClient) ArrayList(java.util.ArrayList) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Aggregations

Operation (io.swagger.v3.oas.annotations.Operation)99 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)99 ApiResponses (io.swagger.v3.oas.models.responses.ApiResponses)48 ApiResponse (io.swagger.v3.oas.models.responses.ApiResponse)47 ProtectedApi (org.gluu.oxtrust.service.filter.ProtectedApi)47 Operation (io.swagger.v3.oas.models.Operation)39 PathItem (io.swagger.v3.oas.models.PathItem)35 OpenAPI (io.swagger.v3.oas.models.OpenAPI)34 Test (org.testng.annotations.Test)31 ArrayList (java.util.ArrayList)23 Schema (io.swagger.v3.oas.models.media.Schema)22 Content (io.swagger.v3.oas.models.media.Content)21 StringSchema (io.swagger.v3.oas.models.media.StringSchema)21 MediaType (io.swagger.v3.oas.models.media.MediaType)20 ObjectSchema (io.swagger.v3.oas.models.media.ObjectSchema)19 IntegerSchema (io.swagger.v3.oas.models.media.IntegerSchema)17 Path (javax.ws.rs.Path)17 Produces (javax.ws.rs.Produces)17 ArraySchema (io.swagger.v3.oas.models.media.ArraySchema)16 Components (io.swagger.v3.oas.models.Components)10