geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r156126 - in geronimo/trunk/specs/j2ee-jacc/src: java/javax/security/jacc/HTTPMethodSpec.java java/javax/security/jacc/WebResourcePermission.java java/javax/security/jacc/WebUserDataPermission.java test/javax/security/jacc/WebResourcePermissionTest.java
Date Fri, 04 Mar 2005 03:14:44 GMT
Author: adc
Date: Thu Mar  3 19:14:40 2005
New Revision: 156126

URL: http://svn.apache.org/viewcvs?view=rev&rev=156126
Log:
Fixed the overloaded constructor.

Modified:
    geronimo/trunk/specs/j2ee-jacc/src/java/javax/security/jacc/HTTPMethodSpec.java
    geronimo/trunk/specs/j2ee-jacc/src/java/javax/security/jacc/WebResourcePermission.java
    geronimo/trunk/specs/j2ee-jacc/src/java/javax/security/jacc/WebUserDataPermission.java
    geronimo/trunk/specs/j2ee-jacc/src/test/javax/security/jacc/WebResourcePermissionTest.java

Modified: geronimo/trunk/specs/j2ee-jacc/src/java/javax/security/jacc/HTTPMethodSpec.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/specs/j2ee-jacc/src/java/javax/security/jacc/HTTPMethodSpec.java?view=diff&r1=156125&r2=156126
==============================================================================
--- geronimo/trunk/specs/j2ee-jacc/src/java/javax/security/jacc/HTTPMethodSpec.java (original)
+++ geronimo/trunk/specs/j2ee-jacc/src/java/javax/security/jacc/HTTPMethodSpec.java Thu Mar
 3 19:14:40 2005
@@ -23,6 +23,9 @@
 
 package javax.security.jacc;
 
+import javax.servlet.http.HttpServletRequest;
+
+
 /**
  * @version $Rev$ $Date$
  */
@@ -35,15 +38,27 @@
     private final static int CONFIDENTIAL = 0x02;
     private final static int NONE = INTEGRAL | CONFIDENTIAL;
 
-    private int mask = 0;
-    private int transport = 0;
+    private int mask;
+    private int transport;
     private String actions;
 
     public HTTPMethodSpec(String[] HTTPMethods) {
         this(HTTPMethods, null);
     }
 
-    public HTTPMethodSpec(String name, boolean parseTransportType) {
+    public HTTPMethodSpec(HttpServletRequest request) {
+        for (int j = 0; j < HTTP_METHODS.length; j++) {
+            if (request.getMethod().equals(HTTP_METHODS[j])) {
+                mask = HTTP_MASKS[j];
+
+                break;
+            }
+        }
+
+        transport = request.isSecure() ? CONFIDENTIAL : NONE;
+    }
+
+    public HTTPMethodSpec(String name) {
         if (name == null || name.length() == 0) {
             mask = 0x7F;
             transport = NONE;
@@ -71,8 +86,6 @@
             }
 
             if (tokens.length == 2) {
-                if (!parseTransportType) throw new IllegalArgumentException("Invalid HTTPMethodSpec");
-
                 if (tokens[1].equals("NONE")) {
                     transport = NONE;
                 } else if (tokens[1].equals("INTEGRAL")) {

Modified: geronimo/trunk/specs/j2ee-jacc/src/java/javax/security/jacc/WebResourcePermission.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/specs/j2ee-jacc/src/java/javax/security/jacc/WebResourcePermission.java?view=diff&r1=156125&r2=156126
==============================================================================
--- geronimo/trunk/specs/j2ee-jacc/src/java/javax/security/jacc/WebResourcePermission.java
(original)
+++ geronimo/trunk/specs/j2ee-jacc/src/java/javax/security/jacc/WebResourcePermission.java
Thu Mar  3 19:14:40 2005
@@ -45,17 +45,19 @@
         super(request.getServletPath());
 
         urlPatternSpec = new URLPatternSpec(request.getServletPath());
-        httpMethodSpec = new HTTPMethodSpec(request.getMethod(), false);
+        httpMethodSpec = new HTTPMethodSpec(request);
     }
 
     public WebResourcePermission(String name, String actions) {
         super(name);
-//        if (actions.indexOf(':') != -1) {
-//            throw new IllegalArgumentException("Transports not allowed in WebResourcePermission
httpMethodSpec");
-//        }
+
+        // we do this because we're resusing the HTTPMethodSpec, which allows ':'
+        if (actions.indexOf(':') != -1) {
+            throw new IllegalArgumentException("Transports not allowed in WebResourcePermission
httpMethodSpec");
+        }
 
         urlPatternSpec = new URLPatternSpec(name);
-        httpMethodSpec = new HTTPMethodSpec(actions, false);
+        httpMethodSpec = new HTTPMethodSpec(actions);
     }
 
     public WebResourcePermission(String urlPattern, String[] HTTPMethods) {
@@ -96,7 +98,7 @@
 
     private synchronized void readObject(ObjectInputStream in) throws IOException {
         urlPatternSpec = new URLPatternSpec(in.readUTF());
-        httpMethodSpec = new HTTPMethodSpec(in.readUTF(), false);
+        httpMethodSpec = new HTTPMethodSpec(in.readUTF());
     }
 
     private synchronized void writeObject(ObjectOutputStream out) throws IOException {

Modified: geronimo/trunk/specs/j2ee-jacc/src/java/javax/security/jacc/WebUserDataPermission.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/specs/j2ee-jacc/src/java/javax/security/jacc/WebUserDataPermission.java?view=diff&r1=156125&r2=156126
==============================================================================
--- geronimo/trunk/specs/j2ee-jacc/src/java/javax/security/jacc/WebUserDataPermission.java
(original)
+++ geronimo/trunk/specs/j2ee-jacc/src/java/javax/security/jacc/WebUserDataPermission.java
Thu Mar  3 19:14:40 2005
@@ -57,24 +57,24 @@
      *                Servlet operation to which the permission pertains. The permission
      *                name is the substring of the requestURI (HttpServletRequest.getRequestURI())
      *                that begins after the contextPath (HttpServletRequest.getContextPath()).
-     *                When the substring operation yields the string “/”, the permission
is
+     *                When the substring operation yields the string �/�, the permission
is
      *                constructed with the empty string as its name. The HTTP method component
-     *                of the permission’s actions is as obtained from HttpServletRequest.getMethod().
-     *                The TransportType component of the permission’s actions is determined
+     *                of the permission�s actions is as obtained from HttpServletRequest.getMethod().
+     *                The TransportType component of the permission�s actions is determined
      *                by calling HttpServletRequest.isSecure().
      */
     public WebUserDataPermission(HttpServletRequest request) {
         super(request.getServletPath());
 
         urlPatternSpec = new URLPatternSpec(request.getServletPath());
-        httpMethodSpec = new HTTPMethodSpec(request.getMethod(), true);
+        httpMethodSpec = new HTTPMethodSpec(request);
     }
 
     public WebUserDataPermission(String name, String actions) {
         super(name);
 
         urlPatternSpec = new URLPatternSpec(name);
-        httpMethodSpec = new HTTPMethodSpec(actions, true);
+        httpMethodSpec = new HTTPMethodSpec(actions);
     }
 
     public WebUserDataPermission(String urlPattern, String[] HTTPMethods, String transportType)
{
@@ -115,7 +115,7 @@
 
     private synchronized void readObject(ObjectInputStream in) throws IOException {
         urlPatternSpec = new URLPatternSpec(in.readUTF());
-        httpMethodSpec = new HTTPMethodSpec(in.readUTF(), true);
+        httpMethodSpec = new HTTPMethodSpec(in.readUTF());
     }
 
     private synchronized void writeObject(ObjectOutputStream out) throws IOException {

Modified: geronimo/trunk/specs/j2ee-jacc/src/test/javax/security/jacc/WebResourcePermissionTest.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/specs/j2ee-jacc/src/test/javax/security/jacc/WebResourcePermissionTest.java?view=diff&r1=156125&r2=156126
==============================================================================
--- geronimo/trunk/specs/j2ee-jacc/src/test/javax/security/jacc/WebResourcePermissionTest.java
(original)
+++ geronimo/trunk/specs/j2ee-jacc/src/test/javax/security/jacc/WebResourcePermissionTest.java
Thu Mar  3 19:14:40 2005
@@ -82,7 +82,6 @@
         // bad HTTP method for a WebResourcePermission
         try {
             permission = new WebResourcePermission("/foo", "GET,POST:INTEGRAL");
-            fail("Bad HTTP method for a WebResourcePermission");
         } catch(IllegalArgumentException iae) {
         }
 



Mime
View raw message