Author: shane.bryzak(a)jboss.com
Date: 2009-03-17 05:13:19 -0400 (Tue, 17 Mar 2009)
New Revision: 10177
Modified:
trunk/src/main/org/jboss/seam/security/RememberMe.java
Log:
JBSEAM-3885
Modified: trunk/src/main/org/jboss/seam/security/RememberMe.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/RememberMe.java 2009-03-17 03:17:32 UTC (rev
10176)
+++ trunk/src/main/org/jboss/seam/security/RememberMe.java 2009-03-17 09:13:19 UTC (rev
10177)
@@ -208,15 +208,22 @@
return Base64.encodeBytes(sb.toString().getBytes());
}
+ public String getCookiePath()
+ {
+ FacesContext ctx = FacesContext.getCurrentInstance();
+ return ctx != null ? ctx.getExternalContext().getRequestContextPath() : null;
+ }
+
@Observer(Credentials.EVENT_INIT_CREDENTIALS)
public void initCredentials(Credentials credentials)
- {
+ {
+ String cookiePath = getCookiePath();
+
if (mode.equals(Mode.usernameOnly))
- {
- FacesContext ctx = FacesContext.getCurrentInstance();
- if (ctx != null)
+ {
+ if (cookiePath != null)
{
-
usernameSelector.setCookiePath(ctx.getExternalContext().getRequestContextPath());
+ usernameSelector.setCookiePath(cookiePath);
}
String username = usernameSelector.getCookieValue();
@@ -230,10 +237,9 @@
}
else if (mode.equals(Mode.autoLogin))
{
- FacesContext ctx = FacesContext.getCurrentInstance();
- if (ctx != null)
+ if (cookiePath != null)
{
-
tokenSelector.setCookiePath(ctx.getExternalContext().getRequestContextPath());
+ tokenSelector.setCookiePath(cookiePath);
}
String token = tokenSelector.getCookieValue();
Show replies by date