Search in sources :

Example 1 with AccessManagerConfig

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);
    }
}
Also used : AccessManager(org.apache.jackrabbit.core.security.AccessManager) WorkspaceAccessManager(org.apache.jackrabbit.core.security.authorization.WorkspaceAccessManager) DefaultAccessManager(org.apache.jackrabbit.core.security.DefaultAccessManager) AccessDeniedException(javax.jcr.AccessDeniedException) AccessManagerConfig(org.apache.jackrabbit.core.config.AccessManagerConfig) AccessControlProvider(org.apache.jackrabbit.core.security.authorization.AccessControlProvider) RepositoryException(javax.jcr.RepositoryException) DefaultAccessManager(org.apache.jackrabbit.core.security.DefaultAccessManager) NoSuchWorkspaceException(javax.jcr.NoSuchWorkspaceException) AccessDeniedException(javax.jcr.AccessDeniedException) AccessControlException(javax.jcr.security.AccessControlException) RepositoryException(javax.jcr.RepositoryException)

Example 2 with AccessManagerConfig

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);
    }
}
Also used : WorkspaceAccessManager(org.apache.jackrabbit.core.security.authorization.WorkspaceAccessManager) AccessManager(org.apache.jackrabbit.core.security.AccessManager) AccessDeniedException(javax.jcr.AccessDeniedException) AccessManagerConfig(org.apache.jackrabbit.core.config.AccessManagerConfig) AccessControlProvider(org.apache.jackrabbit.core.security.authorization.AccessControlProvider) RepositoryException(javax.jcr.RepositoryException) AccessDeniedException(javax.jcr.AccessDeniedException) RepositoryException(javax.jcr.RepositoryException) UnsupportedRepositoryOperationException(javax.jcr.UnsupportedRepositoryOperationException)

Aggregations

AccessDeniedException (javax.jcr.AccessDeniedException)2 RepositoryException (javax.jcr.RepositoryException)2 AccessManagerConfig (org.apache.jackrabbit.core.config.AccessManagerConfig)2 AccessManager (org.apache.jackrabbit.core.security.AccessManager)2 AccessControlProvider (org.apache.jackrabbit.core.security.authorization.AccessControlProvider)2 WorkspaceAccessManager (org.apache.jackrabbit.core.security.authorization.WorkspaceAccessManager)2 NoSuchWorkspaceException (javax.jcr.NoSuchWorkspaceException)1 UnsupportedRepositoryOperationException (javax.jcr.UnsupportedRepositoryOperationException)1 AccessControlException (javax.jcr.security.AccessControlException)1 DefaultAccessManager (org.apache.jackrabbit.core.security.DefaultAccessManager)1