use of org.apache.jackrabbit.core.security.DefaultAccessManager in project jackrabbit by apache.
the class SecurityConfigTest method testConfig2.
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"));
}
use of org.apache.jackrabbit.core.security.DefaultAccessManager in project jackrabbit by apache.
the class DefaultSecurityManager method getAccessManager.
/**
* @see JackrabbitSecurityManager#getAccessManager(Session,AMContext)
*/
public AccessManager getAccessManager(Session session, AMContext amContext) throws RepositoryException {
checkInitialized();
AccessManagerConfig amConfig = repository.getConfig().getSecurityConfig().getAccessManagerConfig();
try {
String wspName = session.getWorkspace().getName();
AccessControlProvider pp = getAccessControlProvider(wspName);
AccessManager accessMgr;
if (amConfig == null) {
log.debug("No configuration entry for AccessManager. Using org.apache.jackrabbit.core.security.DefaultAccessManager");
accessMgr = new DefaultAccessManager();
} else {
accessMgr = amConfig.newInstance(AccessManager.class);
}
accessMgr.init(amContext, pp, workspaceAccessManager);
return accessMgr;
} catch (AccessDeniedException e) {
// re-throw
throw e;
} catch (Exception e) {
// wrap in RepositoryException
String clsName = (amConfig == null) ? "-- missing access manager configuration --" : amConfig.getClassName();
String msg = "Failed to instantiate AccessManager (" + clsName + ")";
log.error(msg, e);
throw new RepositoryException(msg, e);
}
}
Aggregations