geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r560749 - in /geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests: ./ jpa-ear/ jpa-ear/src/test/java/org/apache/geronimo/testsuite/jpa/ jpa-ejb/ jpa-ejb/src/main/java/org/apache/geronimo/itest/ jpa-ejb/src/main/java/org/apache/ge...
Date Sun, 29 Jul 2007 16:07:49 GMT
Author: djencks
Date: Sun Jul 29 09:07:48 2007
New Revision: 560749

URL: http://svn.apache.org/viewvc?view=rev&rev=560749
Log:
GERONIMO-3357 test app showing run-as really works, but with all wrong maven project names
due to svn cp

Added:
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/
      - copied from r559903, geronimo/server/trunk/testsuite/enterprise-testsuite/jpa-tests/
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/java/org/apache/geronimo/itest/TestLoginModule.java
  (with props)
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/src/main/webapp/TestJsp.jsp
  (with props)
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/src/main/webapp/WEB-INF/geronimo-web.xml
  (with props)
Removed:
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/java/org/apache/geronimo/itest/jpa/
Modified:
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ear/pom.xml
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ear/src/test/java/org/apache/geronimo/testsuite/jpa/JPATest.java
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/pom.xml
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/java/org/apache/geronimo/itest/TestSession.java
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/java/org/apache/geronimo/itest/TestSessionBean.java
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/resources/META-INF/ejb-jar.xml
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/resources/META-INF/openejb-jar.xml
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/pom.xml
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/src/main/java/org/apache/geronimo/itest/TestServlet.java
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/src/main/webapp/WEB-INF/web.xml
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/pom.xml

Modified: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ear/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ear/pom.xml?view=diff&rev=560749&r1=559903&r2=560749
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ear/pom.xml (original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ear/pom.xml Sun Jul
29 09:07:48 2007
@@ -22,23 +22,24 @@
 
     <parent>
         <groupId>org.apache.geronimo.testsuite</groupId>
-        <artifactId>jpa-tests</artifactId>
+        <artifactId>sec-tests</artifactId>
         <version>2.1-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
     </parent>
-    <artifactId>jpa-ear</artifactId>
-    <name>Geronimo TestSuite :: Enterprise Testsuite :: JPA - EAR</name>
+    <artifactId>sec-ear</artifactId>
+    <name>Geronimo TestSuite :: Enterprise Testsuite :: Security - EAR</name>
     <packaging>ear</packaging>
 
     <dependencies>
         <dependency>
             <groupId>org.apache.geronimo.testsuite</groupId>
-            <artifactId>jpa-ejb</artifactId>
+            <artifactId>sec-ejb</artifactId>
             <version>${version}</version>
             <type>ejb</type>
         </dependency>
         <dependency>
             <groupId>org.apache.geronimo.testsuite</groupId>
-            <artifactId>jpa-war</artifactId>
+            <artifactId>sec-war</artifactId>
             <version>${version}</version>
             <type>war</type>
         </dependency>
@@ -71,19 +72,19 @@
             <plugin>
                 <artifactId>maven-ear-plugin</artifactId>
                 <configuration>
-                    <displayName>jpa Itest ear</displayName>
-                    <description>jpa Itest ear</description>
+                    <displayName>security Itest ear</displayName>
+                    <description>security Itest ear</description>
                     <version>1.4</version>
                     <modules>
                         <webModule>
                             <groupId>org.apache.geronimo.testsuite</groupId>
-                            <artifactId>jpa-war</artifactId>
-                            <contextRoot>/jpa</contextRoot>
+                            <artifactId>sec-war</artifactId>
+                            <contextRoot>/sec</contextRoot>
                             <bundleFileName>web.war</bundleFileName>
                         </webModule>
                         <ejbModule>
                             <groupId>org.apache.geronimo.testsuite</groupId>
-                            <artifactId>jpa-ejb</artifactId>
+                            <artifactId>sec-ejb</artifactId>
                             <bundleFileName>ejb.jar</bundleFileName>
                         </ejbModule>
                     </modules>

Modified: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ear/src/test/java/org/apache/geronimo/testsuite/jpa/JPATest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ear/src/test/java/org/apache/geronimo/testsuite/jpa/JPATest.java?view=diff&rev=560749&r1=559903&r2=560749
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ear/src/test/java/org/apache/geronimo/testsuite/jpa/JPATest.java
(original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ear/src/test/java/org/apache/geronimo/testsuite/jpa/JPATest.java
Sun Jul 29 09:07:48 2007
@@ -20,6 +20,7 @@
 package org.apache.geronimo.testsuite.jpa;
 
 import org.testng.annotations.Test;
+import org.testng.annotations.BeforeSuite;
 import org.apache.geronimo.testsupport.SeleniumTestSupport;
 
 /**
@@ -31,17 +32,35 @@
 public class JPATest
     extends SeleniumTestSupport
 {
+
+
+    @BeforeSuite
+     protected void startSeleniumClient() throws Exception {
+        log.info("Starting Selenium client");
+
+        selenium = createSeleniumClient("http://foo:foo@localhost:8080/");
+        selenium.start();
+    }
+
+    @Test
+    public void testServletRunAs() throws Exception {
+        selenium.open("/sec/servlet");
+        selenium.waitForPageToLoad("30000");
+        System.out.println("----------------------------------------------");
+        System.out.println(selenium.getText("xpath=/html/body"));
+        assertEquals("TestServlet principal: foo\n" +
+                "Test EJB principal: bar\n" +
+                "Correctly received security exception on noAccess method", selenium.getText("xpath=/html/body"));
+
+    }
+
     @Test
-    public void testIndexContent() throws Exception {
-        selenium.open("/jpa/servlet");
+    public void testJspRunAs() throws Exception {
+        selenium.open("/sec/jsp");
         selenium.waitForPageToLoad("30000");
-        //assertEquals("Hello J2EE 1.4", selenium.getTitle());
-        assertEquals("TestServlet\n" +
-                "Test EJB container managed entity manager test OK: true\n" +
-                "Test EJB app managed entity manager factory test OK: true\n" +
-                "Test servlet container managed entity manager test OK: true\n" +
-                "Test servlet app managed entity manager factory test OK: true\n" +
-                "commit OK", selenium.getText("xpath=/html/body"));
+        System.out.println("----------------------------------------------");
+        System.out.println(selenium.getText("xpath=/html/body"));
+        assertEquals("TestServlet principal: foo Test EJB principal: bar Correctly received
security exception on noAccess method", selenium.getText("xpath=/html/body"));
 
     }
 }

Modified: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/pom.xml?view=diff&rev=560749&r1=559903&r2=560749
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/pom.xml (original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/pom.xml Sun Jul
29 09:07:48 2007
@@ -21,12 +21,13 @@
 
     <parent>
         <groupId>org.apache.geronimo.testsuite</groupId>
-        <artifactId>jpa-tests</artifactId>
+        <artifactId>sec-tests</artifactId>
         <version>2.1-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
     </parent>
 
-    <artifactId>jpa-ejb</artifactId>
-    <name>Geronimo TestSuite :: Enterprise Testsuite :: JPA - JAR</name>
+    <artifactId>sec-ejb</artifactId>
+    <name>Geronimo TestSuite :: Enterprise Testsuite :: Security - JAR</name>
     <packaging>ejb</packaging>
 
     <dependencies>
@@ -41,61 +42,31 @@
             <artifactId>geronimo-jta_1.1_spec</artifactId>
             <scope>test</scope>
         </dependency>
-        
-        <dependency>
-            <groupId>org.apache.openjpa</groupId>
-            <artifactId>openjpa-persistence-jdbc</artifactId>
-            <scope>provided</scope>
-        </dependency>
-        
+                
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-ejb_3.0_spec</artifactId>
             <scope>provided</scope>
         </dependency>
 
-        <!-- the enhancer seems to need xerces -->
         <dependency>
-            <groupId>xerces</groupId>
-            <artifactId>xercesImpl</artifactId>
+            <groupId>org.apache.geronimo.modules</groupId>
+            <artifactId>geronimo-security</artifactId>
+            <version>${version}</version>
             <scope>provided</scope>
         </dependency>
 
+        <!-- the enhancer seems to need xerces -->
+        <!--<dependency>-->
+            <!--<groupId>xerces</groupId>-->
+            <!--<artifactId>xercesImpl</artifactId>-->
+            <!--<scope>provided</scope>-->
+        <!--</dependency>-->
+
     </dependencies>
 
     <build>
         <plugins>
-            <plugin>
-                <artifactId>maven-antrun-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <phase>compile</phase>
-                        <configuration>
-                            <tasks>
-                                <path id="enhance.path.ref">
-                                    <fileset dir="${project.build.outputDirectory}">
-                                        <include name="**/*.class"/>
-                                    </fileset>
-                                </path>
-                                <pathconvert property="enhance.files"
-                                   refid="enhance.path.ref"
-                                   pathsep=" "/>
-                                <java classname="org.apache.openjpa.enhance.PCEnhancer">
-                                    <arg line="-p persistence.xml"/>
-                                    <arg line="${enhance.files}"/>
-                                    <classpath>
-                                        <path refid="maven.dependency.classpath"/>
-                                        <path refid="maven.compile.classpath"/>
-                                    </classpath>
-                                </java>
-                            </tasks>
-                        </configuration>
-                        <goals>
-                            <goal>run</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-ejb-plugin</artifactId>

Added: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/java/org/apache/geronimo/itest/TestLoginModule.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/java/org/apache/geronimo/itest/TestLoginModule.java?view=auto&rev=560749
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/java/org/apache/geronimo/itest/TestLoginModule.java
(added)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/java/org/apache/geronimo/itest/TestLoginModule.java
Sun Jul 29 09:07:48 2007
@@ -0,0 +1,88 @@
+/*
+ * 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.itest;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.io.IOException;
+import java.security.Principal;
+
+import javax.security.auth.spi.LoginModule;
+import javax.security.auth.Subject;
+import javax.security.auth.login.LoginException;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+
+import org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal;
+
+/**
+ * @version $Rev:$ $Date:$
+ */
+public class TestLoginModule implements LoginModule {
+    private Subject subject;
+    private CallbackHandler callbackHandler;
+    private Set<String> users;
+    private String user;
+
+    public void initialize(Subject subject, CallbackHandler callbackHandler, Map<String,
?> sharedState, Map<String, ?> options) {
+        this.subject = subject;
+        this.callbackHandler = callbackHandler;
+        String userList = (String) options.get("users");
+        String[] userArray = userList.split(",");
+        users = new HashSet<String>(Arrays.asList(userArray));
+    }
+
+    public boolean login() throws LoginException {
+        Callback[] callbacks = new Callback[] {
+                new NameCallback("user"),
+                new PasswordCallback("password", false)
+        };
+        try {
+            callbackHandler.handle(callbacks);
+        } catch (IOException e) {
+            throw new LoginException(e.getMessage());
+        } catch (UnsupportedCallbackException e) {
+            throw new LoginException(e.getMessage());
+        }
+        user = ((NameCallback)callbacks[0]).getName();
+        String password = new String(((PasswordCallback)callbacks[1]).getPassword());
+        return user.equals(password) && users.contains(user);
+    }
+
+    public boolean commit() throws LoginException {
+        Principal principal = new GeronimoUserPrincipal(user);
+        subject.getPrincipals().add(principal);
+        return true;
+    }
+
+    public boolean abort() throws LoginException {
+        return true;
+    }
+
+    public boolean logout() throws LoginException {
+        return true;
+    }
+}

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/java/org/apache/geronimo/itest/TestLoginModule.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/java/org/apache/geronimo/itest/TestLoginModule.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/java/org/apache/geronimo/itest/TestLoginModule.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/java/org/apache/geronimo/itest/TestSession.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/java/org/apache/geronimo/itest/TestSession.java?view=diff&rev=560749&r1=559903&r2=560749
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/java/org/apache/geronimo/itest/TestSession.java
(original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/java/org/apache/geronimo/itest/TestSession.java
Sun Jul 29 09:07:48 2007
@@ -16,11 +16,13 @@
  */
 package org.apache.geronimo.itest;
 
+import java.rmi.RemoteException;
+
 /**
  * @version $Rev$ $Date$
  */
 public interface TestSession  extends javax.ejb.EJBObject {
-    boolean testEntityManager();
-    
-    boolean testEntityManagerFactory();
+    String testAccess() throws RemoteException;
+    String testNoAccess() throws RemoteException;
+
 }

Modified: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/java/org/apache/geronimo/itest/TestSessionBean.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/java/org/apache/geronimo/itest/TestSessionBean.java?view=diff&rev=560749&r1=559903&r2=560749
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/java/org/apache/geronimo/itest/TestSessionBean.java
(original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/java/org/apache/geronimo/itest/TestSessionBean.java
Sun Jul 29 09:07:48 2007
@@ -19,11 +19,6 @@
 import javax.ejb.SessionBean;
 import javax.ejb.EJBException;
 import javax.ejb.SessionContext;
-import javax.naming.InitialContext;
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-
-import org.apache.geronimo.itest.jpa.AllFieldTypes;
 
 /**
  * @version $Rev$ $Date$
@@ -32,37 +27,12 @@
 
     SessionContext sessionContext;
 
-    public boolean testEntityManager() {
-        try {
-            EntityManager entityManager = (EntityManager) new InitialContext().lookup("java:comp/env/jpa/test");
-            System.out.println("Accessed entity manager");
-            AllFieldTypes allFieldTypes = new AllFieldTypes();
-            entityManager.persist(allFieldTypes);
-            System.out.println("saved object");
-            return true;
-        } catch (Exception e) {
-            e.printStackTrace();
-            System.out.println("Could not access entity manager");
-            return false;
-        }
+    public String testAccess() {
+        return sessionContext.getCallerPrincipal().getName();
     }
 
-    public boolean testEntityManagerFactory() {
-        try {
-            EntityManagerFactory entityManagerFactory = (EntityManagerFactory) new InitialContext().lookup("java:comp/env/jpa/testEMF");
-            System.out.println("Accessed entity manager factory");
-            EntityManager entityManager = entityManagerFactory.createEntityManager();
-            AllFieldTypes allFieldTypes = new AllFieldTypes();
-            entityManager.persist(allFieldTypes);
-            System.out.println("saved object");
-            entityManager.close();
-            System.out.println("Closed entity manager");
-            return true;
-        } catch (Exception e) {
-            e.printStackTrace();
-            System.out.println("Could not access entity manager");
-            return false;
-        }
+    public String testNoAccess() {
+        return sessionContext.getCallerPrincipal().getName();
     }
 
     public void ejbCreate() {

Modified: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/resources/META-INF/ejb-jar.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/resources/META-INF/ejb-jar.xml?view=diff&rev=560749&r1=559903&r2=560749
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/resources/META-INF/ejb-jar.xml
(original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/resources/META-INF/ejb-jar.xml
Sun Jul 29 09:07:48 2007
@@ -22,7 +22,7 @@
     <display-name>jpa itest ejb</display-name>
     <enterprise-beans>
         <session>
-            <description>JPA Itest ejb</description>
+            <description>Security Itest ejb</description>
             <display-name>TestSession</display-name>
             <ejb-name>TestSession</ejb-name>
             <home>org.apache.geronimo.itest.TestSessionHome</home>
@@ -30,15 +30,23 @@
             <ejb-class>org.apache.geronimo.itest.TestSessionBean</ejb-class>
             <session-type>Stateless</session-type>
             <transaction-type>Container</transaction-type>
-            <persistence-context-ref>
-                <persistence-context-ref-name>jpa/test</persistence-context-ref-name>
-                <persistence-unit-name>test-unit</persistence-unit-name>
-                <persistence-context-type>Transactional</persistence-context-type>
-            </persistence-context-ref>
-            <persistence-unit-ref>
-                <persistence-unit-ref-name>jpa/testEMF</persistence-unit-ref-name>
-                <persistence-unit-name>test-unit</persistence-unit-name>
-            </persistence-unit-ref>
-        </session>
+       </session>
     </enterprise-beans>
+    <assembly-descriptor>
+        <method-permission>
+            <role-name>bar</role-name>
+            <method>
+                <ejb-name>TestSession</ejb-name>
+                <method-name>testAccess</method-name>
+            </method>
+        </method-permission>
+        <method-permission>
+            <role-name>foo</role-name>
+            <method>
+                <ejb-name>TestSession</ejb-name>
+                <method-name>testNoAccess</method-name>
+            </method>
+        </method-permission>
+    </assembly-descriptor>
+
 </ejb-jar>

Modified: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/resources/META-INF/openejb-jar.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/resources/META-INF/openejb-jar.xml?view=diff&rev=560749&r1=559903&r2=560749
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/resources/META-INF/openejb-jar.xml
(original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-ejb/src/main/resources/META-INF/openejb-jar.xml
Sun Jul 29 09:07:48 2007
@@ -19,39 +19,85 @@
     <environment>
         <moduleId>
             <groupId>default</groupId>
-            <artifactId>jpa-ejb</artifactId>
-            <version>1.2-SNAPSHOT</version>
+            <artifactId>sec-ejb</artifactId>
+            <version>2.1-SNAPSHOT</version>
             <type>car</type>
         </moduleId>
         <dependencies>
-            <dependency>
-                <groupId>org.apache.geronimo.configs</groupId>
-                <artifactId>system-database</artifactId>
-                <type>car</type>
-            </dependency>
-
-            <dependency>
-                <groupId>org.apache.geronimo.configs</groupId>
-                <artifactId>openjpa</artifactId>
-                <type>car</type>
-            </dependency>
 
         </dependencies>
     </environment>
     <enterprise-beans>
         <session>
             <ejb-name>TestSession</ejb-name>
-            <persistence-context-ref>
-                <persistence-context-ref-name>jpa/test</persistence-context-ref-name>
-                <persistence-unit-name>test-unit</persistence-unit-name>
-                <persistence-context-type>Transactional</persistence-context-type>
-            </persistence-context-ref>
-            <persistence-unit-ref>
-                <persistence-unit-ref-name>jpa/testEMF</persistence-unit-ref-name>
-                <persistence-unit-name>test-unit</persistence-unit-name>
-            </persistence-unit-ref>
         </session>
     </enterprise-beans>
-
+    <security xmlns="http://geronimo.apache.org/xml/ns/security-2.0">
+        <credential-store>
+            <name xmlns="http://geronimo.apache.org/xml/ns/deployment-1.2">TestCredentialStore</name>
+        </credential-store>
+        <role-mappings>
+            <role role-name="foo">
+                <run-as-subject>
+                    <realm>test-realm</realm>
+                    <id>foo-subject</id>
+                </run-as-subject>
+                <principal class="org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal"
name="foo"/>
+            </role>
+            <role role-name="bar">
+                <run-as-subject>
+                    <realm>test-realm</realm>
+                    <id>bar-subject</id>
+                </run-as-subject>
+                <principal class="org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal"
name="bar"/>
+            </role>
+        </role-mappings>
+    </security>
+    <gbean name="TestCredentialStore" class="org.apache.geronimo.security.credentialstore.SimpleCredentialStoreImpl">
+        <xml-attribute name="credentialStore">
+            <credential-store xmlns="http://geronimo.apache.org/xml/ns/credentialstore-1.0">
+                <realm name="test-realm">
+                    <subject>
+                        <id>foo-subject</id>
+                        <credential>
+                            <type>org.apache.geronimo.security.credentialstore.NameCallbackHandler</type>
+                            <value>foo</value>
+                        </credential>
+                        <credential>
+                            <type>org.apache.geronimo.security.credentialstore.PasswordCallbackHandler</type>
+                            <value>foo</value>
+                        </credential>
+                    </subject>
+                    <subject>
+                        <id>bar-subject</id>
+                        <credential>
+                            <type>org.apache.geronimo.security.credentialstore.NameCallbackHandler</type>
+                            <value>bar</value>
+                        </credential>
+                        <credential>
+                            <type>org.apache.geronimo.security.credentialstore.PasswordCallbackHandler</type>
+                            <value>bar</value>
+                        </credential>
+                    </subject>
+                </realm>
+            </credential-store>
+        </xml-attribute>
+    </gbean>
+    <gbean name="test-realm"
+           class="org.apache.geronimo.security.realm.GenericSecurityRealm">
+        <attribute name="realmName">test-realm</attribute>
+        <xml-reference name="LoginModuleConfiguration">
+            <lc:login-config xmlns:lc="http://geronimo.apache.org/xml/ns/loginconfig-${geronimoSchemaVersion}">
+                <lc:login-module control-flag="REQUIRED" wrap-principals="false">
+                    <lc:login-domain-name>test-realm</lc:login-domain-name>
+                    <lc:login-module-class>org.apache.geronimo.itest.TestLoginModule</lc:login-module-class>
+                    <lc:option name="users">foo,bar</lc:option>
+                </lc:login-module>
+            </lc:login-config>
+        </xml-reference>
+        <reference name="ServerInfo">
+            <name>ServerInfo</name>
+        </reference>
+    </gbean>
 </openejb-jar>
 

Modified: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/pom.xml?view=diff&rev=560749&r1=559903&r2=560749
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/pom.xml (original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/pom.xml Sun Jul
29 09:07:48 2007
@@ -22,18 +22,19 @@
 
     <parent>
         <groupId>org.apache.geronimo.testsuite</groupId>
-        <artifactId>jpa-tests</artifactId>
+        <artifactId>sec-tests</artifactId>
         <version>2.1-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
     </parent>
 
-    <artifactId>jpa-war</artifactId>
-    <name>Geronimo TestSuite :: Enterprise Testsuite :: JPA - WAR</name>
+    <artifactId>sec-war</artifactId>
+    <name>Geronimo TestSuite :: Enterprise Testsuite :: Security - WAR</name>
     <packaging>war</packaging>
 
      <dependencies>
         <dependency>
             <groupId>org.apache.geronimo.testsuite</groupId>
-            <artifactId>jpa-ejb</artifactId>
+            <artifactId>sec-ejb</artifactId>
             <version>${version}</version>
             <optional>true</optional>
         </dependency>

Modified: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/src/main/java/org/apache/geronimo/itest/TestServlet.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/src/main/java/org/apache/geronimo/itest/TestServlet.java?view=diff&rev=560749&r1=559903&r2=560749
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/src/main/java/org/apache/geronimo/itest/TestServlet.java
(original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/src/main/java/org/apache/geronimo/itest/TestServlet.java
Sun Jul 29 09:07:48 2007
@@ -17,21 +17,17 @@
 package org.apache.geronimo.itest;
 
 import java.io.IOException;
+import java.rmi.AccessException;
 import java.rmi.RemoteException;
 
+import javax.ejb.CreateException;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.servlet.ServletException;
+import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-import javax.servlet.ServletException;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import javax.ejb.CreateException;
-import javax.transaction.UserTransaction;
-import javax.transaction.SystemException;
-import javax.transaction.NotSupportedException;
-import javax.transaction.HeuristicMixedException;
-import javax.transaction.HeuristicRollbackException;
-import javax.transaction.RollbackException;
 
 
 /**
@@ -44,43 +40,29 @@
     }
 
     protected void service(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
throws ServletException, IOException {
-        httpServletResponse.getOutputStream().print("TestServlet\n");
+        ServletOutputStream out = httpServletResponse.getOutputStream();
+        out.println("TestServlet principal: " + httpServletRequest.getUserPrincipal().getName());
         try {
             InitialContext ctx = new InitialContext();
 
             //test ejb access using geronimo plan refs
             TestSessionHome home = (TestSessionHome)ctx.lookup("java:comp/env/TestSession");
-            boolean result = home.create().testEntityManager();
-            httpServletResponse.getOutputStream().print("Test EJB container managed entity
manager test OK: " + result);
-            result = home.create().testEntityManagerFactory();
-            httpServletResponse.getOutputStream().print("\nTest EJB app managed entity manager
factory test OK: " + result);
-
-            //test servlet access using spec dd refs
-            TestSessionBean bean = new TestSessionBean();
-            UserTransaction ut = (UserTransaction) ctx.lookup("java:comp/UserTransaction");
-            ut.begin();
-            result = bean.testEntityManager();
-            httpServletResponse.getOutputStream().print("\nTest servlet container managed
entity manager test OK: " + result);
-            result = bean.testEntityManagerFactory();
-            httpServletResponse.getOutputStream().print("\nTest servlet app managed entity
manager factory test OK: " + result);
-            ut.commit();
-            httpServletResponse.getOutputStream().print("\ncommit OK");
+            TestSession session = home.create();
+            String principalName = session.testAccess();
+            out.println("Test EJB principal: " + principalName);
+            try {
+                String bad = session.testNoAccess();
+                out.println("NoAccess method call succeeded with principal: " + bad);
+            } catch (AccessException e) {
+                out.println("Correctly received security exception on noAccess method");
+            }
+
         } catch (NamingException e) {
             System.out.print("Exception:");
             e.printStackTrace();
         } catch (RemoteException e) {
             e.printStackTrace();
         } catch (CreateException e) {
-            e.printStackTrace();
-        } catch (SystemException e) {
-            e.printStackTrace();
-        } catch (NotSupportedException e) {
-            e.printStackTrace();
-        } catch (HeuristicMixedException e) {
-            e.printStackTrace();
-        } catch (HeuristicRollbackException e) {
-            e.printStackTrace();
-        } catch (RollbackException e) {
             e.printStackTrace();
         }
         httpServletResponse.flushBuffer();

Added: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/src/main/webapp/TestJsp.jsp
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/src/main/webapp/TestJsp.jsp?view=auto&rev=560749
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/src/main/webapp/TestJsp.jsp
(added)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/src/main/webapp/TestJsp.jsp
Sun Jul 29 09:07:48 2007
@@ -0,0 +1,52 @@
+<%--
+  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.
+--%>
+<%@ page import="org.apache.geronimo.itest.TestSession" %>
+<%@ page import="javax.naming.InitialContext" %>
+<%@ page import="org.apache.geronimo.itest.TestSessionHome" %>
+<%@ page import="javax.naming.NamingException" %>
+<%@ page import="java.rmi.AccessException" %>
+<%@ page import="java.rmi.RemoteException" %>
+<%@ page import="javax.ejb.CreateException" %>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%
+    ServletOutputStream myout = response.getOutputStream();
+    myout.println("TestServlet principal: " + request.getUserPrincipal().getName());
+    try {
+        InitialContext ctx = new InitialContext();
+
+        //test ejb access using geronimo plan refs
+        TestSessionHome home = (TestSessionHome) ctx.lookup("java:comp/env/TestSession");
+        TestSession sessionBean = home.create();
+        String principalName = sessionBean.testAccess();
+        myout.println("Test EJB principal: " + principalName);
+        try {
+            String bad = sessionBean.testNoAccess();
+            myout.println("NoAccess method call succeeded with principal: " + bad);
+        } catch (AccessException e) {
+            myout.println("Correctly received security exception on noAccess method");
+        }
+
+    } catch (NamingException e) {
+        myout.print("Exception:");
+        e.printStackTrace();
+    } catch (RemoteException e) {
+        e.printStackTrace();
+    } catch (CreateException e) {
+        e.printStackTrace();
+    }
+    myout.flush();
+%>

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/src/main/webapp/TestJsp.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/src/main/webapp/TestJsp.jsp
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/src/main/webapp/TestJsp.jsp
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/src/main/webapp/WEB-INF/geronimo-web.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/src/main/webapp/WEB-INF/geronimo-web.xml?view=auto&rev=560749
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/src/main/webapp/WEB-INF/geronimo-web.xml
(added)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/src/main/webapp/WEB-INF/geronimo-web.xml
Sun Jul 29 09:07:48 2007
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<!--
+  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.
+-->
+
+<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.2">
+    <environment>
+        <moduleId>
+            <groupId>default</groupId>
+            <artifactId>sec-war</artifactId>
+            <version>2.1-SNAPSHOT</version>
+            <type>car</type>
+        </moduleId>
+        <dependencies>
+
+        </dependencies>
+    </environment>
+    
+    <context-root>/sec</context-root>
+    <security-realm-name>test-realm</security-realm-name>
+</web-app>

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/src/main/webapp/WEB-INF/geronimo-web.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/src/main/webapp/WEB-INF/geronimo-web.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/src/main/webapp/WEB-INF/geronimo-web.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/src/main/webapp/WEB-INF/web.xml?view=diff&rev=560749&r1=559903&r2=560749
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/src/main/webapp/WEB-INF/web.xml
(original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/jpa-war/src/main/webapp/WEB-INF/web.xml
Sun Jul 29 09:07:48 2007
@@ -25,16 +25,32 @@
     <display-name>Geronimo EJBRef Itest War</display-name>
 
     <servlet>
-        <display-name>Manifest ClassPath itest servlet</display-name>
+        <display-name>Security itest servlet</display-name>
         <servlet-name>servlet</servlet-name>
         <servlet-class>org.apache.geronimo.itest.TestServlet</servlet-class>
         <load-on-startup>0</load-on-startup>
+        <run-as>
+            <role-name>bar</role-name>
+        </run-as>
+    </servlet>
+    <servlet>
+        <display-name>Security itest jsp</display-name>
+        <servlet-name>testjsp</servlet-name>
+        <jsp-file>/TestJsp.jsp</jsp-file>
+        <load-on-startup>1</load-on-startup>
+        <run-as>
+            <role-name>bar</role-name>
+        </run-as>
     </servlet>
 
     <servlet-mapping>
         <servlet-name>servlet</servlet-name>
         <url-pattern>/servlet</url-pattern>
     </servlet-mapping>
+    <servlet-mapping>
+        <servlet-name>testjsp</servlet-name>
+        <url-pattern>/jsp</url-pattern>
+    </servlet-mapping>
 
     <ejb-ref>
         <ejb-ref-name>TestSession</ejb-ref-name>
@@ -43,29 +59,16 @@
         <remote>org.apache.geronimo.itest.TestSession</remote>
     </ejb-ref>
 
-    <persistence-context-ref>
-        <persistence-context-ref-name>jpa/test</persistence-context-ref-name>
-        <persistence-unit-name>test-unit</persistence-unit-name>
-    </persistence-context-ref>
-    <persistence-unit-ref>
-        <persistence-unit-ref-name>jpa/testEMF</persistence-unit-ref-name>
-        <persistence-unit-name>test-unit</persistence-unit-name>
-    </persistence-unit-ref>
-
-
-<!--
     <security-constraint>
-        <display-name>All</display-name>
         <web-resource-collection>
             <web-resource-name>secureServlet</web-resource-name>
             <url-pattern>/servlet</url-pattern>
+            <url-pattern>/jsp</url-pattern>
             <http-method>GET</http-method>
             <http-method>POST</http-method>
         </web-resource-collection>
         <auth-constraint>
-            <description>All Authenticated</description>
-            <role-name>Authenticated</role-name>
-            <role-name>Everybody</role-name>
+            <role-name>foo</role-name>
         </auth-constraint>
         <user-data-constraint>
             <transport-guarantee>NONE</transport-guarantee>
@@ -76,12 +79,10 @@
         <realm-name>TestRealm</realm-name>
     </login-config>
     <security-role>
-        <role-name>Authenticated</role-name>
+        <role-name>foo</role-name>
     </security-role>
     <security-role>
-        <role-name>Everybody</role-name>
+        <role-name>bar</role-name>
     </security-role>
--->
-
 
 </web-app>

Modified: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/pom.xml?view=diff&rev=560749&r1=559903&r2=560749
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/pom.xml (original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/pom.xml Sun Jul 29 09:07:48
2007
@@ -25,9 +25,9 @@
         <version>2.1-SNAPSHOT</version>
     </parent>
 
-    <artifactId>jpa-tests</artifactId>
+    <artifactId>sec-tests</artifactId>
     <packaging>pom</packaging>
-    <name>Geronimo TestSuite :: Enterprise Testsuite :: JPA Tests</name>
+    <name>Geronimo TestSuite :: Enterprise Testsuite :: Security Tests</name>
 
     <profiles>
         <profile>



Mime
View raw message