use of org.gluu.oxtrust.service.filter.ProtectedApi in project oxTrust by GluuFederation.
the class LDAPAuthenticationWebResource method getLdapConfigurationStatusByName.
@GET
@Path(ApiConstants.NAME_PARAM_PATH + ApiConstants.STATUS)
@Operation(summary = "Check the status of an existing configuration", description = "Check the status of an existing configuration")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = ConnectionStatusDTO.class)), description = "Success") })
@ProtectedApi(scopes = { READ_ACCESS })
public Response getLdapConfigurationStatusByName(@PathParam("name") String name) {
log(logger, "Check the status of an existing configuration");
try {
GluuLdapConfiguration ldapConfiguration = ldapConfigurationService.findLdapConfigurationByName(name);
org.gluu.oxtrust.util.LdapConnectionData ldapConnectionData = LdapConnectionData.from(ldapConfiguration);
ConnectionStatusDTO connectionStatus = ConnectionStatusDTO.from(this.connectionStatus.isUp(ldapConnectionData));
return Response.ok(connectionStatus).build();
} catch (Exception e) {
log(logger, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
use of org.gluu.oxtrust.service.filter.ProtectedApi in project oxTrust by GluuFederation.
the class PeopleWebResource method createPerson.
@POST
@Operation(summary = "Add person", description = "Add a person")
@ApiResponses(value = { @ApiResponse(responseCode = "201", content = @Content(schema = @Schema(implementation = GluuPersonApi.class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response createPerson(GluuPersonApi person) {
log(logger, "Adding person " + person.getDisplayName());
try {
Objects.requireNonNull(person, "Attempt to create null person");
GluuCustomPerson gluuPerson = copyAttributes(person);
String inum = person.getInum();
if (StringHelper.isEmpty(inum)) {
inum = personService.generateInumForNewPerson();
}
gluuPerson.setDn(personService.getDnForPerson(inum));
gluuPerson.setInum(inum);
personService.addPerson(gluuPerson);
return Response.status(Response.Status.CREATED).entity(convert(Arrays.asList(personService.getPersonByInum(inum))).get(0)).build();
} catch (Exception e) {
log(logger, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
use of org.gluu.oxtrust.service.filter.ProtectedApi in project oxTrust by GluuFederation.
the class PeopleWebResource method updatePerson.
@PUT
@Operation(summary = "Update person", description = "Update a person")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = GluuPersonApi.class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response updatePerson(GluuPersonApi person) {
String inum = person.getInum();
log(logger, "Update group " + inum);
try {
Objects.requireNonNull(inum, "inum should not be null");
Objects.requireNonNull(person, "Attempt to update null person");
GluuCustomPerson existingPerson = personService.getPersonByInum(inum);
if (existingPerson != null) {
person.setInum(existingPerson.getInum());
person.setPassword(existingPerson.getUserPassword());
GluuCustomPerson personToUpdate = updateValues(existingPerson, person);
personToUpdate.setDn(personService.getDnForPerson(inum));
personService.updatePerson(personToUpdate);
return Response.ok(convert(Arrays.asList(personService.getPersonByInum(inum))).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();
}
}
use of org.gluu.oxtrust.service.filter.ProtectedApi in project oxTrust by GluuFederation.
the class AuthenticationMethodWebResource method updateAuthenticationMethod.
@PUT
@Operation(summary = "Update authentication methods", description = "Update 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 = { WRITE_ACCESS })
public Response updateAuthenticationMethod(AuthenticationMethod method) {
log(logger, "Processing updateAuthenticationMethod()");
try {
Preconditions.checkNotNull(method, "Attempt to update null method");
GluuConfiguration configuration = configurationService.getConfiguration();
if (method.getDefaultAcr() != null || method.getOxtrustAcr() != null) {
configuration.setAuthenticationMode(method.getDefaultAcr());
configuration.setOxTrustAuthenticationMode(method.getOxtrustAcr());
configurationService.updateConfiguration(configuration);
configuration = configurationService.getConfiguration();
method.setDefaultAcr(configuration.getAuthenticationMode());
method.setOxtrustAcr(configuration.getOxTrustAuthenticationMode());
return Response.ok(method).build();
} else {
return Response.status(Response.Status.PRECONDITION_FAILED).build();
}
} catch (Exception e) {
log(logger, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
}
}
use of org.gluu.oxtrust.service.filter.ProtectedApi in project oxTrust by GluuFederation.
the class GroupWebResource method updateGroup.
@PUT
@Operation(summary = "Update group", description = "Update a group")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = GluuGroupApi.class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { WRITE_ACCESS })
public Response updateGroup(GluuGroupApi group) {
String inum = group.getInum();
inum = inum.equalsIgnoreCase("") ? null : inum;
log("Update group " + inum);
try {
Objects.requireNonNull(inum, "inum should not be null");
Objects.requireNonNull(group, "Attempt to update null group");
GluuGroup existingGroup = groupService.getGroupByInum(inum);
if (existingGroup != null) {
group.setInum(existingGroup.getInum());
GluuGroup groupToUpdate = updateValues(existingGroup, group);
groupToUpdate.setDn(groupService.getDnForGroup(inum));
groupService.updateGroup(groupToUpdate);
return Response.ok(convert(Arrays.asList(groupService.getGroupByInum(inum))).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();
}
}
Aggregations