Search in sources :

Example 1 with SecretKeyInfo

use of org.webpieces.util.security.SecretKeyInfo in project webpieces by deanhiller.

the class CookieTranslator method scopeToCookie.

private RouterCookie scopeToCookie(CookieScopeImpl scopeData) throws UnsupportedEncodingException {
    Map<String, String> mapData = scopeData.getMapData();
    RouterCookie cookie = createBase(scopeData.getName(), null);
    StringBuilder data = translateValuesToCookieFormat(mapData);
    String value = data.toString();
    if (scopeData instanceof SecureCookie) {
        SecretKeyInfo key = config.getSecretKey();
        String sign = security.sign(key, value);
        cookie.value = VERSION + "-" + sign + ":" + value;
    } else {
        cookie.value = VERSION + ":" + value;
    }
    if (cookie.value.length() > 4050)
        throw new CookieTooLargeException("Your webserver has put too many things into the session cookie and" + " browser will end up ignoring the cookie so we exception here to let you " + "know.  Length of JUST the value(not whole cookie)=" + cookie.value.length() + "\ncookie value=" + cookie.value);
    return cookie;
}
Also used : CookieTooLargeException(org.webpieces.router.api.exceptions.CookieTooLargeException) RouterCookie(org.webpieces.ctx.api.RouterCookie) SecretKeyInfo(org.webpieces.util.security.SecretKeyInfo) SecureCookie(org.webpieces.router.impl.ctx.SecureCookie)

Aggregations

RouterCookie (org.webpieces.ctx.api.RouterCookie)1 CookieTooLargeException (org.webpieces.router.api.exceptions.CookieTooLargeException)1 SecureCookie (org.webpieces.router.impl.ctx.SecureCookie)1 SecretKeyInfo (org.webpieces.util.security.SecretKeyInfo)1