Spring Framework CookieGenerator - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework CookieGenerator class.

This code example shows how to use the following methods:setCookieDomain, setCookieName
 
	/** 
	 * Creates a cookie-based SitePreferenceRepository with a custom domain value. 
	 * Allows for convenient specification of to a shared domain such as <code>.app.com</code>. 
	 */ 
	public CookieSitePreferenceRepository(String cookieDomain) { 
		setCookieName(DEFAULT_COOKIE_NAME); 
		setCookieDomain(cookieDomain); 
	} 
 
	public void saveSitePreference(SitePreference preference, HttpServletRequest request, HttpServletResponse response) { 
		addCookie(response, preference.name()); 
	} 
 
	public SitePreference loadSitePreference(HttpServletRequest request) { 
		Cookie cookie = WebUtils.getCookie(request, getCookieName()); 
		return cookie != null ? SitePreference.valueOf(cookie.getValue()) : null; 
	} 
 
	private static final String DEFAULT_COOKIE_NAME = CookieSitePreferenceRepository.class.getName() + ".SITE_PREFERENCE"; 
6
CodeRank
This code example shows how to use the following methods:setCookieName
 
    private static final String MOBILE_SITE_PREFIX = "m_"; 
    private static final String DEFAULT_COOKIE_NAME = CookieSitePreferenceRepository.class.getName() + ".SITE_PREFERENCE"; 
 
    public SitePreferenceHelper() { 
        super(); 
        setCookieName(DEFAULT_COOKIE_NAME); 
    } 
 
    public void resolveSiteType(ModelAndView modelAndView, String viewName, HttpServletRequest request) { 
        SitePreference sitePreference = SitePreferenceUtils.getCurrentSitePreference(request); 
        StringBuffer resultViewName = new StringBuffer(viewName); 
 
        if (sitePreference.isMobile()) { 
            resultViewName = resultViewName.insert(0, MOBILE_SITE_PREFIX); 
        } 
 
        modelAndView.setViewName(resultViewName.toString()); 
         
        String url = UrlHelper.constructCurrentPageUrl(request); 
5
CodeRank
This code example shows how to use the following methods:setCookieDomain, setCookieName, setCookiePath
 
    @Before 
    public void onSetUp() throws Exception { 
        this.action = new AuthenticationViaFormAction(); 
 
        this.warnCookieGenerator = new CookieGenerator(); 
        this.warnCookieGenerator.setCookieName("WARN"); 
        this.warnCookieGenerator.setCookieName("TGT"); 
        this.warnCookieGenerator.setCookieDomain("/"); 
        this.warnCookieGenerator.setCookiePath("/"); 
 
        this.action.setCentralAuthenticationService(getCentralAuthenticationService()); 
        this.action.setWarnCookieGenerator(this.warnCookieGenerator); 
    } 
 
    @Test 
    public void testSuccessfulAuthenticationWithNoService() throws Exception { 
        final MockHttpServletRequest request = new MockHttpServletRequest(); 
        final MockRequestContext context = new MockRequestContext(); 
 
5
CodeRank
See Code Examples for Spring Framework CookieGenerator Methods: