/** * @return options configured for the LoginModules to use. */ public Properties[] getModuleConfig() { Properties[] props = new Properties[0]; if (isLocal()) { props = new Properties[] {config.getParameters()}; } else { AppConfigurationEntry[] entries = getJAASConfig(); if (entries != null) { List<Properties> tmp = new ArrayList<Properties>(entries.length); for (AppConfigurationEntry entry : entries) { Map opt = entry.getOptions(); if (opt != null) { Properties prop = new Properties(); prop.putAll(opt); tmp.add(prop); } } props = tmp.toArray(new Properties[tmp.size()]); } } return props; }
/** * @return options configured for the LoginModules to use. */ public Properties[] getModuleConfig() { Properties[] props = new Properties[0]; if (isLocal()) { props = new Properties[] {config.getParameters()}; } else { AppConfigurationEntry[] entries = getJAASConfig(); if (entries != null) { List<Properties> tmp = new ArrayList<Properties>(entries.length); for (AppConfigurationEntry entry : entries) { Map opt = entry.getOptions(); if (opt != null) { Properties prop = new Properties(); prop.putAll(opt); tmp.add(prop); } } props = tmp.toArray(new Properties[tmp.size()]); } } return props; }
Properties parameters = config.getParameters(); Enumeration< ? > names = parameters.propertyNames(); while (names.hasMoreElements()) {
Properties parameters = config.getParameters(); Enumeration< ? > names = parameters.propertyNames(); while (names.hasMoreElements()) {
/** * * @throws Exception */ public void testPrincipalProviderConfig() throws Exception { PrincipalProviderRegistry ppr = new ProviderRegistryImpl(null); // standard config Element xml = parseXML(new InputSource(new StringReader(PRINCIPAL_PROVIDER_CONFIG)), true); LoginModuleConfig lmc = parser.parseSecurityConfig(xml).getLoginModuleConfig(); PrincipalProvider pp = ppr.registerProvider(lmc.getParameters()); assertEquals(pp, ppr.getProvider(pp.getClass().getName())); assertEquals("org.apache.jackrabbit.core.security.principal.FallbackPrincipalProvider", pp.getClass().getName()); // config specifying an extra name xml = parseXML(new InputSource(new StringReader(PRINCIPAL_PROVIDER_CONFIG1)), true); lmc = parser.parseSecurityConfig(xml).getLoginModuleConfig(); pp = ppr.registerProvider(lmc.getParameters()); assertEquals(pp, ppr.getProvider("test")); assertEquals("org.apache.jackrabbit.core.security.principal.FallbackPrincipalProvider", pp.getClass().getName()); // use alternative class config xml = parseXML(new InputSource(new StringReader(PRINCIPAL_PROVIDER_CONFIG2)), true); lmc = parser.parseSecurityConfig(xml).getLoginModuleConfig(); pp = ppr.registerProvider(lmc.getParameters()); assertEquals(pp, ppr.getProvider("test2")); assertEquals("org.apache.jackrabbit.core.security.principal.FallbackPrincipalProvider", pp.getClass().getName()); // all 3 providers must be registered despite the fact the all configs // specify the same provider class assertEquals(3, ppr.getProviders().length); }
public void testConfig2() throws ConfigurationException { Element xml = parseXML(new InputSource(new StringReader(CONFIG_2)), true); SecurityConfig config = parser.parseSecurityConfig(xml); assertNotNull(config.getAppName()); assertEquals("Jackrabbit", config.getAppName()); SecurityManagerConfig smc = config.getSecurityManagerConfig(); assertNotNull(smc); assertTrue(smc.newInstance(JackrabbitSecurityManager.class) instanceof DefaultSecurityManager); assertNull(smc.getWorkspaceAccessConfig()); assertEquals("security", smc.getWorkspaceName()); assertNull(smc.getUserManagerConfig()); AccessManagerConfig amc = config.getAccessManagerConfig(); assertNotNull(amc); assertTrue(amc.newInstance(AccessManager.class) instanceof DefaultAccessManager); LoginModuleConfig lmc = config.getLoginModuleConfig(); assertNotNull(lmc); assertTrue(lmc.getLoginModule() instanceof DefaultLoginModule); Properties options = lmc.getParameters(); assertNotNull(options); assertEquals("anonymous", options.getProperty("anonymousId")); assertEquals("admin", options.getProperty("adminId")); assertEquals("org.apache.jackrabbit.TestPrincipalProvider", options.getProperty("principalProvider")); }