public int getUserCount() throws IOException { return service.getUserCount(); }
protected void checkValuesInserted(GeoServerUserGroupService userGroupService) throws IOException { assertEquals(5, userGroupService.getUsers().size()); assertEquals(5, userGroupService.getUserCount()); userGroupService.getUserCount(), userGroupService.getUserCountNotHavingProperty("unknown")); assertEquals(0, userGroupService.getUserCountHavingPropertyValue("tel", "123")); userGroupService.getUserCount() - 1, userGroupService.getUserCountNotHavingProperty("tel")); assertEquals(1, userGroupService.getUserCountHavingPropertyValue("tel", "12-34-38")); userGroupService.getUserCount(), userGroupService.getUsersNotHavingProperty("unknown").size()); userGroupService.getUserCount() - 1, userGroupService.getUsersNotHavingProperty("mail").size()); for (GeoServerUser user : userGroupService.getUsersNotHavingProperty("mail")) {
/** * READ_LOCK * * @see org.geoserver.security.GeoServerUserGroupService#getUserCount() */ public int getUserCount() throws IOException { readLock(); try { return getService().getUserCount(); } finally { readUnLock(); } }
/** * 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()); }
@Test public void testUserCount() throws Exception { assertEquals(3, service.getUserCount()); }
@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()); }
@Test public void testEmptyPassword() throws Exception { // all is empty checkEmpty(service); checkEmpty(store); GeoServerUser user = store.createUserObject("userNoPasswd", null, true); store.addUser(user); store.store(); assertEquals(1, service.getUserCount()); user = service.getUserByUsername("userNoPasswd"); assertNull(user.getPassword()); user = (GeoServerUser) service.loadUserByUsername("userNoPasswd"); assertNull(user.getPassword()); }
assertEquals(3, userService.getUserCount()); assertEquals(0, userService.getUserGroups().size()); assertEquals(0, userService.getGroupCount());