use of org.gluu.oxtrust.model.GluuCustomPerson in project oxTrust by GluuFederation.
the class ServiceUtil method deleteGroupFromPerson.
/**
* Delete a Group from a Person
*
* @return void
* @throws Exception
*/
public void deleteGroupFromPerson(GluuGroup group, String dn) throws Exception {
List<String> persons = group.getMembers();
for (String onePerson : persons) {
GluuCustomPerson gluuPerson = personService.getPersonByDn(onePerson);
List<String> memberOflist = gluuPerson.getMemberOf();
List<String> tempMemberOf = new ArrayList<>();
for (String aMemberOf : memberOflist) {
tempMemberOf.add(aMemberOf);
}
for (String oneMemberOf : tempMemberOf) {
if (oneMemberOf.equalsIgnoreCase(dn)) {
tempMemberOf.remove(oneMemberOf);
break;
}
}
List<String> cleanMemberOf = new ArrayList<>();
for (String aMemberOf : tempMemberOf) {
cleanMemberOf.add(aMemberOf);
}
gluuPerson.setMemberOf(cleanMemberOf);
personService.updatePerson(gluuPerson);
}
}
use of org.gluu.oxtrust.model.GluuCustomPerson in project oxTrust by GluuFederation.
the class GroupService method removeGroup.
/*
* (non-Javadoc)
*
* @see
* org.gluu.oxtrust.ldap.service.IGroupService#removeGroup(org.gluu.oxtrust.
* model.GluuGroup)
*/
@Override
public void removeGroup(GluuGroup group) {
if (group.getMembers() != null) {
List<String> memberDNs = group.getMembers();
for (String memberDN : memberDNs) {
if (personService.contains(memberDN)) {
GluuCustomPerson person = personService.getPersonByDn(memberDN);
List<String> groupDNs = person.getMemberOf();
List<String> updatedGroupDNs = new ArrayList<String>();
updatedGroupDNs.addAll(groupDNs);
updatedGroupDNs.remove(group.getDn());
person.setMemberOf(updatedGroupDNs);
try {
personService.updatePerson(person);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
persistenceEntryManager.remove(group);
// clear references in gluuPerson entries
}
use of org.gluu.oxtrust.model.GluuCustomPerson in project oxTrust by GluuFederation.
the class PersonServiceTest method testGetPersonByUid.
@Test
@Parameters({ "person.uid" })
public void testGetPersonByUid(final String personUid) throws Exception {
GluuCustomPerson person = personService.getPersonByUid(personUid);
assertNotNull(person, "Failed to find person");
assertEquals(person.getUid(), personUid);
}
use of org.gluu.oxtrust.model.GluuCustomPerson in project oxTrust by GluuFederation.
the class PeopleWebResource method getPersonByInum.
@GET
@Path(ApiConstants.INUM_PARAM_PATH)
@Operation(summary = "Get person by inum", description = "Get a person by inum")
@ApiResponses(value = { @ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = GluuPersonApi.class)), description = "Success"), @ApiResponse(responseCode = "500", description = "Server error") })
@ProtectedApi(scopes = { READ_ACCESS })
public Response getPersonByInum(@PathParam(ApiConstants.INUM) @NotNull String inum) {
log(logger, "Get person " + inum);
try {
Objects.requireNonNull(inum, "inum should not be null");
GluuCustomPerson person = personService.getPersonByInum(inum);
if (person != null) {
return Response.ok(convert(Arrays.asList(person)).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.model.GluuCustomPerson in project oxTrust by GluuFederation.
the class PeopleWebResource method copyAttributes.
private GluuCustomPerson copyAttributes(GluuPersonApi person) {
GluuCustomPerson gluuCustomPerson = new GluuCustomPerson();
gluuCustomPerson.setUid(person.getUserName());
gluuCustomPerson.setInum(person.getInum());
gluuCustomPerson.setGivenName(person.getGivenName());
gluuCustomPerson.setMail(person.getEmail());
gluuCustomPerson.setDisplayName(person.getDisplayName());
gluuCustomPerson.setSurname(person.getSurName());
gluuCustomPerson.setCreationDate(person.getCreationDate());
gluuCustomPerson.setStatus(person.getStatus().getValue());
gluuCustomPerson.setUserPassword(person.getPassword());
gluuCustomPerson.setAttribute("oxTrustActive", "true");
return gluuCustomPerson;
}
Aggregations