geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject svn commit: r657986 - in /geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests: ./ sec-client/ sec-client/src/ sec-client/src/main/java/org/apache/geronimo/itest/ sec-client/src/main/java/org/apache/geronimo/test/ sec-client/src/main/resource...
Date Mon, 19 May 2008 21:22:41 GMT
Author: djencks
Date: Mon May 19 14:22:41 2008
New Revision: 657986

URL: http://svn.apache.org/viewvc?rev=657986&view=rev
Log:
GERONIMO-4034 example of app client to openejb security

Added:
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/
      - copied from r657575, geronimo/server/trunk/testsuite/enterprise-testsuite/sec-client/
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/goals.txt
      - copied unchanged from r657983, geronimo/server/trunk/testsuite/enterprise-testsuite/sec-client/goals.txt
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/pom.xml
      - copied, changed from r657983, geronimo/server/trunk/testsuite/enterprise-testsuite/sec-client/pom.xml
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/
      - copied from r657983, geronimo/server/trunk/testsuite/enterprise-testsuite/sec-client/src/
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/main/java/org/apache/geronimo/itest/
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/main/java/org/apache/geronimo/itest/TestCallbackHandler.java
  (with props)
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/main/java/org/apache/geronimo/itest/TestClient.java
  (with props)
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/main/java/org/apache/geronimo/itest/TestSession.java
      - copied, changed from r657575, geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/src/main/java/org/apache/geronimo/itest/TestSession.java
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/main/java/org/apache/geronimo/itest/TestSessionHome.java
      - copied, changed from r657575, geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/src/main/java/org/apache/geronimo/itest/TestSessionHome.java
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/src/main/resources/META-INF/application.xml
  (with props)
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/src/test/java/org/apache/geronimo/testsuite/security/ClientTest.java
  (with props)
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/java/org/apache/geronimo/itest/TestInjectionServlet.java
      - copied, changed from r657575, geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/java/org/apache/geronimo/itest/TestServlet.java
Removed:
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/main/java/org/apache/geronimo/test/
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/test/
Modified:
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/pom.xml
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/main/resources/META-INF/geronimo-application-client.xml
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/pom.xml
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/src/test/java/org/apache/geronimo/testsuite/security/RunAsTest.java
    geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/webapp/WEB-INF/web.xml

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?rev=657986&r1=657985&r2=657986&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/pom.xml (original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/pom.xml Mon May 19 14:22:41
2008
@@ -38,6 +38,7 @@
     <modules>
         <module>sec-ejb</module>
         <module>sec-war</module>
+        <module>sec-client</module>
         <module>sec-ear</module>
     </modules>
 

Copied: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/pom.xml
(from r657983, geronimo/server/trunk/testsuite/enterprise-testsuite/sec-client/pom.xml)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/pom.xml?p2=geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/pom.xml&p1=geronimo/server/trunk/testsuite/enterprise-testsuite/sec-client/pom.xml&r1=657983&r2=657986&rev=657986&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-client/pom.xml (original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/pom.xml Mon
May 19 14:22:41 2008
@@ -26,7 +26,7 @@
 
     <parent>
         <groupId>org.apache.geronimo.testsuite</groupId>
-        <artifactId>enterprise-testsuite</artifactId>
+        <artifactId>sec-tests</artifactId>
         <version>2.2-SNAPSHOT</version>
     </parent>
 
@@ -42,6 +42,12 @@
 
     <dependencies>
         <dependency>
+            <groupId>org.apache.geronimo.testsuite</groupId>
+            <artifactId>sec-ejb</artifactId>
+            <version>${version}</version>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
             <groupId>org.apache.geronimo.framework</groupId>
             <artifactId>geronimo-security</artifactId>
             <version>${version}</version>
@@ -57,12 +63,12 @@
                 <configuration>
                     <archive>
                         <manifest>
-                            <mainClass>org.apache.geronimo.test.TestClient</mainClass>
+                            <mainClass>org.apache.geronimo.itest.TestClient</mainClass>
                         </manifest>
                     </archive>
                 </configuration>
             </plugin>
-
+ <!--
             <plugin>
                 <groupId>org.apache.geronimo.buildsupport</groupId>
                 <artifactId>testsuite-maven-plugin</artifactId>
@@ -73,10 +79,6 @@
                         <goals>
                             <goal>generate-surefire-xml</goal>
                         </goals>
-                        <!-- 
-                        Merging the configuration of this plugin with the one it inherits.
-                        Updating the reports in the grandparent directly as we'd have missed
the boat for the parent's install phase.
-                        -->
                         <configuration>
                             <grandParent>true</grandParent>
                         </configuration>
@@ -137,6 +139,7 @@
                     </execution>
                 </executions>
             </plugin>
+-->
         </plugins>
     </build>
 

Added: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/main/java/org/apache/geronimo/itest/TestCallbackHandler.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/main/java/org/apache/geronimo/itest/TestCallbackHandler.java?rev=657986&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/main/java/org/apache/geronimo/itest/TestCallbackHandler.java
(added)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/main/java/org/apache/geronimo/itest/TestCallbackHandler.java
Mon May 19 14:22:41 2008
@@ -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.itest;
+
+import java.io.IOException;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+
+public class TestCallbackHandler implements CallbackHandler {
+
+    public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException
{
+        for (int i = 0; i < callbacks.length; i++) {
+            Callback callback = callbacks[i];
+            if (callback instanceof NameCallback) {
+                ((NameCallback)callback).setName("bar");
+            } else if (callback instanceof PasswordCallback) {
+                ((PasswordCallback)callback).setPassword("bar".toCharArray());
+            } else {
+                throw new UnsupportedCallbackException(callback);
+            }
+            System.out.println("CallbackHandler set user=bar, password=bar");
+        }
+    }
+}

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

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

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

Added: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/main/java/org/apache/geronimo/itest/TestClient.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/main/java/org/apache/geronimo/itest/TestClient.java?rev=657986&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/main/java/org/apache/geronimo/itest/TestClient.java
(added)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/main/java/org/apache/geronimo/itest/TestClient.java
Mon May 19 14:22:41 2008
@@ -0,0 +1,63 @@
+/**
+ *  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.rmi.AccessException;
+import java.rmi.RemoteException;
+
+import javax.ejb.EJB;
+
+import org.apache.geronimo.security.ContextManager;
+
+public class TestClient {
+    
+    @EJB(name="TestSession")
+    private static TestSessionHome sessionHome;
+
+    public static void main(String [] args) throws Exception {
+
+        try {
+            new TestClient().test();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        
+        // needs to be forced because of a bug
+        System.exit(0);
+    }
+
+    public void test() throws Exception {
+        System.out.println("Hello World!");
+        System.out.println("Context: " + ContextManager.getCurrentCaller());
+        try {
+            TestSession session = sessionHome.create();
+            String principalName = session.testAccess();
+            System.out.println("Test EJB principal: " + principalName);
+            try {
+                String bad = session.testNoAccess();
+                System.out.println("NoAccess method call succeeded with principal: " + bad);
+            } catch (AccessException e) {
+                System.out.println("Correctly received security exception on noAccess method");
+            }
+        } catch (RemoteException e) {
+            e.printStackTrace();
+        }
+    }
+    
+}

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

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

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

Copied: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/main/java/org/apache/geronimo/itest/TestSession.java
(from r657575, geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/src/main/java/org/apache/geronimo/itest/TestSession.java)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/main/java/org/apache/geronimo/itest/TestSession.java?p2=geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/main/java/org/apache/geronimo/itest/TestSession.java&p1=geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/src/main/java/org/apache/geronimo/itest/TestSession.java&r1=657575&r2=657986&rev=657986&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/src/main/java/org/apache/geronimo/itest/TestSession.java
(original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/main/java/org/apache/geronimo/itest/TestSession.java
Mon May 19 14:22:41 2008
@@ -21,8 +21,8 @@
 /**
  * @version $Rev$ $Date$
  */
-public interface TestSession  extends javax.ejb.EJBObject {
+public interface TestSession extends javax.ejb.EJBObject {
     String testAccess() throws RemoteException;
     String testNoAccess() throws RemoteException;
 
-}
+}
\ No newline at end of file

Copied: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/main/java/org/apache/geronimo/itest/TestSessionHome.java
(from r657575, geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/src/main/java/org/apache/geronimo/itest/TestSessionHome.java)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/main/java/org/apache/geronimo/itest/TestSessionHome.java?p2=geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/main/java/org/apache/geronimo/itest/TestSessionHome.java&p1=geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/src/main/java/org/apache/geronimo/itest/TestSessionHome.java&r1=657575&r2=657986&rev=657986&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ejb/src/main/java/org/apache/geronimo/itest/TestSessionHome.java
(original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/main/java/org/apache/geronimo/itest/TestSessionHome.java
Mon May 19 14:22:41 2008
@@ -23,8 +23,8 @@
 /**
  * @version $Rev$ $Date$
  */
-public interface TestSessionHome  extends javax.ejb.EJBHome {
+public interface TestSessionHome extends javax.ejb.EJBHome {
 
     public TestSession create( ) throws RemoteException, CreateException;
 
-}
+}
\ No newline at end of file

Modified: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/main/resources/META-INF/geronimo-application-client.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/main/resources/META-INF/geronimo-application-client.xml?rev=657986&r1=657983&r2=657986&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/main/resources/META-INF/geronimo-application-client.xml
(original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-client/src/main/resources/META-INF/geronimo-application-client.xml
Mon May 19 14:22:41 2008
@@ -37,7 +37,25 @@
     </dep:moduleId>
    </dep:server-environment>
 
-   <realm-name>client-properties-realm</realm-name>
-   <callback-handler>org.apache.geronimo.test.TestCallbackHandler</callback-handler>
+   <realm-name>remote-openejb-realm</realm-name>
+   <callback-handler>org.apache.geronimo.itest.TestCallbackHandler</callback-handler>
 
+
+    <gbean name="remote-openejb-realm"
+        class="org.apache.geronimo.security.realm.GenericSecurityRealm">
+        <attribute name="realmName">remote-openejb-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">
+                    <lc:login-domain-name>remote-openejb-realm</lc:login-domain-name>
+                    <lc:login-module-class>org.apache.geronimo.openejb.OpenejbRemoteLoginModule</lc:login-module-class>
+                    <lc:option name="RemoteSecurityRealm">test-realm</lc:option>
+                    <lc:option name="ServerURI">ejbd://localhost:4201</lc:option>
+                </lc:login-module>
+            </lc:login-config>
+        </xml-reference>
+        <reference name="ServerInfo">
+            <name>ServerInfo</name>
+        </reference>
+    </gbean>
 </application-client>

Modified: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/pom.xml?rev=657986&r1=657985&r2=657986&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/pom.xml (original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/pom.xml Mon May
19 14:22:41 2008
@@ -34,6 +34,10 @@
     <name>Geronimo TestSuite :: Enterprise Testsuite :: Security - EAR</name>
     <packaging>ear</packaging>
     
+    <properties>
+        <clientLogFile>${basedir}/target/client.log</clientLogFile>
+    </properties>
+
     <!--
     FIXME: Split this module up... one to build the ear, one to run the tests.
     -->
@@ -52,6 +56,12 @@
             <version>${version}</version>
             <type>war</type>
         </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.testsuite</groupId>
+            <artifactId>sec-client</artifactId>
+            <version>${version}</version>
+            <type>jar</type>
+        </dependency>
     </dependencies>
 
     <build>
@@ -96,6 +106,11 @@
                             <artifactId>sec-ejb</artifactId>
                             <bundleFileName>ejb.jar</bundleFileName>
                         </ejbModule>
+                        <jarModule>
+                            <groupId>org.apache.geronimo.testsuite</groupId>
+                            <artifactId>sec-client</artifactId>
+                            <bundleFileName>client.jar</bundleFileName>
+                        </jarModule>
                     </modules>
                 </configuration>
             </plugin>
@@ -107,6 +122,12 @@
                     <suiteXmlFiles>
                         <suiteXmlFile>${project.build.testOutputDirectory}/testng.xml</suiteXmlFile>
                     </suiteXmlFiles>
+                    <systemProperties>
+                        <property>
+                            <name>clientLogFile</name>
+                            <value>${clientLogFile}</value>
+                        </property>
+                    </systemProperties>
                 </configuration>
             </plugin>
 
@@ -152,6 +173,20 @@
                     </execution>
 
                     <execution>
+                        <phase>pre-integration-test</phase>
+                        <id>run-client</id>
+                        <goals>
+                            <goal>run-client</goal>
+                        </goals>
+                        <configuration>
+                            <moduleId>JEE5/SecClient/1.1/jar</moduleId>
+                            <!--<moduleId>${groupId}/${artifactId}/${version/jar</moduleId>-->
+                            <logOutput>true</logOutput>
+                            <logFile>${clientLogFile}</logFile>
+                        </configuration>
+                    </execution>
+
+                    <execution>
                         <id>undeploy</id>
                         <phase>post-integration-test</phase>
                         <goals>

Added: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/src/main/resources/META-INF/application.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/src/main/resources/META-INF/application.xml?rev=657986&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/src/main/resources/META-INF/application.xml
(added)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/src/main/resources/META-INF/application.xml
Mon May 19 14:22:41 2008
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<application 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/application_1_4.xsd"
version="1.4">
+  <description>security Itest ear</description>
+  <display-name>security Itest ear</display-name>
+  <module>
+    <web>
+      <web-uri>web.war</web-uri>
+      <context-root>/sec</context-root>
+    </web>
+  </module>
+  <module>
+    <ejb>ejb.jar</ejb>
+  </module>
+    <module>
+        <java>client.jar</java>
+    </module>
+</application>
\ No newline at end of file

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/src/main/resources/META-INF/application.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/src/main/resources/META-INF/application.xml
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/src/main/resources/META-INF/application.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/src/test/java/org/apache/geronimo/testsuite/security/ClientTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/src/test/java/org/apache/geronimo/testsuite/security/ClientTest.java?rev=657986&view=auto
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/src/test/java/org/apache/geronimo/testsuite/security/ClientTest.java
(added)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/src/test/java/org/apache/geronimo/testsuite/security/ClientTest.java
Mon May 19 14:22:41 2008
@@ -0,0 +1,64 @@
+/**
+ *  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.security;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.FileInputStream;
+
+import org.apache.geronimo.testsupport.TestSupport;
+import org.testng.annotations.Test;
+
+public class ClientTest extends TestSupport {
+
+    @Test
+    public void testClient() throws Exception {
+        String outputFile = System.getProperty("clientLogFile");
+        assertNotNull(outputFile);
+        FileInputStream in = null;
+        try {
+            in = new FileInputStream(outputFile);
+            BufferedReader reader = 
+                new BufferedReader(new InputStreamReader(in));
+            String output = toString(reader);
+
+            assertTrue("Expected Hello World", output.indexOf("Hello World!") != -1);
+            assertTrue("Expected Principal", output.indexOf("Principal: org.apache.geronimo.security.IdentificationPrincipal")
!= -1);
+            assertTrue("Expected Private Credential", output.indexOf("Private Credential:
org.apache.geronimo.openejb.ServerIdentityToken") != -1);
+
+        } finally {
+            if (in != null) {
+                in.close();
+            }
+        }
+    }
+
+    private String toString(BufferedReader reader)
+        throws IOException {
+        StringBuffer buf = new StringBuffer();
+        String line = null;
+        while ((line = reader.readLine()) != null) {
+            System.out.println(line);
+            buf.append(line).append("\n");
+        }
+        return buf.toString();
+    }
+
+}

Propchange: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/src/test/java/org/apache/geronimo/testsuite/security/ClientTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/src/test/java/org/apache/geronimo/testsuite/security/RunAsTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/src/test/java/org/apache/geronimo/testsuite/security/RunAsTest.java?rev=657986&r1=657985&r2=657986&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/src/test/java/org/apache/geronimo/testsuite/security/RunAsTest.java
(original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-ear/src/test/java/org/apache/geronimo/testsuite/security/RunAsTest.java
Mon May 19 14:22:41 2008
@@ -44,14 +44,23 @@
 
     @Test
     public void testServletRunAs() throws Exception {
-        selenium.open("/sec/servlet");
+        String path = "/sec/servlet";
+        testPath(path);
+    }
+
+    @Test
+    public void testInjectionServletRunAs() throws Exception {
+        testPath("/sec/injectionServlet");
+    }
+
+    private void testPath(String path) throws Exception {
+        selenium.open(path);
         waitForPageLoad();
         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

Copied: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/java/org/apache/geronimo/itest/TestInjectionServlet.java
(from r657575, geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/java/org/apache/geronimo/itest/TestServlet.java)
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/java/org/apache/geronimo/itest/TestInjectionServlet.java?p2=geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/java/org/apache/geronimo/itest/TestInjectionServlet.java&p1=geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/java/org/apache/geronimo/itest/TestServlet.java&r1=657575&r2=657986&rev=657986&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/java/org/apache/geronimo/itest/TestServlet.java
(original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/java/org/apache/geronimo/itest/TestInjectionServlet.java
Mon May 19 14:22:41 2008
@@ -22,6 +22,7 @@
 import java.rmi.RemoteException;
 
 import javax.ejb.CreateException;
+import javax.ejb.EJB;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 import javax.servlet.ServletException;
@@ -34,7 +35,11 @@
 /**
  * @version $Rev$ $Date$
  */
-public class TestServlet extends HttpServlet {
+public class TestInjectionServlet extends HttpServlet {
+
+    @EJB(name="TestSession")
+    private TestSession session;
+
 
     public void init() {
         System.out.println("Test Servlet init");
@@ -44,11 +49,6 @@
         PrintWriter out = httpServletResponse.getWriter();
         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");
-            TestSession session = home.create();
             String principalName = session.testAccess();
             out.println("Test EJB principal: " + principalName);
             try {
@@ -57,17 +57,11 @@
             } 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();
         }
         out.flush();
     }
 
 
-}
+}
\ No newline at end of file

Modified: geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/webapp/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/webapp/WEB-INF/web.xml?rev=657986&r1=657985&r2=657986&view=diff
==============================================================================
--- geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/webapp/WEB-INF/web.xml
(original)
+++ geronimo/server/trunk/testsuite/enterprise-testsuite/sec-tests/sec-war/src/main/webapp/WEB-INF/web.xml
Mon May 19 14:22:41 2008
@@ -34,6 +34,15 @@
         </run-as>
     </servlet>
     <servlet>
+        <display-name>Security itest servlet</display-name>
+        <servlet-name>injectionServlet</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>
@@ -48,6 +57,10 @@
         <url-pattern>/servlet</url-pattern>
     </servlet-mapping>
     <servlet-mapping>
+        <servlet-name>injectionServlet</servlet-name>
+        <url-pattern>/injectionServlet</url-pattern>
+    </servlet-mapping>
+    <servlet-mapping>
         <servlet-name>testjsp</servlet-name>
         <url-pattern>/jsp</url-pattern>
     </servlet-mapping>



Mime
View raw message