Fork me on GitHub

CookieBaker by feliperazeek

CookieBaker is a dead simple Java library to read and write cookies in POJO form to avoid string splits and joins all over your codebase. Behind the scenes CookieBaker stores the cookie in JSON format using Jackson. CookieBaker also provides HMAC support off the shelve, currently using SHA1 by default.

Usage

Define a simple POJO with a default constructor (required by Jackson)

public class SampleObject implements Serializable {

	private String myString;

	public SampleObject() {}
	
	public String getMyString() {
		return myString;
	}

	public void setMyString(String myString) {
		this.myString = myString;
	}
}

Set Cookie

CookieBaker.saveCookie(response, cookieName, mySampleObjectInstance);

Get Cookie

SampleObject o = CookieBaker.getCookie(request, SampleObject.class, cookieName);

Dependencies

JUnit, Servlet API, Jackson, Spring Test


Install

git clone git@github.com:feliperazeek/CookieBaker.git
cd CookieBaker
mvn install
Import jar to your CLASSPATH or add Maven dependency to your project.

    <dependency>
      <groupId>geeks.aretotally.in</groupId>
      <artifactId>cookiebaker</artifactId>
      <version>0.1</version>
    </dependency>


Roadmap

Integrate HTML5 Local Storage with browser auto-detection.


License

The GNU General Public License, or GPL, is an open source license. Open source doesn't just mean that you can view the source code — it has political and philosophical implications as well. Open source, or "Free Software", means you are free to modify and redistribute the source code under certain conditions. Free doesn't refer to the price, it refers to freedom. The difference between the two meanings of free is often characterized as "Free as in speech vs. free as in beer." The GPL is free as in speech.


Author

Felipe Oliveira (felipera at gmail dot com)

Blog: Geeks Are Totally In!

Twitter: @_felipera


Download

You can download this project in either zip or tar formats.

You can also clone the project with Git by running:

$ git clone git://github.com/feliperazeek/CookieBaker