store.createUserObject(user.getUsername(), encPassword, user.isEnabled()); for (Object key : user.getProperties().keySet()) { newUser.getProperties().put(key, user.getProperties().get(key));
public void insertValues(GeoServerUserGroupStore userGroupStore) throws Exception { userGroupStore.createUserObject( GeoServerUser.ADMIN_USERNAME, GeoServerUser.DEFAULT_ADMIN_PASSWD, GeoServerUser.AdminEnabled); GeoServerUser user1 = userGroupStore.createUserObject("user1", "11111", true); GeoServerUser user2 = userGroupStore.createUserObject("user2", "22222", true); GeoServerUser disableduser = userGroupStore.createUserObject("disableduser", "", false); GeoServerUser groupAdminUser = userGroupStore.createUserObject("groupAdminUser", "foo", true);
if (attr != null) { GeoServerUser user = userGroupStore.createUserObject( username, attr.getPassword(), attr.isEnabled()); userGroupStore.addUser(user);
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()); }
GeoServerUser user = ugStore.createUserObject(username, password, true); ugStore.addUser(user);
.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();
GeoServerUserGroupStore store = service.createStore(); store.load(); store.addUser(store.createUserObject("cite", "cite", true)); store.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 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")); }
@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()); }
GeoServerUser u1 = ugstore.createUserObject("user1", "passwd1", true); ugstore.addUser(u1); GeoServerUser u2 = ugstore.createUserObject("user2", "passwd2", true); ugstore.addUser(u2); ugstore.store(); GeoServerUser u3 = ugstore.createUserObject("user3", "passwd3", true); ugstore.addUser(u3); ugstore.removeUser(u1);
GeoServerUser theUser = null; theUser = usergroupStore.createUserObject(username, "", true); theUser.getProperties().put("propertyA", "A"); theUser.getProperties().put("propertyB", "B");
@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()); }
GeoServerUserGroupService ugservice = createUserGroupService("testWebServiceAuthKey2"); 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();
GeoServerUser sa = ugStore.createUserObject("sa", "", true); ugStore.addUser(sa); ugStore.store();
@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(); }
GeoServerUser sa = ugStore.createUserObject("sa", "", true); ugStore.addUser(sa); ugStore.store();
GeoServerUserGroupStore store2 = createStore(service2); GeoServerUser user = store1.createUserObject("user", "ps", true); GeoServerUserGroup group = store2.createGroupObject("group", true);
@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(); } ; } }
assertFalse(store.isModified()); GeoServerUser user = store.createUserObject("uuuu", "", true); GeoServerUserGroup group = store.createGroupObject("gggg", true);