[Yanel-commits] rev 26033 - public/yanel/trunk/src/resources/xml/src/java/org/wyona/yanel/impl/resources

michi at wyona.com michi at wyona.com
Tue Jul 17 10:59:41 CEST 2007


Author: michi
Date: 2007-07-17 10:59:41 +0200 (Tue, 17 Jul 2007)
New Revision: 26033

Modified:
   public/yanel/trunk/src/resources/xml/src/java/org/wyona/yanel/impl/resources/XMLResource.java
Log:
get username added

Modified: public/yanel/trunk/src/resources/xml/src/java/org/wyona/yanel/impl/resources/XMLResource.java
===================================================================
--- public/yanel/trunk/src/resources/xml/src/java/org/wyona/yanel/impl/resources/XMLResource.java	2007-07-17 08:59:20 UTC (rev 26032)
+++ public/yanel/trunk/src/resources/xml/src/java/org/wyona/yanel/impl/resources/XMLResource.java	2007-07-17 08:59:41 UTC (rev 26033)
@@ -54,6 +54,10 @@
 import org.wyona.yarep.core.RepositoryFactory;
 import org.wyona.yarep.core.Revision;
 import org.wyona.yarep.util.RepoPath;
+
+import org.wyona.security.core.api.Identity;
+import org.wyona.security.core.api.IdentityMap;
+
 import org.xml.sax.InputSource;
 import org.xml.sax.XMLReader;
 import org.xml.sax.helpers.XMLReaderFactory;
@@ -96,6 +100,8 @@
 public class XMLResource extends Resource implements ViewableV2, ModifiableV2, VersionableV2, CreatableV2, IntrospectableV1, TranslatableV1, WorkflowableV1 {
 
     private static Category log = Category.getInstance(XMLResource.class);
+
+    private static String IDENTITY_MAP_KEY = "identity-map";
     
     /**
      *
@@ -169,7 +175,7 @@
                     xsltHandlers[i].getTransformer().setParameter("content-language", getContentLanguage());
 
                     // Username
-                    xsltHandlers[i].getTransformer().setParameter("username", "HUGO");
+                    xsltHandlers[i].getTransformer().setParameter("username", getUsername());
                 }
                 
                 // create i18n transformer:
@@ -692,4 +698,14 @@
         return WorkflowHelper.getWorkflowIntrospection(this);
     }
 
+    /**
+     * Get username from session
+     */
+    private String getUsername() {
+        IdentityMap im = (IdentityMap) getRequest().getSession(true).getAttribute(IDENTITY_MAP_KEY);
+        if (im != null) {
+            return ((Identity)im.get(getRealm().getID())).getUsername();
+        }
+        return null;
+    }
 }



More information about the Yanel-commits mailing list