use of org.apache.jackrabbit.api.security.principal.PrincipalIterator in project jackrabbit by apache.
the class PrincipalManagerImpl method getGroupMembership.
/**
* {@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);
}
use of org.apache.jackrabbit.api.security.principal.PrincipalIterator in project jackrabbit by apache.
the class PrincipalManagerImpl method findPrincipals.
/**
* {@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);
}
use of org.apache.jackrabbit.api.security.principal.PrincipalIterator in project jackrabbit by apache.
the class PrincipalManagerImpl method getPrincipals.
/**
* {@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);
}
use of org.apache.jackrabbit.api.security.principal.PrincipalIterator in project sling by apache.
the class AuthorizableResourceProvider method listChildren.
@Override
public Iterator<Resource> listChildren(ResolveContext<Object> ctx, Resource parent) {
try {
String path = parent.getPath();
ResourceResolver resourceResolver = parent.getResourceResolver();
// handle children of /system/userManager
if (SYSTEM_USER_MANAGER_PATH.equals(path)) {
List<Resource> resources = new ArrayList<Resource>();
if (resourceResolver != null) {
resources.add(getResource(ctx, SYSTEM_USER_MANAGER_USER_PATH, null, null));
resources.add(getResource(ctx, SYSTEM_USER_MANAGER_GROUP_PATH, null, null));
}
return resources.iterator();
}
int searchType = -1;
if (SYSTEM_USER_MANAGER_USER_PATH.equals(path)) {
searchType = PrincipalManager.SEARCH_TYPE_NOT_GROUP;
} else if (SYSTEM_USER_MANAGER_GROUP_PATH.equals(path)) {
searchType = PrincipalManager.SEARCH_TYPE_GROUP;
}
if (searchType != -1) {
PrincipalIterator principals = null;
Session session = resourceResolver.adaptTo(Session.class);
if (session != null) {
PrincipalManager principalManager = AccessControlUtil.getPrincipalManager(session);
principals = principalManager.getPrincipals(searchType);
}
if (principals != null) {
return new ChildrenIterator(parent, principals);
}
}
} catch (RepositoryException re) {
throw new SlingException("Error listing children of resource: " + parent.getPath(), re);
}
return null;
}
use of org.apache.jackrabbit.api.security.principal.PrincipalIterator in project jackrabbit by apache.
the class AbstractLoginModule method getPrincipals.
/**
* @return a Collection of principals that contains the current user
* principal and all groups it is member of.
*/
protected Set<Principal> getPrincipals() {
// use linked HashSet instead of HashSet in order to maintain the order
// of principals (as in the Subject).
Set<Principal> principals = new LinkedHashSet<Principal>();
principals.add(principal);
PrincipalIterator groups = principalProvider.getGroupMembership(principal);
while (groups.hasNext()) {
principals.add(groups.nextPrincipal());
}
return principals;
}
Aggregations