Author: remy.maucherat(a)jboss.com
Date: 2008-11-12 09:46:39 -0500 (Wed, 12 Nov 2008)
New Revision: 851
Modified:
trunk/java/org/apache/catalina/core/ApplicationFilterChain.java
trunk/java/org/apache/catalina/security/SecurityUtil.java
trunk/webapps/docs/changelog.xml
Log:
- 46011: Make principal accessible to filters.
Modified: trunk/java/org/apache/catalina/core/ApplicationFilterChain.java
===================================================================
--- trunk/java/org/apache/catalina/core/ApplicationFilterChain.java 2008-11-05 22:28:30
UTC (rev 850)
+++ trunk/java/org/apache/catalina/core/ApplicationFilterChain.java 2008-11-12 14:46:39
UTC (rev 851)
@@ -228,7 +228,7 @@
Object[] args = new Object[]{req, res, this};
SecurityUtil.doAsPrivilege
- ("doFilter", filter, classType, args);
+ ("doFilter", filter, classType, args, principal);
args = null;
} else {
@@ -409,7 +409,7 @@
Object[] args = new Object[]{ev, this};
SecurityUtil.doAsPrivilege
- ("doFilterEvent", (Filter) filter, cometClassType,
args);
+ ("doFilterEvent", (Filter) filter, cometClassType,
args, principal);
args = null;
} else {
Modified: trunk/java/org/apache/catalina/security/SecurityUtil.java
===================================================================
--- trunk/java/org/apache/catalina/security/SecurityUtil.java 2008-11-05 22:28:30 UTC (rev
850)
+++ trunk/java/org/apache/catalina/security/SecurityUtil.java 2008-11-12 14:46:39 UTC (rev
851)
@@ -196,6 +196,31 @@
final Class[] targetType,
final Object[] targetArguments)
throws java.lang.Exception{
+
+ doAsPrivilege(
+ methodName, targetObject, targetType, targetArguments, null);
+ }
+
+ /**
+ * Perform work as a particular <code>Subject</code>. Here the work
+ * will be granted to a <code>null</code> subject.
+ *
+ * @param methodName the method to apply the security restriction
+ * @param targetObject the <code>Filter</code> on which the method will
+ * be called.
+ * @param targetType <code>Class</code> array used to instanciate a
+ * <code>Method</code> object.
+ * @param targetArguments <code>Object</code> array contains the
+ * runtime parameters instance.
+ * @param principal the <code>Principal</code> 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 @@
targetType);
}
- execute(method, targetObject, targetArguments, null);
+ execute(method, targetObject, targetArguments, principal);
}
Modified: trunk/webapps/docs/changelog.xml
===================================================================
--- trunk/webapps/docs/changelog.xml 2008-11-05 22:28:30 UTC (rev 850)
+++ trunk/webapps/docs/changelog.xml 2008-11-12 14:46:39 UTC (rev 851)
@@ -16,6 +16,17 @@
<body>
+<section name="JBoss Web 2.1.2.CR1 (remm)">
+ <subsection name="Catalina">
+ <changelog>
+ <fix>
+ <bug>46011</bug>: Make Principal accessible (if set) via
Subject.getSubject(AccessController.getContext()) when processing filters.
+ Based on a patch provided by tsveg1. (markt)
+ </fix>
+ </changelog>
+ </subsection>
+</section>
+
<section name="JBoss Web 2.1.1.GA (remm)">
<subsection name="General">
<changelog>