-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dedicated OSGi configuration for granting access to UI
No longer leverage PID SlingWebConsoleSecurityProvider as defaults no longer reasonably set in AEMaaCS This closes #781
- Loading branch information
Showing
3 changed files
with
109 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
accesscontroltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/ui/PrincipalUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package biz.netcentric.cq.tools.actool.ui; | ||
|
||
/*- | ||
* #%L | ||
* Access Control Tool Bundle | ||
* %% | ||
* Copyright (C) 2015 - 2024 Cognizant Netcentric | ||
* %% | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* #L% | ||
*/ | ||
|
||
import java.security.Principal; | ||
import java.util.Collection; | ||
import java.util.HashSet; | ||
import java.util.Iterator; | ||
import java.util.Set; | ||
|
||
import javax.jcr.RepositoryException; | ||
|
||
import org.apache.jackrabbit.api.JackrabbitSession; | ||
import org.apache.jackrabbit.api.security.user.Authorizable; | ||
import org.apache.jackrabbit.api.security.user.AuthorizableTypeException; | ||
import org.apache.jackrabbit.api.security.user.Group; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
|
||
/** | ||
* Encapsulates all principals bound to a given session. | ||
* Natively exposed from Oak 1.40 onwards (see OAK-8611). | ||
*/ | ||
class BoundPrincipals { | ||
|
||
private static final Logger log = LoggerFactory.getLogger(BoundPrincipals.class); | ||
|
||
private Set<Principal> boundPrincipals; | ||
|
||
BoundPrincipals(@NotNull JackrabbitSession session) throws RepositoryException { | ||
final String userId = session.getUserID(); | ||
// newer Oak versions expose bound principals via session attribute (https://issues.apache.org/jira/browse/OAK-9415) | ||
boundPrincipals = (Set<Principal>)session.getAttribute("oak.bound-principals"); | ||
if (boundPrincipals == null) { | ||
boundPrincipals = new HashSet<>(); | ||
Authorizable authorizable = session.getUserManager().getAuthorizable(userId); | ||
if (authorizable == null) { | ||
throw new AuthorizableTypeException("Could not find authorizable for session's user ID " + userId); | ||
} | ||
boundPrincipals.add(authorizable.getPrincipal()); | ||
|
||
Iterator<Group> groupIterator = authorizable.memberOf(); | ||
while (groupIterator.hasNext()) { | ||
boundPrincipals.add(groupIterator.next().getPrincipal()); | ||
} | ||
} | ||
} | ||
|
||
public boolean containsOneOf(@NotNull Collection<String> principalNames) { | ||
for (Principal principal : boundPrincipals) { | ||
if (principalNames.contains(principal.getName())) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
} |
84 changes: 0 additions & 84 deletions
84
...ltool-bundle/src/main/java/biz/netcentric/cq/tools/actool/ui/WebConsoleConfigTracker.java
This file was deleted.
Oops, something went wrong.