Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 46625 invoked from network); 25 Feb 2010 20:19:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 25 Feb 2010 20:19:06 -0000 Received: (qmail 52151 invoked by uid 500); 25 Feb 2010 20:19:06 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 52107 invoked by uid 500); 25 Feb 2010 20:19:06 -0000 Mailing-List: contact scm-help@geronimo.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: dev@geronimo.apache.org List-Id: Delivered-To: mailing list scm@geronimo.apache.org Received: (qmail 52100 invoked by uid 99); 25 Feb 2010 20:19:06 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Feb 2010 20:19:06 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Feb 2010 20:19:04 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id B7691238889B; Thu, 25 Feb 2010 20:18:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r916436 - /geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/ServletSecurityElement.java Date: Thu, 25 Feb 2010 20:18:43 -0000 To: scm@geronimo.apache.org From: djencks@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100225201843.B7691238889B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: djencks Date: Thu Feb 25 20:18:43 2010 New Revision: 916436 URL: http://svn.apache.org/viewvc?rev=916436&view=rev Log: GERONIMO-5158 initial attempt to fix return get* values... still needs clarification Modified: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/ServletSecurityElement.java Modified: geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/ServletSecurityElement.java URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/ServletSecurityElement.java?rev=916436&r1=916435&r2=916436&view=diff ============================================================================== --- geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/ServletSecurityElement.java (original) +++ geronimo/specs/trunk/geronimo-servlet_3.0_spec/src/main/java/javax/servlet/ServletSecurityElement.java Thu Feb 25 20:18:43 2010 @@ -20,9 +20,12 @@ package javax.servlet; +import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.LinkedHashSet; +import javax.servlet.annotation.HttpMethodConstraint; import javax.servlet.annotation.ServletSecurity; /** @@ -40,27 +43,34 @@ methodNames = Collections.emptySet(); } - public ServletSecurityElement(HttpConstraintElement httpConstraintElement) { - super(httpConstraintElement.getEmptyRoleSemantic(), httpConstraintElement.getTransportGuarantee(), httpConstraintElement.getRolesAllowed()); + public ServletSecurityElement(HttpConstraintElement defaultHttpConstraintElement) { + super(defaultHttpConstraintElement.getEmptyRoleSemantic(), defaultHttpConstraintElement.getTransportGuarantee(), defaultHttpConstraintElement.getRolesAllowed()); httpMethodConstraints = Collections.emptySet(); methodNames = Collections.emptySet(); } - public ServletSecurityElement(Collection httpMethodConstraints) { + public ServletSecurityElement(Collection httpMethodConstraints) throws IllegalArgumentException { this.httpMethodConstraints = httpMethodConstraints; - this.methodNames = Collections.emptySet(); + this.methodNames = toMethodNames(httpMethodConstraints); } - public ServletSecurityElement(HttpConstraintElement httpConstraintElement, Collection httpMethodConstraints) { + public ServletSecurityElement(HttpConstraintElement httpConstraintElement, Collection httpMethodConstraints) throws IllegalArgumentException { super(httpConstraintElement.getEmptyRoleSemantic(), httpConstraintElement.getTransportGuarantee(), httpConstraintElement.getRolesAllowed()); - this.httpMethodConstraints = httpMethodConstraints; - this.methodNames = Collections.emptySet(); + this.httpMethodConstraints = Collections.unmodifiableCollection(httpMethodConstraints); + this.methodNames = toMethodNames(httpMethodConstraints); } - public ServletSecurityElement(ServletSecurity servletSecurity) { + public ServletSecurityElement(ServletSecurity servletSecurity) throws IllegalArgumentException { super(servletSecurity.value().value(), servletSecurity.value().transportGuarantee(), servletSecurity.value().rolesAllowed()); - httpMethodConstraints = Collections.emptySet(); - methodNames = Collections.emptySet(); + Collection httpMethodConstraints = new ArrayList(); + for (HttpMethodConstraint constraint: servletSecurity.httpMethodConstraints()) { + httpMethodConstraints.add(new HttpMethodConstraintElement(constraint.value(), + new HttpConstraintElement(constraint.emptyRoleSemantic(), + constraint.transportGuarantee(), + constraint.rolesAllowed()))); + } + this.httpMethodConstraints = Collections.unmodifiableCollection(httpMethodConstraints); + methodNames = toMethodNames(httpMethodConstraints); } public Collection getHttpMethodConstraints() { @@ -70,4 +80,14 @@ public Collection getMethodNames() { return methodNames; } + + private static Collection toMethodNames(Collection constraints) throws IllegalArgumentException { + Collection methodNames = new LinkedHashSet(constraints.size()); + for (HttpMethodConstraintElement constraint: constraints) { + if (!methodNames.add(constraint.getMethodName())) { + throw new IllegalArgumentException("duplicate method name: " + constraint.getMethodName()); + } + } + return Collections.unmodifiableCollection(methodNames); + } }