View Javadoc

1   package org.springframework.security.ui.savedrequest;
2   
3   import javax.servlet.http.Cookie;
4   import java.io.Serializable;
5   
6   /**
7    * Stores off the values of a cookie in a serializable holder
8    *
9    * @author Ray Krueger
10   */
11  public class SavedCookie implements Serializable {
12      private java.lang.String name;
13      private java.lang.String value;
14      private java.lang.String comment;
15      private java.lang.String domain;
16      private int maxAge;
17      private java.lang.String path;
18      private boolean secure;
19      private int version;
20  
21      public SavedCookie(String name, String value, String comment, String domain, int maxAge, String path, boolean secure, int version) {
22          this.name = name;
23          this.value = value;
24          this.comment = comment;
25          this.domain = domain;
26          this.maxAge = maxAge;
27          this.path = path;
28          this.secure = secure;
29          this.version = version;
30      }
31  
32      public SavedCookie(Cookie cookie) {
33          this(cookie.getName(), cookie.getValue(), cookie.getComment(),
34                  cookie.getDomain(), cookie.getMaxAge(), cookie.getPath(), cookie.getSecure(), cookie.getVersion());
35      }
36  
37      public String getName() {
38          return name;
39      }
40  
41      public String getValue() {
42          return value;
43      }
44  
45      public String getComment() {
46          return comment;
47      }
48  
49      public String getDomain() {
50          return domain;
51      }
52  
53      public int getMaxAge() {
54          return maxAge;
55      }
56  
57      public String getPath() {
58          return path;
59      }
60  
61      public boolean isSecure() {
62          return secure;
63      }
64  
65      public int getVersion() {
66          return version;
67      }
68  
69      public Cookie getCookie() {
70          Cookie c = new Cookie(getName(), getValue());
71  
72          if (getComment() != null)
73              c.setComment(getComment());
74  
75          if (getDomain() != null)
76              c.setDomain(getDomain());
77  
78          if (getPath() != null)
79              c.setPath(getPath());
80  
81          c.setVersion(getVersion());
82          c.setMaxAge(getMaxAge());
83          c.setSecure(isSecure());
84          return c;
85      }
86  }