use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit-oak by apache.
the class UserImporter method start.
// ---------------------------------------------< ProtectedNodeImporter >---
@Override
public boolean start(@Nonnull Tree protectedParent) throws RepositoryException {
Authorizable auth = null;
if (isMemberNode(protectedParent)) {
Tree groupTree = protectedParent;
while (isMemberNode(groupTree) && !groupTree.isRoot()) {
groupTree = groupTree.getParent();
}
auth = userManager.getAuthorizable(groupTree);
} else if (isMemberReferencesListNode(protectedParent)) {
auth = userManager.getAuthorizable(protectedParent.getParent());
}
if (auth == null || !auth.isGroup()) {
log.debug("Cannot handle protected node " + protectedParent + ". It nor one of its parents represent a valid Group.");
return false;
} else {
currentMembership = getMembership(auth.getPath());
return true;
}
}
use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit-oak by apache.
the class AuthorizableImpl method getMembership.
/**
* Retrieve the group membership of this authorizable.
*
* @param includeInherited Flag indicating whether the resulting iterator only
* contains groups this authorizable is declared member of or if inherited
* group membership is respected.
*
* @return Iterator of groups this authorizable is (declared) member of.
* @throws RepositoryException If an error occurs.
*/
@Nonnull
private Iterator<Group> getMembership(boolean includeInherited) throws RepositoryException {
if (isEveryone()) {
return Collections.<Group>emptySet().iterator();
}
MembershipProvider mMgr = getMembershipProvider();
Iterator<String> oakPaths = mMgr.getMembership(getTree(), includeInherited);
Authorizable everyoneGroup = userManager.getAuthorizable(EveryonePrincipal.getInstance());
if (everyoneGroup instanceof GroupImpl) {
String everyonePath = ((GroupImpl) everyoneGroup).getTree().getPath();
oakPaths = Iterators.concat(oakPaths, ImmutableSet.of(everyonePath).iterator());
}
if (oakPaths.hasNext()) {
AuthorizableIterator groups = AuthorizableIterator.create(oakPaths, userManager, AuthorizableType.GROUP);
return new RangeIteratorAdapter(groups, groups.getSize());
} else {
return RangeIteratorAdapter.EMPTY;
}
}
use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit-oak by apache.
the class PrincipalProviderImpl method getPrincipals.
@Nonnull
@Override
public Set<? extends Principal> getPrincipals(@Nonnull String userID) {
Set<Principal> principals = new HashSet<Principal>();
try {
Authorizable authorizable = userManager.getAuthorizable(userID);
if (authorizable != null && !authorizable.isGroup()) {
principals.add(authorizable.getPrincipal());
principals.addAll(getGroupMembership(authorizable));
}
} catch (RepositoryException e) {
log.debug(e.getMessage());
}
return principals;
}
use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit-oak by apache.
the class UserQueryManagerTest method testQueryNoScope.
@Test
public void testQueryNoScope() throws Exception {
Group g = createGroup(null, EveryonePrincipal.getInstance());
g.setProperty(propertyName, v);
user.setProperty(propertyName, v);
root.commit();
Query q = new Query() {
@Override
public <T> void build(QueryBuilder<T> builder) {
builder.setCondition(builder.eq(propertyName, v));
}
};
Iterator<Authorizable> result = queryMgr.findAuthorizables(q);
assertResultContainsAuthorizables(result, user, g);
}
use of org.apache.jackrabbit.api.security.user.Authorizable in project jackrabbit-oak by apache.
the class UserQueryManagerTest method testQueryNameMatchesWithUnderscorePrincipalName.
@Test
public void testQueryNameMatchesWithUnderscorePrincipalName() throws Exception {
Group g = createGroup("g", new PrincipalImpl("group_with_underscore"));
root.commit();
Query q = new Query() {
@Override
public <T> void build(QueryBuilder<T> builder) {
builder.setCondition(builder.nameMatches("group_with_underscore"));
}
};
Iterator<Authorizable> result = queryMgr.findAuthorizables(q);
assertResultContainsAuthorizables(result, g);
}
Aggregations