You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by lh...@apache.org on 2010/06/04 06:01:48 UTC

svn commit: r951258 - in /incubator/shiro/trunk/samples/spring/src/main: java/org/apache/shiro/samples/spring/web/IndexController.java webapp/WEB-INF/resources/sampleIndex.jsp

Author: lhazlewood
Date: Fri Jun  4 04:01:47 2010
New Revision: 951258

URL: http://svn.apache.org/viewvc?rev=951258&view=rev
Log:
Made a minor change to the IndexController to see the actual session attributes and values (previous code only showed that there was a value, but didn't show the value itself)

Modified:
    incubator/shiro/trunk/samples/spring/src/main/java/org/apache/shiro/samples/spring/web/IndexController.java
    incubator/shiro/trunk/samples/spring/src/main/webapp/WEB-INF/resources/sampleIndex.jsp

Modified: incubator/shiro/trunk/samples/spring/src/main/java/org/apache/shiro/samples/spring/web/IndexController.java
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/samples/spring/src/main/java/org/apache/shiro/samples/spring/web/IndexController.java?rev=951258&r1=951257&r2=951258&view=diff
==============================================================================
--- incubator/shiro/trunk/samples/spring/src/main/java/org/apache/shiro/samples/spring/web/IndexController.java (original)
+++ incubator/shiro/trunk/samples/spring/src/main/java/org/apache/shiro/samples/spring/web/IndexController.java Fri Jun  4 04:01:47 2010
@@ -18,19 +18,20 @@
  */
 package org.apache.shiro.samples.spring.web;
 
-import java.util.HashMap;
-import java.util.Map;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.samples.spring.SampleManager;
+import org.apache.shiro.session.Session;
+import org.apache.shiro.subject.Subject;
 import org.springframework.validation.BindException;
 import org.springframework.validation.Errors;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.mvc.SimpleFormController;
 
-import org.apache.shiro.SecurityUtils;
-import org.apache.shiro.samples.spring.SampleManager;
-import org.apache.shiro.subject.Subject;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
 
 /**
  * Spring MVC controller responsible for rendering the Shiro Spring sample
@@ -81,6 +82,14 @@ public class IndexController extends Sim
         Map<String, Object> refData = new HashMap<String, Object>();
         refData.put("hasRole1", hasRole1);
         refData.put("hasRole2", hasRole2);
+
+        Session session = subject.getSession();
+        Map<Object, Object> sessionAttributes = new LinkedHashMap<Object, Object>();
+        for (Object key : session.getAttributeKeys()) {
+            sessionAttributes.put(key, session.getAttribute(key));
+        }
+        refData.put("sessionAttributes", sessionAttributes);
+
         refData.put("subjectSession", subject.getSession());
         return refData;
     }

Modified: incubator/shiro/trunk/samples/spring/src/main/webapp/WEB-INF/resources/sampleIndex.jsp
URL: http://svn.apache.org/viewvc/incubator/shiro/trunk/samples/spring/src/main/webapp/WEB-INF/resources/sampleIndex.jsp?rev=951258&r1=951257&r2=951258&view=diff
==============================================================================
--- incubator/shiro/trunk/samples/spring/src/main/webapp/WEB-INF/resources/sampleIndex.jsp (original)
+++ incubator/shiro/trunk/samples/spring/src/main/webapp/WEB-INF/resources/sampleIndex.jsp Fri Jun  4 04:01:47 2010
@@ -34,11 +34,18 @@
     Session ID: ${subjectSession.id}
 
     <h3>Session Attribute Keys</h3>
-    <ul>
-        <c:forEach items="${subjectSession.attributeKeys}" var="key">
-            <li>${key}</li>
+    <table border="1">
+        <tr>
+            <th>Key</th>
+            <th>Value</th>
+        </tr>
+        <c:forEach items="${sessionAttributes}" var="entry">
+            <tr>
+                <td>${entry.key}</td>
+                <td>${entry.value}</td>
+            </tr>
         </c:forEach>
-    </ul>
+    </table>
 
     <p style="font-weight: bold;">
         <shiro:hasRole name="role1">You have role 1.<br/></shiro:hasRole>
@@ -64,8 +71,9 @@
 
     <p>
         Click <a href="<c:url value="/s/shiro.jnlp?sessionId=${subjectSession.id}"/>">here</a> to launch webstart
-        application. (Need to be running <span style="font-weight:bold">mvn jetty:run-exploded</span> to have webstart app 
-        resources available through the webapp context) 
+        application. (Need to be running <span style="font-weight:bold">mvn jetty:run-exploded</span> to have webstart
+        app
+        resources available through the webapp context)
     </p>