[seam-commits] Seam SVN: r10181 - in trunk/src/main/org/jboss/seam: faces and 1 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Thu Mar 19 00:07:11 EDT 2009
Author: dan.j.allen
Date: 2009-03-19 00:07:10 -0400 (Thu, 19 Mar 2009)
New Revision: 10181
Modified:
trunk/src/main/org/jboss/seam/faces/Selector.java
trunk/src/main/org/jboss/seam/security-2.1.xsd
trunk/src/main/org/jboss/seam/security/RememberMe.java
Log:
JBSEAM-4014
also add null check it setEnabled() during component initialization
Modified: trunk/src/main/org/jboss/seam/faces/Selector.java
===================================================================
--- trunk/src/main/org/jboss/seam/faces/Selector.java 2009-03-18 16:30:37 UTC (rev 10180)
+++ trunk/src/main/org/jboss/seam/faces/Selector.java 2009-03-19 04:07:10 UTC (rev 10181)
@@ -15,8 +15,9 @@
*/
public abstract class Selector extends AbstractMutable implements Serializable
{
+ public static final int DEFAULT_MAX_AGE = 31536000; // 1 year in seconds
private boolean cookieEnabled;
- private int cookieMaxAge = 31536000; //1 year (in seconds)
+ private int cookieMaxAge = DEFAULT_MAX_AGE;
private String cookiePath= "/";
/**
Modified: trunk/src/main/org/jboss/seam/security/RememberMe.java
===================================================================
--- trunk/src/main/org/jboss/seam/security/RememberMe.java 2009-03-18 16:30:37 UTC (rev 10180)
+++ trunk/src/main/org/jboss/seam/security/RememberMe.java 2009-03-19 04:07:10 UTC (rev 10181)
@@ -119,6 +119,8 @@
private TokenStore tokenStore;
private boolean enabled;
+
+ private int cookieMaxAge = Selector.DEFAULT_MAX_AGE;
private boolean autoLoggedIn;
@@ -148,18 +150,28 @@
if (this.enabled != enabled)
{
this.enabled = enabled;
- if (mode.equals(Mode.usernameOnly))
+ // selector is null during component initialization (setup handled in @Create method)
+ if (usernameSelector != null && mode.equals(Mode.usernameOnly))
{
usernameSelector.setCookieEnabled(enabled);
usernameSelector.setDirty();
}
- else if (mode.equals(Mode.autoLogin))
+ // selector is null during component initialization (setup handled in @Create method)
+ else if (tokenSelector != null && mode.equals(Mode.autoLogin))
{
tokenSelector.setCookieEnabled(enabled);
tokenSelector.setDirty();
}
}
}
+
+ public int getCookieMaxAge() {
+ return cookieMaxAge;
+ }
+
+ public void setCookieMaxAge(int cookieMaxAge) {
+ this.cookieMaxAge = cookieMaxAge;
+ }
public TokenStore getTokenStore()
{
@@ -177,10 +189,12 @@
if (mode.equals(Mode.usernameOnly))
{
usernameSelector = new UsernameSelector();
+ usernameSelector.setCookieEnabled(enabled);
}
else if (mode.equals(Mode.autoLogin))
{
tokenSelector = new TokenSelector();
+ tokenSelector.setCookieEnabled(enabled);
// Default to JpaTokenStore
if (tokenStore == null)
@@ -339,8 +353,15 @@
// Password is set to null during authentication, so we set dirty
usernameSelector.setDirty();
- if ( !enabled ) usernameSelector.clearCookieValue();
- usernameSelector.setCookieValueIfEnabled( Identity.instance().getCredentials().getUsername() );
+ if ( !enabled )
+ {
+ usernameSelector.clearCookieValue();
+ }
+ else
+ {
+ usernameSelector.setCookieMaxAge(cookieMaxAge);
+ usernameSelector.setCookieValueIfEnabled( Identity.instance().getCredentials().getUsername() );
+ }
}
else if (mode.equals(Mode.autoLogin))
{
@@ -363,6 +384,7 @@
String value = generateTokenValue();
tokenStore.createToken(identity.getPrincipal().getName(), value);
tokenSelector.setCookieEnabled(enabled);
+ tokenSelector.setCookieMaxAge(cookieMaxAge);
tokenSelector.setCookieValueIfEnabled(encodeToken(identity.getPrincipal().getName(), value));
}
}
@@ -385,4 +407,4 @@
{
return autoLoggedIn;
}
-}
\ No newline at end of file
+}
Modified: trunk/src/main/org/jboss/seam/security-2.1.xsd
===================================================================
--- trunk/src/main/org/jboss/seam/security-2.1.xsd 2009-03-18 16:30:37 UTC (rev 10180)
+++ trunk/src/main/org/jboss/seam/security-2.1.xsd 2009-03-19 04:07:10 UTC (rev 10181)
@@ -12,22 +12,23 @@
</xs:complexType>
</xs:element>
- <xs:element name="faces-security-events">
- <xs:complexType mixed="true">
- <xs:attributeGroup ref="components:attlist.component"/>
- <xs:attributeGroup ref="security:attlist.faces-security-events"/>
- </xs:complexType>
- </xs:element>
-
<xs:attributeGroup name="attlist.identity">
<xs:attribute name="authenticate-method" type="components:expressionType"/>
<xs:attribute name="remember-me" type="components:boolean"/>
<xs:attribute name="jaas-config-name" type="components:string"/>
</xs:attributeGroup>
- <xs:attributeGroup name="attlist.faces-security-events">
+ <xs:element name="remember-me">
+ <xs:complexType mixed="true">
+ <xs:attributeGroup ref="components:attlist.component"/>
+ <xs:attributeGroup ref="security:attlist.remember-me"/>
+ </xs:complexType>
+ </xs:element>
+
+ <xs:attributeGroup name="attlist.remember-me">
<xs:attribute name="cookie-max-age" type="components:int"/>
- </xs:attributeGroup>
+ <xs:attribute name="enabled" type="components:boolean"/>
+ </xs:attributeGroup>
<xs:element name="identity-manager">
<xs:complexType mixed="true">
More information about the seam-commits
mailing list