Commits

Anonymous committed 22bc19c

Added lib path to orion app
Put osuser.xml in ear/lib so orion can pick it up
Look up session correctly
EJB now works again in Orion

Comments (0)

Files changed (6)

       <fileset dir="${lib}/core">
         <include name="commons-logging.jar"/>
       </fileset>
+      <fileset dir="example/manager/WEB-INF/classes">
+        <include name="osuser.xml"/>
+      </fileset>
 	  </copy>
     <copy todir="${tmp}/example/manager/WEB-INF/lib">
       <fileset dir="${lib}/optional/">

example/META-INF/orion-application.xml

 		<group name="foobars" />
 	</security-role-mapping>
 	<persistence path="persistence" />
+  <library path="lib" />
 	<user-manager class="com.opensymphony.user.adapter.orion.OrionUserManagerAdapter">
 	</user-manager>
 	<log>

src/etc/orion/orion-user.xml

 	<provider class="com.opensymphony.user.provider.orion.OrionAccessProvider" />
 	<provider class="com.opensymphony.user.provider.orion.OrionCredentialsProvider" />
 	<provider class="com.opensymphony.user.provider.memory.MemoryProfileProvider" />
-<!--
-    <provider class="com.opensymphony.user.provider.castor.CastorAccessProvider" />
-	<provider class="com.opensymphony.user.provider.castor.CastorCredentialsProvider" />
-	<provider class="com.opensymphony.user.provider.castor.CastorProfileProvider" />
- -->
 </opensymphony-user>

src/java/com/opensymphony/user/provider/ejb/EJBAccessProvider.java

 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import java.rmi.RemoteException;
+
 import java.util.*;
 
 import javax.ejb.CreateException;
  * @author <a href="mailto:joe@truemesh.com">Joe Walnes</a>
  * @author <a href="mailto:mike@atlassian.com">Mike Cannon-Brookes</a>
  * @author <a href="mailto:plightbo@cisco.com">Patrick Lightbody</a>
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
  */
 public class EJBAccessProvider implements AccessProvider {
     //~ Static fields/initializers /////////////////////////////////////////////
 
-    private static final Log logger = LogFactory.getLog(EJBProfileProvider.class);
+    private static final Log log = LogFactory.getLog(EJBProfileProvider.class);
 
     //~ Instance fields ////////////////////////////////////////////////////////
 
-    private UserManagerSession session;
+    private UserManager session;
 
     //~ Methods ////////////////////////////////////////////////////////////////
 
         }
 
         try {
-            if (logger.isDebugEnabled()) {
-                logger.debug("adding user (" + username + ") to group (" + groupname + ")");
+            if (log.isDebugEnabled()) {
+                log.debug("adding user (" + username + ") to group (" + groupname + ")");
             }
 
             return session.addToGroup(username, groupname);
     }
 
     public boolean handles(String name) {
-        if (session.groupExists(name)) {
-            return true;
-        }
+        try {
+            if (session.groupExists(name)) {
+                return true;
+            }
 
-        // @TODO: consider this! It binds the users and groups together into one place
-        if (session.userExists(name)) {
-            return true;
+            // @TODO: consider this! It binds the users and groups together into one place
+            if (session.userExists(name)) {
+                return true;
+            }
+        } catch (RemoteException e) {
+            log.error(e.getMessage(), e);
         }
 
         return false;
     }
 
     public boolean inGroup(String username, String groupname) {
-        return session.isUserInGroup(username, groupname);
+        try {
+            return session.isUserInGroup(username, groupname);
+        } catch (RemoteException e) {
+            log.error(e.getMessage(), e);
+        }
+
+        return false;
     }
 
     public boolean init(Properties properties) {
         try {
             String managerLocation = properties.getProperty("location.manager", UserManagerHomeFactory.JNDI_NAME);
-            session = (UserManagerSession) EJBUtils.lookup(managerLocation, UserManagerSession.class);
+            session = ((UserManagerHome) EJBUtils.lookup(managerLocation, UserManagerHome.class)).create();
 
             return true;
         } catch (Exception e) {
-            logger.fatal("Unable to look up session bean", e);
+            log.fatal("Unable to look up session bean", e);
             throw new UserManagerImplementationException("Unable to look up user manager session bean", e);
         }
     }
 
     public List list() {
-        return session.getGroupNames();
+        try {
+            return session.getGroupNames();
+        } catch (RemoteException e) {
+            log.error(e.getMessage(), e);
+        }
+
+        return Collections.EMPTY_LIST;
     }
 
     public List listGroupsContainingUser(String username) {
         try {
             return session.getUserGroups(username);
         } catch (Exception e) {
-            logger.info(e);
+            log.info(e);
             throw new UserManagerImplementationException(e);
         }
     }
             return session.getUsersInGroup(groupname);
         } catch (Exception e) {
             e.printStackTrace();
-            logger.info(e);
+            log.info(e);
             throw new UserManagerImplementationException(e);
         }
     }
     }
 
     public boolean removeFromGroup(String username, String groupname) {
-        if (logger.isDebugEnabled()) {
-            logger.debug("removing user (" + username + ") from group (" + groupname + ")");
+        if (log.isDebugEnabled()) {
+            log.debug("removing user (" + username + ") from group (" + groupname + ")");
         }
 
         try {

src/java/com/opensymphony/user/provider/ejb/EJBCredentialsProvider.java

 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import java.rmi.RemoteException;
+
 import java.util.List;
 import java.util.Properties;
 
 /**
  * @author <a href="mailto:joe@truemesh.com">Joe Walnes</a>
  * @author <a href="mailto:mike@atlassian.com">Mike Cannon-Brookes</a>
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
  */
 public class EJBCredentialsProvider implements CredentialsProvider {
     //~ Static fields/initializers /////////////////////////////////////////////
 
-    private static final Log logger = LogFactory.getLog(EJBCredentialsProvider.class);
+    private static final Log log = LogFactory.getLog(EJBCredentialsProvider.class);
 
     //~ Instance fields ////////////////////////////////////////////////////////
 
-    private UserManagerSession session;
+    private UserManager session;
 
     //~ Methods ////////////////////////////////////////////////////////////////
 
     public boolean authenticate(String name, String password) {
-        if (logger.isDebugEnabled()) {
-            logger.debug("EJBCredentialsProvider.authenticate");
+        if (log.isDebugEnabled()) {
+            log.debug("EJBCredentialsProvider.authenticate");
         }
 
         try {
     }
 
     public boolean changePassword(String name, String password) {
-        if (logger.isDebugEnabled()) {
-            logger.debug("EJBCredentialsProvider.changePassword");
+        if (log.isDebugEnabled()) {
+            log.debug("EJBCredentialsProvider.changePassword");
         }
 
         try {
     }
 
     public boolean create(String name) {
-        if (logger.isDebugEnabled()) {
-            logger.debug("create() name = " + name);
+        if (log.isDebugEnabled()) {
+            log.debug("create() name = " + name);
         }
 
         try {
             return session.createUser(name);
         } catch (CreateException e) {
-            logger.error("CreateException creating : " + name, e);
+            log.error("CreateException creating : " + name, e);
 
             return false;
         } catch (Exception e) {
     }
 
     public boolean handles(String name) {
-        if (session.userExists(name)) {
-            return true;
+        try {
+            if (session.userExists(name)) {
+                return true;
+            }
+        } catch (RemoteException e) {
+            log.error(e.getMessage(), e);
         }
 
         return false;
     public boolean init(Properties properties) {
         try {
             String managerLocation = properties.getProperty("location.manager", UserManagerHomeFactory.JNDI_NAME);
-            session = (UserManagerSession) EJBUtils.lookup(managerLocation, UserManagerSession.class);
+            session = ((UserManagerHome) EJBUtils.lookup(managerLocation, UserManagerHome.class)).create();
 
             return true;
         } catch (Exception e) {
-            logger.fatal("Unable to look up session bean", e);
+            log.fatal("Unable to look up session bean", e);
             throw new UserManagerImplementationException("Unable to look up user manager session bean", e);
         }
     }
 
     public List list() {
-        if (logger.isDebugEnabled()) {
-            logger.debug("EJBCredentialsProvider.list");
+        if (log.isDebugEnabled()) {
+            log.debug("EJBCredentialsProvider.list");
         }
 
         try {
     }
 
     public boolean remove(String name) {
-        if (logger.isDebugEnabled()) {
-            logger.debug("EJBCredentialsProvider.remove");
+        if (log.isDebugEnabled()) {
+            log.debug("EJBCredentialsProvider.remove");
         }
 
         try {

src/java/com/opensymphony/user/provider/ejb/EJBProfileProvider.java

 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import java.rmi.RemoteException;
+
 import java.util.List;
 import java.util.Properties;
 
 /**
  * @author <a href="mailto:joe@truemesh.com">Joe Walnes</a>
  * @author <a href="mailto:mike@atlassian.com">Mike Cannon-Brookes</a>
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
  */
 public class EJBProfileProvider implements ProfileProvider {
     //~ Static fields/initializers /////////////////////////////////////////////
 
-    private static final Log logger = LogFactory.getLog(EJBProfileProvider.class);
+    private static final Log log = LogFactory.getLog(EJBProfileProvider.class);
 
     //~ Instance fields ////////////////////////////////////////////////////////
 
-    private UserManagerSession session;
+    private UserManager session;
 
     //~ Methods ////////////////////////////////////////////////////////////////
 
     }
 
     public boolean handles(String name) {
-        if (session.userExists(name)) {
-            return true;
-        }
+        try {
+            if (session.userExists(name)) {
+                return true;
+            }
 
-        if (session.groupExists(name)) {
-            return true;
+            if (session.groupExists(name)) {
+                return true;
+            }
+        } catch (RemoteException e) {
+            log.error(e.getMessage(), e);
         }
 
         return false;
     public boolean init(Properties properties) {
         try {
             String managerLocation = properties.getProperty("location.manager", UserManagerHomeFactory.JNDI_NAME);
-            session = (UserManagerSession) EJBUtils.lookup(managerLocation, UserManagerSession.class);
+            session = ((UserManagerHome) EJBUtils.lookup(managerLocation, UserManagerHome.class)).create();
 
             return true;
         } catch (Exception e) {
-            logger.fatal("Unable to look up session bean", e);
+            log.fatal("Unable to look up session bean", e);
             throw new UserManagerImplementationException("Unable to look up user manager session bean", e);
         }
     }