You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ak...@apache.org on 2007/01/20 13:40:01 UTC
svn commit: r498109 - in
/geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/test:
java/org/apache/geronimo/web25/deployment/ resources/deployables/war3/
resources/deployables/war3/WEB-INF/ resources/deployables/war3/auth/
resources/deployables...
Author: akulshreshtha
Date: Sat Jan 20 04:40:00 2007
New Revision: 498109
URL: http://svn.apache.org/viewvc?view=rev&rev=498109
Log:
G-1585 Added testcase for extension pattern (*.do) in security constraints
Added:
geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/test/java/org/apache/geronimo/web25/deployment/SecurityConfigTest.java (with props)
geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/test/resources/deployables/war3/
- copied from r497678, geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/resources/deployables/war3/
geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/test/resources/deployables/war3/WEB-INF/
- copied from r498019, geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/resources/deployables/war3/WEB-INF/
geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/test/resources/deployables/war3/auth/
- copied from r498019, geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/resources/deployables/war3/auth/
geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/test/resources/deployables/war3/protected/
- copied from r498019, geronimo/server/trunk/modules/geronimo-tomcat6-builder/src/test/resources/deployables/war3/protected/
Modified:
geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/test/resources/deployables/war3/WEB-INF/geronimo-web.xml
geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/test/resources/deployables/war3/WEB-INF/web.xml
Added: geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/test/java/org/apache/geronimo/web25/deployment/SecurityConfigTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/test/java/org/apache/geronimo/web25/deployment/SecurityConfigTest.java?view=auto&rev=498109
==============================================================================
--- geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/test/java/org/apache/geronimo/web25/deployment/SecurityConfigTest.java (added)
+++ geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/test/java/org/apache/geronimo/web25/deployment/SecurityConfigTest.java Sat Jan 20 04:40:00 2007
@@ -0,0 +1,111 @@
+/**
+ * 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.web25.deployment;
+
+import java.io.File;
+import java.net.URL;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.jar.JarFile;
+
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.deployment.ModuleIDBuilder;
+import org.apache.geronimo.deployment.util.DeploymentUtil;
+import org.apache.geronimo.deployment.util.UnpackedJarFile;
+import org.apache.geronimo.deployment.xmlbeans.XmlBeansUtil;
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.j2ee.deployment.EARContext;
+import org.apache.geronimo.j2ee.deployment.Module;
+import org.apache.geronimo.kernel.Kernel;
+import org.apache.geronimo.kernel.Naming;
+import org.apache.geronimo.security.jacc.ComponentPermissions;
+import org.apache.geronimo.testsupport.TestSupport;
+import org.apache.geronimo.xbeans.javaee.WebAppDocument;
+import org.apache.geronimo.xbeans.javaee.WebAppType;
+import org.apache.xmlbeans.XmlObject;
+import org.apache.xmlbeans.XmlOptions;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SecurityConfigTest extends TestSupport {
+
+ private ClassLoader classLoader = this.getClass().getClassLoader();
+
+ private XmlOptions options = new XmlOptions();
+
+ private WebModuleBuilder webModuleBuilder = new WebModuleBuilder(null);
+
+ public void testNoSecConstraint() throws Exception {
+ String warName = "war3";
+ File path = new File(BASEDIR, "src/test/resources/deployables/"
+ + warName);
+
+ // parse the spec dd
+ String specDD = "";
+ WebAppType webApp = null;
+ UnpackedJarFile jarFile = new UnpackedJarFile(path);
+ URL specDDUrl = DeploymentUtil.createJarURL(jarFile, "WEB-INF/web.xml");
+ // read in the entire specDD as a string
+ specDD = DeploymentUtil.readAll(specDDUrl);
+ // parse it
+ XmlObject parsed = XmlBeansUtil.parse(specDD);
+ WebAppDocument webAppDoc = webModuleBuilder
+ .convertToServletSchema(parsed);
+ webApp = webAppDoc.getWebApp();
+ Set securityRoles = AbstractWebModuleBuilder.collectRoleNames(webApp);
+ Map rolePermissions = new HashMap();
+ try {
+ ComponentPermissions componentPermissions = webModuleBuilder
+ .buildSpecSecurityConfig(webApp, securityRoles, rolePermissions);
+ } catch (IllegalArgumentException e) {
+ // This is a known issue
+ //System.out.println("Exception caught: " + e.getMessage());
+ }
+ }
+
+ private static class WebModuleBuilder extends AbstractWebModuleBuilder {
+
+ protected WebModuleBuilder(Kernel kernel) {
+ super(kernel, null, null, null, null);
+ }
+
+ protected Module createModule(Object plan, JarFile moduleFile,
+ String targetPath, URL specDDUrl, boolean standAlone,
+ String contextRoot, AbstractName earName, Naming naming,
+ ModuleIDBuilder idBuilder) throws DeploymentException {
+ return null;
+ }
+
+ public void initContext(EARContext earContext, Module module,
+ ClassLoader classLoader) throws DeploymentException {
+ }
+
+ public void addGBeans(EARContext earContext, Module module,
+ ClassLoader classLoader, Collection repositories)
+ throws DeploymentException {
+ }
+
+ public String getSchemaNamespace() {
+ return null;
+ }
+ }
+
+}
Propchange: geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/test/java/org/apache/geronimo/web25/deployment/SecurityConfigTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/test/java/org/apache/geronimo/web25/deployment/SecurityConfigTest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/test/java/org/apache/geronimo/web25/deployment/SecurityConfigTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/test/resources/deployables/war3/WEB-INF/geronimo-web.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/test/resources/deployables/war3/WEB-INF/geronimo-web.xml?view=diff&rev=498109&r1=498019&r2=498109
==============================================================================
--- geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/test/resources/deployables/war3/WEB-INF/geronimo-web.xml (original)
+++ geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/test/resources/deployables/war3/WEB-INF/geronimo-web.xml Sat Jan 20 04:40:00 2007
@@ -18,8 +18,8 @@
-->
<web-app
- xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.1"
- xmlns:sec="http://geronimo.apache.org/xml/ns/security-1.1">
+ xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.2"
+ xmlns:sec="http://geronimo.apache.org/xml/ns/security-1.2">
<context-root>/test</context-root>
<login-domain-name>demo-properties-realm</login-domain-name>
Modified: geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/test/resources/deployables/war3/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/test/resources/deployables/war3/WEB-INF/web.xml?view=diff&rev=498109&r1=498019&r2=498109
==============================================================================
--- geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/test/resources/deployables/war3/WEB-INF/web.xml (original)
+++ geronimo/server/trunk/modules/geronimo-web-2.5-builder/src/test/resources/deployables/war3/WEB-INF/web.xml Sat Jan 20 04:40:00 2007
@@ -17,25 +17,14 @@
limitations under the License.
-->
-<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
-<web-app>
<description>Test Web Deployment</description>
- <resource-env-ref>
- <resource-env-ref-name>fake-resource-env-ref</resource-env-ref-name>
- <resource-env-ref-type>javax.jms.Queue</resource-env-ref-type>
- </resource-env-ref>
- <resource-ref>
- <res-ref-name>fake-resource-ref</res-ref-name>
- <res-type>javax.sql.DataSource</res-type>
- <res-auth>Container</res-auth>
- <res-sharing-scope>Shareable</res-sharing-scope>
- </resource-ref>
<security-constraint>
<web-resource-collection>
<web-resource-name>Admin Role</web-resource-name>
- <url-pattern>/protected/*</url-pattern>
+ <url-pattern>*.do</url-pattern>
</web-resource-collection>
<auth-constraint>
<role-name>content-administrator</role-name>
@@ -44,11 +33,10 @@
<security-constraint>
<web-resource-collection>
- <web-resource-name>NO ACCESS</web-resource-name>
- <url-pattern>/auth/logon.html</url-pattern>
+ <web-resource-name>Unrestricted ACCESS</web-resource-name>
+ <url-pattern>/login.do</url-pattern>
</web-resource-collection>
- <auth-constraint/>
- </security-constraint>
+ </security-constraint>
<login-config>
<auth-method>FORM</auth-method>
@@ -62,30 +50,5 @@
<security-role>
<role-name>content-administrator</role-name>
</security-role>
-
- <ejb-ref>
- <ejb-ref-name>fake-ejb-ref</ejb-ref-name>
- <ejb-ref-type>Entity</ejb-ref-type>
- <home>some.package.FakeHome</home>
- <remote>some.package.Fake</remote>
- </ejb-ref>
- <ejb-ref>
- <ejb-ref-name>another-ejb-ref</ejb-ref-name>
- <ejb-ref-type>Entity</ejb-ref-type>
- <home>some.package.FakeHome</home>
- <remote>some.package.Fake</remote>
- </ejb-ref>
- <ejb-local-ref>
- <ejb-ref-name>fake-ejb-local-ref</ejb-ref-name>
- <ejb-ref-type>Entity</ejb-ref-type>
- <local-home>some.package.FakeLocalHome</local-home>
- <local>some.package.FakeLocal</local>
- </ejb-local-ref>
- <ejb-local-ref>
- <ejb-ref-name>another-ejb-local-ref</ejb-ref-name>
- <ejb-ref-type>Entity</ejb-ref-type>
- <local-home>some.package.FakeLocalHome</local-home>
- <local>some.package.FakeLocal</local>
- </ejb-local-ref>
</web-app>