protected void checkRole(GeoServerRole role) { if (helper.roleMap.containsKey(role.getAuthority()) == false) throw new IllegalArgumentException("Role: " + role.getAuthority() + " does not exist"); }
public void updateRole(GeoServerRole role) throws IOException { if (helper.roleMap.containsKey(role.getAuthority())) { helper.roleMap.put(role.getAuthority(), role); setModified(true); } else throw new IllegalArgumentException( "The role " + role.getAuthority() + " does not exist"); }
public void addRole(GeoServerRole role) throws IOException { if (helper.roleMap.containsKey(role.getAuthority())) throw new IllegalArgumentException( "The role " + role.getAuthority() + " already exists"); else { helper.roleMap.put(role.getAuthority(), role); setModified(true); } }
public Map<String, String> getParentMappings() throws IOException { Map<String, String> parentMap = new HashMap<String, String>(); for (GeoServerRole role : roleMap.values()) { GeoServerRole parentRole = role_parentMap.get(role); parentMap.put( role.getAuthority(), parentRole == null ? null : parentRole.getAuthority()); } return Collections.unmodifiableMap(parentMap); }
public void validate(SecurityRoleServiceConfig config) throws SecurityConfigException { for (GeoServerRole systemRole : GeoServerRole.SystemRoles) { if (systemRole.getAuthority().equals(config.getAdminRoleName())) throw createSecurityException(RESERVED_ROLE_NAME, systemRole.getAuthority()); if (systemRole.getAuthority().equals(config.getGroupAdminRoleName())) throw createSecurityException(RESERVED_ROLE_NAME, systemRole.getAuthority()); } }
protected void checkReservedNames(String roleName) throws IOException { for (GeoServerRole systemRole : GeoServerRole.SystemRoles) { if (systemRole.getAuthority().equals(roleName)) throw createSecurityException(RESERVED_NAME, roleName); } }
public int compareTo(GeoServerRole o) { if (o == null) return 1; if (getAuthority().equals(o.getAuthority())) { if (getUserName() == null && o.getUserName() == null) return 0; if (getUserName() == null) return -1; if (o.getUserName() == null) return 1; return getUserName().compareTo(o.getUserName()); } return getAuthority().compareTo(o.getAuthority()); }
public int hashCode() { int hash = getAuthority().hashCode(); if (getUserName() != null) hash += getUserName().hashCode(); return hash; }
public void addRole(GeoServerRole role) throws IOException { checkReservedNames(role.getAuthority()); checkNotExistingRoleName(role.getAuthority()); checkNotExistingInOtherServices(role.getAuthority()); getStore().addRole(role); }
public void setParentRole(GeoServerRole role, GeoServerRole parentRole) throws IOException { checkExistingRoleName(role.getAuthority()); if (parentRole != null) checkExistingRoleName(parentRole.getAuthority()); getStore().setParentRole(role, parentRole); } }
public SortedSet<String> getUserNamesForRole(GeoServerRole role) throws IOException { checkExistingRoleName(role.getAuthority()); return service.getUserNamesForRole(role); }
public GeoServerRole getParentRole(GeoServerRole role) throws IOException { checkExistingRoleName(role.getAuthority()); return service.getParentRole(role); }
public SortedSet<String> getGroupNamesForRole(GeoServerRole role) throws IOException { checkExistingRoleName(role.getAuthority()); return service.getGroupNamesForRole(role); }
public void updateRole(GeoServerRole role) throws IOException { checkExistingRoleName(role.getAuthority()); getStore().updateRole(role); }
/** * Checks if the roles is mapped to a system role, see * * <p>{@link SecurityRoleServiceConfig#getAdminRoleName()} {@link * SecurityRoleServiceConfig#getGroupAdminRoleName()} * * @param role * @throws IOException */ public void checkRoleIsMapped(GeoServerRole role) throws IOException { GeoServerRole mappedRole = service.getAdminRole(); if (mappedRole != null && mappedRole.equals(role)) throw createSecurityException(ADMIN_ROLE_NOT_REMOVABLE_$1, role.getAuthority()); mappedRole = service.getGroupAdminRole(); if (mappedRole != null && mappedRole.equals(role)) throw createSecurityException(GROUP_ADMIN_ROLE_NOT_REMOVABLE_$1, role.getAuthority()); }
public void associateRoleToUser(GeoServerRole role, String username) throws IOException { checkExistingRoleName(role.getAuthority()); checkValidUserName(username); getStore().associateRoleToUser(role, username); }
public void disAssociateRoleFromUser(GeoServerRole role, String username) throws IOException { checkExistingRoleName(role.getAuthority()); checkValidUserName(username); getStore().disAssociateRoleFromUser(role, username); }
public void disAssociateRoleFromGroup(GeoServerRole role, String groupname) throws IOException { checkExistingRoleName(role.getAuthority()); checkValidGroupName(groupname); getStore().disAssociateRoleFromGroup(role, groupname); }
public void associateRoleToGroup(GeoServerRole role, String groupname) throws IOException { checkExistingRoleName(role.getAuthority()); checkValidGroupName(groupname); getStore().associateRoleToGroup(role, groupname); }
protected void checkValuesRemoved(GeoServerRoleService roleService) throws IOException { GeoServerRole role_admin = roleService.getRoleByName(GeoServerRole.ADMIN_ROLE.getAuthority()); GeoServerRole role_wms = roleService.getRoleByName("ROLE_WMS"); assertEquals(2, roleService.getRoles().size()); assertEquals(2, roleService.getRoleCount()); assertTrue(roleService.getRoles().contains(role_admin)); assertTrue(roleService.getRoles().contains(role_wms)); assertNull(roleService.getParentRole(role_wms)); assertEquals(1, roleService.getRolesForUser("user1").size()); assertTrue(roleService.getRolesForUser("user1").contains(role_wms)); assertEquals(0, roleService.getRolesForGroup("g_wfs").size()); assertEquals(1, roleService.getRolesForGroup("g_all").size()); assertTrue(roleService.getRolesForGroup("g_all").contains(role_wms)); }