Java Code Examples for io.netty.handler.codec.http.cookie.DefaultCookie#setPath()

The following examples show how to use io.netty.handler.codec.http.cookie.DefaultCookie#setPath() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Response.java    From netty-rest with Apache License 2.0 6 votes vote down vote up
public Response addCookie(String name, String value, String domain, Boolean isHttpOnly, Long maxAge, String path, Boolean isSecured) {
    if(cookies == null) {
        cookies = Lists.newArrayList();
    }
    final DefaultCookie defaultCookie = new DefaultCookie(name, value);
    if(domain != null) {
        defaultCookie.setDomain(domain);
    }
    if(isHttpOnly != null) {
        defaultCookie.setHttpOnly(isHttpOnly);
    }
    if(maxAge != null) {
        defaultCookie.setMaxAge(maxAge);
    }
    if(path != null) {
        defaultCookie.setPath(path);
    }
    if(isSecured != null) {
        defaultCookie.setSecure(isSecured);
    }
    cookies.add(defaultCookie);
    return this;
}
 
Example 2
Source File: CookieHelper.java    From wisdom with Apache License 2.0 6 votes vote down vote up
/**
 * Converts the Wisdom's cookie to a Netty's cookie.
 *
 * @param cookie the Wisdom's cookie
 * @return the Netty's cookie with the same metadata and content than the input cookie.
 */
public static DefaultCookie convertWisdomCookieToNettyCookie(Cookie cookie) {
    DefaultCookie nettyCookie = new DefaultCookie(cookie.name(), cookie.value());
    nettyCookie.setMaxAge(cookie.maxAge());
    // Comments are not supported anymore by netty.
    if (cookie.domain() != null) {
        nettyCookie.setDomain(cookie.domain());
    }
    if (cookie.isSecure()) {
        nettyCookie.setSecure(true);
    }
    if (cookie.path() != null) {
        nettyCookie.setPath(cookie.path());
    }
    if (cookie.isHttpOnly()) {
        nettyCookie.setHttpOnly(true);
    }
    return nettyCookie;
}
 
Example 3
Source File: ShiroAuthenticator.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
private DefaultCookie createCookie(String value, Long maxAge) {
   DefaultCookie nettyCookie = new DefaultCookie(cookieConfig.getAuthCookieName(), value);
   nettyCookie.setMaxAge(maxAge);
   nettyCookie.setHttpOnly(true);
   nettyCookie.setSecure(cookieConfig.isSecureOnly());
   nettyCookie.setPath("/");

   if (cookieConfig.isDomainNameSet()) {
      nettyCookie.setDomain(cookieConfig.getDomainName());
   }
   return nettyCookie;
}
 
Example 4
Source File: NoopAuthenticator.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
private DefaultCookie createCookie(String value, Long maxAge) {
   DefaultCookie nettyCookie = new DefaultCookie(authCookieName, value);
   nettyCookie.setMaxAge(maxAge);
   nettyCookie.setHttpOnly(true);
   nettyCookie.setPath("/");
   nettyCookie.setDomain(domainName);
   return nettyCookie;
}
 
Example 5
Source File: WebSocketHelper.java    From whirlpool with Apache License 2.0 5 votes vote down vote up
public static DefaultCookie createCookie(String authCookieName, String domainName, String value, Long maxAge) {
    DefaultCookie nettyCookie = new DefaultCookie(authCookieName, value);
    nettyCookie.setMaxAge(maxAge);
    nettyCookie.setHttpOnly(false);
    nettyCookie.setPath("/");
    if (domainName != null && !"none".equals(domainName)) {
        nettyCookie.setDomain(domainName);
    }
    return nettyCookie;
}