Return-Path: Delivered-To: apmail-geronimo-scm-archive@www.apache.org Received: (qmail 6760 invoked from network); 27 Jul 2010 14:28:56 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 27 Jul 2010 14:28:56 -0000 Received: (qmail 21792 invoked by uid 500); 27 Jul 2010 14:28:56 -0000 Delivered-To: apmail-geronimo-scm-archive@geronimo.apache.org Received: (qmail 21666 invoked by uid 500); 27 Jul 2010 14:28:55 -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 21659 invoked by uid 99); 27 Jul 2010 14:28:55 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 Jul 2010 14:28:55 +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; Tue, 27 Jul 2010 14:28:51 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id AC673238899C; Tue, 27 Jul 2010 14:27:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r979723 - in /geronimo/server/trunk/testsuite/javaee6-testsuite: ./ servlet3.0-security-test/ servlet3.0-security-test/src/ servlet3.0-security-test/src/main/ servlet3.0-security-test/src/main/java/ servlet3.0-security-test/src/main/java/or... Date: Tue, 27 Jul 2010 14:27:58 -0000 To: scm@geronimo.apache.org From: xiaming@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100727142758.AC673238899C@eris.apache.org> Author: xiaming Date: Tue Jul 27 14:27:57 2010 New Revision: 979723 URL: http://svn.apache.org/viewvc?rev=979723&view=rev Log: GERONIMO-5453 commit servlet 3.0 security test code to trunk which is provided by LiWenQin Added: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/pom.xml (with props) geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/AnnotationWebServlet.java (with props) geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet1.java (with props) geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet2.java (with props) geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet3.java (with props) geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet4.java (with props) geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServletContextListener.java (with props) geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/geronimo-web.xml (with props) geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/web.xml (with props) geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/org/ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/org/apache/ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/org/apache/geronimo/ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/org/apache/geronimo/testsuite/ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/org/apache/geronimo/testsuite/servlets/ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/org/apache/geronimo/testsuite/servlets/ServletsTest.java (with props) geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/resources/ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/resources/testng.xml (with props) Modified: geronimo/server/trunk/testsuite/javaee6-testsuite/pom.xml Modified: geronimo/server/trunk/testsuite/javaee6-testsuite/pom.xml URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/pom.xml?rev=979723&r1=979722&r2=979723&view=diff ============================================================================== --- geronimo/server/trunk/testsuite/javaee6-testsuite/pom.xml (original) +++ geronimo/server/trunk/testsuite/javaee6-testsuite/pom.xml Tue Jul 27 14:27:57 2010 @@ -54,6 +54,8 @@ beanvalidation-test servlet3.0-test + servlet3.0-security-test + ejb3.1lite-test Added: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/pom.xml URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/pom.xml?rev=979723&view=auto ============================================================================== --- geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/pom.xml (added) +++ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/pom.xml Tue Jul 27 14:27:57 2010 @@ -0,0 +1,102 @@ + + + + + + + + 4.0.0 + + + org.apache.geronimo.testsuite + javaee6-testsuite + 3.0-SNAPSHOT + + + servlet3.0-security-test + Geronimo TestSuite :: Java EE 6 Testsuite :: Test Servlet 3.0 Security + war + + + + org.apache.geronimo.specs + geronimo-servlet_3.0_spec + provided + + + org.apache.servicemix.bundles + org.apache.servicemix.bundles.commons-httpclient + 3.1_4 + + + + + + it + + + it + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + + + + ${project.build.testOutputDirectory}/testng.xml + + + + + + org.apache.geronimo.buildsupport + geronimo-maven-plugin + + + deploy-wars + pre-integration-test + + deploy-module + + + ${project.build.directory}/${project.artifactId}-${project.version}.war + + + + + undeploy-war-as-moduleId + post-integration-test + + undeploy-module + + + ${project.groupId}/${project.artifactId}/${project.version}/car + + + + + + + + + Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/pom.xml ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/pom.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/AnnotationWebServlet.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/AnnotationWebServlet.java?rev=979723&view=auto ============================================================================== --- geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/AnnotationWebServlet.java (added) +++ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/AnnotationWebServlet.java Tue Jul 27 14:27:57 2010 @@ -0,0 +1,39 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.testsuite.servlet30.main; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.annotation.WebServlet; + +@WebServlet(name = "WebServlet", urlPatterns = {"/WebServlet1", "/WebServlet2"} ) +public class AnnotationWebServlet extends javax.servlet.http.HttpServlet{ + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + PrintWriter printWriter = response.getWriter(); + printWriter.write("AnnotationWebServlet.doGet"); + } + + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + PrintWriter printWriter = response.getWriter(); + printWriter.write("AnnotationWebServlet.doPost"); + } +} Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/AnnotationWebServlet.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/AnnotationWebServlet.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/AnnotationWebServlet.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet1.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet1.java?rev=979723&view=auto ============================================================================== --- geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet1.java (added) +++ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet1.java Tue Jul 27 14:27:57 2010 @@ -0,0 +1,51 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.testsuite.servlet30.main; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * Servlet implementation class for Servlet: SampleServlet + * + * @web.servlet + * name="SampleServlet" + * display-name="SampleServlet" + * + * @web.servlet-mapping + * url-pattern="/SampleServlet" + * + */ +public class SampleServlet1 extends javax.servlet.http.HttpServlet { + + private static final long serialVersionUID = 9018839728530599983L; + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + PrintWriter printWriter = response.getWriter(); + printWriter.write("SampleServlet1.doGet"); + } + + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + PrintWriter printWriter = response.getWriter(); + printWriter.write("SampleServlet1.doPost"); + } +} \ No newline at end of file Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet1.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet1.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet1.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet2.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet2.java?rev=979723&view=auto ============================================================================== --- geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet2.java (added) +++ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet2.java Tue Jul 27 14:27:57 2010 @@ -0,0 +1,43 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.testsuite.servlet30.main; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.ServletException; +import javax.servlet.annotation.HttpMethodConstraint; +import javax.servlet.annotation.ServletSecurity; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +@ServletSecurity(httpMethodConstraints = { @HttpMethodConstraint(value = "POST", rolesAllowed = "RoleB") }) +public class SampleServlet2 extends javax.servlet.http.HttpServlet { + + private static final long serialVersionUID = 7870791395515797291L; + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + PrintWriter printWriter = response.getWriter(); + printWriter.write("SampleServlet2.doGet"); + } + + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + PrintWriter printWriter = response.getWriter(); + printWriter.write("SampleServlet2.doPost"); + } +} \ No newline at end of file Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet2.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet2.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet2.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet3.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet3.java?rev=979723&view=auto ============================================================================== --- geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet3.java (added) +++ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet3.java Tue Jul 27 14:27:57 2010 @@ -0,0 +1,46 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.testsuite.servlet30.main; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * @version $Rev$ $Date$ + */ +public class SampleServlet3 extends HttpServlet { + + private static final long serialVersionUID = -4328073983584515406L; + + @Override + protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + PrintWriter printWriter = resp.getWriter(); + printWriter.write("SampleServlet3.doGet"); + } + + @Override + protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + PrintWriter printWriter = resp.getWriter(); + printWriter.write("SampleServlet3.doPost"); + } +} Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet3.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet3.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet3.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet4.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet4.java?rev=979723&view=auto ============================================================================== --- geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet4.java (added) +++ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet4.java Tue Jul 27 14:27:57 2010 @@ -0,0 +1,48 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.testsuite.servlet30.main; + +import java.io.IOException; +import java.io.PrintWriter; + +import javax.servlet.annotation.HttpMethodConstraint; +import javax.servlet.annotation.ServletSecurity; +import javax.servlet.annotation.HttpConstraint; +import javax.servlet.annotation.WebServlet; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + + +@WebServlet("/SampleServlet4") +@ServletSecurity(httpMethodConstraints = {@HttpMethodConstraint(value = "POST", rolesAllowed = "RoleB") }) +public class SampleServlet4 extends HttpServlet{ + + private static final long serialVersionUID = 1L; + + protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + PrintWriter printWriter = response.getWriter(); + printWriter.write("SampleServlet4.doGet"); + } + + protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + PrintWriter printWriter = response.getWriter(); + printWriter.write("SampleServlet4.doPost"); + } +} Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet4.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet4.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServlet4.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServletContextListener.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServletContextListener.java?rev=979723&view=auto ============================================================================== --- geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServletContextListener.java (added) +++ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServletContextListener.java Tue Jul 27 14:27:57 2010 @@ -0,0 +1,62 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.geronimo.testsuite.servlet30.main; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import javax.servlet.HttpConstraintElement; +import javax.servlet.HttpMethodConstraintElement; +import javax.servlet.Servlet; +import javax.servlet.ServletContext; +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; +import javax.servlet.ServletSecurityElement; +import javax.servlet.ServletRegistration.Dynamic; +import javax.servlet.annotation.ServletSecurity; +import javax.servlet.annotation.WebListener; + +/** + * @version $Rev$ $Date$ + */ +@WebListener +public class SampleServletContextListener implements ServletContextListener { + + @Override + public void contextDestroyed(ServletContextEvent servletContextEvent) { + } + + @Override + public void contextInitialized(ServletContextEvent servletContextEvent) { + + ServletContext servletContext = servletContextEvent.getServletContext(); + + //dynamic register /SampleServlet3Dynamic and security constraint + Dynamic servlet3Dynamic = servletContext.addServlet("SampleServlet3Dynamic", SampleServlet3.class); + servlet3Dynamic.addMapping("/SampleServlet3Dynamic", "/TestDynamic"); + HttpConstraintElement httpConstraintElement = new HttpConstraintElement(); + List httpMethodConstraintElements = new ArrayList(); + httpMethodConstraintElements.add(new HttpMethodConstraintElement("GET", new HttpConstraintElement(ServletSecurity.TransportGuarantee.NONE, "RoleC"))); + ServletSecurityElement servletSecurityElement = new ServletSecurityElement(httpConstraintElement, httpMethodConstraintElements); + Set uneffectedUrlPatterns = servlet3Dynamic.setServletSecurity(servletSecurityElement); + if (uneffectedUrlPatterns.size() == 0) { + throw new RuntimeException("/SampleServlet3Dynamic should be returned as it is defined in the web.xml file"); + } + } +} Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServletContextListener.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServletContextListener.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/java/org/apache/geronimo/testsuite/servlet30/main/SampleServletContextListener.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/geronimo-web.xml URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/geronimo-web.xml?rev=979723&view=auto ============================================================================== --- geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/geronimo-web.xml (added) +++ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/geronimo-web.xml Tue Jul 27 14:27:57 2010 @@ -0,0 +1,64 @@ + + + + + + ${project.groupId} + ${project.artifactId} + ${project.version} + car + + + /servlet30 + demo-properties-realm + + + + + + + + + + + + + + + + + + + + + demo-properties-realm + + ServerInfo + + + + + demo-properties-realm + org.apache.geronimo.security.realm.providers.PropertiesFileLoginModule + var/security/demo_users.properties + var/security/demo_groups.properties + + + + + Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/geronimo-web.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/geronimo-web.xml ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/geronimo-web.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/web.xml URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/web.xml?rev=979723&view=auto ============================================================================== --- geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/web.xml (added) +++ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/web.xml Tue Jul 27 14:27:57 2010 @@ -0,0 +1,94 @@ + + + + SampleServlet + + + SampleServlet1 + SampleServlet1 + org.apache.geronimo.testsuite.servlet30.main.SampleServlet1 + + + + SampleServlet2 + SampleServlet2 + org.apache.geronimo.testsuite.servlet30.main.SampleServlet2 + + + + SampleServlet3 + SampleServlet3 + org.apache.geronimo.testsuite.servlet30.main.SampleServlet3 + + + SampleServlet1 + /SampleServlet1 + /SampleServlet1/* + + + SampleServlet2 + /SampleServlet2 + /SampleServlet2/* + + + SampleServlet3 + /SampleServlet3 + /SampleServlet3/* + + + + index.html + index.htm + index.jsp + + + + + resource1 + /SampleServlet1 + /SampleServlet3Dynamic + POST + + + + + + + resource2 + /SampleServlet2 + GET + + + RoleA + + + + + BASIC + demo-properties-realm + + + RoleA + + + RoleB + + + RoleC + + Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/web.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/web.xml ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/main/webapp/WEB-INF/web.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/org/apache/geronimo/testsuite/servlets/ServletsTest.java URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/org/apache/geronimo/testsuite/servlets/ServletsTest.java?rev=979723&view=auto ============================================================================== --- geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/org/apache/geronimo/testsuite/servlets/ServletsTest.java (added) +++ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/org/apache/geronimo/testsuite/servlets/ServletsTest.java Tue Jul 27 14:27:57 2010 @@ -0,0 +1,201 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.geronimo.testsuite.servlets; + +import java.net.HttpURLConnection; + +import javax.servlet.annotation.HttpMethodConstraint; +import javax.servlet.annotation.ServletSecurity; +import javax.servlet.annotation.WebServlet; +import javax.servlet.http.HttpServlet; + +import org.apache.commons.httpclient.Credentials; +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.HttpMethodBase; +import org.apache.commons.httpclient.UsernamePasswordCredentials; +import org.apache.commons.httpclient.auth.AuthScope; +import org.apache.commons.httpclient.methods.GetMethod; +import org.apache.commons.httpclient.methods.PostMethod; + +import org.testng.Assert; +import org.testng.annotations.Test; + + +public class ServletsTest { + +/**In web.xml, it reads as follows: + * + * + * resource1 + * /SampleServlet + * /SampleServlet3Dynamic + * POST + * + * + * + * The Test1 and Test2 tests the description above. + */ + + /** + * Test1 + * test + */ + @Test + public void test_SampleServlet_POST_Sucess() throws Exception { + Assert.assertEquals( invoke("/SampleServlet1", "POST", "alan", "starcraft"), HttpURLConnection.HTTP_OK); + } + + /** + * Test2 + */ + @Test + public void test_SampleServlet1_GET_Fail() throws Exception { + Assert.assertEquals(invoke("/SampleServlet1", "GET", "alan", "starcraft"), HttpURLConnection.HTTP_FORBIDDEN); + } + + /** + * Test3 + * + + resource2 + /SampleServlet2 + GET + + + RoleA + + + */ + @Test + public void test_SampleServlet2_GET_RoleA_Success() throws Exception { + Assert.assertEquals(invoke("/SampleServlet2" , "GET", "alan" , "starcraft" ) , HttpURLConnection.HTTP_OK); + } + + /** + * Test4 + */ + @Test + public void test_SampleServlet2_GET_RoleB_Fail() throws Exception { + Assert.assertEquals(invoke("/SampleServlet2" , "GET", "george" , "bone" ) , HttpURLConnection.HTTP_FORBIDDEN); + } + + /** + * Test5 + * @WebServlet("/SampleServlet4") + * @ServletSecurity(httpMethodConstraints = {@HttpMethodConstraint(value = "POST", rolesAllowed = "RoleB") }) + * public class SampleServlet4 extends HttpServlet{ + */ + @Test + public void test_SampleServlet4_POST_RoleB_Success() throws Exception { + Assert.assertEquals(invoke("/SampleServlet4", "POST", "george", "bone"), HttpURLConnection.HTTP_OK); + } + + /** + * Test6 + */ + @Test + public void test_SampleServlet4_POST_RoleC_Fail() throws Exception { + Assert.assertEquals(invoke("/SampleServlet4", "POST", "gracie", "biscuit"), HttpURLConnection.HTTP_FORBIDDEN); + } + + /** + * Test7 + */ + @Test + public void test_SampleServlet3_All_Success() throws Exception { + Assert.assertEquals(invoke("/SampleServlet3", "POST", "unknown", "unknown"), HttpURLConnection.HTTP_OK); + } + + /** + * Test8 + * URL "/SampleServlet3Dynamic" are set both in web.xml and ServletRegistration.Dynamic + * IN web.xml,GET access is forbidden by all users. + * In ServletRegistration.Dynamic, GET access is allowled by RoleC + * But web.xml content's priority is higher. + */ + @Test + public void test_SampleServlet3Dynamic_GET_RoleC_Fail() throws Exception { + Assert.assertEquals(invoke("/SampleServlet3Dynamic", "GET", "gracie", "biscuit"), HttpURLConnection.HTTP_FORBIDDEN); + } + + + /** + * Test9 + */ + @Test + public void test_SampleServlet3Dynamic_POST_RoleAll_Success() throws Exception { + Assert.assertEquals(invoke("/SampleServlet3Dynamic", "POST", "unknown", "unknown"), HttpURLConnection.HTTP_OK); + } + + + /** + * Test10 + * Test @WebServlet annotation feature in Servlet 3.0 + */ + @Test + public void test_annotation_WebServlet() throws Exception{ + Assert.assertEquals(invoke("/WebServlet1", "POST", "unknown", "unknown"), HttpURLConnection.HTTP_OK); + } + + /** + * Test11 + * Test @WebServlet annotation feature in Servlet 3.0 + * Test mapping two url in @WebServlet + * (name = "WebServlet", urlPatterns = {"/WebServlet1", "/WebServlet2"} ) + */ + @Test + public void test_annotation_WebServlet2() throws Exception{ + Assert.assertEquals(invoke("/WebServlet2", "GET", "unknown", "unknown"), HttpURLConnection.HTTP_OK); + } + + + + /** + * Test12 + * In ServletRegistration.Dynamic, GET access is allowled by RoleC + */ + @Test + public void test_TestDynamic_GET_RoleC_Sucess() throws Exception{ + Assert.assertEquals(invoke("/TestDynamic", "GET", "gracie", "biscuit"), HttpURLConnection.HTTP_OK); + } + + /** + * Test13 + */ + @Test + public void test_TestDynamic_GET_RoleB_Fail() throws Exception{ + Assert.assertEquals(invoke("/TestDynamic", "GET", "george", "bone"), HttpURLConnection.HTTP_FORBIDDEN); + } + + private int invoke(String address, String methodName, String userName, String password) throws Exception { + HttpClient client = new HttpClient(); + Credentials defaultcreds = new UsernamePasswordCredentials(userName, password); + client.getState().setCredentials(AuthScope.ANY, defaultcreds); + String url = "http://localhost:8080/servlet30" + address; + HttpMethodBase httpMethod; + if (methodName.equals("GET")) { + httpMethod = new GetMethod(url); + } else { + httpMethod = new PostMethod(url); + } + return client.executeMethod(httpMethod); + } + +} \ No newline at end of file Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/org/apache/geronimo/testsuite/servlets/ServletsTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/org/apache/geronimo/testsuite/servlets/ServletsTest.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/java/org/apache/geronimo/testsuite/servlets/ServletsTest.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/resources/testng.xml URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/resources/testng.xml?rev=979723&view=auto ============================================================================== --- geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/resources/testng.xml (added) +++ geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/resources/testng.xml Tue Jul 27 14:27:57 2010 @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/resources/testng.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/resources/testng.xml ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: geronimo/server/trunk/testsuite/javaee6-testsuite/servlet3.0-security-test/src/test/resources/testng.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml