private LoginModuleConfig buildLoginModuleConfig(){ Properties prop=new Properties(); prop.put("anonymousId", "anonymous"); prop.put("adminId", "admin"); BeanConfig beanConfig=new BeanConfig("org.apache.jackrabbit.core.security.simple.SimpleLoginModule",prop); LoginModuleConfig loginModuleConfig=new LoginModuleConfig(beanConfig); return loginModuleConfig; }
public LoginModule getLoginModule() throws ConfigurationException { return newInstance(LoginModule.class); } }
/** * Creates an access manager configuration object from the * given bean configuration. * * @param config bean configuration */ public LoginModuleConfig(BeanConfig config) { super(config); setValidate(false); // JCR-1920 }
public void login() throws LoginException { try { module = config.getLoginModule(); } catch (ConfigurationException e) { throw new LoginException(e.getMessage()); Properties parameters = config.getParameters(); Enumeration< ? > names = parameters.propertyNames(); while (names.hasMoreElements()) {
/** * @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; }
public void login() throws LoginException { try { module = config.getLoginModule(); } catch (ConfigurationException e) { throw new LoginException(e.getMessage()); Properties parameters = config.getParameters(); Enumeration< ? > names = parameters.propertyNames(); while (names.hasMoreElements()) {
/** * @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; }
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")); }
/** * Parses the login module configuration. * * @param security the <security> element. * @return the login module configuration or <code>null</code>. * @throws ConfigurationException if the configuration is broken */ public LoginModuleConfig parseLoginModuleConfig(Element security) throws ConfigurationException { // Optional login module Element loginModule = getElement(security, LOGIN_MODULE_ELEMENT, false); if (loginModule != null) { return new LoginModuleConfig(parseBeanConfig(security, LOGIN_MODULE_ELEMENT)); } else { return null; } }
/** * * @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); }
/** * Creates an access manager configuration object from the * given bean configuration. * * @param config bean configuration */ public LoginModuleConfig(BeanConfig config) { super(config); setValidate(false); // JCR-1920 }
public LoginModule getLoginModule() throws ConfigurationException { return newInstance(LoginModule.class); } }
/** * Parses the login module configuration. * * @param security the <security> element. * @return the login module configuration or <code>null</code>. * @throws ConfigurationException if the configuration is broken */ public LoginModuleConfig parseLoginModuleConfig(Element security) throws ConfigurationException { // Optional login module Element loginModule = getElement(security, LOGIN_MODULE_ELEMENT, false); if (loginModule != null) { return new LoginModuleConfig(parseBeanConfig(security, LOGIN_MODULE_ELEMENT)); } else { return null; } }