[jboss-cvs] JBossAS SVN: r60782 - in branches/Branch_4_2/testsuite/src: main/org/jboss/test/jacc/test/allstarrole and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Feb 21 17:18:36 EST 2007
Author: anil.saldhana at jboss.com
Date: 2007-02-21 17:18:36 -0500 (Wed, 21 Feb 2007)
New Revision: 60782
Added:
branches/Branch_4_2/testsuite/src/main/org/jboss/test/jacc/test/allstarrole/
branches/Branch_4_2/testsuite/src/main/org/jboss/test/jacc/test/allstarrole/AllStarRoleJaccPolicy.java
branches/Branch_4_2/testsuite/src/main/org/jboss/test/jacc/test/allstarrole/JBAS1824AllStarRoleJaccTestCase.java
branches/Branch_4_2/testsuite/src/resources/security/jacc/allStarRole/
branches/Branch_4_2/testsuite/src/resources/security/jacc/allStarRole/WEB-INF/
branches/Branch_4_2/testsuite/src/resources/security/jacc/allStarRole/WEB-INF/classes/
branches/Branch_4_2/testsuite/src/resources/security/jacc/allStarRole/WEB-INF/classes/roles.properties
branches/Branch_4_2/testsuite/src/resources/security/jacc/allStarRole/WEB-INF/classes/users.properties
branches/Branch_4_2/testsuite/src/resources/security/jacc/allStarRole/WEB-INF/jboss-web.xml
branches/Branch_4_2/testsuite/src/resources/security/jacc/allStarRole/WEB-INF/web.xml
branches/Branch_4_2/testsuite/src/resources/security/jacc/allStarRole/index.html
Log:
JBAS-1824:Generate WebResourcePermission(uri,null) for <role-name>*</role-name>: Tests
Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/jacc/test/allstarrole/AllStarRoleJaccPolicy.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/jacc/test/allstarrole/AllStarRoleJaccPolicy.java (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/jacc/test/allstarrole/AllStarRoleJaccPolicy.java 2007-02-21 22:18:36 UTC (rev 60782)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jacc.test.allstarrole;
+
+import java.security.Permission;
+import java.security.Permissions;
+import java.security.Policy;
+import java.security.ProtectionDomain;
+
+import javax.security.jacc.PolicyContextException;
+import javax.security.jacc.WebResourcePermission;
+
+import org.jboss.security.jacc.DelegatingPolicy;
+
+//$Id$
+
+/**
+ * JBAS-1824: Jacc Policy Provider for testing that bypasses authorization checks
+ * for <role-name>*</role-name>
+ *
+ * This policy is an extension of DelegatingPolicy and only checks for the
+ * presence of WebResourcePermission(url, null) for role-name '*'
+ * @author <a href="mailto:Anil.Saldhana at jboss.org">Anil Saldhana</a>
+ * @since Feb 16, 2007
+ * @version $Revision$
+ */
+public class AllStarRoleJaccPolicy extends DelegatingPolicy
+{
+ public AllStarRoleJaccPolicy()
+ {
+ super();
+ }
+
+ public AllStarRoleJaccPolicy(Policy delegate)
+ {
+ super(delegate);
+ }
+
+ public boolean implies(ProtectionDomain domain, Permission permission)
+ {
+ boolean implied = false;
+
+ if (permission instanceof WebResourcePermission == false)
+ {
+ // Let DelegatingPolicy handle the check
+ implied = super.implies(domain, permission);
+ }
+ else
+ {
+ try
+ {
+ Permissions perms = this.getPermissionsForRole("*");
+ if(perms != null)
+ implied = perms.implies(new WebResourcePermission("/*",(String)null));
+ }
+ catch (PolicyContextException e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
+ return implied;
+ }
+}
Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/jacc/test/allstarrole/JBAS1824AllStarRoleJaccTestCase.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/jacc/test/allstarrole/JBAS1824AllStarRoleJaccTestCase.java (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/jacc/test/allstarrole/JBAS1824AllStarRoleJaccTestCase.java 2007-02-21 22:18:36 UTC (rev 60782)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.jacc.test.allstarrole;
+
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.jboss.test.JBossTestCase;
+import org.jboss.test.JBossTestSetup;
+import org.jboss.test.util.web.HttpUtils;
+
+//$Id$
+
+/**
+ * JBAS-1824: <role-name>*</role-name> should create WebResourcePermission(url,null)
+ * if requested.
+ * @author <a href="mailto:Anil.Saldhana at jboss.org">Anil Saldhana</a>
+ * @since Feb 16, 2007
+ * @version $Revision$
+ */
+public class JBAS1824AllStarRoleJaccTestCase extends JBossTestCase
+{
+ private String baseURLAuth = HttpUtils.getBaseURL("jduke", "theduke");
+
+ public JBAS1824AllStarRoleJaccTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testSuccessfulAuthorizationBypass() throws Exception
+ {
+ //Try a successful access
+ HttpUtils.accessURL(new URL(baseURLAuth + "/jacc-allstarrole/index.html"));
+ }
+
+ public void testUnsuccessfulAuthorizationBypass() throws Exception
+ {
+ //Try a unsuccessful access
+ HttpUtils.accessURL(new URL(baseURLAuth + "/jacc-allstarrole-noconfig/index.html")
+ , "JBossTest Servlets", HttpURLConnection.HTTP_FORBIDDEN);
+ }
+
+ public static Test suite() throws Exception
+ {
+ TestSuite suite = new TestSuite();
+ suite.addTest(new TestSuite(JBAS1824AllStarRoleJaccTestCase.class));
+
+ // Create an initializer for the test suite
+ Test wrapper = new JBossTestSetup(suite)
+ {
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ deploy("jacc-allstarrole.war");
+ deploy("jacc-allstarrole-noconfig.war");
+ // Make sure the security cache is clear
+ flushAuthCache();
+ }
+ protected void tearDown() throws Exception
+ {
+ undeploy("jacc-allstarrole-noconfig.war");
+ undeploy("jacc-allstarrole.war");
+ super.tearDown();
+ }
+ };
+ return wrapper;
+ }
+}
Added: branches/Branch_4_2/testsuite/src/resources/security/jacc/allStarRole/WEB-INF/classes/roles.properties
===================================================================
--- branches/Branch_4_2/testsuite/src/resources/security/jacc/allStarRole/WEB-INF/classes/roles.properties (rev 0)
+++ branches/Branch_4_2/testsuite/src/resources/security/jacc/allStarRole/WEB-INF/classes/roles.properties 2007-02-21 22:18:36 UTC (rev 60782)
@@ -0,0 +1,19 @@
+scott=Echo
+stark=Java,Coder
+stark.CallerPrincipal=callerStark
+
+starksm.Roles=ProjectUser
+starksm.CallerPrincipal=callerStarksm
+scott.Roles=ProjectUser
+scott.CallerPrincipal=callerScott
+
+jduke=Role1,Role2,Echo
+jduke.CallerPrincipal=callerJduke
+jdukeman=Role2,Role3
+jdukeman.CallerPrincipal=callerJdukeman
+
+# Roles for the unit-tests cert alias
+unit-tests=CertUser
+unit-tests.CallerPrincipal=callerX509
+
+invoker=HttpInvoker
\ No newline at end of file
Added: branches/Branch_4_2/testsuite/src/resources/security/jacc/allStarRole/WEB-INF/classes/users.properties
===================================================================
--- branches/Branch_4_2/testsuite/src/resources/security/jacc/allStarRole/WEB-INF/classes/users.properties (rev 0)
+++ branches/Branch_4_2/testsuite/src/resources/security/jacc/allStarRole/WEB-INF/classes/users.properties 2007-02-21 22:18:36 UTC (rev 60782)
@@ -0,0 +1,8 @@
+scott=echoman
+stark=javaman
+jduke=theduke
+jdukeman=anotherduke
+# Old http-invoker login
+invoker=invoker
+# jmx-console login
+admin=admin
\ No newline at end of file
Added: branches/Branch_4_2/testsuite/src/resources/security/jacc/allStarRole/WEB-INF/jboss-web.xml
===================================================================
--- branches/Branch_4_2/testsuite/src/resources/security/jacc/allStarRole/WEB-INF/jboss-web.xml (rev 0)
+++ branches/Branch_4_2/testsuite/src/resources/security/jacc/allStarRole/WEB-INF/jboss-web.xml 2007-02-21 22:18:36 UTC (rev 60782)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE jboss-web PUBLIC
+ "-//JBoss//DTD Web Application 2.4//EN"
+ "http://www.jboss.org/j2ee/dtd/jboss-web_4_2.dtd">
+
+<jboss-web>
+ <security-domain>java:/jaas/userinrole</security-domain>
+ <jacc-star-role-allow>true</jacc-star-role-allow>
+</jboss-web>
Added: branches/Branch_4_2/testsuite/src/resources/security/jacc/allStarRole/WEB-INF/web.xml
===================================================================
--- branches/Branch_4_2/testsuite/src/resources/security/jacc/allStarRole/WEB-INF/web.xml (rev 0)
+++ branches/Branch_4_2/testsuite/src/resources/security/jacc/allStarRole/WEB-INF/web.xml 2007-02-21 22:18:36 UTC (rev 60782)
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
+
+ <description>JBAS-1824:All Star Role Jacc</description>
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>Any Authenticated User</web-resource-name>
+ <url-pattern>/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>*</role-name>
+ </auth-constraint>
+ </security-constraint>
+
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>ResourceUser Required</web-resource-name>
+ <url-pattern>/restricted/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>ResourceUser</role-name>
+ </auth-constraint>
+ </security-constraint>
+
+ <security-role>
+ <role-name>ResourceUser</role-name>
+ </security-role>
+
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>JBossTest Servlets</realm-name>
+ </login-config>
+</web-app>
Added: branches/Branch_4_2/testsuite/src/resources/security/jacc/allStarRole/index.html
===================================================================
--- branches/Branch_4_2/testsuite/src/resources/security/jacc/allStarRole/index.html (rev 0)
+++ branches/Branch_4_2/testsuite/src/resources/security/jacc/allStarRole/index.html 2007-02-21 22:18:36 UTC (rev 60782)
@@ -0,0 +1 @@
+Test Page.
More information about the jboss-cvs-commits
mailing list