All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dropbox.core.DbxStandardSessionStore Maven / Gradle / Ivy

The newest version!
package com.dropbox.core;

import com.dropbox.core.DbxSessionStore;

import javax.servlet.http.HttpSession;

/**
 * A {@link DbxSessionStore} implementation that stores the value using the standard
 * {@link HttpSession} interface from the Java Servlet API.
 *
 * Example:
 * 
 * DbxWebAuth getDbxWebAuth(HttpServletRequest request)
 * {
 *     HttpSession session = request.getSession(true);
 *     String key = "dropbox-auth-csrf-token";
 *     DbxSessionStore csrfStore = new StandardSessionStore(session, key);
 *     return new DbxWebAuth(..., csrfStore);
 * }
 * 
*/ public final class DbxStandardSessionStore implements DbxSessionStore { public final String key; public final HttpSession session; public DbxStandardSessionStore(String key, HttpSession session) { this.key = key; this.session = session; } @Override public String get() { Object v = session.getAttribute(key); if (v instanceof String) return (String) v; return null; } @Override public void set(String value) { session.setAttribute(key, value); } @Override public void clear() { session.removeAttribute(key); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy