public int getGroupCount() throws IOException { return service.getGroupCount(); }
/** * READ_LOCK * * @see org.geoserver.security.GeoServerUserGroupService#getGroupCount() */ public int getGroupCount() throws IOException { readLock(); try { return getService().getGroupCount(); } finally { readUnLock(); } } /** READ_LOCK */
/** * Additional Validation. Removing this configuration may also remove the file where the users * and groups are contained. (the file may be stored within the configuration sub directory). * The design insists on an empty user/group file. */ @Override public void validateRemoveUserGroupService(SecurityUserGroupServiceConfig config) throws SecurityConfigException { XMLUserGroupServiceConfig xmlConfig = (XMLUserGroupServiceConfig) config; File file = new File(xmlConfig.getFileName()); // check if if file name is absolute and not in standard role directory try { if (file.isAbsolute() && !file.getCanonicalPath() .startsWith( manager.userGroup() .get(config.getName()) .file() .getCanonicalPath() + File.separator)) return; // file in security sub dir, check if roles exists GeoServerUserGroupService service = manager.loadUserGroupService(config.getName()); if (service.getGroupCount() > 0 || service.getUserCount() > 0) { throw createSecurityException(USERGROUP_SERVICE_NOT_EMPTY_$1, config.getName()); } } catch (IOException e) { throw new RuntimeException(); } super.validateRemoveUserGroupService(config); }
protected void checkEmpty(GeoServerUserGroupService userService) throws IOException { assertEquals(0, userService.getUsers().size()); assertEquals(0, userService.getUserGroups().size()); assertEquals(0, userService.getUserCount()); assertEquals(0, userService.getGroupCount()); }
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()); }
assertEquals(4, userGroupService.getGroupCount()); GeoServerUserGroup admins = userGroupService.getGroupByGroupname("admins"); GeoServerUserGroup group1 = userGroupService.getGroupByGroupname("group1");
@Test public void testGroupCount() throws Exception { assertEquals(3, service.getGroupCount()); }
store1.store(); assertTrue(service1.getUserGroups().size() == 1); assertTrue(service1.getGroupCount() == 1); assertTrue(service2.getGroupCount() == 1); } finally { xmlFile.delete();
@Test public void testDefault() throws Exception { GeoServerUserGroupService service = getSecurityManager().loadUserGroupService(XMLUserGroupService.DEFAULT_NAME); assertEquals(1, service.getUsers().size()); assertEquals(1, service.getUserCount()); assertEquals(0, service.getUserGroups().size()); assertEquals(0, service.getGroupCount()); GeoServerUser admin = service.getUserByUsername(GeoServerUser.ADMIN_USERNAME); assertNotNull(admin); assertEquals(GeoServerUser.AdminEnabled, admin.isEnabled()); GeoServerMultiplexingPasswordEncoder enc = getEncoder(service); assertTrue( enc.isPasswordValid(admin.getPassword(), GeoServerUser.DEFAULT_ADMIN_PASSWD, null)); assertEquals(admin.getProperties().size(), 0); assertEquals(0, service.getGroupsForUser(admin).size()); }
assertEquals(3, userService.getUserCount()); assertEquals(0, userService.getUserGroups().size()); assertEquals(0, userService.getGroupCount());
assertTrue(user.getAuthorities().contains(new GeoServerRole("ROLE_MYROLE_2"))); assertEquals(2, webServiceAuthKeyBodyResponseUGS.getGroupCount()); assertEquals(2, webServiceAuthKeyBodyResponseUGS.getUserGroups().size()); assertEquals(
expect(ugService2.getGroupCount()).andReturn(1).anyTimes(); expect(secMgr.loadUserGroupService("test2")).andReturn(ugService2).anyTimes();