import javax.security.auth.Subject;
import javax.security.auth.x500.X500Principal;
+import org.argeo.api.acr.NamespaceUtils;
import org.argeo.api.cms.CmsConstants;
import org.argeo.api.cms.CmsSession;
import org.argeo.api.cms.CmsSessionId;
return role.implied(currentSubject(), context);
}
+ /** Implies this {@link SystemRole} in this context. */
+ public final static boolean implies(String role, String context) {
+ return SystemRole.implied(NamespaceUtils.parsePrefixedName(role), currentSubject(), context);
+ }
+
/** Executes as the current user */
public final static <T> T doAs(PrivilegedAction<T> action) {
return Subject.doAs(currentSubject(), action);
QName getName();
default boolean implied(Subject subject, String context) {
+ return implied(getName(), subject, context);
+ }
+
+ static boolean implied(QName name, Subject subject, String context) {
Set<ImpliedByPrincipal> roles = subject.getPrincipals(ImpliedByPrincipal.class);
for (ImpliedByPrincipal role : roles) {
if (role.isSystemRole()) {
- if (role.getRoleName().equals(getName())) {
+ if (role.getRoleName().equals(name)) {
// !! if context is not specified, it is considered irrelevant
if (context == null)
return true;
}
}
return false;
- }
+ }
}