You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shiro.apache.org by ka...@apache.org on 2010/10/09 03:26:39 UTC
svn commit: r1006094 - in /shiro/trunk/web/src:
main/java/org/apache/shiro/web/servlet/SimpleCookie.java
test/java/org/apache/shiro/web/servlet/SimpleCookieTest.java
Author: kaosko
Date: Sat Oct 9 01:26:39 2010
New Revision: 1006094
URL: http://svn.apache.org/viewvc?rev=1006094&view=rev
Log:
FIXED - issue SHIRO-183: Unable to correctly extract the Initialization Vector or ciphertext
https://issues.apache.org/jira/browse/SHIRO-183
- always write value for cookie's Max-Age attribute
Modified:
shiro/trunk/web/src/main/java/org/apache/shiro/web/servlet/SimpleCookie.java
shiro/trunk/web/src/test/java/org/apache/shiro/web/servlet/SimpleCookieTest.java
Modified: shiro/trunk/web/src/main/java/org/apache/shiro/web/servlet/SimpleCookie.java
URL: http://svn.apache.org/viewvc/shiro/trunk/web/src/main/java/org/apache/shiro/web/servlet/SimpleCookie.java?rev=1006094&r1=1006093&r2=1006094&view=diff
==============================================================================
--- shiro/trunk/web/src/main/java/org/apache/shiro/web/servlet/SimpleCookie.java (original)
+++ shiro/trunk/web/src/main/java/org/apache/shiro/web/servlet/SimpleCookie.java Sat Oct 9 01:26:39 2010
@@ -61,6 +61,7 @@ public class SimpleCookie implements Coo
protected static final String COOKIE_HEADER_NAME = "Set-Cookie";
protected static final String PATH_ATTRIBUTE_NAME = "Path";
protected static final String EXPIRES_ATTRIBUTE_NAME = "Expires";
+ protected static final String MAXAGE_ATTRIBUTE_NAME = "Max-Age";
protected static final String DOMAIN_ATTRIBUTE_NAME = "Domain";
protected static final String VERSION_ATTRIBUTE_NAME = "Version";
protected static final String COMMENT_ATTRIBUTE_NAME = "Comment";
@@ -281,7 +282,13 @@ public class SimpleCookie implements Coo
}
private void appendExpires(StringBuffer sb, int maxAge) {
- if (maxAge > DEFAULT_MAX_AGE) {
+ // if maxAge is negative, cookie should should expire when browser closes
+ sb.append(ATTRIBUTE_DELIMITER);
+ sb.append(MAXAGE_ATTRIBUTE_NAME).append(NAME_VALUE_DELIMITER).append(maxAge);
+ // Write the expires header used by older browsers, but may be unnecessary
+ // and it is not by the spec, see http://www.faqs.org/rfcs/rfc2965.html
+ // TODO consider completely removing the following
+ if (maxAge >= 0) {
sb.append(ATTRIBUTE_DELIMITER);
Date expires;
if (maxAge == 0) {
Modified: shiro/trunk/web/src/test/java/org/apache/shiro/web/servlet/SimpleCookieTest.java
URL: http://svn.apache.org/viewvc/shiro/trunk/web/src/test/java/org/apache/shiro/web/servlet/SimpleCookieTest.java?rev=1006094&r1=1006093&r2=1006094&view=diff
==============================================================================
--- shiro/trunk/web/src/test/java/org/apache/shiro/web/servlet/SimpleCookieTest.java (original)
+++ shiro/trunk/web/src/test/java/org/apache/shiro/web/servlet/SimpleCookieTest.java Sat Oct 9 01:26:39 2010
@@ -88,6 +88,8 @@ public class SimpleCookieTest extends Te
.append(SimpleCookie.ATTRIBUTE_DELIMITER)
.append(SimpleCookie.PATH_ATTRIBUTE_NAME).append(SimpleCookie.NAME_VALUE_DELIMITER).append(Cookie.ROOT_PATH)
.append(SimpleCookie.ATTRIBUTE_DELIMITER)
+ .append(SimpleCookie.MAXAGE_ATTRIBUTE_NAME).append(SimpleCookie.NAME_VALUE_DELIMITER).append(SimpleCookie.DEFAULT_MAX_AGE)
+ .append(SimpleCookie.ATTRIBUTE_DELIMITER)
.append(SimpleCookie.HTTP_ONLY_ATTRIBUTE_NAME)
.toString();