From 21d50bde6fc7f7ded3edf7913f765e30f2b4ca5b Mon Sep 17 00:00:00 2001 From: markt Date: Wed, 5 Nov 2008 16:17:16 +0000 Subject: [PATCH] Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=46011 Make Principal accessible (if set) via Subject.getSubject(AccessController.getContext()) when processing filters. Based on a patch provided by tsveg1 git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@711600 13f79535-47bb-0310-9956-ffa450edef68 --- .../catalina/core/ApplicationFilterChain.java | 2 +- .../org/apache/catalina/security/SecurityUtil.java | 29 ++++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/java/org/apache/catalina/core/ApplicationFilterChain.java b/java/org/apache/catalina/core/ApplicationFilterChain.java index 24ae109ee..5b4757692 100644 --- a/java/org/apache/catalina/core/ApplicationFilterChain.java +++ b/java/org/apache/catalina/core/ApplicationFilterChain.java @@ -228,7 +228,7 @@ final class ApplicationFilterChain implements FilterChain, CometFilterChain { Object[] args = new Object[]{req, res, this}; SecurityUtil.doAsPrivilege - ("doFilter", filter, classType, args); + ("doFilter", filter, classType, args, principal); args = null; } else { diff --git a/java/org/apache/catalina/security/SecurityUtil.java b/java/org/apache/catalina/security/SecurityUtil.java index 8a6a4b209..3afbd9218 100644 --- a/java/org/apache/catalina/security/SecurityUtil.java +++ b/java/org/apache/catalina/security/SecurityUtil.java @@ -180,7 +180,7 @@ public final class SecurityUtil{ /** - * Perform work as a particular Subject. Here the work + * Perform work as a particular Subject. Here the work * will be granted to a null subject. * * @param methodName the method to apply the security restriction @@ -196,6 +196,31 @@ public final class SecurityUtil{ final Class[] targetType, final Object[] targetArguments) throws java.lang.Exception{ + + doAsPrivilege( + methodName, targetObject, targetType, targetArguments, null); + } + + /** + * Perform work as a particular Subject. Here the work + * will be granted to a null subject. + * + * @param methodName the method to apply the security restriction + * @param targetObject the Filter on which the method will + * be called. + * @param targetType Class array used to instanciate a + * Method object. + * @param targetArguments Object array contains the + * runtime parameters instance. + * @param principal the Principal to which the security + * privilege apply + */ + public static void doAsPrivilege(final String methodName, + final Filter targetObject, + final Class[] targetType, + final Object[] targetArguments, + Principal principal) + throws java.lang.Exception{ Method method = null; Method[] methodsCache = null; @@ -215,7 +240,7 @@ public final class SecurityUtil{ targetType); } - execute(method, targetObject, targetArguments, null); + execute(method, targetObject, targetArguments, principal); } -- 2.11.0