/** * Removes a role service configuration. * * @param config The role service configuration. */ public void removeRoleService(SecurityRoleServiceConfig config) throws IOException, SecurityConfigException { SecurityConfigValidator validator = SecurityConfigValidator.getConfigurationValiator( GeoServerRoleService.class, config.getClassName()); validator.validateRemoveRoleService(config); roleServices.remove(config.getName()); roleServiceHelper.removeConfig(config.getName()); }
/** * Additional Validation. Removing this configuration may also remove the file where the roles * are contained. (the file may be stored within the configuration sub directory). The design * insists on an empty role file. */ @Override public void validateRemoveRoleService(SecurityRoleServiceConfig config) throws SecurityConfigException { super.validateRemoveRoleService(config); XMLRoleServiceConfig xmlConfig = (XMLRoleServiceConfig) config; File file = new File(xmlConfig.getFileName()); // check if if file name is absolute and not in standard role directory try { if (file.isAbsolute() && !file.getCanonicalPath() .startsWith( manager.role().get(config.getName()).dir().getCanonicalPath() + File.separator)) return; // file in security sub dir, check if roles exists if (manager.loadRoleService(config.getName()).getRoleCount() > 0) { throw createSecurityException(ROLE_SERVICE_NOT_EMPTY_$1, config.getName()); } } catch (IOException e) { throw new RuntimeException(); } }
@Override protected void validateRemoveConfig(SecurityRoleServiceConfig config) throws SecurityConfigException { SecurityConfigValidator.getConfigurationValiator( GeoServerRoleService.class, config.getClassName()) .validateRemoveRoleService(config); }
@Override protected void validateRemoveConfig(SecurityRoleServiceConfig config) throws SecurityConfigException { SecurityConfigValidator.getConfigurationValiator(GeoServerRoleService.class, config.getClassName()).validateRemoveRoleService(config); }
@Override protected void validateRemoveConfig(SecurityRoleServiceConfig config) throws SecurityConfigException { SecurityConfigValidator.getConfigurationValiator(GeoServerRoleService.class, config.getClassName()).validateRemoveRoleService(config); }
try { config.setName(null); validator.validateRemoveRoleService(config); fail("no name should fail"); validator.validateRemoveRoleService(config); fail("role service active should fail");