[Yanel-commits] rev 28300 - public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/workflow

josias at wyona.com josias at wyona.com
Thu Nov 1 09:20:17 CET 2007


Author: josias
Date: 2007-11-01 09:20:17 +0100 (Thu, 01 Nov 2007)
New Revision: 28300

Modified:
   public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/workflow/RoleCondition.java
Log:
removed IdentityMap and use getEnvironment().getIdentity() instead

Modified: public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/workflow/RoleCondition.java
===================================================================
--- public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/workflow/RoleCondition.java	2007-11-01 08:18:50 UTC (rev 28299)
+++ public/yanel/trunk/src/impl/java/org/wyona/yanel/impl/workflow/RoleCondition.java	2007-11-01 08:20:17 UTC (rev 28300)
@@ -15,12 +15,8 @@
  */
 package org.wyona.yanel.impl.workflow;
 
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
 import org.apache.log4j.Category;
 import org.wyona.security.core.api.Identity;
-import org.wyona.security.core.api.IdentityMap;
 import org.wyona.security.core.api.Role;
 import org.wyona.yanel.core.Resource;
 import org.wyona.yanel.core.api.attributes.WorkflowableV1;
@@ -32,8 +28,6 @@
     
     private static Category log = Category.getInstance(RoleCondition.class);
     
-    public static String IDENTITY_MAP_KEY = "identity-map";
-
     protected Role role;
 
     public void setExpression(String expression) {
@@ -45,11 +39,8 @@
         // TODO: the cast should not be necessary, the workflowable interface should 
         //       extend a resource interface
         Resource resource = ((Resource)workflowable);
-        HttpServletRequest request = resource.getRequest();
         try {
-            // TODO: it should be possible to get the identity from the framework,
-            //       without knowledge duplication
-            Identity identity = getIdentity(request, resource.getRealm().getID());
+            Identity identity = resource.getEnvironment().getIdentity();
             
             if (identity == null) {
                 identity = new Identity();
@@ -71,21 +62,4 @@
         }
     }
 
-    /**
-     * Gets the identity from the session associated with the given request.
-     * @param request
-     * @return identity or null if there is no identity in the session for the current
-     *                  realm or if there is no session at all
-     */
-    private Identity getIdentity(HttpServletRequest request, String realmID) throws Exception {
-        HttpSession session = request.getSession(false);
-        if (session != null) {
-            IdentityMap identityMap = (IdentityMap)session.getAttribute(IDENTITY_MAP_KEY);
-            if (identityMap != null) {
-                return (Identity)identityMap.get(realmID);
-            }
-        }
-        return null;
-    }
-
 }
\ No newline at end of file



More information about the Yanel-commits mailing list