[Yanel-commits] rev 51881 -
public/yanel/trunk/src/webapp/src/java/org/wyona/yanel/servlet/security/impl
michi at wyona.com
michi at wyona.com
Thu Jul 29 09:16:39 CEST 2010
Author: michi
Date: 2010-07-29 09:16:39 +0200 (Thu, 29 Jul 2010)
New Revision: 51881
Modified:
public/yanel/trunk/src/webapp/src/java/org/wyona/yanel/servlet/security/impl/DefaultWebAuthenticatorImpl.java
Log:
get user ID made public such that it can be reused
Modified: public/yanel/trunk/src/webapp/src/java/org/wyona/yanel/servlet/security/impl/DefaultWebAuthenticatorImpl.java
===================================================================
--- public/yanel/trunk/src/webapp/src/java/org/wyona/yanel/servlet/security/impl/DefaultWebAuthenticatorImpl.java 2010-07-29 06:39:43 UTC (rev 51880)
+++ public/yanel/trunk/src/webapp/src/java/org/wyona/yanel/servlet/security/impl/DefaultWebAuthenticatorImpl.java 2010-07-29 07:16:39 UTC (rev 51881)
@@ -393,7 +393,7 @@
realmElement.setAttributeNS(YanelServlet.NAMESPACE, "name", realm.getName());
realmElement.setAttributeNS(YanelServlet.NAMESPACE, "mount-point", realm.getMountPoint().toString());
- String currentUserId = getCurrentUserId(request, realm);
+ String currentUserId = getCurrentUserId(request.getSession(true), realm);
if (currentUserId != null) {
Element userElement = (Element) rootElement.appendChild(adoc.createElementNS(YanelServlet.NAMESPACE, "user"));
userElement.setAttributeNS(YanelServlet.NAMESPACE, "id", currentUserId);
@@ -585,10 +585,13 @@
*/
/**
- * Get current user id. Return null if not signed in yet.
+ * Get current user id (if signed-in) for a specific realm.
+ * @param session HTTP session
+ * @param realm Realm
+ * @return Username and if not signed-in, then null
*/
- String getCurrentUserId(HttpServletRequest request, Realm realm) {
- IdentityMap identityMap = (IdentityMap)request.getSession(true).getAttribute(YanelServlet.IDENTITY_MAP_KEY);
+ public static String getCurrentUserId(HttpSession session, Realm realm) {
+ IdentityMap identityMap = (IdentityMap)session.getAttribute(YanelServlet.IDENTITY_MAP_KEY);
if (identityMap != null) {
Identity identity = (Identity) identityMap.get(realm.getID());
if (identity != null && !identity.isWorld()) return identity.getUsername();
More information about the Yanel-commits
mailing list