001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.wicket.markup.html.form.persistence;
018:
019: import org.apache.wicket.IClusterable;
020:
021: /**
022: * This class provides default values that are used by the CookieValuePersister
023: * class when it creates cookies.
024: *
025: * @author Juergen Donnerstag
026: */
027: public class CookieValuePersisterSettings implements IClusterable {
028: private static final long serialVersionUID = 1L;
029:
030: /** Max age that the component will be persisted in seconds. */
031: private int maxAge = 3600 * 24 * 30; // 30 days
032:
033: /** Cookie comment. */
034: private String comment;
035:
036: /** Cookie domain. */
037: private String domain;
038:
039: /** Whether the cookie is secure. */
040: private boolean secure;
041:
042: /** Cookie version. */
043: private int version;
044:
045: /**
046: * Gets the max age. After
047: *
048: * @return the max age
049: */
050: public int getMaxAge() {
051: return maxAge;
052: }
053:
054: /**
055: * Sets the maximum age of the cookie in seconds.
056: *
057: * @param maxAge
058: * the max age in secs.
059: */
060: public void setMaxAge(int maxAge) {
061: this .maxAge = maxAge;
062: }
063:
064: /**
065: * Gets the cookie comment.
066: *
067: * @return the cookie comment
068: */
069: public String getComment() {
070: return comment;
071: }
072:
073: /**
074: * Sets the cookie comment.
075: *
076: * @param comment
077: * the cookie comment
078: */
079: public void setComment(String comment) {
080: this .comment = comment;
081: }
082:
083: /**
084: * Gets the cookie domain name.
085: *
086: * @return the cookie domain name
087: */
088: public String getDomain() {
089: return domain;
090: }
091:
092: /**
093: * Sets the cookie domain name.
094: *
095: * @param domain
096: * the cookie domain name
097: */
098: public void setDomain(String domain) {
099: this .domain = domain;
100: }
101:
102: /**
103: * Returns true if the browser is sending cookies only over a secure
104: * protocol, or false if the browser can send cookies using any protocol.
105: *
106: * @return whether this cookie is secure
107: */
108: public boolean getSecure() {
109: return secure;
110: }
111:
112: /**
113: * Indicates to the browser whether the cookie should only be sent using a
114: * secure protocol, such as HTTPS or SSL.
115: *
116: * @param secure
117: * if true, sends the cookie from the browser to the server using
118: * only when using a secure protocol; if false, sent on any
119: * protocol
120: */
121: public void setSecure(boolean secure) {
122: this .secure = secure;
123: }
124:
125: /**
126: * Returns the version of the protocol this cookie complies with. Version 1
127: * complies with RFC 2109, and version 0 complies with the original cookie
128: * specification drafted by Netscape. Cookies provided by a browser use and
129: * identify the browser's cookie version.
130: *
131: * @return 0 if the cookie complies with the original Netscape
132: * specification; 1 if the cookie complies with RFC 2109
133: */
134: public int getVersion() {
135: return version;
136: }
137:
138: /**
139: * Sets the version of the cookie protocol this cookie complies with.
140: * Version 0 complies with the original Netscape cookie specification.
141: * Version 1 complies with RFC 2109. <br/>Since RFC 2109 is still somewhat
142: * new, consider version 1 as experimental; do not use it yet on production
143: * sites.
144: *
145: * @param version
146: * 0 if the cookie should comply with the original Netscape
147: * specification; 1 if the cookie should comply with RFC 2109
148: */
149: public void setVersion(int version) {
150: this.version = version;
151: }
152: }
|