Search in sources :

Example 96 with AccessControlContext

use of java.security.AccessControlContext in project karaf by apache.

the class JaasHelper method currentUserHasRole.

public static boolean currentUserHasRole(String requestedRole) {
    if (ROLE_WILDCARD.equals(requestedRole)) {
        return true;
    }
    AccessControlContext acc = AccessController.getContext();
    if (acc == null) {
        return false;
    }
    Subject subject = Subject.getSubject(acc);
    if (subject == null) {
        return false;
    }
    return currentUserHasRole(subject.getPrincipals(), requestedRole);
}
Also used : AccessControlContext(java.security.AccessControlContext) Subject(javax.security.auth.Subject)

Aggregations

AccessControlContext (java.security.AccessControlContext)96 Subject (javax.security.auth.Subject)23 ProtectionDomain (java.security.ProtectionDomain)20 PrivilegedAction (java.security.PrivilegedAction)18 Permissions (java.security.Permissions)13 PrivilegedActionException (java.security.PrivilegedActionException)12 IOException (java.io.IOException)10 SocketPermission (java.net.SocketPermission)10 Test (org.testng.annotations.Test)8 Principal (java.security.Principal)7 DatagramSocket (java.net.DatagramSocket)5 InetAddress (java.net.InetAddress)4 MulticastSocket (java.net.MulticastSocket)4 CodeSource (java.security.CodeSource)4 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)4 ExecutorService (java.util.concurrent.ExecutorService)4 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)4 ReflectionException (javax.management.ReflectionException)4 Test (org.junit.Test)4 InvocationTargetException (java.lang.reflect.InvocationTargetException)3