in src/main/java/org/apache/sling/jackrabbit/usermanager/impl/resource/AuthorizableResourceProvider.java [226:275]
protected <T> T maybeDoAuthorizableWork(@NotNull ResolveContext<Object> ctx, @NotNull String path,
@NotNull AuthorizableWorker<T> authorizableWorker, @Nullable PrincipalWorker<T> principalWorker) {
T result = null;
// the principalId should be the first segment after the prefix
String suffix = null;
if (path.startsWith(systemUserManagerUserPrefix)) {
suffix = path.substring(systemUserManagerUserPrefix.length());
} else if (path.startsWith(systemUserManagerGroupPrefix)) {
suffix = path.substring(systemUserManagerGroupPrefix.length());
}
if (suffix != null) {
String pid;
String relPath;
int firstSlash = suffix.indexOf('/');
if (firstSlash == -1) {
pid = suffix;
relPath = null;
} else {
pid = suffix.substring(0, firstSlash);
relPath = suffix.substring(firstSlash + 1);
}
Session session = ctx.getResourceResolver().adaptTo(Session.class);
if (session != null) {
try {
UserManager userManager = AccessControlUtil.getUserManager(session);
if (userManager != null) {
Authorizable authorizable = userManager.getAuthorizable(pid);
if (authorizable != null) {
result = authorizableWorker.doWork(authorizable, relPath);
} else if (principalWorker != null && relPath == null){
// SLING-11098 check for a principal that is not an authorizable like the everyone group
PrincipalManager principalManager = AccessControlUtil.getPrincipalManager(session);
if (principalManager != null) {
@Nullable
Principal principal = principalManager.getPrincipal(pid);
if (principal != null) {
result = principalWorker.doWork(principal);
}
}
}
}
} catch (RepositoryException re) {
throw new SlingException(
"Error looking up Authorizable for principal: " + pid, re);
}
}
}
return result;
}