diff options
| author | Benjamin Culkin <scorpress@gmail.com> | 2024-05-19 17:56:33 -0400 |
|---|---|---|
| committer | Benjamin Culkin <scorpress@gmail.com> | 2024-05-19 17:56:33 -0400 |
| commit | aedc34d55462a75e329bbf342251ff6504cd117e (patch) | |
| tree | bcc8f1f2352582717b484df302aeea6696b8f000 /projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOCookie.java | |
Initial import from SVN
Diffstat (limited to 'projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOCookie.java')
| -rw-r--r-- | projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOCookie.java | 203 |
1 files changed, 203 insertions, 0 deletions
diff --git a/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOCookie.java b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOCookie.java new file mode 100644 index 0000000..78427f0 --- /dev/null +++ b/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOCookie.java @@ -0,0 +1,203 @@ +/* +Wotonomy: OpenStep design patterns for pure Java applications. +Copyright (C) 2000 Blacksmith, Inc. + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with this library; if not, see http://www.gnu.org +*/ + +package net.wotonomy.web; + +import net.wotonomy.foundation.NSDate; + +/** +* A pure java implementation of WOCookie that extends +* javax.servlet.httpd.Cookie for greater compatibility. +* +* @author michael@mpowers.net +* @author $Author: cgruber $ +* @version $Revision: 905 $ +*/ +public class WOCookie + extends javax.servlet.http.Cookie +{ + /** + * Default constructor. + */ + public WOCookie () + { + super( "", "" ); + } + + /** + * Constructs a cookie with the specified name and value. + */ + public WOCookie( String aName, String aValue ) + { + super( aName, aValue ); + } + + /** + * Constructs a cookie with the specified name and value. + * Also sets the path to the current application's path. + */ + public static WOCookie cookieWithName (String aName, String aValue) + { + WOCookie result = new WOCookie( aName, aValue ); + //TODO: Set the path to the current application's path. + return result; + } + + /** + * Constructs a cookie with the specified attributes. + */ + public static WOCookie cookieWithName (String aName, String aValue, + String aPath, String aDomain, NSDate expirationDate, boolean secure) + { + WOCookie result = new WOCookie( aName, aValue ); + result.setPath( aPath ); + result.setDomain( aDomain ); + result.setExpires( expirationDate ); + result.setSecure( secure ); + return result; + } + + /** + * Returns the name of the cookie. + */ + public String name () + { + return this.getName(); + } + + /** + * Sets the name of the cookie. + */ + public void setName (String aString) + { + // super.setName( aString ); + throw new RuntimeException( "Not yet implemented." ); + } + + /** + * Returns the value of the cookie. + */ + public String value () + { + return this.getValue(); + } + + /** + * Sets the value of the cookie. + */ + public void setValue (String aString) + { + super.setValue( aString ); + } + + /** + * Gets the domain of the cookie. + */ + public String domain () + { + return this.getDomain(); + } + + /** + * Sets the domain of the cookie. + */ + public void setDomain (String aString) + { + super.setDomain( aString ); + } + + /** + * Gets the path of the cookie. + */ + public String path () + { + return this.getPath(); + } + + /** + * Sets the path of the cookie. + */ + public void setPath (String aString) + { + super.setPath( aString ); + } + + /** + * Gets the expiration date of the cookie. + * If in the past, the cookie will persist until browser shutdown. + */ + public NSDate expires () + { + return new NSDate( this.getMaxAge() ); + } + + /** + * Sets the expiration date of the cookie. + */ + public void setExpires (NSDate aDate) + { + this.setMaxAge( (int) aDate.timeIntervalSinceNow() ); + } + + /** + * Returns whether the cookie will only be sent over a secure protocol. + */ + public boolean isSecure () + { + return this.getSecure(); + } + + /** + * Sets whether the cookie will only be sent over a secure protocol. + */ + public void setIsSecure (boolean isSecure) + { + this.setSecure( isSecure ); + } + + /** + * Returns the string as it appears in the HTTP header of the response. + * This would normally be called by WOResponse, but is handled automatically + * by the servlet implementation. + */ + public String headerString () + { + new RuntimeException( "Not implemented yet." ); + return null; + } +} + +/* + * $Log$ + * Revision 1.2 2006/02/19 01:44:02 cgruber + * Add xmlrpc files + * Remove jclark and replace with dom4j and javax.xml.sax stuff + * Re-work dependencies and imports so it all compiles. + * + * Revision 1.1 2006/02/16 13:22:22 cgruber + * Check in all sources in eclipse-friendly maven-enabled packages. + * + * Revision 1.1.1.1 2000/12/21 15:53:04 mpowers + * Contributing wotonomy. + * + * Revision 1.2 2000/12/20 16:25:50 michael + * Added log to all files. + * + * + */ + |
