Search in sources :

Example 96 with Content

use of io.swagger.v3.oas.annotations.media.Content in project oxTrust by GluuFederation.

the class AuthenticationMethodWebResource method getCurrentAuthentication.

@GET
@Operation(summary = "Get current authentication methods", description = "Get current authentication methods")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = AuthenticationMethod.class)), description = Constants.RESULT_SUCCESS), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { READ_ACCESS })
public Response getCurrentAuthentication() {
    log(logger, "Processing getCurrentAuthentication()");
    try {
        GluuConfiguration configuration = configurationService.getConfiguration();
        AuthenticationMethod method = new AuthenticationMethod();
        method.setDefaultAcr(configuration.getAuthenticationMode());
        method.setOxtrustAcr(configuration.getOxTrustAuthenticationMode());
        return Response.ok(method).build();
    } catch (Exception e) {
        log(logger, e);
        return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
    }
}
Also used : AuthenticationMethod(org.gluu.oxtrust.api.server.model.AuthenticationMethod) 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 97 with Content

use of io.swagger.v3.oas.annotations.media.Content in project oxTrust by GluuFederation.

the class GroupWebResource method getGroupMembers.

@GET
@Path(ApiConstants.INUM_PARAM_PATH + ApiConstants.GROUP_MEMBERS)
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = GluuPersonApi[].class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@Operation(summary = "Get group members", description = "Get a group members")
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response getGroupMembers(@PathParam(ApiConstants.INUM) @NotNull String inum) {
    log("Get members of group " + inum);
    inum = inum.equalsIgnoreCase("") ? null : inum;
    try {
        Objects.requireNonNull(inum, "inum should not be null");
        GluuGroup group = groupService.getGroupByInum(inum);
        List<String> members = new ArrayList<String>();
        if (group != null) {
            GluuGroupApi gluuGroupApi = convert(Arrays.asList(group)).get(0);
            members = gluuGroupApi.getMembers();
            return Response.ok(computeMembers(members)).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 : GluuGroupApi(org.gluu.oxtrust.api.server.model.GluuGroupApi) ArrayList(java.util.ArrayList) GluuGroup(org.gluu.oxtrust.model.GluuGroup) 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 Content

use of io.swagger.v3.oas.annotations.media.Content in project oxTrust by GluuFederation.

the class GroupWebResource method getGroupByInum.

@GET
@Path(ApiConstants.INUM_PARAM_PATH)
@Operation(summary = "Get group by inum", description = "Get a group by inum")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = GluuGroupApi.class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { READ_ACCESS })
public Response getGroupByInum(@PathParam(ApiConstants.INUM) @NotNull String inum) {
    log("Get group having group" + inum);
    inum = inum.equalsIgnoreCase("") ? null : inum;
    try {
        Objects.requireNonNull(inum, "inum should not be null");
        GluuGroup group = groupService.getGroupByInum(inum);
        if (group != null) {
            return Response.ok(convert(Arrays.asList(group)).get(0)).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 : GluuGroup(org.gluu.oxtrust.model.GluuGroup) 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 Content

use of io.swagger.v3.oas.annotations.media.Content in project oxTrust by GluuFederation.

the class OxtrustSettingWebResource method updateOxtrustSetting.

@PUT
@Operation(summary = "Update oxtrust settings", description = "Update oxtrust settings")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = OxtrustSetting.class)), description = Constants.RESULT_SUCCESS), @ApiResponse(responseCode = "404", description = "Not found"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response updateOxtrustSetting(OxtrustSetting oxtrustSetting) {
    try {
        log(logger, "Processing oxtrust settings update request");
        Preconditions.checkNotNull(oxtrustSetting, "Attempt to update null oxtrust settings");
        GluuConfiguration configurationUpdate = configurationService.getConfiguration();
        configurationUpdate.setScimEnabled(Boolean.valueOf(oxtrustSetting.getEnableScim()));
        configurationUpdate.setPassportEnabled(Boolean.valueOf(oxtrustSetting.getEnablePassport()));
        configurationUpdate.setPasswordResetAllowed(Boolean.valueOf(oxtrustSetting.getAllowPasswordReset()));
        configurationUpdate.setProfileManagment(Boolean.valueOf(oxtrustSetting.getAllowProfileManagement()));
        configurationService.updateConfiguration(configurationUpdate);
        return Response.ok(Constants.RESULT_SUCCESS).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) PUT(javax.ws.rs.PUT) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Example 100 with Content

use of io.swagger.v3.oas.annotations.media.Content 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)

Aggregations

OpenAPI (io.swagger.v3.oas.models.OpenAPI)121 Test (org.testng.annotations.Test)120 MediaType (io.swagger.v3.oas.models.media.MediaType)70 Schema (io.swagger.v3.oas.models.media.Schema)70 Operation (io.swagger.v3.oas.annotations.Operation)65 Content (io.swagger.v3.oas.models.media.Content)64 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)62 OpenAPIV3Parser (io.swagger.v3.parser.OpenAPIV3Parser)59 ArraySchema (io.swagger.v3.oas.models.media.ArraySchema)57 IntegerSchema (io.swagger.v3.oas.models.media.IntegerSchema)53 Operation (io.swagger.v3.oas.models.Operation)52 ObjectSchema (io.swagger.v3.oas.models.media.ObjectSchema)51 StringSchema (io.swagger.v3.oas.models.media.StringSchema)50 ProtectedApi (org.gluu.oxtrust.service.filter.ProtectedApi)42 PathItem (io.swagger.v3.oas.models.PathItem)41 ArrayList (java.util.ArrayList)41 RequestBody (io.swagger.v3.oas.models.parameters.RequestBody)40 ApiResponse (io.swagger.v3.oas.models.responses.ApiResponse)37 SwaggerParseResult (io.swagger.v3.parser.core.models.SwaggerParseResult)37 ParseOptions (io.swagger.v3.parser.core.models.ParseOptions)33