use of controlP5.Group in project oxTrust by GluuFederation.
the class Scim2GroupService method createGroup.
public Group createGroup(Group group) throws Exception {
log.debug(" copying gluuGroup ");
GluuGroup gluuGroup = copyUtils2.copy(group, null, false);
if (gluuGroup == null) {
throw new Exception("Scim2GroupService.createGroup(): Failed to create group; GluuGroup is null");
}
log.debug(" generating inum ");
String inum = groupService.generateInumForNewGroup();
log.debug(" getting DN ");
String dn = groupService.getDnForGroup(inum);
log.debug(" getting iname ");
String iname = groupService.generateInameForNewGroup(group.getDisplayName().replaceAll(" ", ""));
log.debug(" setting dn ");
gluuGroup.setDn(dn);
log.debug(" setting inum ");
gluuGroup.setInum(inum);
log.debug(" setting iname ");
gluuGroup.setIname(iname);
log.info("group.getMembers().size() : " + group.getMembers().size());
if (group.getMembers().size() > 0) {
serviceUtil.personMembersAdder(gluuGroup, dn);
}
// As per spec, the SP must be the one to assign the meta attributes
log.info(" Setting meta: create group ");
// Date should be in UTC format
DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.dateTime().withZoneUTC();
Date dateCreated = DateTime.now().toDate();
String relativeLocation = "/scim/v2/Groups/" + inum;
gluuGroup.setAttribute("oxTrustMetaCreated", dateTimeFormatter.print(dateCreated.getTime()));
gluuGroup.setAttribute("oxTrustMetaLastModified", dateTimeFormatter.print(dateCreated.getTime()));
gluuGroup.setAttribute("oxTrustMetaLocation", relativeLocation);
// For custom script: create group
if (externalScimService.isEnabled()) {
externalScimService.executeScimCreateGroupMethods(gluuGroup);
}
log.debug("adding new GluuGroup");
groupService.addGroup(gluuGroup);
Group createdGroup = copyUtils2.copy(gluuGroup, null);
return createdGroup;
}
use of controlP5.Group in project oxTrust by GluuFederation.
the class GroupWebService method updateGroup.
@Path("{id}")
@PUT
@Consumes({ Constants.MEDIA_TYPE_SCIM_JSON, MediaType.APPLICATION_JSON })
@Produces({ Constants.MEDIA_TYPE_SCIM_JSON + "; charset=utf-8", MediaType.APPLICATION_JSON + "; charset=utf-8" })
@HeaderParam("Accept")
@DefaultValue(Constants.MEDIA_TYPE_SCIM_JSON)
@ApiOperation(value = "Update group", notes = "Update group (https://tools.ietf.org/html/rfc7644#section-3.5.1)", response = Group.class)
public Response updateGroup(@HeaderParam("Authorization") String authorization, @QueryParam(OxTrustConstants.QUERY_PARAMETER_TEST_MODE_OAUTH2_TOKEN) final String token, @PathParam("id") String id, @ApiParam(value = "Group", required = true) Group group, @QueryParam(OxTrustConstants.QUERY_PARAMETER_ATTRIBUTES) final String attributesArray) throws Exception {
Response authorizationResponse;
if (jsonConfigurationService.getOxTrustappConfiguration().isScimTestMode()) {
log.info(" ##### SCIM Test Mode is ACTIVE");
authorizationResponse = processTestModeAuthorization(token);
} else {
authorizationResponse = processAuthorization(authorization);
}
if (authorizationResponse != null) {
return authorizationResponse;
}
try {
Group updatedGroup = scim2GroupService.updateGroup(id, group);
// Serialize to JSON
String json = serializeToJson(updatedGroup, attributesArray);
URI location = new URI(updatedGroup.getMeta().getLocation());
return Response.ok(json).location(location).build();
} catch (EntryPersistenceException ex) {
log.error("Failed to update group", ex);
ex.printStackTrace();
return getErrorResponse(Response.Status.NOT_FOUND, ErrorScimType.INVALID_VALUE, "Resource " + id + " not found");
} catch (DuplicateEntryException ex) {
log.error("DuplicateEntryException", ex);
ex.printStackTrace();
return getErrorResponse(Response.Status.CONFLICT, ErrorScimType.UNIQUENESS, ex.getMessage());
} catch (Exception ex) {
log.error("Failed to update group", ex);
ex.printStackTrace();
return getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, INTERNAL_SERVER_ERROR_MESSAGE);
}
}
use of controlP5.Group in project oxTrust by GluuFederation.
the class GroupWebService method searchGroups.
@GET
@Produces({ Constants.MEDIA_TYPE_SCIM_JSON + "; charset=utf-8", MediaType.APPLICATION_JSON + "; charset=utf-8" })
@HeaderParam("Accept")
@DefaultValue(Constants.MEDIA_TYPE_SCIM_JSON)
@ApiOperation(value = "Search groups", notes = "Returns a list of groups (https://tools.ietf.org/html/rfc7644#section-3.4.2.2)", response = ListResponse.class)
public Response searchGroups(@HeaderParam("Authorization") String authorization, @QueryParam(OxTrustConstants.QUERY_PARAMETER_TEST_MODE_OAUTH2_TOKEN) final String token, @QueryParam(OxTrustConstants.QUERY_PARAMETER_FILTER) final String filterString, @QueryParam(OxTrustConstants.QUERY_PARAMETER_START_INDEX) final int startIndex, @QueryParam(OxTrustConstants.QUERY_PARAMETER_COUNT) final int count, @QueryParam(OxTrustConstants.QUERY_PARAMETER_SORT_BY) final String sortBy, @QueryParam(OxTrustConstants.QUERY_PARAMETER_SORT_ORDER) final String sortOrder, @QueryParam(OxTrustConstants.QUERY_PARAMETER_ATTRIBUTES) final String attributesArray) throws Exception {
Response authorizationResponse;
if (jsonConfigurationService.getOxTrustappConfiguration().isScimTestMode()) {
log.info(" ##### SCIM Test Mode is ACTIVE");
authorizationResponse = processTestModeAuthorization(token);
} else {
authorizationResponse = processAuthorization(authorization);
}
if (authorizationResponse != null) {
return authorizationResponse;
}
try {
if (count > getMaxCount()) {
String detail = "Too many results (=" + count + ") would be returned; max is " + getMaxCount() + " only.";
return getErrorResponse(Response.Status.BAD_REQUEST, ErrorScimType.TOO_MANY, detail);
} else {
log.info(" Searching groups from LDAP ");
VirtualListViewResponse vlvResponse = new VirtualListViewResponse();
List<GluuGroup> groupList = search(groupService.getDnForGroup(null), GluuGroup.class, filterString, startIndex, count, sortBy, sortOrder, vlvResponse, attributesArray);
// List<GluuGroup> groupList = groupService.getAllGroupsList();
ListResponse groupsListResponse = new ListResponse();
List<String> schema = new ArrayList<String>();
schema.add(Constants.LIST_RESPONSE_SCHEMA_ID);
log.info(" setting schema");
groupsListResponse.setSchemas(schema);
// Set total
groupsListResponse.setTotalResults(vlvResponse.getTotalResults());
if (count > 0 && groupList != null && !groupList.isEmpty()) {
for (GluuGroup gluuGroup : groupList) {
Group group = copyUtils2.copy(gluuGroup, null);
log.info(" group to be added displayName : " + group.getDisplayName());
groupsListResponse.getResources().add(group);
log.info(" group added? : " + groupsListResponse.getResources().contains(group));
}
// Set the rest of results info
groupsListResponse.setItemsPerPage(vlvResponse.getItemsPerPage());
groupsListResponse.setStartIndex(vlvResponse.getStartIndex());
}
// Serialize to JSON
String json = serializeToJson(groupsListResponse, attributesArray);
URI location = new URI(appConfiguration.getBaseEndpoint() + "/scim/v2/Groups");
return Response.ok(json).location(location).build();
}
} catch (Exception ex) {
log.error("Error in searchGroups", ex);
ex.printStackTrace();
return getErrorResponse(Response.Status.BAD_REQUEST, ErrorScimType.INVALID_FILTER, INTERNAL_SERVER_ERROR_MESSAGE);
}
}
use of controlP5.Group in project oxTrust by GluuFederation.
the class GroupWebService method createGroup.
@POST
@Consumes({ Constants.MEDIA_TYPE_SCIM_JSON, MediaType.APPLICATION_JSON })
@Produces({ Constants.MEDIA_TYPE_SCIM_JSON + "; charset=utf-8", MediaType.APPLICATION_JSON + "; charset=utf-8" })
@HeaderParam("Accept")
@DefaultValue(Constants.MEDIA_TYPE_SCIM_JSON)
@ApiOperation(value = "Create group", notes = "Create group (https://tools.ietf.org/html/rfc7644#section-3.3)", response = Group.class)
public Response createGroup(@HeaderParam("Authorization") String authorization, @QueryParam(OxTrustConstants.QUERY_PARAMETER_TEST_MODE_OAUTH2_TOKEN) final String token, @ApiParam(value = "Group", required = true) Group group, @QueryParam(OxTrustConstants.QUERY_PARAMETER_ATTRIBUTES) final String attributesArray) throws Exception {
Response authorizationResponse;
if (jsonConfigurationService.getOxTrustappConfiguration().isScimTestMode()) {
log.info(" ##### SCIM Test Mode is ACTIVE");
authorizationResponse = processTestModeAuthorization(token);
} else {
authorizationResponse = processAuthorization(authorization);
}
if (authorizationResponse != null) {
return authorizationResponse;
}
try {
Group createdGroup = scim2GroupService.createGroup(group);
// Serialize to JSON
String json = serializeToJson(createdGroup, attributesArray);
URI location = new URI(createdGroup.getMeta().getLocation());
// Return HTTP response with status code 201 Created
return Response.created(location).entity(json).build();
} catch (DuplicateEntryException ex) {
log.error("DuplicateEntryException", ex);
ex.printStackTrace();
return getErrorResponse(Response.Status.CONFLICT, ErrorScimType.UNIQUENESS, ex.getMessage());
} catch (Exception ex) {
log.error("Failed to create group", ex);
ex.printStackTrace();
return getErrorResponse(Response.Status.INTERNAL_SERVER_ERROR, INTERNAL_SERVER_ERROR_MESSAGE);
}
}
use of controlP5.Group in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method revisitGroups.
public void revisitGroups(Definitions def) {
List<RootElement> rootElements = def.getRootElements();
Category defaultCat = Bpmn2Factory.eINSTANCE.createCategory();
defaultCat.setName("default");
for (RootElement root : rootElements) {
if (root instanceof Process) {
Process process = (Process) root;
List<Artifact> processArtifacts = process.getArtifacts();
if (processArtifacts != null) {
for (Artifact ar : processArtifacts) {
if (ar instanceof Group) {
Group group = (Group) ar;
Iterator<FeatureMap.Entry> iter = group.getAnyAttribute().iterator();
while (iter.hasNext()) {
FeatureMap.Entry entry = iter.next();
if (entry.getEStructuralFeature().getName().equals("categoryval")) {
CategoryValue catval = Bpmn2Factory.eINSTANCE.createCategoryValue();
catval.setValue((String) entry.getValue());
defaultCat.getCategoryValue().add(catval);
group.setCategoryValueRef(catval);
}
}
}
}
}
}
}
// only add category if it includes at least one categoryvalue
if (defaultCat.getCategoryValue() != null && defaultCat.getCategoryValue().size() > 0) {
rootElements.add(defaultCat);
}
}
Aggregations