Author: remy.maucherat(a)jboss.com
Date: 2009-11-04 17:25:59 -0500 (Wed, 04 Nov 2009)
New Revision: 1240
Modified:
trunk/java/org/apache/catalina/Wrapper.java
trunk/java/org/apache/catalina/core/StandardWrapper.java
trunk/java/org/apache/catalina/core/StandardWrapperFacade.java
trunk/java/org/apache/catalina/startup/ContextConfig.java
Log:
- The behavior of setServletSecurity has been simplified, avoiding the need to save what
the pattern set was at the time
the method was called.
Modified: trunk/java/org/apache/catalina/Wrapper.java
===================================================================
--- trunk/java/org/apache/catalina/Wrapper.java 2009-11-04 22:24:35 UTC (rev 1239)
+++ trunk/java/org/apache/catalina/Wrapper.java 2009-11-04 22:25:59 UTC (rev 1240)
@@ -429,18 +429,10 @@
/**
* Set an associated ServletSecurity.
- */
- public void setServletSecurity(ServletSecurityElement servletSecurity);
-
-
- /**
- * Set an associated ServletSecurity on mappings which are currently associated
- * with the Servlet. This will not set security on patters which are currently
- * defined in a security constraint.
- *
+ *
* @return the set of patterns for which the servlet security will not be defined
- */
- public Set<String> setServletSecurityOnCurrentMappings(ServletSecurityElement
servletSecurity);
+ */
+ public Set<String> setServletSecurity(ServletSecurityElement servletSecurity);
/**
@@ -448,9 +440,4 @@
*/
public ServletSecurityElement getServletSecurity();
- /**
- * Get an associated ServletSecurity patterns, if any.
- */
- public Set<String> getServletSecurityPatterns();
-
}
Modified: trunk/java/org/apache/catalina/core/StandardWrapper.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardWrapper.java 2009-11-04 22:24:35 UTC (rev
1239)
+++ trunk/java/org/apache/catalina/core/StandardWrapper.java 2009-11-04 22:25:59 UTC (rev
1240)
@@ -231,12 +231,6 @@
/**
- * Associated servlet security patterns.
- */
- protected Set<String> servletSecurityPatterns = null;
-
-
- /**
* The notification sequence number.
*/
protected long sequenceNumber = 0;
@@ -654,39 +648,28 @@
/**
- * Set an associated ServletSecurity.
- */
- public void setServletSecurity(ServletSecurityElement servletSecurity) {
- ServletSecurityElement oldServletSecurity = this.servletSecurity;
- this.servletSecurity = servletSecurity;
- support.firePropertyChange("servletSecurity", oldServletSecurity,
this.servletSecurity);
- }
-
-
- /**
* Set an associated ServletSecurity on mappings which are currently associated
* with the Servlet. This will not set security on patters which are currently
* defined in a security constraint.
*
* @return the set of patterns for which the servlet security will not be defined
*/
- public Set<String> setServletSecurityOnCurrentMappings(ServletSecurityElement
servletSecurity) {
+ public Set<String> setServletSecurity(ServletSecurityElement servletSecurity)
{
ServletSecurityElement oldServletSecurity = this.servletSecurity;
this.servletSecurity = servletSecurity;
support.firePropertyChange("servletSecurity", oldServletSecurity,
this.servletSecurity);
// Now find to which mappings this servlet security will apply, and return the
list
// for which is will not apply
Set<String> ignoredPatterns = new HashSet<String>();
- servletSecurityPatterns = new HashSet<String>();
+ HashSet<String> currentMappings = new HashSet<String>();
for (String mapping : findMappings()) {
- servletSecurityPatterns.add(mapping);
+ currentMappings.add(mapping);
}
SecurityConstraint[] constraints = ((Context) getParent()).findConstraints();
for (SecurityConstraint constraint : constraints) {
for (SecurityCollection collection : constraint.findCollections()) {
for (String pattern : collection.findPatterns()) {
- if (servletSecurityPatterns.contains(pattern)) {
- servletSecurityPatterns.remove(pattern);
+ if (currentMappings.contains(pattern)) {
ignoredPatterns.add(pattern);
}
}
@@ -697,14 +680,6 @@
/**
- * Get an associated ServletSecurity patterns, if any.
- */
- public Set<String> getServletSecurityPatterns() {
- return servletSecurityPatterns;
- }
-
-
- /**
* Return the fully qualified servlet class name for this servlet.
*/
public String getServletClass() {
Modified: trunk/java/org/apache/catalina/core/StandardWrapperFacade.java
===================================================================
--- trunk/java/org/apache/catalina/core/StandardWrapperFacade.java 2009-11-04 22:24:35 UTC
(rev 1239)
+++ trunk/java/org/apache/catalina/core/StandardWrapperFacade.java 2009-11-04 22:25:59 UTC
(rev 1240)
@@ -291,7 +291,7 @@
if (servletSecurity == null) {
throw new
IllegalArgumentException(sm.getString("servletRegistration.iae"));
}
- return wrapper.setServletSecurityOnCurrentMappings(servletSecurity);
+ return wrapper.setServletSecurity(servletSecurity);
}
public void setMultipartConfig(MultipartConfigElement multipartConfig) {
Modified: trunk/java/org/apache/catalina/startup/ContextConfig.java
===================================================================
--- trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-11-04 22:24:35 UTC (rev
1239)
+++ trunk/java/org/apache/catalina/startup/ContextConfig.java 2009-11-04 22:25:59 UTC (rev
1240)
@@ -2134,30 +2134,25 @@
}
SecurityCollection collection = new SecurityCollection();
collection.addMethod(httpMethodConstraint.getMethodName());
- if (wrapper.getServletSecurityPatterns() != null) {
- for (String urlPattern :
wrapper.getServletSecurityPatterns()) {
- collection.addPattern(urlPattern);
- }
- } else {
- String[] urlPatterns = wrapper.findMappings();
- Set<String> servletSecurityPatterns = new
HashSet<String>();
- for (String urlPattern : urlPatterns) {
- servletSecurityPatterns.add(urlPattern);
- }
- SecurityConstraint[] constraints =
context.findConstraints();
- for (SecurityConstraint constraint2 : constraints) {
- for (SecurityCollection collection2 :
constraint2.findCollections()) {
- for (String urlPattern : collection2.findPatterns())
{
- if
(servletSecurityPatterns.contains(urlPattern)) {
- servletSecurityPatterns.remove(urlPattern);
- }
+ // Determine pattern set
+ String[] urlPatterns = wrapper.findMappings();
+ Set<String> servletSecurityPatterns = new
HashSet<String>();
+ for (String urlPattern : urlPatterns) {
+ servletSecurityPatterns.add(urlPattern);
+ }
+ SecurityConstraint[] constraints = context.findConstraints();
+ for (SecurityConstraint constraint2 : constraints) {
+ for (SecurityCollection collection2 :
constraint2.findCollections()) {
+ for (String urlPattern : collection2.findPatterns()) {
+ if (servletSecurityPatterns.contains(urlPattern)) {
+ servletSecurityPatterns.remove(urlPattern);
}
}
}
- for (String urlPattern : servletSecurityPatterns) {
- collection.addPattern(urlPattern);
- }
}
+ for (String urlPattern : servletSecurityPatterns) {
+ collection.addPattern(urlPattern);
+ }
constraint.addCollection(collection);
context.addConstraint(constraint);
}
@@ -2185,30 +2180,25 @@
constraint.setUserConstraint(org.apache.catalina.realm.Constants.CONFIDENTIAL_TRANSPORT);
}
SecurityCollection collection = new SecurityCollection();
- if (wrapper.getServletSecurityPatterns() != null) {
- for (String urlPattern : wrapper.getServletSecurityPatterns()) {
- collection.addPattern(urlPattern);
- }
- } else {
- String[] urlPatterns = wrapper.findMappings();
- Set<String> servletSecurityPatterns = new
HashSet<String>();
- for (String urlPattern : urlPatterns) {
- servletSecurityPatterns.add(urlPattern);
- }
- SecurityConstraint[] constraints = context.findConstraints();
- for (SecurityConstraint constraint2 : constraints) {
- for (SecurityCollection collection2 :
constraint2.findCollections()) {
- for (String urlPattern : collection2.findPatterns()) {
- if (servletSecurityPatterns.contains(urlPattern)) {
- servletSecurityPatterns.remove(urlPattern);
- }
+ // Determine pattern set
+ String[] urlPatterns = wrapper.findMappings();
+ Set<String> servletSecurityPatterns = new
HashSet<String>();
+ for (String urlPattern : urlPatterns) {
+ servletSecurityPatterns.add(urlPattern);
+ }
+ SecurityConstraint[] constraints = context.findConstraints();
+ for (SecurityConstraint constraint2 : constraints) {
+ for (SecurityCollection collection2 :
constraint2.findCollections()) {
+ for (String urlPattern : collection2.findPatterns()) {
+ if (servletSecurityPatterns.contains(urlPattern)) {
+ servletSecurityPatterns.remove(urlPattern);
}
}
}
- for (String urlPattern : servletSecurityPatterns) {
- collection.addPattern(urlPattern);
- }
}
+ for (String urlPattern : servletSecurityPatterns) {
+ collection.addPattern(urlPattern);
+ }
for (String methodOmission : methodOmissions) {
collection.addMethodOmission(methodOmission);
}
Show replies by date