/** * @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); } }
/** * @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); } }
@Override protected AccessManager createAccessManager(Subject subject) throws AccessDeniedException, RepositoryException { AccessManagerConfig amConfig = context.getRepository().getConfig().getAccessManagerConfig(); try { HippoAMContext ctx = new HippoAMContext( new File((context.getRepository()).getConfig().getHomeDir()), context.getRepositoryContext().getFileSystem(), this, subject, context.getHierarchyManager(), context.getPrivilegeManager(), this, getWorkspace().getName(), context.getNodeTypeManager(), getItemStateManager()); AccessManager accessMgr = amConfig.newInstance(AccessManager.class); accessMgr.init(ctx); if (accessMgr instanceof ItemStateListener) { context.getItemStateManager().addListener((ItemStateListener) accessMgr); } return accessMgr; } catch (AccessDeniedException ex) { throw ex; } catch (Exception ex) { String msg = "failed to instantiate AccessManager implementation: "+amConfig.getClassName(); log.error(msg, ex); throw new RepositoryException(msg, ex); } }
@Override protected AccessManager createAccessManager(Subject subject) throws AccessDeniedException, RepositoryException { AccessManagerConfig amConfig = context.getRepository().getConfig().getAccessManagerConfig(); try { HippoAMContext ctx = new HippoAMContext( new File((context.getRepository()).getConfig().getHomeDir()), context.getRepositoryContext().getFileSystem(), this, subject, context.getHierarchyManager(), context.getPrivilegeManager(), this, getWorkspace().getName(), context.getNodeTypeManager(), getItemStateManager()); AccessManager accessMgr = amConfig.newInstance(AccessManager.class); accessMgr.init(ctx); if (accessMgr instanceof ItemStateListener) { context.getItemStateManager().addListener((ItemStateListener) accessMgr); } return accessMgr; } catch (AccessDeniedException ex) { throw ex; } catch (Exception ex) { String msg = "failed to instantiate AccessManager implementation: "+amConfig.getClassName(); log.error(msg, ex); throw new RepositoryException(msg, ex); } }
assertEquals( "org.apache.jackrabbit.core.security.DefaultAccessManager", amc.getClassName()); assertTrue(amc.getParameters().isEmpty());