tomee-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject tomee git commit: TOMEE-2014 applygin patch from Magesh to use security manager if there
Date Tue, 14 Feb 2017 13:46:47 GMT
Repository: tomee
Updated Branches:
  refs/heads/master ebe3b7232 -> dc4683e9e


TOMEE-2014 applygin patch from Magesh to use security manager if there


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/dc4683e9
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/dc4683e9
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/dc4683e9

Branch: refs/heads/master
Commit: dc4683e9ecaf585ff0b66fe31767ad0ea59984a1
Parents: ebe3b72
Author: rmannibucau <rmannibucau@apache.org>
Authored: Tue Feb 14 14:43:49 2017 +0100
Committer: rmannibucau <rmannibucau@apache.org>
Committed: Tue Feb 14 14:43:49 2017 +0100

----------------------------------------------------------------------
 .../core/security/AbstractSecurityService.java       |  7 +++----
 .../apache/openejb/util/JavaSecurityManagers.java    | 15 +++++++++++++++
 2 files changed, 18 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/dc4683e9/container/openejb-core/src/main/java/org/apache/openejb/core/security/AbstractSecurityService.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/security/AbstractSecurityService.java
b/container/openejb-core/src/main/java/org/apache/openejb/core/security/AbstractSecurityService.java
index fe89ef1..57e2c9c 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/core/security/AbstractSecurityService.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/core/security/AbstractSecurityService.java
@@ -34,7 +34,6 @@ import javax.security.auth.Subject;
 import javax.security.auth.login.LoginException;
 import javax.security.jacc.EJBMethodPermission;
 import javax.security.jacc.PolicyConfigurationFactory;
-import javax.security.jacc.PolicyContext;
 import javax.servlet.http.HttpServletRequest;
 import java.io.Serializable;
 import java.lang.reflect.Method;
@@ -150,7 +149,7 @@ public abstract class AbstractSecurityService implements DestroyableResource,
Se
     @Override
     public void contextEntered(final ThreadContext oldContext, final ThreadContext newContext)
{
         final String moduleID = newContext.getBeanContext().getModuleID();
-        PolicyContext.setContextID(moduleID);
+        JavaSecurityManagers.setContextID(moduleID);
 
         final ProvidedSecurityContext providedSecurityContext = newContext.get(ProvidedSecurityContext.class);
         SecurityContext securityContext = oldContext != null ? oldContext.get(SecurityContext.class)
:
@@ -190,9 +189,9 @@ public abstract class AbstractSecurityService implements DestroyableResource,
Se
     @Override
     public void contextExited(final ThreadContext exitedContext, final ThreadContext reenteredContext)
{
         if (reenteredContext == null) {
-            PolicyContext.setContextID(null);
+            JavaSecurityManagers.setContextID(null);
         } else {
-            PolicyContext.setContextID(reenteredContext.getBeanContext().getModuleID());
+            JavaSecurityManagers.setContextID(reenteredContext.getBeanContext().getModuleID());
         }
     }
 

http://git-wip-us.apache.org/repos/asf/tomee/blob/dc4683e9/container/openejb-core/src/main/java/org/apache/openejb/util/JavaSecurityManagers.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/util/JavaSecurityManagers.java
b/container/openejb-core/src/main/java/org/apache/openejb/util/JavaSecurityManagers.java
index 6da5d1b..b22fd21 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/util/JavaSecurityManagers.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/util/JavaSecurityManagers.java
@@ -16,6 +16,7 @@
  */
 package org.apache.openejb.util;
 
+import javax.security.jacc.PolicyContext;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 import java.util.Properties;
@@ -96,4 +97,18 @@ public final class JavaSecurityManagers {
             });
         }
     }
+
+    public static void setContextID(final String moduleID) {
+        if (System.getSecurityManager() == null) {
+            PolicyContext.setContextID(moduleID);
+        } else {
+            AccessController.doPrivileged(new PrivilegedAction<String>() {
+                @Override
+                public String run() {
+                    PolicyContext.setContextID(moduleID);
+                    return null;
+                }
+            });
+        }
+    }
 }


Mime
View raw message