@Override public void initializeFromConfig(SecurityNamedServiceConfig config) throws IOException { if (config != null) this.name = config.getName(); }
public void validateAddNamedService(Class<?> extensionPoint, SecurityNamedServiceConfig config) throws SecurityConfigException { checkExtensionPont(extensionPoint, config.getClassName()); checkServiceName(extensionPoint, config.getName()); SortedSet<String> names = getNamesFor(extensionPoint); if (names.contains(config.getName())) throw createSecurityException(alreadyExistsErrorCode(extensionPoint), config.getName()); }
public void saveFilter(SecurityNamedServiceConfig config, MigrationHelper migrationHelper) throws IOException, SecurityConfigException { SecurityConfigValidator validator = SecurityConfigValidator.getConfigurationValiator( GeoServerSecurityFilter.class, config.getClassName()); boolean fireChanged = false; if (config.getId() == null) { config.initBeforeSave(); validator.validateAddFilter(config); } else { validator.validateModifiedFilter( config, filterHelper.loadConfig(config.getName(), migrationHelper)); // remove all cached authentications for this filter getAuthenticationCache().removeAll(config.getName()); if (!securityConfig .getFilterChain() .patternsForFilter(config.getName(), true) .isEmpty()) { fireChanged = true; } } filterHelper.saveConfig(config); if (fireChanged) { fireChanged(); } }
/** saves the user group service config to persistence */ public void saveConfig(SecurityNamedServiceConfig config) throws IOException { Resource dir = getRoot().get(config.getName()); boolean isNew = config.getId() == null; if (isNew) { config.setId(newId()); } try { saveConfigFile(config, dir, persister()); } catch (Exception e) { // catch exception, if the config was new, clear out the id since it was not added if (isNew) { config.setId(null); } if (e instanceof IOException) { throw (IOException) e; } throw new IOException(e); } }
/** Loads the auth provider for the named config from persistence. */ public GeoServerAuthenticationProvider load(String name) throws IOException { SecurityNamedServiceConfig config = loadConfig(name); if (config == null) { // no such config return null; } // look up the service for this config GeoServerAuthenticationProvider authProvider = null; for (GeoServerSecurityProvider p : lookupSecurityProviders()) { if (p.getAuthenticationProviderClass() == null) { continue; } if (p.getAuthenticationProviderClass().getName().equals(config.getClassName())) { authProvider = p.createAuthenticationProvider(config); break; } } if (authProvider == null) { throw new IOException("No authentication provider matching config: " + config); } authProvider.setName(name); authProvider.setSecurityManager(GeoServerSecurityManager.this); authProvider.initializeFromConfig(config); return authProvider; }
@Override protected void onSetUp(SystemTestData testData) throws Exception { SecurityNamedServiceConfig filterCfg = new BaseSecurityNamedServiceConfig(); filterCfg.setName("custom"); filterCfg.setClassName(AuthCapturingFilter.class.getName()); GeoServerSecurityManager secMgr = getSecurityManager(); secMgr.saveFilter(filterCfg); SecurityManagerConfig cfg = secMgr.getSecurityConfig(); cfg.getFilterChain() .insertAfter( "/web/**", filterCfg.getName(), GeoServerSecurityFilterChain.REMEMBER_ME_FILTER); // cfg.getFilterChain().put("/web/**", Arrays.asList( // new FilterChainEntry(filterCfg.getName(), Position.AFTER, // GeoServerSecurityFilterChain.REMEMBER_ME_FILTER))); secMgr.saveSecurityConfig(cfg); }
/** * Determines if the configuration object represents a new configuration, or an existing one. */ protected boolean isNew() { return configModel.getObject().getId() == null; }
void updatePanel(SecurityNamedServicePanelInfo panelInfo, AjaxRequestTarget target) { //create a new config object T config = null; try { config = (T) panelInfo.getServiceConfigClass().newInstance(); } catch (Exception e) { throw new WicketRuntimeException( "Unable to create config class: " + panelInfo.getServiceConfigClass(), e); } config.setClassName(panelInfo.getServiceClass().getCanonicalName()); //update the form model form.setModel(new CompoundPropertyModel<T>(config)); //create the new panel panel = createPanel("content", panelInfo, new Model(config)); //remove the old panel if it is there if (panelContainer.get("content") != null) { panelContainer.remove("content"); } panelContainer.add(panel); if (target != null) { target.addComponent(panelContainer); } }
protected SecurityNamedServiceConfig createFilterConfig(String name, Class<?> aClass) { SecurityNamedServiceConfig config = new BaseSecurityNamedServiceConfig(); config.setName(name); config.setClassName(aClass.getName()); return config; }
/** Loads the filter for the named config from persistence. */ public GeoServerSecurityFilter load(String name) throws IOException { SecurityNamedServiceConfig config = loadConfig(name); if (config == null) { // no such config return null; } // look up the service for this config GeoServerSecurityFilter filter = null; for (GeoServerSecurityProvider p : lookupSecurityProviders()) { if (p.getFilterClass() == null) { continue; } if (p.getFilterClass().getName().equals(config.getClassName())) { filter = p.createFilter(config); break; } } if (filter == null) { throw new IOException("No authentication provider matching config: " + config); } filter.setName(name); filter.setSecurityManager(GeoServerSecurityManager.this); filter.initializeFromConfig(config); return filter; }
/** * Determines if the configuration object represents a new configuration, or an existing one. */ protected boolean isNew() { return configModel.getObject().getId() == null; }
void updatePanel(SecurityNamedServicePanelInfo panelInfo, AjaxRequestTarget target) { // create a new config object T config = null; try { config = (T) panelInfo.getServiceConfigClass().newInstance(); } catch (Exception e) { throw new WicketRuntimeException( "Unable to create config class: " + panelInfo.getServiceConfigClass(), e); } config.setClassName(panelInfo.getServiceClass().getCanonicalName()); // update the form model form.setModel(new CompoundPropertyModel<T>(config)); // create the new panel panel = createPanel("content", panelInfo, new Model(config)); // remove the old panel if it is there if (panelContainer.get("content") != null) { panelContainer.remove("content"); } panelContainer.add(panel); if (target != null) { target.add(panelContainer); } }
public void validateRemoveNamedService( Class<?> extensionPoint, SecurityNamedServiceConfig config) throws SecurityConfigException { checkServiceName(extensionPoint, config.getName()); }
public void validateModifiedNamedService( Class<?> extensionPoint, SecurityNamedServiceConfig config) throws SecurityConfigException { checkExtensionPont(extensionPoint, config.getClassName()); checkServiceName(extensionPoint, config.getName()); SortedSet<String> names = getNamesFor(extensionPoint); if (names.contains(config.getName()) == false) throw createSecurityException(notFoundErrorCode(extensionPoint), config.getName()); }
continue; if (p.getUserGroupServiceClass().getName().equals(config.getClassName())) { service = p.createUserGroupService(config); break; boolean needsLockProtection = GeoServerSecurityProvider.getProvider( GeoServerUserGroupService.class, config.getClassName()) .roleServiceNeedsLockProtection(); if (needsLockProtection) service = new LockingUserGroupService(service);
/** * Determines if the configuration object represents a new configuration, or an existing one. */ protected boolean isNew() { return configModel.getObject().getId() == null; }
void updatePanel(SecurityNamedServicePanelInfo panelInfo, AjaxRequestTarget target) { //create a new config object T config = null; try { config = (T) panelInfo.getServiceConfigClass().newInstance(); } catch (Exception e) { throw new WicketRuntimeException( "Unable to create config class: " + panelInfo.getServiceConfigClass(), e); } config.setClassName(panelInfo.getServiceClass().getCanonicalName()); //update the form model form.setModel(new CompoundPropertyModel<T>(config)); //create the new panel panel = createPanel("content", panelInfo, new Model(config)); //remove the old panel if it is there if (panelContainer.get("content") != null) { panelContainer.remove("content"); } panelContainer.add(panel); if (target != null) { target.addComponent(panelContainer); } }
@Override public void initializeFromConfig(SecurityNamedServiceConfig config) throws IOException { this.name = config.getName(); adminRoleName = ((SecurityRoleServiceConfig) config).getAdminRoleName(); groupAdminRoleName = ((SecurityRoleServiceConfig) config).getGroupAdminRoleName(); }
public void removeFilter(SecurityNamedServiceConfig config) throws IOException, SecurityConfigException { SecurityConfigValidator validator = SecurityConfigValidator.getConfigurationValiator( GeoServerSecurityFilter.class, config.getClassName()); validator.validateRemoveFilter(config); getAuthenticationCache().removeAll(config.getName()); filterHelper.removeConfig(config.getName()); }
continue; if (p.getRoleServiceClass().getName().equals(config.getClassName())) { service = p.createRoleService(config); break; boolean needsLockProtection = GeoServerSecurityProvider.getProvider( GeoServerRoleService.class, config.getClassName()) .roleServiceNeedsLockProtection(); if (needsLockProtection) {