protected void addRolesToCreate(GeoServerRoleStore roleStore, String... roleNames) throws IOException { for (String roleName : roleNames) { expect(roleStore.createRoleObject(roleName)) .andReturn(new GeoServerRole(roleName)) .anyTimes(); } } }
public void removeValues(GeoServerRoleStore roleStore) throws IOException { GeoServerRole role_auth = roleStore.createRoleObject("ROLE_AUTHENTICATED"); GeoServerRole role_wfs = roleStore.getRoleByName("ROLE_WFS"); roleStore.removeRole(role_wfs); roleStore.removeRole(role_auth); }
GeoServerRole newRole = store.createRoleObject(role.getAuthority()); for (Object key : role.getProperties().keySet()) { newRole.getProperties().put(key, role.getProperties().get(key));
protected GeoServerRoleStore createRoleStore( String name, GeoServerSecurityManager secMgr, String... roleNames) throws IOException { GeoServerRoleStore roleStore = createNiceMock(GeoServerRoleStore.class); expect(roleStore.getSecurityManager()).andReturn(secMgr).anyTimes(); expect(roleStore.getName()).andReturn(name).anyTimes(); for (String roleName : roleNames) { expect(roleStore.getRoleByName(roleName)) .andReturn(new GeoServerRole(roleName)) .anyTimes(); } for (GeoServerRole role : GeoServerRole.SystemRoles) { String roleName = role.getAuthority(); expect(roleStore.createRoleObject(roleName)) .andReturn(new GeoServerRole(roleName)) .anyTimes(); } expect(secMgr.loadRoleService(name)).andReturn(roleStore).anyTimes(); return roleStore; }
public void insertValues(GeoServerRoleStore roleStore) throws IOException { GeoServerRole role_admin = roleStore.createRoleObject(GeoServerRole.ADMIN_ROLE.getAuthority()); GeoServerRole role_auth = roleStore.createRoleObject("ROLE_AUTHENTICATED"); GeoServerRole role_wfs = roleStore.createRoleObject("ROLE_WFS"); GeoServerRole role_wms = roleStore.createRoleObject("ROLE_WMS"); role_auth.getProperties().put("employee", ""); role_auth.getProperties().put("bbox", "lookupAtRuntime"); roleStore.addRole(role_admin); roleStore.addRole(role_auth); roleStore.addRole(role_wfs); roleStore.addRole(role_wms); roleStore.setParentRole(role_wms, role_auth); roleStore.setParentRole(role_wfs, role_auth); roleStore.associateRoleToUser(role_admin, "admin"); roleStore.associateRoleToUser(role_wms, "user1"); roleStore.associateRoleToUser(role_wfs, "user1"); roleStore.associateRoleToGroup(role_wms, "g_wms"); roleStore.associateRoleToGroup(role_wfs, "g_wfs"); roleStore.associateRoleToGroup(role_wms, "g_all"); roleStore.associateRoleToGroup(role_wfs, "g_all"); }
GeoServerRole role = roleStore.getRoleByName(roleName); if (role == null) { role = roleStore.createRoleObject(roleName); roleStore.addRole(role); userGroupStore.addUser(GeoServerUser.createDefaultAdmin()); GeoServerRole localAdminRole = roleStore.createRoleObject(XMLRoleService.DEFAULT_LOCAL_ADMIN_ROLE); roleStore.addRole(localAdminRole); roleStore.associateRoleToUser(localAdminRole, GeoServerUser.ADMIN_USERNAME); roleStore.createRoleObject(XMLRoleService.DEFAULT_LOCAL_GROUP_ADMIN_ROLE)); if (roleName.length() > 0) { if (roleStore.getRoleByName(roleName) == null) { roleStore.addRole(roleStore.createRoleObject(roleName)); if (roleName.length() > 0 && roleName.equals("*") == false) { if (roleStore.getRoleByName(roleName) == null) roleStore.addRole(roleStore.createRoleObject(roleName));
GeoServerRole role = roleStore.getRoleByName(roleName); if (role == null) { role = roleStore.createRoleObject(roleName); roleStore.addRole(role);
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()); }
assertFalse(store.isModified()); GeoServerRole role = store.createRoleObject("ROLE_DUMMY"); GeoServerRole role_parent = store.createRoleObject("ROLE_PARENT");
GeoServerRole role_test1 = store1.createRoleObject("ROLE_TEST1");
@Override protected void onFormSubmit(GeoServerRole role) throws IOException { GeoServerRoleStore store = null; try { store = new RoleStoreValidationWrapper(getRoleStore(roleServiceName)); //copy into a new one so we can set the name properly GeoServerRole newRole= store.createRoleObject(get("form:name").getDefaultModelObjectAsString()); newRole.setUserName(role.getUserName()); newRole.getProperties().putAll(role.getProperties()); role = newRole; store.addRole(role); String parentRoleName = get("form:parent").getDefaultModelObjectAsString(); if (parentRoleName != null) { GeoServerRole parentRole = store.getRoleByName(parentRoleName); store.setParentRole(role, parentRole); } store.store(); } catch (IOException ex) { try {store.load(); } catch (IOException ex2) {}; throw ex; } }
store.createRoleObject(get("form:name").getDefaultModelObjectAsString()); newRole.setUserName(role.getUserName()); newRole.getProperties().putAll(role.getProperties());
GeoServerRoleStore rstore = rservice.createStore(); rstore.load(); GeoServerRole no_one = rstore.createRoleObject("NO_ONE"); rstore.addRole(no_one); GeoServerRole rcite = rstore.createRoleObject("cite"); rstore.addRole(rcite); rstore.associateRoleToUser(rstore.createRoleObject("cite"), "cite"); rstore.store();
@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(); }
role = roleStore.createRoleObject("userrole1"); roleStore.addRole(role); roleStore.associateRoleToUser(role, username); role = roleStore.createRoleObject("userrole2"); roleStore.addRole(role); roleStore.associateRoleToUser(role, username); usergroupStore.addGroup(theGroup1); usergroupStore.associateUserToGroup(theUser, theGroup1); role = roleStore.createRoleObject("grouprole1a"); roleStore.addRole(role); roleStore.associateRoleToGroup(role, "theGroup1"); role = roleStore.createRoleObject("grouprole1b"); roleStore.addRole(role); roleStore.associateRoleToGroup(role, "theGroup1"); usergroupStore.addGroup(theGroup2); usergroupStore.associateUserToGroup(theUser, theGroup2); role = roleStore.createRoleObject("grouprole2a"); roleStore.addRole(role); roleStore.associateRoleToGroup(role, "theGroup2"); role = roleStore.createRoleObject("grouprole2aa"); roleStore.addRole(role); roleStore.setParentRole(tmp, role); role = roleStore.createRoleObject("grouprole2aaa");
role = roleStore.createRoleObject("persrole1"); role.getProperties().put("propertyA", ""); role.getProperties().put("propertyX", "X"); roleStore.associateRoleToUser(role, username); role = roleStore.createRoleObject("persrole2"); role.getProperties().put("propertyB", ""); role.getProperties().put("propertyY", "Y");
GeoServerRole adminRole = store.createRoleObject("adminRole"); GeoServerRole groupAdminRole = store.createRoleObject("groupAdminRole"); GeoServerRole role1 = store.createRoleObject("role1"); store.addRole(adminRole); store.addRole(groupAdminRole);
GeoServerRoleStore store2 = createStore(service2); GeoServerRole role_test1 = store1.createRoleObject("ROLE_TEST"); GeoServerRole role_test2 = store2.createRoleObject("ROLE_TEST");
@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(); }
GeoServerRole role = roleStore.createRoleObject("ROLE_DUMMY"); roleStore.addRole(role); roleStore.associateRoleToUser(role, "cite");