public GeoServerUserGroup getGroupByGroupname(String groupname) throws IOException { return service.getGroupByGroupname(groupname); }
@Override public GeoServerUserGroup getGroupByGroupname(String groupname) throws IOException { return filterGroup(delegate.getGroupByGroupname(groupname)); }
protected void checkNotExistingGroupName(String groupName) throws IOException { checkGroupName(groupName); if (service.getGroupByGroupname(groupName) != null) throw createSecurityException(GROUP_ALREADY_EXISTS_$1, groupName); }
protected void checkExistingGroupName(String groupName) throws IOException { checkGroupName(groupName); if (service.getGroupByGroupname(groupName) == null) throw createSecurityException(GROUP_NOT_FOUND_$1, groupName); }
/** * READ_LOCK * * @see org.geoserver.security.GeoServerUserGroupService#getGroupByGroupname(java.lang.String) */ public GeoServerUserGroup getGroupByGroupname(String groupname) throws IOException { readLock(); try { return getService().getGroupByGroupname(groupname); } finally { readUnLock(); } }
/** * Checks if a group name is valid if this validator was constructed with {@link * GeoServerUserGroupService} objects, a cross check is done * * @param groupName * @throws RoleServiceException */ protected void checkValidGroupName(String groupName) throws IOException { if (isNotEmpty(groupName) == false) throw createSecurityException(GROUPNAME_REQUIRED); if (services.length == 0) return; for (GeoServerUserGroupService service : services) { if (service.getGroupByGroupname(groupName) != null) return; } throw createSecurityException(GROUPNAME_NOT_FOUND_$1, groupName); }
protected void checkValuesRemoved(GeoServerUserGroupService userGroupService) throws IOException { GeoServerUser admin = GeoServerUser.createDefaultAdmin(); GeoServerUser user1 = userGroupService.getUserByUsername("user1"); GeoServerUser disableduser = userGroupService.getUserByUsername("disableduser"); GeoServerUser groupAdminUser = userGroupService.getUserByUsername("groupAdminUser"); assertEquals(4, userGroupService.getUsers().size()); assertEquals(4, userGroupService.getUserCount()); assertTrue(userGroupService.getUsers().contains(admin)); assertTrue(userGroupService.getUsers().contains(user1)); assertTrue(userGroupService.getUsers().contains(disableduser)); assertTrue(userGroupService.getUsers().contains(groupAdminUser)); GeoServerUserGroup admins = userGroupService.getGroupByGroupname("admins"); GeoServerUserGroup group1 = userGroupService.getGroupByGroupname("group1"); assertEquals(3, userGroupService.getUserGroups().size()); assertEquals(3, userGroupService.getGroupCount()); assertTrue(userGroupService.getUserGroups().contains(admins)); assertTrue(userGroupService.getUserGroups().contains(group1)); assertEquals(0, userGroupService.getGroupsForUser(disableduser).size()); assertEquals(1, userGroupService.getUsersForGroup(group1).size()); assertTrue(userGroupService.getUsersForGroup(group1).contains(user1)); assertEquals(0, userGroupService.getUsersHavingProperty("mail").size()); assertEquals(0, userGroupService.getUsersHavingPropertyValue("tel", "11-22-33").size()); }
protected void checkValuesModified(GeoServerUserGroupService userGroupService) throws IOException { GeoServerUser disableduser = userGroupService.getUserByUsername("disableduser"); assertTrue(disableduser.isEnabled()); GeoServerMultiplexingPasswordEncoder encoder = getEncoder(userGroupService); assertTrue(encoder.isPasswordValid(disableduser.getPassword(), "hallo", null)); assertEquals(1, disableduser.getProperties().size()); assertEquals("miller", disableduser.getProperties().getProperty("lastname")); GeoServerUser user2 = userGroupService.getUserByUsername("user2"); assertEquals(1, user2.getProperties().size()); assertEquals("11-22-33", user2.getProperties().getProperty("tel")); GeoServerUserGroup disabledgroup = userGroupService.getGroupByGroupname("disabledgroup"); assertTrue(disabledgroup.isEnabled()); GeoServerUserGroup group1 = userGroupService.getGroupByGroupname("group1"); GeoServerUser user1 = userGroupService.getUserByUsername("user1"); assertEquals(1, userGroupService.getUsersForGroup(group1).size()); assertTrue(userGroupService.getUsersForGroup(group1).contains(user1)); assertEquals(0, userGroupService.getGroupsForUser(user2).size()); assertEquals(0, userGroupService.getUsersHavingProperty("mail").size()); assertEquals(0, userGroupService.getUsersHavingPropertyValue("tel", "12-34-38").size()); assertEquals(1, userGroupService.getUsersHavingPropertyValue("tel", "11-22-33").size()); user2 = userGroupService.getUsersHavingPropertyValue("tel", "11-22-33").first(); assertEquals("11-22-33", user2.getProperties().getProperty("tel")); }
GeoServerUserGroup admins = userGroupService.getGroupByGroupname("admins"); GeoServerUserGroup group1 = userGroupService.getGroupByGroupname("group1"); GeoServerUserGroup group2 = userGroupService.getGroupByGroupname("group2"); GeoServerUserGroup disabledgroup = userGroupService.getGroupByGroupname("disabledgroup"); assertNull(userGroupService.getGroupByGroupname("yyy"));
protected GeoServerUserGroup getGroup(GeoServerUserGroupService service, String groupName) throws IOException { GeoServerUserGroup group = service.getGroupByGroupname(groupName); if (group == null) { throw new IllegalArgumentException("Provided groupname does not exist: " + groupName); } return group; } }
@Test public void testGroupByName() throws Exception { assertNotNull(service.getGroupByGroupname("extra")); assertNull(service.getGroupByGroupname("dummy")); }
@Test public void testUsersForGroup() throws Exception { SortedSet<GeoServerUser> users = service.getUsersForGroup(service.getGroupByGroupname("other")); assertNotNull(users); assertEquals(2, users.size()); }
@Test public void testHideGroups() throws Exception { GeoServerUserGroupService ugService = getSecurityManager().loadUserGroupService(ugStore.getName()); assertTrue(ugService.getUserGroups().contains(users)); assertNotNull(ugService.getGroupByGroupname("users")); assertTrue(ugService.getUserGroups().contains(admins)); assertNotNull(ugService.getGroupByGroupname("admins")); setAuth(); ugService = getSecurityManager().loadUserGroupService(ugStore.getName()); assertTrue(ugService.getUserGroups().contains(users)); assertNotNull(ugService.getGroupByGroupname("users")); assertFalse(ugService.getUserGroups().contains(admins)); assertNull(ugService.getGroupByGroupname("admins")); }
for (String groupName : GroupAdminProperty.get(user.getProperties())) { try { adminGroups.add(ugService.getGroupByGroupname(groupName)); } catch (IOException e) { throw new WicketRuntimeException(e);
for (String groupName : GroupAdminProperty.get(user.getProperties())) { try { adminGroups.add(ugService.getGroupByGroupname(groupName)); } catch (IOException e) { throw new WicketRuntimeException(e);
for (String groupName : GroupAdminProperty.get(user.getProperties())) { try { adminGroups.add(ugService.getGroupByGroupname(groupName)); } catch (IOException e) { throw new WicketRuntimeException(e);