Search in sources :

Example 56 with ApiResponse

use of io.swagger.v3.oas.annotations.responses.ApiResponse in project oxTrust by GluuFederation.

the class OxtrustSettingWebResource method getOxtrustSettings.

@GET
@Operation(summary = "Get oxtrust settings", description = "Get oxtrust settings")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = OxtrustSetting.class)), description = Constants.RESULT_SUCCESS), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { READ_ACCESS })
public Response getOxtrustSettings() {
    try {
        log(logger, "Processing oxtrust settings retrieval request");
        GluuConfiguration configurationUpdate = configurationService.getConfiguration();
        OxtrustSetting setting = new OxtrustSetting();
        setting.setAllowPasswordReset(String.valueOf(configurationUpdate.isPasswordResetAllowed()));
        setting.setAllowProfileManagement(String.valueOf(configurationUpdate.isProfileManagment()));
        setting.setEnablePassport(String.valueOf(configurationUpdate.isPassportEnabled()));
        setting.setEnableScim(String.valueOf(configurationUpdate.isScimEnabled()));
        return Response.ok(setting).build();
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : OxtrustSetting(org.gluu.oxtrust.api.server.model.OxtrustSetting) GluuConfiguration(org.gluu.oxtrust.model.GluuConfiguration) GET(javax.ws.rs.GET) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 57 with ApiResponse

use of io.swagger.v3.oas.annotations.responses.ApiResponse in project oxTrust by GluuFederation.

the class PassportProviderWebResource method getProviderById.

@GET
@Path(ApiConstants.ID_PARAM_PATH)
@Operation(summary = "Get passport provider by id", description = "Get passport provider by id")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Provider.class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { READ_ACCESS })
public Response getProviderById(@PathParam(ApiConstants.ID) @NotNull String id) {
    log(logger, "Get group having group" + id);
    id = id.equalsIgnoreCase("") ? null : id;
    try {
        Objects.requireNonNull(id, "inum should not be null");
        this.ldapOxPassportConfiguration = passportService.loadConfigurationFromLdap();
        this.passportConfiguration = this.ldapOxPassportConfiguration.getPassportConfiguration();
        List<Provider> providers = new ArrayList<>();
        providers.addAll(this.passportConfiguration.getProviders());
        Provider existingProvider = getExistingProvider(providers, id);
        if (existingProvider != null) {
            return Response.ok(existingProvider).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 : ArrayList(java.util.ArrayList) Provider(org.gluu.model.passport.Provider) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 58 with ApiResponse

use of io.swagger.v3.oas.annotations.responses.ApiResponse in project oxTrust by GluuFederation.

the class CustomScriptWebResource method deleteCustomScript.

@DELETE
@Path(ApiConstants.INUM_PARAM_PATH)
@Operation(summary = "Delete custom script", description = "Delete an custom script")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response deleteCustomScript(@PathParam(ApiConstants.INUM) @NotNull String inum) {
    log(logger, "Delete custom script" + inum);
    try {
        Objects.requireNonNull(inum);
        CustomScript existingScript = customScriptService.getScriptByInum(inum);
        if (existingScript != null) {
            customScriptService.remove(existingScript);
            return Response.ok().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 : CustomScript(org.gluu.model.custom.script.model.CustomScript) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 59 with ApiResponse

use of io.swagger.v3.oas.annotations.responses.ApiResponse in project oxTrust by GluuFederation.

the class LDAPAuthenticationWebResource method createLdapConfiguration.

@POST
@Operation(summary = "Create a new configuration", description = "Create a new configuration")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = LdapConfigurationDTO.class)), description = "Success") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response createLdapConfiguration(@Valid LdapConfigurationDTO ldapConfiguration) {
    log(logger, "Create a new configuration");
    try {
        if (existingLdapConfigurationValidator.isInvalid(ldapConfiguration)) {
            throw new LdapConfigurationDuplicatedException(ldapConfiguration.getConfigId());
        }
        GluuLdapConfiguration gluuLdapConfiguration = ldapConfigurationDtoAssembly.fromDto(ldapConfiguration);
        ldapConfigurationService.save(gluuLdapConfiguration);
        return Response.ok(read(ldapConfiguration.getConfigId())).build();
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : LdapConfigurationDuplicatedException(org.gluu.oxtrust.api.server.util.LdapConfigurationDuplicatedException) GluuLdapConfiguration(org.gluu.model.ldap.GluuLdapConfiguration) LdapConfigurationDuplicatedException(org.gluu.oxtrust.api.server.util.LdapConfigurationDuplicatedException) ProtectedApi(org.gluu.oxtrust.service.filter.ProtectedApi) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 60 with ApiResponse

use of io.swagger.v3.oas.annotations.responses.ApiResponse in project oxTrust by GluuFederation.

the class OxTrustJsonSettingWebResource method getOxtrustJsonSettings.

@GET
@Operation(summary = "Get json oxtrust settings", description = "Get json oxtrust settings")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = OxTrustJsonSetting.class)), description = Constants.RESULT_SUCCESS), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { READ_ACCESS })
public Response getOxtrustJsonSettings() {
    try {
        log(logger, "Processing oxtrust json settings retrival");
        this.oxTrustappConfiguration = jsonConfigurationService.getOxTrustappConfiguration();
        OxTrustJsonSetting setting = new OxTrustJsonSetting();
        setting.setOrgName(this.oxTrustappConfiguration.getOrganizationName());
        setting.setSupportEmail(this.oxTrustappConfiguration.getOrgSupportEmail());
        setting.setAuthenticationRecaptchaEnabled(this.oxTrustappConfiguration.isAuthenticationRecaptchaEnabled());
        setting.setCleanServiceInterval(this.oxTrustappConfiguration.getCleanServiceInterval());
        setting.setEnforceEmailUniqueness(this.oxTrustappConfiguration.getEnforceEmailUniqueness());
        setting.setPasswordResetRequestExpirationTime(this.oxTrustappConfiguration.getPasswordResetRequestExpirationTime());
        setting.setLoggingLevel(this.oxTrustappConfiguration.getLoggingLevel());
        return Response.ok(setting).build();
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : OxTrustJsonSetting(org.gluu.oxtrust.api.server.model.OxTrustJsonSetting) 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)113 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)99 ApiResponse (io.swagger.v3.oas.models.responses.ApiResponse)85 Test (org.testng.annotations.Test)53 Operation (io.swagger.v3.oas.models.Operation)51 OpenAPI (io.swagger.v3.oas.models.OpenAPI)48 ProtectedApi (org.gluu.oxtrust.service.filter.ProtectedApi)48 ApiResponses (io.swagger.v3.oas.models.responses.ApiResponses)44 PathItem (io.swagger.v3.oas.models.PathItem)41 Schema (io.swagger.v3.oas.models.media.Schema)38 MediaType (io.swagger.v3.oas.models.media.MediaType)31 Path (javax.ws.rs.Path)30 ObjectSchema (io.swagger.v3.oas.models.media.ObjectSchema)29 IntegerSchema (io.swagger.v3.oas.models.media.IntegerSchema)27 StringSchema (io.swagger.v3.oas.models.media.StringSchema)27 Content (io.swagger.v3.oas.models.media.Content)26 ArraySchema (io.swagger.v3.oas.models.media.ArraySchema)25 ArrayList (java.util.ArrayList)25 Components (io.swagger.v3.oas.models.Components)19 Parameter (io.swagger.v3.oas.models.parameters.Parameter)19