use of io.swagger.v3.oas.models.responses.ApiResponses in project oxTrust by GluuFederation.
the class GroupWebResource method createGroup.
@POST
@Operation(summary = "Add group", description = "Add a group")
@ApiResponses(value = { @ApiResponse(responseCode = "201", content = @Content(schema = @Schema(implementation = GluuGroupApi.class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response createGroup(GluuGroupApi group) {
log("Adding group " + group.getDisplayName());
try {
Objects.requireNonNull(group, "Attempt to create null group");
GluuGroup gluuGroup = copyAttributes(group);
String inum = gluuGroup.getInum();
if (StringHelper.isEmpty(inum)) {
inum = groupService.generateInumForNewGroup();
}
gluuGroup.setDn(groupService.getDnForGroup(inum));
gluuGroup.setInum(inum);
groupService.addGroup(gluuGroup);
return Response.status(Response.Status.CREATED).entity(convert(Arrays.asList(groupService.getGroupByInum(inum))).get(0)).build();
} catch (Exception e) {
log(logger, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
use of io.swagger.v3.oas.models.responses.ApiResponses in project oxTrust by GluuFederation.
the class OxAuthJsonSettingWebResource method updateOxauthJsonSetting.
@PUT
@Operation(summary = "Update json oxauth settings", description = "Updates the oxAuth JSON configuration")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = OxAuthJsonConfiguration.class)), description = Constants.RESULT_SUCCESS), @ApiResponse(responseCode = "404", description = "Not found"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response updateOxauthJsonSetting(OxAuthJsonConfiguration oxAuthJsonSetting) {
try {
log(logger, "Processing oxauth json settings update request");
Preconditions.checkNotNull(oxAuthJsonSetting, "Attempt to update null oxauth json settings");
String value = new ObjectMapper().writeValueAsString(oxAuthJsonSetting);
jsonConfigurationService.saveOxAuthDynamicConfigJson(value);
return Response.ok(Constants.RESULT_SUCCESS).build();
} catch (Exception e) {
log(logger, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
use of io.swagger.v3.oas.models.responses.ApiResponses in project oxTrust by GluuFederation.
the class PassportProviderWebResource method deleteProvider.
@DELETE
@Path(ApiConstants.ID_PARAM_PATH)
@Operation(summary = "Delete passport provider", description = "Delete a passport provider")
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response deleteProvider(@PathParam(ApiConstants.ID) @NotNull String id) {
log(logger, "Delete passport provider having id " + id);
try {
Objects.requireNonNull(id, "id should not be null");
this.ldapOxPassportConfiguration = passportService.loadConfigurationFromLdap();
this.passportConfiguration = this.ldapOxPassportConfiguration.getPassportConfiguration();
List<Provider> providers = new ArrayList<>();
providers.addAll(this.passportConfiguration.getProviders());
Provider found = null;
for (Provider provider : providers) {
if (id.equalsIgnoreCase(provider.getId())) {
found = provider;
break;
}
}
if (found != null) {
providers.remove(found);
this.passportConfiguration.setProviders(providers);
this.ldapOxPassportConfiguration.setPassportConfiguration(this.passportConfiguration);
this.passportService.updateLdapOxPassportConfiguration(this.ldapOxPassportConfiguration);
return Response.ok().build();
} else {
return Response.ok(Response.Status.NOT_FOUND).build();
}
} catch (Exception e) {
log(logger, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
use of io.swagger.v3.oas.models.responses.ApiResponses in project oxTrust by GluuFederation.
the class ScopeWebResource method getScopeClaims.
@GET
@Path(ApiConstants.INUM_PARAM_PATH + ApiConstants.CLAIMS)
@Operation(summary = "Get scope claims", description = "List all claims of a scope")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = GluuAttribute[].class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response getScopeClaims(@PathParam(ApiConstants.INUM) @NotNull String inum) {
log(logger, "List all claims of scope ==> " + inum);
try {
Objects.requireNonNull(inum, "inum should not be null");
Scope oxAuthScope = scopeService.getScopeByInum(inum);
List<String> claimsDn = new ArrayList<String>();
List<GluuAttribute> attributes = new ArrayList<GluuAttribute>();
if (oxAuthScope != null) {
claimsDn.addAll(oxAuthScope.getOxAuthClaims());
for (String claimDn : claimsDn) {
attributes.add(attributeService.getAttributeByDn(claimDn));
}
return Response.ok(attributes).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();
}
}
use of io.swagger.v3.oas.models.responses.ApiResponses in project oxTrust by GluuFederation.
the class ScopeWebResource method updateScope.
@PUT
@Operation(summary = "Update openid connect scope", description = "Update openidconect scope")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = Scope.class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response updateScope(Scope scope) {
String inum = scope.getInum();
log(logger, "Update scope " + inum);
try {
Objects.requireNonNull(scope, "Attempt to update scope null value");
Objects.requireNonNull(inum);
Scope existingScope = scopeService.getScopeByInum(inum);
if (existingScope != null) {
scope.setInum(existingScope.getInum());
scopeService.updateScope(scope);
return Response.ok(scopeService.getScopeByInum(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();
}
}
Aggregations