protected void checkExistingRoleService(String roleServiceName) throws FilterConfigException { if (isNotEmpty(roleServiceName) == false) return; // the active role service should be used try { if (manager.listRoleServices().contains(roleServiceName) == false) throw createFilterException( FilterConfigException.UNKNOWN_ROLE_SERVICE, roleServiceName); } catch (IOException e) { throw new RuntimeException(e); } }
/** * Calculates the union of roles from all role services and adds {@link * GeoServerRole#ANONYMOUS_ROLE} and {@link GeoServerRole#AUTHENTICATED_ROLE} * * @throws IOException */ public SortedSet<GeoServerRole> getRolesForAccessControl() throws IOException { SortedSet<GeoServerRole> allRoles = new TreeSet<GeoServerRole>(); for (String serviceName : listRoleServices()) { // catch the IOException for each role service. // As an example, it does not make sense to throw an IOException if // a jdbc connection cannot be established. try { allRoles.addAll(loadRoleService(serviceName).getRoles()); } catch (IOException ex) { LOGGER.log(Level.WARNING, ex.getMessage(), ex); } } allRoles.add(GeoServerRole.AUTHENTICATED_ROLE); allRoles.add(GeoServerRole.ANONYMOUS_ROLE); return allRoles; } }
protected boolean isNewRoleService(String name) throws IOException { return !(getSecurityManager().listRoleServices().contains(name)); }
protected SortedSet<String> getNamesFor(Class<?> extensionPoint) { try { if (extensionPoint == GeoServerUserGroupService.class) return manager.listUserGroupServices(); if (extensionPoint == GeoServerRoleService.class) return manager.listRoleServices(); if (extensionPoint == GeoServerAuthenticationProvider.class) return manager.listAuthenticationProviders(); if (extensionPoint == AuthenticationProvider.class) return manager.listAuthenticationProviders(); if (extensionPoint == GeoServerSecurityFilter.class) return manager.listFilters(); if (extensionPoint == PasswordValidator.class) return manager.listPasswordValidators(); if (extensionPoint == MasterPasswordProvider.class) { return manager.listMasterPasswordProviders(); } } catch (IOException ex) { throw new RuntimeException(ex); } throw new RuntimeException("Unkwnown extension point: " + extensionPoint.getName()); }
protected void checkNotExistingInOtherServices(String roleName) throws IOException { checkRoleName(roleName); for (String serviceName : service.getSecurityManager().listRoleServices()) { // dont check myself if (service.getName().equals(serviceName)) continue; GeoServerRole role = null; try { role = service.getSecurityManager() .loadRoleService(serviceName) .getRoleByName(roleName); } catch (IOException ex) { LOGGER.log(Level.WARNING, ex.getMessage(), ex); throw createSecurityException(CANNOT_CHECK_ROLE_IN_SERVICE, roleName, serviceName); } if (role != null) { throw createSecurityException(ALREADY_EXISTS_IN, roleName, serviceName); } } }
for (String name : listRoleServices()) { SecurityNamedServiceConfig config = roleServiceHelper.loadConfig(name); for (Class<?> classWithEncryption : configClasses) {
if (manager.listRoleServices().contains(roleServiceName) == false) throw createSecurityException(ROLE_SERVICE_NOT_FOUND_$1, roleServiceName); } catch (IOException e) {
expect(secMgr.listRoleServices()) .andReturn(new TreeSet<String>(Arrays.asList(XMLRoleService.DEFAULT_NAME))) .anyTimes();
@Override protected List<SecurityRoleServiceConfig> getItems() { List<SecurityRoleServiceConfig> result = new ArrayList<SecurityRoleServiceConfig>(); try { for (String name : getSecurityManager().listRoleServices()) { result.add(getSecurityManager().loadRoleServiceConfig(name)); } } catch (IOException ex) { throw new RuntimeException(ex); } return result; }
@Override protected List<SecurityRoleServiceConfig> getItems() { List <SecurityRoleServiceConfig> result = new ArrayList<SecurityRoleServiceConfig>(); try { for (String name : getSecurityManager().listRoleServices()) { result.add(getSecurityManager().loadRoleServiceConfig(name)); } } catch (IOException ex) { throw new RuntimeException(ex); } return result; }
@Override protected List<SecurityRoleServiceConfig> getItems() { List <SecurityRoleServiceConfig> result = new ArrayList<SecurityRoleServiceConfig>(); try { for (String name : getSecurityManager().listRoleServices()) { result.add(getSecurityManager().loadRoleServiceConfig(name)); } } catch (IOException ex) { throw new RuntimeException(ex); } return result; }
@Override protected List<SecurityRoleServiceConfig> load() { GeoServerSecurityManager secMgr = GeoServerApplication.get().getSecurityManager(); List<SecurityRoleServiceConfig> configs = new ArrayList(); try { for (String roleServiceName : secMgr.listRoleServices()) { SecurityRoleServiceConfig config = secMgr.loadRoleServiceConfig(roleServiceName); configs.add(config); } } catch (IOException e) { throw new RuntimeException(e); } return configs; } }
@Override protected List<SecurityRoleServiceConfig> load() { GeoServerSecurityManager secMgr = GeoServerApplication.get().getSecurityManager(); List<SecurityRoleServiceConfig> configs = new ArrayList(); try { for (String roleServiceName : secMgr.listRoleServices()) { SecurityRoleServiceConfig config = secMgr.loadRoleServiceConfig(roleServiceName); configs.add(config); } } catch (IOException e) { throw new RuntimeException(e); } return configs; } }
@Override protected List<SecurityRoleServiceConfig> load() { GeoServerSecurityManager secMgr = GeoServerApplication.get().getSecurityManager(); List<SecurityRoleServiceConfig> configs = new ArrayList(); try { for (String roleServiceName : secMgr.listRoleServices()) { SecurityRoleServiceConfig config = secMgr.loadRoleServiceConfig(roleServiceName); configs.add(config); } } catch (IOException e) { throw new RuntimeException(e); } return configs; } }
RoleServiceNamesModel() { try { this.serviceNames = new ArrayList( GeoServerApplication.get().getSecurityManager().listRoleServices()); } catch (IOException e) { throw new WicketRuntimeException(e); } }
RoleServiceNamesModel() { try { this.serviceNames = new ArrayList( GeoServerApplication.get().getSecurityManager().listRoleServices()); } catch (IOException e) { throw new WicketRuntimeException(e); } }
RoleServiceNamesModel() { try { this.serviceNames = new ArrayList( GeoServerApplication.get().getSecurityManager().listRoleServices()); } catch (IOException e) { throw new WicketRuntimeException(e); } }
protected List<String> getUserNames(String roleName) { SortedSet<String> resultSet = new TreeSet<>(); GeoServerSecurityManager securityManager = securityManager(); try { if (roleName == null) { for (String serviceName : securityManager.listUserGroupServices()) { for (GeoServerUser user : securityManager.loadUserGroupService(serviceName).getUsers()) { resultSet.add(user.getUsername()); } } } else { for (String serviceName : securityManager.listRoleServices()) { GeoServerRoleService roleService = securityManager.loadRoleService(serviceName); GeoServerRole role = roleService.getRoleByName(roleName); if (role != null) { resultSet.addAll(roleService.getUserNamesForRole(role)); } } } } catch (IOException e) { LOGGER.log(Level.WARNING, e.getLocalizedMessage(), e); } return new ArrayList<>(resultSet); }
public GeoServerSecurityService getDefaultSecurityService() throws IOException { if (defaultSecurityService != null) { return defaultSecurityService; } for (String serviceName : securityManager.listUserGroupServices()) { if (serviceName.equals(getDefaultServiceName())) { final GeoServerUserGroupService userGroupService = securityManager.loadUserGroupService(serviceName); defaultSecurityService = userGroupService; return userGroupService; } } for (String roleServiceName : securityManager.listRoleServices()) { if (roleServiceName.equals(getDefaultServiceName())) { final GeoServerRoleService roleService = securityManager.loadRoleService(roleServiceName); defaultSecurityService = roleService; return roleService; } } defaultSecurityService = securityManager.getActiveRoleService(); return defaultSecurityService; }
@Override public GeoServerSecurityManager createSecurityManager(MockTestData testData) throws Exception { GeoServerSecurityManager secMgr = createMock(GeoServerSecurityManager.class); GeoServerRoleStore roleStore1 = createRoleStore("test", secMgr, "role1", "parent1"); addRolesToCreate(roleStore1, "", "duplicated", "xxx"); GeoServerRoleStore roleStore2 = createRoleStore("test1", secMgr, "duplicated"); expect(secMgr.listRoleServices()) .andReturn(new TreeSet<String>(Arrays.asList("test", "test1"))) .anyTimes(); replay(roleStore1, roleStore2, secMgr); return secMgr; } });