use of org.apache.jackrabbit.core.config.AccessManagerConfig 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);
}
}
use of org.apache.jackrabbit.core.config.AccessManagerConfig in project jackrabbit by apache.
the class SimpleSecurityManager method getAccessManager.
/**
* @see JackrabbitSecurityManager#getAccessManager(Session,AMContext)
*/
public AccessManager getAccessManager(Session session, AMContext amContext) throws RepositoryException {
checkInitialized();
try {
String wspName = session.getWorkspace().getName();
AccessControlProvider acP = getAccessControlProvider(systemSession, wspName);
AccessManagerConfig amc = config.getAccessManagerConfig();
AccessManager accessMgr;
if (amc == null) {
accessMgr = new SimpleAccessManager();
} else {
accessMgr = amc.newInstance(AccessManager.class);
}
accessMgr.init(amContext, acP, workspaceAccessManager);
return accessMgr;
} catch (AccessDeniedException ade) {
// re-throw
throw ade;
} catch (Exception e) {
// wrap in RepositoryException
String msg = "failed to instantiate AccessManager implementation: " + SimpleAccessManager.class.getName();
log.error(msg, e);
throw new RepositoryException(msg, e);
}
}
Aggregations