/** * {@inheritDoc} */ public Principal getEveryone() { checkIsValid(); Principal everyone = getPrincipal(EveryonePrincipal.NAME); if (everyone == null) { everyone = EveryonePrincipal.getInstance(); } return everyone; }
/** * {@inheritDoc} */ public boolean hasPrincipal(String principalName) { return internalGetPrincipal(principalName) != null; }
/** * Test if a group which is not item based will be wrapped by a JackrabbitPrincipal implementation. * @throws NotExecutableException * @throws RepositoryException */ public void testJackrabbitPrincipal() throws NotExecutableException, RepositoryException { final PrincipalProvider testProvider = new CustomPrincipalProvider(); testProvider.init(new Properties()); PrincipalManagerImpl principalManager = new PrincipalManagerImpl(superuser, new PrincipalProvider[] { testProvider }); Principal principalFromManager = principalManager.getPrincipal(TESTGROUP_NAME); assertTrue(principalFromManager instanceof JackrabbitPrincipal); } }
/** * @param session The session used to create the principal manager. * @return A new instance of PrincipalManagerImpl * @throws javax.jcr.RepositoryException If an error occurs. */ protected PrincipalManager createPrincipalManager(SessionImpl session) throws RepositoryException { return new PrincipalManagerImpl(session, getPrincipalProviderRegistry().getProviders()); }
/** * @param principalName the name of the principal * @return The principal with the given name or <code>null</code> if none * of the providers knows that principal of if the Session is not allowed * to see it. */ private Principal internalGetPrincipal(String principalName) { checkIsValid(); for (PrincipalProvider provider : providers) { Principal principal = provider.getPrincipal(principalName); if (principal != null && provider.canReadPrincipal(session, principal)) { return disguise(principal, provider); } } // nothing found or not allowed to see it. return null; }
/** * {@inheritDoc} */ public PrincipalIterator getGroupMembership(Principal principal) { checkIsValid(); List<CheckedIteratorEntry> entries = new ArrayList<CheckedIteratorEntry>(providers.length + 1); for (PrincipalProvider pp : providers) { PrincipalIterator groups = pp.getGroupMembership(principal); if (groups.hasNext()) { entries.add(new CheckedIteratorEntry(groups, pp)); } } // additional entry for the 'everyone' group if (!(principal instanceof EveryonePrincipal)) { Iterator<Principal> it = Collections.singletonList(getEveryone()).iterator(); entries.add(new CheckedIteratorEntry(it, null)); } return new CheckedPrincipalIterator(entries); }
/** * {@inheritDoc} */ public PrincipalIterator findPrincipals(String simpleFilter) { checkIsValid(); List<CheckedIteratorEntry> entries = new ArrayList<CheckedIteratorEntry>(providers.length); for (PrincipalProvider pp : providers) { PrincipalIterator it = pp.findPrincipals(simpleFilter); if (it.hasNext()) { entries.add(new CheckedIteratorEntry(it, pp)); } } return new CheckedPrincipalIterator(entries); }
/** * @param session The session used to create the principal manager. * @return A new instance of PrincipalManagerImpl * @throws javax.jcr.RepositoryException If an error occurs. */ protected PrincipalManager createPrincipalManager(SessionImpl session) throws RepositoryException { return new PrincipalManagerImpl(session, getPrincipalProviderRegistry().getProviders()); }
/** * @param principalName the name of the principal * @return The principal with the given name or <code>null</code> if none * of the providers knows that principal of if the Session is not allowed * to see it. */ private Principal internalGetPrincipal(String principalName) { checkIsValid(); for (PrincipalProvider provider : providers) { Principal principal = provider.getPrincipal(principalName); if (principal != null && provider.canReadPrincipal(session, principal)) { return disguise(principal, provider); } } // nothing found or not allowed to see it. return null; }
/** * {@inheritDoc} */ public PrincipalIterator getGroupMembership(Principal principal) { checkIsValid(); List<CheckedIteratorEntry> entries = new ArrayList<CheckedIteratorEntry>(providers.length + 1); for (PrincipalProvider pp : providers) { PrincipalIterator groups = pp.getGroupMembership(principal); if (groups.hasNext()) { entries.add(new CheckedIteratorEntry(groups, pp)); } } // additional entry for the 'everyone' group if (!(principal instanceof EveryonePrincipal)) { Iterator<Principal> it = Collections.singletonList(getEveryone()).iterator(); entries.add(new CheckedIteratorEntry(it, null)); } return new CheckedPrincipalIterator(entries); }
/** * {@inheritDoc} */ public PrincipalIterator findPrincipals(String simpleFilter, int searchType) { checkIsValid(); List<CheckedIteratorEntry> entries = new ArrayList<CheckedIteratorEntry>(providers.length); for (PrincipalProvider pp : providers) { PrincipalIterator it = pp.findPrincipals(simpleFilter, searchType); if (it.hasNext()) { entries.add(new CheckedIteratorEntry(it, pp)); } } return new CheckedPrincipalIterator(entries); }
/** * @param session Session for the principal manager must be created. * @return A new instance of PrincipalManagerImpl. Note that this implementation * uses a workspace specific principal provider registry, that retrieves * the configured providers from the registry obtained through * {@link #getPrincipalProviderRegistry()} but has a workspace specific * default provider. * @throws RepositoryException */ @Override protected PrincipalManager createPrincipalManager(SessionImpl session) throws RepositoryException { return new PrincipalManagerImpl(session, getPrincipalProviderRegistry(session).getProviders()); }
/** * {@inheritDoc} */ public Principal getEveryone() { checkIsValid(); Principal everyone = getPrincipal(EveryonePrincipal.NAME); if (everyone == null) { everyone = EveryonePrincipal.getInstance(); } return everyone; }
/** * {@inheritDoc} */ public PrincipalIterator findPrincipals(String simpleFilter) { checkIsValid(); List<CheckedIteratorEntry> entries = new ArrayList<CheckedIteratorEntry>(providers.length); for (PrincipalProvider pp : providers) { PrincipalIterator it = pp.findPrincipals(simpleFilter); if (it.hasNext()) { entries.add(new CheckedIteratorEntry(it, pp)); } } return new CheckedPrincipalIterator(entries); }
/** * {@inheritDoc} */ public Principal getPrincipal(String principalName) { return internalGetPrincipal(principalName); }
/** * @param session Session for the principal manager must be created. * @return A new instance of PrincipalManagerImpl. Note that this implementation * uses a workspace specific principal provider registry, that retrieves * the configured providers from the registry obtained through * {@link #getPrincipalProviderRegistry()} but has a workspace specific * default provider. * @throws RepositoryException */ @Override protected PrincipalManager createPrincipalManager(SessionImpl session) throws RepositoryException { return new PrincipalManagerImpl(session, getPrincipalProviderRegistry(session).getProviders()); }
/** * {@inheritDoc} */ public PrincipalIterator findPrincipals(String simpleFilter, int searchType) { checkIsValid(); List<CheckedIteratorEntry> entries = new ArrayList<CheckedIteratorEntry>(providers.length); for (PrincipalProvider pp : providers) { PrincipalIterator it = pp.findPrincipals(simpleFilter, searchType); if (it.hasNext()) { entries.add(new CheckedIteratorEntry(it, pp)); } } return new CheckedPrincipalIterator(entries); }
/** * {@inheritDoc} */ public boolean hasPrincipal(String principalName) { return internalGetPrincipal(principalName) != null; }
/** * @see JackrabbitSecurityManager#getPrincipalManager(Session) */ public synchronized PrincipalManager getPrincipalManager(Session session) throws RepositoryException { checkInitialized(); if (session instanceof SessionImpl) { SessionImpl sImpl = ((SessionImpl)session); return new PrincipalManagerImpl(sImpl, principalProviderRegistry.getProviders()); } else { throw new RepositoryException("Internal error: SessionImpl expected."); } }
/** * {@inheritDoc} * @param searchType */ public PrincipalIterator getPrincipals(int searchType) { checkIsValid(); List<CheckedIteratorEntry> entries = new ArrayList<CheckedIteratorEntry>(providers.length); for (PrincipalProvider pp : providers) { PrincipalIterator it = pp.getPrincipals(searchType); if (it.hasNext()) { entries.add(new CheckedIteratorEntry(it, pp)); } } return new CheckedPrincipalIterator(entries); }