use of org.apache.jackrabbit.core.security.simple.SimpleSecurityManager in project jackrabbit by apache.
the class SecurityConfigTest method testConfig1.
public void testConfig1() throws ConfigurationException {
Element xml = parseXML(new InputSource(new StringReader(CONFIG_1)), 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 SimpleSecurityManager);
assertNull(smc.getWorkspaceAccessConfig());
assertNull(smc.getWorkspaceName());
assertNotNull(config.getAccessManagerConfig());
assertTrue(config.getAccessManagerConfig().newInstance(AccessManager.class) instanceof SimpleAccessManager);
assertNull(config.getLoginModuleConfig());
}
use of org.apache.jackrabbit.core.security.simple.SimpleSecurityManager in project jackrabbit by apache.
the class RepositoryImpl method initSecurityManager.
/**
* Creates the {@link org.apache.jackrabbit.core.security.JackrabbitSecurityManager SecurityManager}
* of this <code>Repository</code> and adds it to the repository context.
*
* @throws RepositoryException if an error occurs.
*/
private synchronized void initSecurityManager() throws RepositoryException {
SecurityManagerConfig smc = getConfig().getSecurityConfig().getSecurityManagerConfig();
if (smc == null) {
log.debug("No configuration entry for SecurityManager. Using org.apache.jackrabbit.core.security.simple.SimpleSecurityManager");
securityMgr = new SimpleSecurityManager();
} else {
securityMgr = smc.newInstance(JackrabbitSecurityManager.class);
}
log.info("SecurityManager = " + securityMgr.getClass());
context.setSecurityManager(securityMgr);
String workspaceName = getConfig().getDefaultWorkspaceName();
if (smc != null && smc.getWorkspaceName() != null) {
workspaceName = smc.getWorkspaceName();
}
// mark the workspace as 'active' for that it does not get disposed
// by the workspace-janitor
// TODO: There should be a cleaner way to do this
markWorkspaceActive(workspaceName);
// FIXME: Note that this call must be done *after* the security
// manager has been added to the repository context, since the
// initialisation code may invoke code that depends on the presence
// of a security manager. It would be better if this was not the case.
SystemSession systemSession = getSystemSession(workspaceName);
securityMgr.init(this, systemSession);
// initial security specific repository descriptors that are defined
// by JackrabbitRepository
ValueFactory vf = ValueFactoryImpl.getInstance();
boolean hasUserMgt;
try {
securityMgr.getUserManager(systemSession);
hasUserMgt = true;
} catch (RepositoryException e) {
hasUserMgt = false;
}
setDescriptor(JackrabbitRepository.OPTION_USER_MANAGEMENT_SUPPORTED, vf.createValue(hasUserMgt));
boolean hasPrincipalMgt;
try {
securityMgr.getPrincipalManager(systemSession);
hasPrincipalMgt = true;
} catch (RepositoryException e) {
hasPrincipalMgt = false;
}
setDescriptor(JackrabbitRepository.OPTION_PRINCIPAL_MANAGEMENT_SUPPORTED, vf.createValue(hasPrincipalMgt));
setDescriptor(JackrabbitRepository.OPTION_PRIVILEGE_MANAGEMENT_SUPPORTED, vf.createValue(true));
}
Aggregations