@Override public void associateUserToGroup(GeoServerUser user, GeoServerUserGroup group) throws IOException { // TODO: should probably throw exception if trying to add to filtered group if (filterUser(user) != null && filterGroup(group) != null) { delegateAsStore().associateUserToGroup(user, group); } }
/** * WRITE_LOCK * * @see * org.geoserver.security.GeoServerUserGroupStore#associateUserToGroup(org.geoserver.security.impl.GeoServerUser, * org.geoserver.security.impl.GeoServerUserGroup) */ public void associateUserToGroup(GeoServerUser user, GeoServerUserGroup group) throws IOException { writeLock(); try { getStore().associateUserToGroup(user, group); } finally { writeUnLock(); } }
public void associateUserToGroup(GeoServerUser user, GeoServerUserGroup group) throws IOException { checkExistingUserName(user.getUsername()); checkExistingGroupName(group.getGroupname()); getStore().associateUserToGroup(user, group); }
store.associateUserToGroup(newUser, newGroup);
userGroupStore.addGroup(group2); userGroupStore.associateUserToGroup(admin, admins); userGroupStore.associateUserToGroup(user1, group1); userGroupStore.associateUserToGroup(user2, group1); userGroupStore.associateUserToGroup(disableduser, disabledgroup); userGroupStore.associateUserToGroup(groupAdminUser, group2);
ugStore.associateUserToGroup(user, group);
@PostMapping(value = "/service/{serviceName}/user/{user}/group/{group}") public @ResponseStatus(HttpStatus.OK) void associateUserToGroup( @PathVariable("serviceName") String serviceName, @PathVariable("user") String userName, @PathVariable("group") String groupName) throws IOException { GeoServerUserGroupStore store = getStore(serviceName); try { store.associateUserToGroup(getUser(store, userName), getGroup(store, groupName)); } finally { store.store(); } }
@Test public void testAssignUserToGroup() throws Exception { testCreateNewUser(); GeoServerUserGroupService ugService = getSecurityManager().loadUserGroupService(ugStore.getName()); GeoServerUserGroupStore ugStore = ugService.createStore(); GeoServerUser bill = ugStore.getUserByUsername("bill"); ugStore.associateUserToGroup(bill, users); ugStore.store(); assertEquals(1, ugStore.getGroupsForUser(bill).size()); assertTrue(ugStore.getGroupsForUser(bill).contains(users)); ugStore.associateUserToGroup(bill, admins); ugStore.store(); assertEquals(1, ugStore.getGroupsForUser(bill).size()); assertTrue(ugStore.getGroupsForUser(bill).contains(users)); assertFalse(ugStore.getGroupsForUser(bill).contains(admins)); }
for (GeoServerUserGroup g : add) ugStore.associateUserToGroup(user, g); for (GeoServerUserGroup g : remove) ugStore.disAssociateUserFromGroup(user,g);
for (GeoServerUserGroup g : add) ugStore.associateUserToGroup(user, g); for (GeoServerUserGroup g : remove) ugStore.disAssociateUserFromGroup(user,g);
for (GeoServerUserGroup g : add) ugStore.associateUserToGroup(user, g); for (GeoServerUserGroup g : remove) ugStore.disAssociateUserFromGroup(user, g);
@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(); }
store2.associateUserToGroup(user, group); } catch (IOException ex) { try {
ugStore.associateUserToGroup(user, group);
ugStore.associateUserToGroup(user, group);
usergroupStore.associateUserToGroup(theUser, theGroup1); role = roleStore.createRoleObject("grouprole1a"); roleStore.addRole(role); usergroupStore.associateUserToGroup(theUser, theGroup2); role = roleStore.createRoleObject("grouprole2a"); roleStore.addRole(role);
ugStore.associateUserToGroup(user, group);
@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(); } ; } }
store.associateUserToGroup(user, group); assertTrue(store.isModified()); store.store();