Author: adc Date: Fri Mar 25 16:57:52 2005 New Revision: 159082 URL: http://svn.apache.org/viewcvs?view=rev&rev=159082 Log: Fixes to http spec
Modified: geronimo/trunk/specs/j2ee-jacc/src/java/javax/security/jacc/HTTPMethodSpec.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=159081&r2=159082 ============================================================================== --- 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 Fri Mar 25 16:57:52 2005 @@ -46,52 +46,51 @@ } public HTTPMethodSpec(String name, boolean parseTransportType) { - if (name == null || name.length() == 0) { - this.mask = 0x7F; - this.transport = NONE; - } else { - String[] tokens = name.split(":", 2); - - if (tokens[0].length() == 0) { - this.mask = 0x7F; + if (parseTransportType) { + if (name == null || name.length() == 0) { + this.transport = NONE; } else { - String[] methods = tokens[0].split(",", -1); - int tmpMask = 0; - - for (int i = 0; i < methods.length; i++) { - boolean found = false; + String[] tokens = name.split(":", 2); - for (int j = 0; j < HTTP_METHODS.length; j++) { - if (methods[i].equals(HTTP_METHODS[j])) { - tmpMask |= HTTP_MASKS[j]; - found = true; - - break; - } + if (tokens.length == 2) { + if (tokens[1].equals("NONE")) { + this.transport = NONE; + } else if (tokens[1].equals("INTEGRAL")) { + this.transport = INTEGRAL; + } else if (tokens[1].equals("CONFIDENTIAL")) { + this.transport = CONFIDENTIAL; + } else { + throw new IllegalArgumentException("Invalid transportType: " + tokens[1]); } - if (!found) throw new IllegalArgumentException("Invalid HTTPMethodSpec"); + } else { + this.transport = NONE; } - this.mask = tmpMask; + name = tokens[0]; } + } else { + this.transport = NA; + } - if (tokens.length == 2) { - if (!parseTransportType) throw new IllegalArgumentException("Invalid HTTPMethodSpec"); + if (name == null || name.length() == 0) { + this.mask = 0x7F; + } else { + String[] methods = name.split(",", -1); + int tmpMask = 0; - if (tokens[1].equals("NONE")) { - this.transport = NONE; - } else if (tokens[1].equals("INTEGRAL")) { - this.transport = INTEGRAL; - } else if (tokens[1].equals("CONFIDENTIAL")) { - this.transport = CONFIDENTIAL; - } else { - throw new IllegalArgumentException("Invalid transportType: " + tokens[1]); + for (int i = 0; i < methods.length; i++) { + boolean found = false; + + for (int j = 0; j < HTTP_METHODS.length; j++) { + if (methods[i].equals(HTTP_METHODS[j])) { + tmpMask |= HTTP_MASKS[j]; + found = true; + + break; + } } - } else { - if (parseTransportType) - this.transport = NONE; - else - this.transport = NA; + if (!found) throw new IllegalArgumentException("Invalid HTTPMethodSpec"); } + this.mask = tmpMask; } } 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=159081&r2=159082 ============================================================================== --- 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 Fri Mar 25 16:57:52 2005 @@ -161,9 +161,15 @@ pA = new WebResourcePermission("/foo/bar/*:/foo/bar/cat/dog", ""); pB = new WebResourcePermission("/foo/bar/*:/foo/bar/cat/*", ""); - + assertTrue(pA.implies(pB)); assertFalse(pB.implies(pA)); + + pA = new WebResourcePermission("/:/a.jsp:/b.jsp:/c.jsp", "GET,POST,PUT,DELETE,HEAD,OPTIONS,TRACE"); + pB = new WebResourcePermission("/:/a.jsp:/c.jsp:/b.jsp", (String) null); + + assertTrue(pA.implies(pB)); + assertTrue(pB.implies(pA)); } /*