Author: christian.bauer(a)jboss.com
Date: 2008-05-21 05:44:51 -0400 (Wed, 21 May 2008)
New Revision: 8244
Modified:
trunk/examples/wiki/src/etc/META-INF/components-dev.xml
trunk/examples/wiki/src/etc/META-INF/components-prod.xml
trunk/examples/wiki/src/etc/META-INF/components-test.xml
trunk/examples/wiki/src/etc/WEB-INF/components.xml
trunk/examples/wiki/src/etc/WEB-INF/web.xml
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/Authenticator.java
Log:
Optional extended session lifetime for authenticated users
Modified: trunk/examples/wiki/src/etc/META-INF/components-dev.xml
===================================================================
--- trunk/examples/wiki/src/etc/META-INF/components-dev.xml 2008-05-21 08:11:08 UTC (rev
8243)
+++ trunk/examples/wiki/src/etc/META-INF/components-dev.xml 2008-05-21 09:44:51 UTC (rev
8244)
@@ -26,6 +26,7 @@
<property name="appname">lacewiki</property>
<property name="adminContact">+41 123 123 123,
admin(a)my.address</property>
<property name="debug">true</property>
+ <property
name="authenticatedSessionTimeoutMinutes">180</property>
</component>
<!-- Mailserver for notification messages -->
Modified: trunk/examples/wiki/src/etc/META-INF/components-prod.xml
===================================================================
--- trunk/examples/wiki/src/etc/META-INF/components-prod.xml 2008-05-21 08:11:08 UTC (rev
8243)
+++ trunk/examples/wiki/src/etc/META-INF/components-prod.xml 2008-05-21 09:44:51 UTC (rev
8244)
@@ -26,6 +26,7 @@
<property name="appname">lacewiki</property>
<property name="adminContact">+41 123 123 123,
admin(a)my.address</property>
<property name="debug">false</property>
+ <property
name="authenticatedSessionTimeoutMinutes">180</property>
</component>
<!-- Mailserver for notification messages -->
Modified: trunk/examples/wiki/src/etc/META-INF/components-test.xml
===================================================================
--- trunk/examples/wiki/src/etc/META-INF/components-test.xml 2008-05-21 08:11:08 UTC (rev
8243)
+++ trunk/examples/wiki/src/etc/META-INF/components-test.xml 2008-05-21 09:44:51 UTC (rev
8244)
@@ -26,6 +26,7 @@
<property name="appname">lacewiki</property>
<property name="adminContact">+41 123 123 123,
admin(a)my.address</property>
<property name="debug">true</property>
+ <property
name="authenticatedSessionTimeoutMinutes">180</property>
</component>
<!-- Mailserver for notification messages -->
Modified: trunk/examples/wiki/src/etc/WEB-INF/components.xml
===================================================================
--- trunk/examples/wiki/src/etc/WEB-INF/components.xml 2008-05-21 08:11:08 UTC (rev 8243)
+++ trunk/examples/wiki/src/etc/WEB-INF/components.xml 2008-05-21 09:44:51 UTC (rev 8244)
@@ -125,7 +125,7 @@
<factory name="skin" scope="SESSION" value="d"/>
- <factory name="sessionTimeoutSeconds" scope="SESSION"
+ <factory name="sessionTimeoutSeconds" scope="EVENT"
value="#{facesContext.externalContext.getSession(true).getMaxInactiveInterval()}"/>
<factory name="currentPreferencesUser" scope="EVENT"
Modified: trunk/examples/wiki/src/etc/WEB-INF/web.xml
===================================================================
--- trunk/examples/wiki/src/etc/WEB-INF/web.xml 2008-05-21 08:11:08 UTC (rev 8243)
+++ trunk/examples/wiki/src/etc/WEB-INF/web.xml 2008-05-21 09:44:51 UTC (rev 8244)
@@ -128,9 +128,9 @@
<!-- Misc Settings -->
- <!-- Session timeout: half hour (careful, large and long sessions need heap
size>-->
+ <!-- Session timeout,can be extended for authenticated users in components.xml!
-->
<session-config>
- <session-timeout>30</session-timeout>
+ <session-timeout>10</session-timeout>
</session-config>
</web-app>
Modified: trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/Authenticator.java
===================================================================
---
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/Authenticator.java 2008-05-21
08:11:08 UTC (rev 8243)
+++
trunk/examples/wiki/src/main/org/jboss/seam/wiki/core/action/Authenticator.java 2008-05-21
09:44:51 UTC (rev 8244)
@@ -23,6 +23,7 @@
import org.jboss.seam.wiki.core.model.Role;
import org.jboss.seam.wiki.util.Hash;
import org.jboss.seam.wiki.util.WikiUtil;
+import org.jboss.seam.wiki.WikiInit;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
@@ -30,6 +31,8 @@
@Name("authenticator")
public class Authenticator {
+ protected final static String REGULAR_SESSION_MAX_INACTIVE_SECONDS =
"regularSessionMaxInactiveInterval";
+
@Logger
Log log;
@@ -197,11 +200,22 @@
@Observer("org.jboss.seam.security.loginSuccessful")
public void extendSessionTime() {
-
//ServletContexts.getInstance().getRequest().getSession().setMaxInactiveInterval(LONG_SESSION_TIME);
+ // Store the regular session timeout value, so we can set it back later on
logout
+ int regularSessionTimeout =
ServletContexts.getInstance().getRequest().getSession().getMaxInactiveInterval();
+ Contexts.getSessionContext().set(REGULAR_SESSION_MAX_INACTIVE_SECONDS,
regularSessionTimeout);
+ WikiInit init = (WikiInit)Component.getInstance(WikiInit.class);
+ if (init.getAuthenticatedSessionTimeoutMinutes() != 0) {
+ log.debug("setting timeout of authenticated user session to minutes:
" + init.getAuthenticatedSessionTimeoutMinutes());
+
ServletContexts.getInstance().getRequest().getSession().setMaxInactiveInterval(
+ init.getAuthenticatedSessionTimeoutMinutes()*60
+ );
+ }
}
@Observer("org.jboss.seam.security.loggedOut")
public void resetSessionTime() {
-
//ServletContexts.getInstance().getRequest().getSession().setMaxInactiveInterval(STD_SESSION_TIME);
+ int regularSessionTimeout = (Integer)
Contexts.getSessionContext().get(REGULAR_SESSION_MAX_INACTIVE_SECONDS);
+ log.debug("resetting timeout of user session after logout to minutes: "
+ regularSessionTimeout/60);
+
ServletContexts.getInstance().getRequest().getSession().setMaxInactiveInterval(regularSessionTimeout);
}
}
Show replies by date