@Override public void addUser(GeoServerUser user) throws IOException, PasswordPolicyException { if (filterUser(user) != null) { delegateAsStore().addUser(user); } }
public void addUser(GeoServerUser user) throws IOException, PasswordPolicyException { checkNotExistingUserName(user.getUsername()); getStore().addUser(user); }
/** * WRITE_LOCK * * @see * org.geoserver.security.GeoServerUserGroupStore#addUser(org.geoserver.security.impl.GeoServerUser) */ public void addUser(GeoServerUser user) throws IOException, PasswordPolicyException { writeLock(); try { getStore().addUser(user); } finally { writeUnLock(); } }
newUser.getProperties().put(key, user.getProperties().get(key)); store.addUser(newUser); newUserDict.put(newUser.getUsername(), newUser);
protected void createServices() throws Exception { GeoServerRoleService rservice = createRoleService("rs1"); GeoServerRoleStore rstore = rservice.createStore(); GeoServerRole root, derived; rstore.addRole(root = rstore.createRoleObject(rootRole)); rstore.addRole(derived = rstore.createRoleObject(derivedRole)); rstore.setParentRole(derived, root); rstore.associateRoleToUser(derived, testUserName); rstore.associateRoleToUser(derived, "castest"); rstore.store(); SecurityManagerConfig mconfig = getSecurityManager().loadSecurityConfig(); mconfig.setRoleServiceName("rs1"); getSecurityManager().saveSecurityConfig(mconfig); GeoServerUserGroupService ugservice = createUserGroupService("ug1"); GeoServerUserGroupStore ugstore = ugservice.createStore(); GeoServerUser u1 = ugstore.createUserObject(testUserName, testPassword, true); ugstore.addUser(u1); GeoServerUser u2 = ugstore.createUserObject("abc@xyz.com", "abc", true); ugstore.addUser(u2); GeoServerUser u3 = ugstore.createUserObject("castest", "castest", true); ugstore.addUser(u3); ugstore.store(); GeoServerAuthenticationProvider prov = createAuthProvider(testProviderName, ugservice.getName()); prepareAuthProviders(prov.getName()); }
ugStore.addUser(user);
@PostMapping(value = "/service/{serviceName}/users") public @ResponseStatus(HttpStatus.CREATED) void insertUser( @PathVariable("serviceName") String serviceName, @RequestBody JaxbUser user) throws PasswordPolicyException, IOException { GeoServerUserGroupStore store = getStore(serviceName); try { store.addUser(user.toUser(store)); } finally { store.store(); } }
.createStore(); ugStore.addUser(ugStore.createUserObject("cite", "cite", true)); ugStore.addUser(ugStore.createUserObject("cite_noinfo", "cite", true)); ugStore.addUser(ugStore.createUserObject("cite_nostates", "cite", true)); ugStore.addUser(ugStore.createUserObject("cite_texas", "cite", true)); ugStore.addUser(ugStore.createUserObject("cite_mosaic1", "cite", true)); ugStore.addUser(ugStore.createUserObject("cite_mosaic2", "cite", true)); ugStore.store();
@Test public void testWebServiceAuthKeyMapper() throws Exception { GeoServerUserGroupService ugservice = createUserGroupService("testWebServiceAuthKey"); GeoServerUserGroupStore ugstore = ugservice.createStore(); GeoServerUser u1 = ugstore.createUserObject("user1", "passwd1", true); ugstore.addUser(u1); GeoServerUser u2 = ugstore.createUserObject("user2", "passwd2", true); ugstore.addUser(u2); ugstore.store(); WebServiceAuthenticationKeyMapper propMapper = GeoServerExtensions.extensions(WebServiceAuthenticationKeyMapper.class) .iterator() .next(); propMapper.setUserGroupServiceName("testWebServiceAuthKey"); propMapper.setSecurityManager(getSecurityManager()); propMapper.setWebServiceUrl("http://service/{key}"); propMapper.setHttpClient(new TestHttpClient("testkey", "user1")); GeoServerUser user = propMapper.getUser("testkey"); assertNotNull(user); assertEquals(user.getUsername(), "user1"); boolean error = false; try { user = propMapper.getUser("wrongkey"); } catch (UsernameNotFoundException e) { error = true; } assertTrue(error); }
@Test public void testEraseCredentials() throws Exception { GeoServerUser user = store.createUserObject("user", "foobar", true); store.addUser(user); store.store(); user = store.getUserByUsername("user"); assertNotNull(user.getPassword()); user.eraseCredentials(); user = store.getUserByUsername("user"); assertNotNull(user.getPassword()); }
@Test public void testCreateNewUser() throws Exception { setAuth(); GeoServerUserGroupService ugService = getSecurityManager().loadUserGroupService(ugStore.getName()); GeoServerUserGroupStore ugStore = ugService.createStore(); GeoServerUser bill = ugStore.createUserObject("bill", "foobar", true); ugStore.addUser(bill); ugStore.store(); assertNotNull(ugService.getUserByUsername("bill")); }
@Override protected void onSetUp(SystemTestData testData) throws Exception { super.onSetUp(testData); // Create the test restuser if needed GeoServerUserGroupService service = getSecurityManager().loadUserGroupService(XMLUserGroupService.DEFAULT_NAME); if (service.getUserByUsername(USERNAME) == null) { GeoServerUser user = service.createUserObject(USERNAME, USERPW, true); GeoServerUserGroupStore store = service.createStore(); store.addUser(user); store.store(); service.load(); } xp = XMLUnit.newXpathEngine(); }
@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()); }
@Override protected void onSetUp(SystemTestData testData) throws Exception { addUser("pippo", "clown", null, Arrays.asList("CIRCUS", "KLINIEK", "ZEVER")); addUser("jantje", "jantje", null, Arrays.asList("MOPJES", "ZEVER")); GeoServerSecurityManager secMgr = getSecurityManager(); GeoServerUserGroupService userGroupService = secMgr.loadUserGroupService("default"); GeoServerRoleService roleService = secMgr.loadRoleService("default"); GeoServerUserGroupStore userGroupStore = userGroupService.createStore(); GeoServerRoleStore rolesStore = roleService.createStore(); GeoServerUser roleUserTest = userGroupService.createUserObject("role_user_test", "role_user_test", true); userGroupStore.addUser(roleUserTest); GeoServerRole roleTest = rolesStore.createRoleObject("ROLE_TEST"); rolesStore.addRole(roleTest); rolesStore.associateRoleToUser(roleTest, "role_user_test"); GeoServerRole roleTest2 = rolesStore.createRoleObject("ROLE_TEST_2"); rolesStore.addRole(roleTest2); GeoServerUserGroup roleGroup = userGroupService.createGroupObject("ROLE_GROUP", true); userGroupStore.addGroup(roleGroup); userGroupStore.associateUserToGroup(roleUserTest, roleGroup); rolesStore.associateRoleToGroup(roleTest2, "ROLE_GROUP"); userGroupStore.store(); rolesStore.store(); }
new UserGroupStoreValidationWrapper(getUserGroupStore(ugServiceName)); try { ugStore.addUser(user);
new UserGroupStoreValidationWrapper(getUserGroupStore(ugServiceName)); try { ugStore.addUser(user);
@Override protected void onSetUp(SystemTestData testData) throws Exception { super.onSetUp(testData); // set up the services GeoServerUserGroupService ugService = createUserGroupService("gaugs"); GeoServerRoleService roleService = createRoleService("gars"); getSecurityManager().setActiveRoleService(roleService); // add the users GeoServerUserGroupStore ugStore = createStore(ugService); GeoServerUser bob = ugStore.createUserObject("bob", "foobar", true); GroupAdminProperty.set(bob.getProperties(), new String[] {"users"}); ugStore.addUser(bob); GeoServerUser alice = ugStore.createUserObject("alice", "foobar", true); ugStore.addUser(alice); GeoServerUserGroup users = ugStore.createGroupObject("users", true); ugStore.addGroup(users); GeoServerUserGroup admins = ugStore.createGroupObject("admins", true); ugStore.addGroup(admins); ugStore.store(); // grant bob group admin privilege GeoServerRole groupAdminRole = null; GeoServerRoleStore roleStore = createStore(roleService); roleStore.addRole(roleStore.createRoleObject("adminRole")); roleStore.addRole(groupAdminRole = roleStore.createRoleObject("groupAdminRole")); roleStore.associateRoleToUser(groupAdminRole, bob.getUsername()); roleStore.store(); }
@Test public void testRemoveUserNotInGroup() throws Exception { GeoServerUserGroupService ugService = getSecurityManager().loadUserGroupService(ugStore.getName()); GeoServerUserGroupStore ugStore = ugService.createStore(); GeoServerUser sally = ugStore.createUserObject("sally", "foobar", true); ugStore.addUser(sally); ugStore.associateUserToGroup(sally, admins); ugStore.store(); setAuth(); ugService = getSecurityManager().loadUserGroupService(ugStore.getName()); ugStore = ugService.createStore(); try { ugStore.removeUser(sally); fail(); } catch (IOException e) { ugStore.load(); } ; } }