Element xGroup = new Element("group", ns); Element xId = new Element("id", ns); xId.setText(group.getId()); xGroup.addContent(xId); Element xDomain = new Element("domain", ns); xDomain.setText(group.getGroupName().getDomain()); xGroup.addContent(xDomain); Element xName = new Element("name", ns); xName.setText(group.getGroupName().getName()); xGroup.addContent(xName); if (group.getParentId() != null) { Element xParentId = new Element("parentId", ns); xParentId.setText(group.getParentId()); xGroup.addContent(xParentId); if (!CollectionUtils.isEmpty(group.getRoles())) { Element xRoles = new Element("roles", ns); for (String role : group.getRoles()) { Element xRole = new Element("role", ns); xRole.setText(role);
/** * Transform hibernate group to group. * * @param hibernateGroup the hibernate group * @return the group */ public static Group transformHibernateGroupToGroup(HibernateGroup hibernateGroup) { if (hibernateGroup == null) { return null; } Group group = new Group(); group.setId(hibernateGroup.getId()); group.setGroupName(transformHibernateGroupToGroupName(hibernateGroup)); group.setRoles(new HashSet<String>(hibernateGroup.getRoles())); if (hibernateGroup.getParentGroup() != null) { group.setParentId(hibernateGroup.getParentGroup().getId()); } group.setAttributes(new HashMap<String, String>(hibernateGroup.getAttributes())); return group; }
/** * Fill group related fields. * * @param group the group */ public void fillGroupRelatedFields(Group group) { setName(group.getGroupName().getName()); if (CollectionUtils.isNotEmpty(getEffectiveRoles())) { getEffectiveRoles().removeAll(getRoles()); if (CollectionUtils.isNotEmpty(group.getRoles())) { getEffectiveRoles().addAll(group.getRoles()); } } else { if (CollectionUtils.isNotEmpty(group.getRoles())) { setEffectiveRoles(new HashSet<String>(group.getRoles())); } } if (CollectionUtils.isNotEmpty(group.getRoles())) { setRoles(new HashSet<String>(group.getRoles())); } else { setRoles(new HashSet<String>(0)); } if (MapUtils.isNotEmpty(group.getAttributes())) { setAttributes(new HashMap<String, String>(group.getAttributes())); } else { setAttributes(new HashMap<String, String>()); } }
/** * Converts group DTO to userDb model. * @param source * @return {@link Group} */ protected static Group convertGroup(GroupDTO source) { Group result = new Group(); if (source.getName()!=null && source.getName().trim().length()>0) { String domain = (source.getDomain()!=null && source.getDomain().trim().length()>0)? source.getDomain():null; result.setGroupName(new GroupName(domain, source.getName())); } if (source.getRolesCSV()!=null && source.getRolesCSV().trim().length()>0) { result.setRoles(convertCSVToSet(source.getRolesCSV())); } return result; }
group.setId(id); if (group.getParentId() != null) { Group parentGroup = loadGroup(group.getParentId()); if (parentGroup == null) { throw new ImportException("Group with id: " + group.getParentId() + " does not exist, so group with id: " + group.getId() + " can not be assignrd to it."); assignGroup(group.getGroupName(), parentGroup.getGroupName()); } catch (Exception e) { throw new ImportException(e.getMessage(), e);
@Override public String addGroup(Group group) throws GroupExistsException, DomainNotSupportedException { if (group.getGroupName().getDomain() == null) { group.getGroupName().setDomain(UserCatalogConstants.DEFAULT_DOMAIN_NAME); } else { checkIfDomainSupported(group.getGroupName().getDomain()); } return groupDao.save(UserCatalogModelHibernateModelTransformer.transformGroupToHibernateGroup(group)); }
/** * Transform group to hibernate group. * * @param group the group * @return the hibernate group */ public static HibernateGroup transformGroupToHibernateGroup(Group group) { if (group == null) { return null; } HibernateGroup hibernateGroup = new HibernateGroup(); hibernateGroup.setId(group.getId()); hibernateGroup.setDomain(group.getGroupName().getDomain()); hibernateGroup.fillGroupRelatedFields(group); return hibernateGroup; }
if (cascade) { for (Group childGroup : childGroups) { deleteGroup(childGroup.getGroupName(), true); unassignGroup(childGroup.getGroupName(), groupName); } catch (CrossDomainOperationException e) { logger.error("Previously loaded group could not be unassigned. " if (group.getParentId() != null) { Group parentGroup = UserCatalogModelHibernateModelTransformer.transformHibernateGroupToGroup(groupDao .load(group.getParentId())); try { unassignGroup(group.getGroupName(), parentGroup.getGroupName()); } catch (Exception e) { logger.error("Previously loaded group could not be unassigned. "
@Override public void updateGroup(Group group) throws GroupNotFoundException { HibernateGroup hibernateGroup = groupDao.load(group.getGroupName()); if (hibernateGroup == null) { throw new GroupNotFoundException(group.getGroupName()); } hibernateGroup.fillGroupRelatedFields(group); groupDao.update(hibernateGroup); for (HibernateUser hibernateUser : hibernateGroup.getEffectiveUsers()) { hibernateUser.setEffectiveRoles(getEffectiveRoles(hibernateUser)); try { userDao.update(hibernateUser); } catch (UserNotFoundException e) { logger.error("Previously loaded user could not be updated. " + "Very bad situation. Debug thoroughly.", e); } } }
Element root = doc.getRootElement(); Namespace ns = root.getNamespace(); Group group = new Group(); String id = root.getChildText("id", ns); group.setId(id); String parentId = root.getChildText("parentId", ns); group.setParentId(parentId); String domain = root.getChildText("domain", ns); String name = root.getChildText("name", ns); GroupName groupName = new GroupName(domain, name); group.setGroupName(groupName); roles.add(roleElement.getValue()); group.setRoles(roles);
for (Group group : groups.getResults()) { userCatalogFacade.deleteGroup(group.getGroupName(), false);
@Override public GenericResponse updateGroup(GroupAwareRequest request) { Map<String, Serializable> auxParams = new HashMap<String, Serializable>(); if (request.getGroup()!=null && request.getGroup().getGroupName()!=null && request.getGroup().getGroupName().getDomain()!=null) { auxParams.put(XACMLConstants.SUBJECT_AUX_PARAM_DOMAIN_ROOT_SUFFIX, extractDomainRoot(request.getGroup().getGroupName().getDomain())); auxParams.put(XACMLConstants.SUBJECT_AUX_PARAM_DOMAIN_SUFFIX, request.getGroup().getGroupName().getDomain());
@Override public IdentifiedResponse addGroup(GroupAwareRequest request) { Map<String, Serializable> auxParams = new HashMap<String, Serializable>(); if (request.getGroup()!=null && request.getGroup().getGroupName()!=null && request.getGroup().getGroupName().getDomain()!=null) { auxParams.put(XACMLConstants.SUBJECT_AUX_PARAM_DOMAIN_ROOT_SUFFIX, extractDomainRoot(request.getGroup().getGroupName().getDomain())); auxParams.put(XACMLConstants.SUBJECT_AUX_PARAM_DOMAIN_SUFFIX, request.getGroup().getGroupName().getDomain()); } else { if (disallowNullDomain) {