@Override public void addRole(GeoServerRole role) throws IOException { if (filterRole(role) != null) { delegateAsStore().addRole(role); } }
/** * WRITE_LOCK * * @see * org.geoserver.security.GeoServerRoleStore#addRole(org.geoserver.security.impl.GeoServerRole) */ public void addRole(GeoServerRole role) throws IOException { writeLock(); try { getStore().addRole(role); } finally { writeUnLock(); } }
public void addRole(GeoServerRole role) throws IOException { checkReservedNames(role.getAuthority()); checkNotExistingRoleName(role.getAuthority()); checkNotExistingInOtherServices(role.getAuthority()); getStore().addRole(role); }
newRole.getProperties().put(key, role.getProperties().get(key)); store.addRole(newRole); newRoleDict.put(newRole.getAuthority(), newRole);
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"); }
if (role == null) { role = roleStore.createRoleObject(roleName); roleStore.addRole(role); GeoServerRole localAdminRole = roleStore.createRoleObject(XMLRoleService.DEFAULT_LOCAL_ADMIN_ROLE); roleStore.addRole(localAdminRole); roleStore.associateRoleToUser(localAdminRole, GeoServerUser.ADMIN_USERNAME); roleStore.addRole( 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));
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()); }
protected void insert(GeoServerRoleService roleService, String roleName) throws IOException { GeoServerRoleStore store = getStore(roleService); try { store.addRole(new GeoServerRole(roleName)); } finally { store.store(); } }
protected void addTestUser( String username, List<String> roles, GeoServerRoleService service, GeoServerRoleStore store) throws Exception { if (roles != null && !roles.isEmpty()) { for (String roleName : roles) { GeoServerRole role = store.getRoleByName(roleName); if (role == null) { role = service.createRoleObject(roleName); store.addRole(role); } store.associateRoleToUser(role, username); } } store.store(); }
@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; } }
@Override protected void onFormSubmit(GeoServerRole role) throws IOException { GeoServerRoleStore store = null; try { //copy into a new one so we can set the name properly GeoServerRole newRole = new GeoServerRole(get("form:name").getDefaultModelObjectAsString()); newRole.setUserName(role.getUserName()); newRole.getProperties().putAll(role.getProperties()); role = newRole; store = new RoleStoreValidationWrapper(getRoleStore(roleServiceName)); 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; } }
newRole.getProperties().putAll(role.getProperties()); role = newRole; store.addRole(role);
@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(); }
roleStore.addRole(GeoServerRole.ADMIN_ROLE); roleStore.associateRoleToUser(GeoServerRole.ADMIN_ROLE, "sa"); roleStore.store();
roleStore.addRole(GeoServerRole.ADMIN_ROLE); roleStore.associateRoleToUser(GeoServerRole.ADMIN_ROLE, "sa"); roleStore.store();
roleStore.addRole(GeoServerRole.ADMIN_ROLE); roleStore.associateRoleToUser(GeoServerRole.ADMIN_ROLE, sa.getUsername()); roleStore.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(); }
roleStore.addRole(role); roleStore.associateRoleToUser(role, "cite"); roleStore.associateRoleToUser(role, "cite_noinfo");