Skip to content

Commit

Permalink
cookies - Introduced domain & secure flags on RestxSessionCookieDescr…
Browse files Browse the repository at this point in the history
…iptor
  • Loading branch information
fcamblor committed Aug 22, 2017
1 parent 2c0fbbd commit 6529fad
Showing 1 changed file with 19 additions and 0 deletions.
@@ -1,5 +1,7 @@
package restx.security;

import com.google.common.base.Optional;

import static restx.http.HTTP.headerTokenCompatible;

/**
Expand All @@ -8,10 +10,19 @@
public class RestxSessionCookieDescriptor {
private String cookieName;
private String cookieSignatureName;
private String domain;
private Boolean secure;

public RestxSessionCookieDescriptor(String cookieName, String cookieSignatureName) {
this(cookieName, cookieSignatureName, Optional.<String>absent(), Optional.<Boolean>absent());
}

public RestxSessionCookieDescriptor(String cookieName, String cookieSignatureName,
Optional<String> domain, Optional<Boolean> secure) {
this.cookieName = headerTokenCompatible(cookieName, "_");
this.cookieSignatureName = headerTokenCompatible(cookieSignatureName, "_");
this.domain = domain.orNull();
this.secure = secure.orNull();
}

public String getCookieName() {
Expand All @@ -21,4 +32,12 @@ public String getCookieName() {
public String getCookieSignatureName() {
return cookieSignatureName;
}

public Optional<String> getDomain() {
return Optional.fromNullable(domain);
}

public Optional<Boolean> getSecure() {
return Optional.fromNullable(secure);
}
}

0 comments on commit 6529fad

Please sign in to comment.