/** * Generates and returns new XSRF token. */ public XsrfToken getNewXsrfToken() { return new XsrfToken(generateTokenValue()); }
/** * Servlet initialization. */ @Override public void init() { // do not overwrite values set via constructor if (sessionCookieName == null) { sessionCookieName = getInitParameterValue(COOKIE_NAME_PARAM); } if (sessionCookieName == null) { throw new IllegalStateException(COOKIE_NAME_NOT_SET_ERROR_MSG); } }
/** * Retrieves and returns specified initialization parameter first from * {@link ServletConfig} followed by {@link ServletContext}, if former returns * {@code null}. */ private String getInitParameterValue(String name) { String paramValue = null; paramValue = getServletConfig().getInitParameter(name); if (paramValue == null) { paramValue = getServletContext().getInitParameter(name); } return paramValue; } }
/** * Generates new XSRF token. * * @return session cookie MD5 hash. */ private String generateTokenValue() { if (sessionCookieName == null) { throw new IllegalStateException(COOKIE_NAME_NOT_SET_ERROR_MSG); } // generate XSRF cookie using session cookie Cookie sessionCookie = Util.getCookie(getThreadLocalRequest(), sessionCookieName, false); if (sessionCookie == null || sessionCookie.getValue() == null || sessionCookie.getValue().length() == 0) { throw new RpcTokenException("Session cookie is not set or empty! " + "Unable to generate XSRF cookie"); } byte[] cookieBytes = sessionCookie.getValue().getBytes(); return StringUtils.toHexString(Md5Utils.getMd5Digest(cookieBytes)); }
/** * Generates new XSRF token. * * @return session cookie MD5 hash. */ private String generateTokenValue() { if (sessionCookieName == null) { throw new IllegalStateException(COOKIE_NAME_NOT_SET_ERROR_MSG); } // generate XSRF cookie using session cookie Cookie sessionCookie = Util.getCookie(getThreadLocalRequest(), sessionCookieName, false); if (sessionCookie == null || sessionCookie.getValue() == null || sessionCookie.getValue().length() == 0) { throw new RpcTokenException("Session cookie is not set or empty! " + "Unable to generate XSRF cookie"); } byte[] cookieBytes = sessionCookie.getValue().getBytes(); return StringUtils.toHexString(Md5Utils.getMd5Digest(cookieBytes)); }
/** * Retrieves and returns specified initialization parameter first from * {@link ServletConfig} followed by {@link ServletContext}, if former returns * {@code null}. */ private String getInitParameterValue(String name) { String paramValue = null; paramValue = getServletConfig().getInitParameter(name); if (paramValue == null) { paramValue = getServletContext().getInitParameter(name); } return paramValue; } }
/** * Generates and returns new XSRF token. */ public XsrfToken getNewXsrfToken() { return new XsrfToken(generateTokenValue()); }
/** * Servlet initialization. */ @Override public void init() { // do not overwrite values set via constructor if (sessionCookieName == null) { sessionCookieName = getInitParameterValue(COOKIE_NAME_PARAM); } if (sessionCookieName == null) { throw new IllegalStateException(COOKIE_NAME_NOT_SET_ERROR_MSG); } }
/** * Generates new XSRF token. * * @return session cookie MD5 hash. */ private String generateTokenValue() { if (sessionCookieName == null) { throw new IllegalStateException(COOKIE_NAME_NOT_SET_ERROR_MSG); } // generate XSRF cookie using session cookie Cookie sessionCookie = Util.getCookie(getThreadLocalRequest(), sessionCookieName, false); if (sessionCookie == null || sessionCookie.getValue() == null || sessionCookie.getValue().length() == 0) { throw new RpcTokenException("Session cookie is not set or empty! " + "Unable to generate XSRF cookie"); } byte[] cookieBytes = sessionCookie.getValue().getBytes(); return StringUtils.toHexString(Md5Utils.getMd5Digest(cookieBytes)); }
/** * Retrieves and returns specified initialization parameter first from * {@link ServletConfig} followed by {@link ServletContext}, if former returns * {@code null}. */ private String getInitParameterValue(String name) { String paramValue = null; paramValue = getServletConfig().getInitParameter(name); if (paramValue == null) { paramValue = getServletContext().getInitParameter(name); } return paramValue; } }
/** * Generates and returns new XSRF token. */ public XsrfToken getNewXsrfToken() { return new XsrfToken(generateTokenValue()); }
/** * Servlet initialization. */ @Override public void init() { // do not overwrite values set via constructor if (sessionCookieName == null) { sessionCookieName = getInitParameterValue(COOKIE_NAME_PARAM); } if (sessionCookieName == null) { throw new IllegalStateException(COOKIE_NAME_NOT_SET_ERROR_MSG); } }