@Override public Group getGroup(String name, Group parent) { if (name == null || parent == null) { return null; } Group group = getGroup(name); if (group.getParentGroup() == null || !group.getParentGroup().getName().equals(parent.getName())) { group = null; } return group; }
@Override protected void doPopulateIdentityInstance(Object toIdentity, Group fromGroup, JPAIdentityStore store) { store.setModelProperty(toIdentity, PROPERTY_IDENTITY_NAME, fromGroup.getName(), true); if (fromGroup.getParentGroup() != null) { Object parentIdentity = store.lookupIdentityObjectById(fromGroup.getParentGroup()); if (parentIdentity == null) { store.add(fromGroup.getParentGroup()); parentIdentity = store.lookupIdentityObjectById(fromGroup.getParentGroup()); } store.setModelProperty(toIdentity, PROPERTY_PARENT_GROUP, parentIdentity, true); } }
@Override public Group getGroup(String name, Group parent) { Group ldapGroup = getGroup(name); Group ldapGroupParent = ldapGroup.getParentGroup(); if (parent != null && ldapGroup != null && ldapGroupParent != null && ldapGroupParent.getName().equals(parent.getName())) { return ldapGroup; } return null; }
@Override public Group getGroup(String name, Group parent) { Group group = getGroup(name); Group parentGroup = group.getParentGroup(); if (parentGroup == null || !parentGroup.getName().equals(parent.getName())) { group = null; } return group; }
private Group addGroup(Group group) { SimpleGroup fileGroup = null; if (group.getParentGroup() != null) { fileGroup = new SimpleGroup(group.getName(), getGroup(group.getParentGroup().getName())); } else { fileGroup = new SimpleGroup(group.getName()); } updateCommonProperties(group, fileGroup); getConfig().getGroups().put(fileGroup.getName(), fileGroup); flushGroups(); return fileGroup; }
/** * <p> * Finds groups by the creation date. * </p> * * @throws Exception */ @Test public void testFindWithParent() throws Exception { Group group = loadOrCreateGroup("someGroup", "Parent Group", true); IdentityManager identityManager = getIdentityManager(); IdentityQuery<Group> query = identityManager.<Group> createQuery(Group.class); query.setParameter(Group.PARENT, group.getParentGroup().getName()); List<Group> result = query.getResultList(); assertFalse(result.isEmpty()); assertTrue(result.size() == 1); assertEquals(group.getName(), result.get(0).getName()); assertEquals(group.getParentGroup().getName(), result.get(0).getParentGroup().getName()); }
protected Group addGroup(Group group) { if (group.getName() == null) { throw new IdentityManagementException("No identifier was provided."); } LDAPGroup ldapGroup = new LDAPGroup(this.configuration.getGroupDNSuffix()); ldapGroup.setName(group.getName()); if (group.getParentGroup() != null) { String parentName = group.getParentGroup().getName(); LDAPGroup parentGroup = (LDAPGroup) getGroup(parentName); if (parentGroup == null) { throw new RuntimeException("Parent group [" + parentName + "] does not exists."); } parentGroup.addChildGroup(ldapGroup); ldapGroup.setParentGroup(parentGroup); getLdapManager().modifyAttribute(parentGroup.getDN(), parentGroup.getLDAPAttributes().get(MEMBER)); } store(ldapGroup); return ldapGroup; }
/** * <p> * Creates a new {@link Group} instance as a child of another {@link Group} using the API. This method also checks if the * group was properly created by retrieving his information from the store. * </p> * * @throws Exception */ @Test public void testCreateWithParentGroup() throws Exception { Group childGroup = loadOrCreateGroup("childGroup", "parentGroup", true); // let's retrieve the group information and see if it was properly stored IdentityManager identityManager = getIdentityManager(); Group storedChildGroup = identityManager.getGroup(childGroup.getName()); assertNotNull(storedChildGroup); assertNotNull(storedChildGroup.getParentGroup()); assertEquals(childGroup.getKey(), storedChildGroup.getKey()); assertEquals(childGroup.getName(), storedChildGroup.getName()); assertEquals(childGroup.getParentGroup().getName(), storedChildGroup.getParentGroup().getName()); }
/** * <p> * Loads from the LDAP tree an already stored group. * </p> * * @throws Exception */ @Test public void testGet() throws Exception { Group storedGroupInstance = getIdentityType(true); IdentityManager identityManager = getIdentityManager(); storedGroupInstance = identityManager.getGroup(storedGroupInstance.getName()); assertNotNull(storedGroupInstance); assertNotNull(storedGroupInstance.getParentGroup()); assertEquals("GROUP:///Test Parent Group/Test Group", storedGroupInstance.getKey()); assertEquals("Test Group", storedGroupInstance.getName()); }
if (group.getParentGroup() != null) { parentGroupName = group.getParentGroup().getName();
/** * <p> * Loads from the LDAP tree an already stored group. * </p> * * @throws Exception */ @Test public void testGetWithParent() throws Exception { Group storedGroupInstance = getIdentityType(true); IdentityManager identityManager = getIdentityManager(); storedGroupInstance = identityManager.getGroup("Test Group", new SimpleGroup("Test Parent Group")); assertNotNull(storedGroupInstance); assertNotNull(storedGroupInstance.getParentGroup()); assertEquals("GROUP:///Test Parent Group/Test Group", storedGroupInstance.getKey()); assertEquals("Test Group", storedGroupInstance.getName()); Group invalidGroupInstance = identityManager.getGroup("Test Group", new SimpleGroup("Invalid Parent Group")); assertNull(invalidGroupInstance); }