You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ec...@apache.org on 2008/03/28 08:05:02 UTC

svn commit: r642105 - in /geronimo/samples/branches/1.0/migration-security: ./ modules/security.ear/src/META-INF/geronimo/ modules/security.jar/src/META-INF/ modules/security.jar/src/META-INF/geronimo/ modules/security.jar/src/com/ibm/j2g/ modules/secu...

Author: ecraig
Date: Fri Mar 28 00:05:00 2008
New Revision: 642105

URL: http://svn.apache.org/viewvc?rev=642105&view=rev
Log:
GERONIMO-3910
Cleaned up samples/branches/1.0/migration-security


Added:
    geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/
    geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/
    geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/
    geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/demo/
    geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/demo/security/
    geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/demo/security/BusinessLogic.java
    geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/demo/security/BusinessLogicEJB.java
    geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/demo/security/BusinessLogicHome.java
    geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/demo/security/BusinessLogicSession.java
    geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/demo/security/BusinessLogicUtil.java
    geronimo/samples/branches/1.0/migration-security/modules/security.war/src/org/
    geronimo/samples/branches/1.0/migration-security/modules/security.war/src/org/apache/
    geronimo/samples/branches/1.0/migration-security/modules/security.war/src/org/apache/geronimo/
    geronimo/samples/branches/1.0/migration-security/modules/security.war/src/org/apache/geronimo/demo/
    geronimo/samples/branches/1.0/migration-security/modules/security.war/src/org/apache/geronimo/demo/security/
    geronimo/samples/branches/1.0/migration-security/modules/security.war/src/org/apache/geronimo/demo/security/LogoutServlet.java
    geronimo/samples/branches/1.0/migration-security/modules/security.war/src/org/apache/geronimo/demo/security/UploadServlet.java
Removed:
    geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/com/ibm/j2g/
    geronimo/samples/branches/1.0/migration-security/modules/security.war/src/com/ibm/j2g/
Modified:
    geronimo/samples/branches/1.0/migration-security/build.xml
    geronimo/samples/branches/1.0/migration-security/modules/security.ear/src/META-INF/geronimo/geronimo-application.xml
    geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/META-INF/ejb-jar.xml
    geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/META-INF/geronimo/openejb-jar.xml
    geronimo/samples/branches/1.0/migration-security/modules/security.war/src/WEB-INF/geronimo/geronimo-web.xml
    geronimo/samples/branches/1.0/migration-security/modules/security.war/src/WEB-INF/web.xml

Modified: geronimo/samples/branches/1.0/migration-security/build.xml
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-security/build.xml?rev=642105&r1=642104&r2=642105&view=diff
==============================================================================
--- geronimo/samples/branches/1.0/migration-security/build.xml (original)
+++ geronimo/samples/branches/1.0/migration-security/build.xml Fri Mar 28 00:05:00 2008
@@ -114,7 +114,7 @@
             <arg value="--password"/>
             <arg value="${geronimo.password}"/>
             <arg value="undeploy"/>
-            <arg value="com/ibm/j2g/security"/>
+            <arg value="org/apache/geronimo/demo/security"/>
         </java>
 
         <java jar="${geronimo.home}/bin/deployer.jar" fork="true">

Modified: geronimo/samples/branches/1.0/migration-security/modules/security.ear/src/META-INF/geronimo/geronimo-application.xml
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-security/modules/security.ear/src/META-INF/geronimo/geronimo-application.xml?rev=642105&r1=642104&r2=642105&view=diff
==============================================================================
--- geronimo/samples/branches/1.0/migration-security/modules/security.ear/src/META-INF/geronimo/geronimo-application.xml (original)
+++ geronimo/samples/branches/1.0/migration-security/modules/security.ear/src/META-INF/geronimo/geronimo-application.xml Fri Mar 28 00:05:00 2008
@@ -16,7 +16,7 @@
   limitations under the License.
 -->
 <application xmlns="http://geronimo.apache.org/xml/ns/j2ee/application"
-    configId="com/ibm/j2g/security"
+    configId="org/apache/geronimo/demo/security"
     parentId="org/apache/geronimo/Server">
 
     <security xmlns="http://geronimo.apache.org/xml/ns/security">

Modified: geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/META-INF/ejb-jar.xml
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/META-INF/ejb-jar.xml?rev=642105&r1=642104&r2=642105&view=diff
==============================================================================
--- geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/META-INF/ejb-jar.xml (original)
+++ geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/META-INF/ejb-jar.xml Fri Mar 28 00:05:00 2008
@@ -32,9 +32,9 @@
 
          <ejb-name>BusinessLogic</ejb-name>
 
-         <home>com.ibm.j2g.security.BusinessLogicHome</home>
-         <remote>com.ibm.j2g.security.BusinessLogic</remote>
-         <ejb-class>com.ibm.j2g.security.BusinessLogicSession</ejb-class>
+         <home>org.apache.geronimo.demo.security.BusinessLogicHome</home>
+         <remote>org.apache.geronimo.demo.security.BusinessLogic</remote>
+         <ejb-class>org.apache.geronimo.demo.security.BusinessLogicSession</ejb-class>
          <session-type>Stateless</session-type>
          <transaction-type>Container</transaction-type>
 

Modified: geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/META-INF/geronimo/openejb-jar.xml
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/META-INF/geronimo/openejb-jar.xml?rev=642105&r1=642104&r2=642105&view=diff
==============================================================================
--- geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/META-INF/geronimo/openejb-jar.xml (original)
+++ geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/META-INF/geronimo/openejb-jar.xml Fri Mar 28 00:05:00 2008
@@ -17,8 +17,8 @@
 -->
 <openejb-jar
     xmlns="http://www.openejb.org/xml/ns/openejb-jar"
-    configId="com/ibm/j2g/security/ejb"
-    parentId="com/ibm/j2g/security">
+    configId="org/apache/geronimo/demo/security/ejb"
+    parentId="org/apache/geronimo/demo/security">
 
     <enterprise-beans>
         <session>

Added: geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/demo/security/BusinessLogic.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/demo/security/BusinessLogic.java?rev=642105&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/demo/security/BusinessLogic.java (added)
+++ geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/demo/security/BusinessLogic.java Fri Mar 28 00:05:00 2008
@@ -0,0 +1,20 @@
+/*
+ * Generated by XDoclet - Do not edit!
+ */
+package org.apache.geronimo.demo.security;
+
+/**
+ * Remote interface for BusinessLogic.
+ * @xdoclet-generated at ${TODAY}
+ * @copyright The XDoclet Team
+ * @author XDoclet
+ * @version ${version}
+ */
+public interface BusinessLogic
+   extends javax.ejb.EJBObject
+{
+
+   public java.lang.String upload(  )
+      throws java.rmi.RemoteException;
+
+}

Added: geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/demo/security/BusinessLogicEJB.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/demo/security/BusinessLogicEJB.java?rev=642105&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/demo/security/BusinessLogicEJB.java (added)
+++ geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/demo/security/BusinessLogicEJB.java Fri Mar 28 00:05:00 2008
@@ -0,0 +1,89 @@
+/*
+* 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.demo.security;
+
+import java.rmi.RemoteException;
+
+import javax.ejb.EJBException;
+import javax.ejb.SessionBean;
+import javax.ejb.SessionContext;
+
+/**
+ * Business logic stateless bean.
+ * 
+ * @ejb.bean name="BusinessLogic" display-name="BusinessLogic bean"
+ *           jndi-name="ejb/BusinessLogic" type="Stateless" view-type="remote"
+ */
+public class BusinessLogicEJB implements SessionBean {
+
+    /** Serial version uid. */
+    private static final long serialVersionUID = 4688250533090120601L;
+
+    /**
+     * @ejb.interface-method
+     * @ejb.permission role-name = "uploader"
+     * 
+     * @return result message
+     */
+    public String upload() {
+        return "File successfully uploaded";
+    }
+
+    /**
+     * @see javax.ejb.SessionBean#setSessionContext(javax.ejb.SessionContext)
+     */
+    public void setSessionContext(SessionContext ctx) throws EJBException,
+            RemoteException {
+        // Nothing...
+    }
+
+    /**
+     * Create method.
+     * 
+     * @ejb.create-method
+     * @ejb.permission unchecked="true"
+     * 
+     * @throws EJBException
+     * @throws RemoteException
+     */
+    public void ejbCreate() throws EJBException, RemoteException {
+        // Nothing...
+    }
+
+    /**
+     * @see javax.ejb.SessionBean#ejbRemove()
+     */
+    public void ejbRemove() throws EJBException, RemoteException {
+        // Nothing...
+    }
+
+    /**
+     * @see javax.ejb.SessionBean#ejbActivate()
+     */
+    public void ejbActivate() throws EJBException, RemoteException {
+        // Nothing...
+
+    }
+
+    /**
+     * @see javax.ejb.SessionBean#ejbPassivate()
+     */
+    public void ejbPassivate() throws EJBException, RemoteException {
+        // Nothing...
+    }
+}

Added: geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/demo/security/BusinessLogicHome.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/demo/security/BusinessLogicHome.java?rev=642105&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/demo/security/BusinessLogicHome.java (added)
+++ geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/demo/security/BusinessLogicHome.java Fri Mar 28 00:05:00 2008
@@ -0,0 +1,22 @@
+/*
+ * Generated by XDoclet - Do not edit!
+ */
+package org.apache.geronimo.demo.security;
+
+/**
+ * Home interface for BusinessLogic.
+ * @xdoclet-generated at ${TODAY}
+ * @copyright The XDoclet Team
+ * @author XDoclet
+ * @version ${version}
+ */
+public interface BusinessLogicHome
+   extends javax.ejb.EJBHome
+{
+   public static final String COMP_NAME="java:comp/env/ejb/BusinessLogic";
+   public static final String JNDI_NAME="ejb/BusinessLogic";
+
+   public org.apache.geronimo.demo.security.BusinessLogic create()
+      throws java.rmi.RemoteException,javax.ejb.CreateException,java.rmi.RemoteException;
+
+}

Added: geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/demo/security/BusinessLogicSession.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/demo/security/BusinessLogicSession.java?rev=642105&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/demo/security/BusinessLogicSession.java (added)
+++ geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/demo/security/BusinessLogicSession.java Fri Mar 28 00:05:00 2008
@@ -0,0 +1,42 @@
+/*
+ * Generated by XDoclet - Do not edit!
+ */
+package org.apache.geronimo.demo.security;
+
+/**
+ * Session layer for BusinessLogic.
+ * @xdoclet-generated at ${TODAY}
+ * @copyright The XDoclet Team
+ * @author XDoclet
+ * @version ${version}
+ */
+public class BusinessLogicSession
+   extends org.apache.geronimo.demo.security.BusinessLogicEJB
+   implements javax.ejb.SessionBean
+{
+   public void ejbActivate() throws javax.ejb.EJBException, java.rmi.RemoteException
+   {
+
+      super.ejbActivate();
+   }
+
+   public void ejbPassivate() throws javax.ejb.EJBException, java.rmi.RemoteException
+   {
+      super.ejbPassivate();
+   }
+
+   public void setSessionContext(javax.ejb.SessionContext ctx) throws javax.ejb.EJBException, java.rmi.RemoteException
+   {
+      super.setSessionContext(ctx);
+   }
+
+   public void unsetSessionContext() 
+   {
+   }
+
+   public void ejbRemove() throws javax.ejb.EJBException, java.rmi.RemoteException
+   {
+      super.ejbRemove();
+   }
+
+}

Added: geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/demo/security/BusinessLogicUtil.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/demo/security/BusinessLogicUtil.java?rev=642105&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/demo/security/BusinessLogicUtil.java (added)
+++ geronimo/samples/branches/1.0/migration-security/modules/security.jar/src/org/apache/geronimo/demo/security/BusinessLogicUtil.java Fri Mar 28 00:05:00 2008
@@ -0,0 +1,130 @@
+/*
+ * Generated file - Do not edit!
+ */
+package org.apache.geronimo.demo.security;
+
+/**
+ * Utility class for BusinessLogic.
+ * @xdoclet-generated at ${TODAY}
+ * @copyright The XDoclet Team
+ * @author XDoclet
+ * @version ${version}
+ */
+public class BusinessLogicUtil
+{
+   /** Cached remote home (EJBHome). Uses lazy loading to obtain its value (loaded by getHome() methods). */
+   private static org.apache.geronimo.demo.security.BusinessLogicHome cachedRemoteHome = null;
+
+   private static Object lookupHome(java.util.Hashtable environment, String jndiName, Class narrowTo) throws javax.naming.NamingException {
+      // Obtain initial context
+      javax.naming.InitialContext initialContext = new javax.naming.InitialContext(environment);
+      try {
+         Object objRef = initialContext.lookup(jndiName);
+         // only narrow if necessary
+         if (java.rmi.Remote.class.isAssignableFrom(narrowTo))
+            return javax.rmi.PortableRemoteObject.narrow(objRef, narrowTo);
+         else
+            return objRef;
+      } finally {
+         initialContext.close();
+      }
+   }
+
+   // Home interface lookup methods
+
+   /**
+    * Obtain remote home interface from default initial context
+    * @return Home interface for BusinessLogic. Lookup using COMP_NAME
+    */
+   public static org.apache.geronimo.demo.security.BusinessLogicHome getHome() throws javax.naming.NamingException
+   {
+      if (cachedRemoteHome == null) {
+            cachedRemoteHome = (org.apache.geronimo.demo.security.BusinessLogicHome) lookupHome(null, org.apache.geronimo.demo.security.BusinessLogicHome.COMP_NAME, org.apache.geronimo.demo.security.BusinessLogicHome.class);
+      }
+      return cachedRemoteHome;
+   }
+
+   /**
+    * Obtain remote home interface from parameterised initial context
+    * @param environment Parameters to use for creating initial context
+    * @return Home interface for BusinessLogic. Lookup using COMP_NAME
+    */
+   public static org.apache.geronimo.demo.security.BusinessLogicHome getHome( java.util.Hashtable environment ) throws javax.naming.NamingException
+   {
+       return (org.apache.geronimo.demo.security.BusinessLogicHome) lookupHome(environment, org.apache.geronimo.demo.security.BusinessLogicHome.COMP_NAME, org.apache.geronimo.demo.security.BusinessLogicHome.class);
+   }
+
+   /** Cached per JVM server IP. */
+   private static String hexServerIP = null;
+
+   // initialise the secure random instance
+   private static final java.security.SecureRandom seeder = new java.security.SecureRandom();
+
+   /**
+    * A 32 byte GUID generator (Globally Unique ID). These artificial keys SHOULD <strong>NOT </strong> be seen by the user,
+    * not even touched by the DBA but with very rare exceptions, just manipulated by the database and the programs.
+    *
+    * Usage: Add an id field (type java.lang.String) to your EJB, and add setId(XXXUtil.generateGUID(this)); to the ejbCreate method.
+    */
+   public static final String generateGUID(Object o) {
+       StringBuffer tmpBuffer = new StringBuffer(16);
+       if (hexServerIP == null) {
+           java.net.InetAddress localInetAddress = null;
+           try {
+               // get the inet address
+
+               localInetAddress = java.net.InetAddress.getLocalHost();
+           }
+           catch (java.net.UnknownHostException uhe) {
+               System.err.println("BusinessLogicUtil: Could not get the local IP address using InetAddress.getLocalHost()!");
+               // todo: find better way to get around this...
+               uhe.printStackTrace();
+               return null;
+           }
+           byte serverIP[] = localInetAddress.getAddress();
+           hexServerIP = hexFormat(getInt(serverIP), 8);
+       }
+
+       String hashcode = hexFormat(System.identityHashCode(o), 8);
+       tmpBuffer.append(hexServerIP);
+       tmpBuffer.append(hashcode);
+
+       long timeNow      = System.currentTimeMillis();
+       int timeLow       = (int)timeNow & 0xFFFFFFFF;
+       int node          = seeder.nextInt();
+
+       StringBuffer guid = new StringBuffer(32);
+       guid.append(hexFormat(timeLow, 8));
+       guid.append(tmpBuffer.toString());
+       guid.append(hexFormat(node, 8));
+       return guid.toString();
+   }
+
+   private static int getInt(byte bytes[]) {
+       int i = 0;
+       int j = 24;
+       for (int k = 0; j >= 0; k++) {
+           int l = bytes[k] & 0xff;
+           i += l << j;
+           j -= 8;
+       }
+       return i;
+   }
+
+   private static String hexFormat(int i, int j) {
+       String s = Integer.toHexString(i);
+       return padHex(s, j) + s;
+   }
+
+   private static String padHex(String s, int i) {
+       StringBuffer tmpBuffer = new StringBuffer();
+       if (s.length() < i) {
+           for (int j = 0; j < i - s.length(); j++) {
+               tmpBuffer.append('0');
+           }
+       }
+       return tmpBuffer.toString();
+   }
+
+}
+

Modified: geronimo/samples/branches/1.0/migration-security/modules/security.war/src/WEB-INF/geronimo/geronimo-web.xml
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-security/modules/security.war/src/WEB-INF/geronimo/geronimo-web.xml?rev=642105&r1=642104&r2=642105&view=diff
==============================================================================
--- geronimo/samples/branches/1.0/migration-security/modules/security.war/src/WEB-INF/geronimo/geronimo-web.xml (original)
+++ geronimo/samples/branches/1.0/migration-security/modules/security.war/src/WEB-INF/geronimo/geronimo-web.xml Fri Mar 28 00:05:00 2008
@@ -16,8 +16,8 @@
   limitations under the License.
 -->
 <web-app xmlns="http://geronimo.apache.org/xml/ns/web" 
-   configId="com/ibm/j2g/security/web" 
-   parentId="com/ibm/j2g/security">
+   configId="org/apache/geronimo/demo/security/web" 
+   parentId="org/apache/geronimo/demo/security">
 
     <context-root>/security</context-root>
     <context-priority-classloader>true</context-priority-classloader>

Modified: geronimo/samples/branches/1.0/migration-security/modules/security.war/src/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-security/modules/security.war/src/WEB-INF/web.xml?rev=642105&r1=642104&r2=642105&view=diff
==============================================================================
--- geronimo/samples/branches/1.0/migration-security/modules/security.war/src/WEB-INF/web.xml (original)
+++ geronimo/samples/branches/1.0/migration-security/modules/security.war/src/WEB-INF/web.xml Fri Mar 28 00:05:00 2008
@@ -42,13 +42,13 @@
    <servlet>
       <display-name>Upload Servlet</display-name>
       <servlet-name>Upload</servlet-name>
-      <servlet-class>com.ibm.j2g.security.UploadServlet</servlet-class>
+      <servlet-class>org.apache.geronimo.demo.security.UploadServlet</servlet-class>
 
    </servlet>
    <servlet>
       <display-name>Logout Servlet</display-name>
       <servlet-name>Logout</servlet-name>
-      <servlet-class>com.ibm.j2g.security.LogoutServlet</servlet-class>
+      <servlet-class>org.apache.geronimo.demo.security.LogoutServlet</servlet-class>
 
    </servlet>
 
@@ -121,8 +121,8 @@
    <ejb-ref >
       <ejb-ref-name>ejb/BusinessLogic</ejb-ref-name>
       <ejb-ref-type>Session</ejb-ref-type>
-      <home>com.ibm.j2g.security.BusinessLogicHome</home>
-      <remote>com.ibm.j2g.security.BusinessLogic</remote>
+      <home>org.apache.geronimo.demo.security.BusinessLogicHome</home>
+      <remote>org.apache.geronimo.demo.security.BusinessLogic</remote>
       <ejb-link>BusinessLogic</ejb-link>
    </ejb-ref>
 

Added: geronimo/samples/branches/1.0/migration-security/modules/security.war/src/org/apache/geronimo/demo/security/LogoutServlet.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-security/modules/security.war/src/org/apache/geronimo/demo/security/LogoutServlet.java?rev=642105&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-security/modules/security.war/src/org/apache/geronimo/demo/security/LogoutServlet.java (added)
+++ geronimo/samples/branches/1.0/migration-security/modules/security.war/src/org/apache/geronimo/demo/security/LogoutServlet.java Fri Mar 28 00:05:00 2008
@@ -0,0 +1,38 @@
+/*
+* 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.demo.security;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class LogoutServlet extends HttpServlet {
+
+    /**
+     * @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest,
+     *      javax.servlet.http.HttpServletResponse)
+     */
+    protected void service(HttpServletRequest req, HttpServletResponse resp)
+            throws ServletException, IOException {
+        req.getSession().invalidate();
+        resp.sendRedirect(req.getContextPath() + "/");
+        return;
+    }
+}

Added: geronimo/samples/branches/1.0/migration-security/modules/security.war/src/org/apache/geronimo/demo/security/UploadServlet.java
URL: http://svn.apache.org/viewvc/geronimo/samples/branches/1.0/migration-security/modules/security.war/src/org/apache/geronimo/demo/security/UploadServlet.java?rev=642105&view=auto
==============================================================================
--- geronimo/samples/branches/1.0/migration-security/modules/security.war/src/org/apache/geronimo/demo/security/UploadServlet.java (added)
+++ geronimo/samples/branches/1.0/migration-security/modules/security.war/src/org/apache/geronimo/demo/security/UploadServlet.java Fri Mar 28 00:05:00 2008
@@ -0,0 +1,85 @@
+/*
+* 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.demo.security;
+
+import java.io.IOException;
+import java.rmi.RemoteException;
+
+import javax.ejb.CreateException;
+import javax.naming.NamingException;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.geronimo.demo.security.BusinessLogic;
+import org.apache.geronimo.demo.security.BusinessLogicHome;
+import org.apache.geronimo.demo.security.BusinessLogicUtil;
+
+public class UploadServlet extends HttpServlet {
+
+    /** Business logic reference */
+    private BusinessLogicHome logicHome;
+
+    /**
+     * @see javax.servlet.Servlet#destroy()
+     */
+    public void destroy() {
+        logicHome = null;
+        super.destroy();
+    }
+
+    /**
+     * @see javax.servlet.GenericServlet#init()
+     */
+    public void init() throws ServletException {
+        super.init();
+        try {
+            logicHome = BusinessLogicUtil.getHome();
+        } catch (Throwable t) {
+            throw new ServletException(t);
+        }
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest,
+     *      javax.servlet.http.HttpServletResponse)
+     */
+    protected void service(HttpServletRequest req, HttpServletResponse resp)
+            throws ServletException, IOException {
+        BusinessLogic logic = getLogic();
+        req.setAttribute("result", logic.upload());
+        req.getRequestDispatcher("main.jsp").forward(req, resp);
+    }
+
+    /**
+     * Helper for getting business logic bean reference.
+     * 
+     * @return business logic bean reference
+     * @throws ServletException
+     *             wrapper exception
+     */
+    protected BusinessLogic getLogic() throws ServletException {
+        try {
+            return logicHome.create();
+        } catch (RemoteException e) {
+            throw new ServletException(e);
+        } catch (CreateException e) {
+            throw new ServletException(e);
+        }
+    }
+}