Tabnine Logo
Cookie
Code IndexAdd Tabnine to your IDE (free)

How to use
Cookie
in
org.pac4j.core.context

Best Java code snippets using org.pac4j.core.context.Cookie (Showing top 20 results out of 315)

origin: jooby-project/jooby

@Override public Collection<Cookie> getRequestCookies() {
 return req.cookies().stream().map(c -> {
  Cookie cookie = new Cookie(c.name(), c.value().orElse(null));
  c.domain().ifPresent(cookie::setDomain);
  c.path().ifPresent(cookie::setPath);
  cookie.setSecure(c.secure());
  cookie.setHttpOnly(c.httpOnly());
  return cookie;
 }).collect(Collectors.toList());
}
origin: jooby-project/jooby

@Override
public void addResponseCookie(final Cookie cookie) {
 Definition c = new Definition(cookie.getName(), cookie.getValue());
 Optional.ofNullable(cookie.getDomain()).ifPresent(c::domain);
 Optional.ofNullable(cookie.getPath()).ifPresent(c::path);
 c.httpOnly(cookie.isHttpOnly());
 c.maxAge(cookie.getMaxAge());
 c.secure(cookie.isSecure());
 rsp.cookie(c);
}
origin: pippo-java/pippo

@Override
public Collection<Cookie> getRequestCookies() {
  return getRequest().getCookies().stream().map(c -> {
    Cookie cookie = new Cookie(c.getName(), c.getValue());
    cookie.setComment(c.getComment());
    cookie.setSecure(c.getSecure());
    cookie.setPath(c.getPath());
    cookie.setHttpOnly(c.isHttpOnly());
    cookie.setDomain(c.getDomain());
    cookie.setMaxAge(c.getMaxAge());
    cookie.setVersion(c.getVersion());
    return cookie;
  }).collect(Collectors.toList());
}
origin: org.apache.knox/gateway-provider-security-pac4j

public void set(WebContext context, String key, Object value) {
  logger.debug("Save in session: {} = {}", key, value);
  final Cookie cookie = new Cookie(PAC4J_SESSION_PREFIX + key, compressEncryptBase64(value));
  try {
    String domain = Urls.getDomainName(context.getFullRequestURL(), this.domainSuffix);
    if (domain == null) {
      domain = context.getServerName();
    }
    cookie.setDomain(domain);
  } catch (final Exception e) {
    throw new TechnicalException(e);
  }
  cookie.setHttpOnly(true);
  cookie.setSecure(ContextHelper.isHttpsOrSecure(context));
  context.addResponseCookie(cookie);
}
origin: pac4j/jax-rs-pac4j

@Override
public Collection<Cookie> getRequestCookies() {
  return requestContext.getCookies().values().stream().map(c -> {
    Cookie nc = new Cookie(c.getName(), c.getValue());
    nc.setDomain(c.getDomain());
    nc.setPath(c.getPath());
    nc.setVersion(c.getVersion());
    return nc;
  }).collect(Collectors.toList());
}
origin: org.pac4j/vertx-pac4j

@Override
public Collection<Cookie> getRequestCookies() {
  return routingContext.cookies().stream().map(cookie -> {
    final Cookie p4jCookie = new Cookie(cookie.getName(), cookie.getValue());
    p4jCookie.setDomain(cookie.getDomain());
    p4jCookie.setPath(cookie.getPath());
    return p4jCookie;
  }).collect(Collectors.toList());
}
origin: org.pac4j/pac4j-http

@Override
public TokenCredentials extract(final WebContext context) {
  final Collection<Cookie> col = context.getRequestCookies();
  for (final Cookie c : col) {
    if (c.getName().equals(this.cookieName)) {
      return new TokenCredentials(c.getValue());
    }
  }
  return null;
}
origin: org.pac4j/pac4j-http

  @Test
  public void testAuthentication() {
    final CookieClient client = new CookieClient(USERNAME, new SimpleTestTokenAuthenticator());
    final MockWebContext context = MockWebContext.create();

    final Cookie c = new Cookie(USERNAME, Base64.getEncoder().encodeToString(getClass().getName().getBytes(StandardCharsets.UTF_8)));
    context.getRequestCookies().add(c);
    final TokenCredentials credentials = client.getCredentials(context);
    final CommonProfile profile = client.getUserProfile(credentials, context);
    assertEquals(c.getValue(), profile.getId());
  }
}
origin: apache/knox

@Override
public Object get(WebContext context, String key) {
  final Cookie cookie = ContextHelper.getCookie(context, PAC4J_SESSION_PREFIX + key);
  Object value = null;
  if (cookie != null) {
    value = uncompressDecryptBase64(cookie.getValue());
  }
  logger.debug("Get from session: {} = {}", key, value);
  return value;
}
origin: io.ratpack/ratpack-pac4j

@Override
public Collection<Cookie> getRequestCookies() {
 final List<Cookie> newCookies = new ArrayList<>();
 final Set<io.netty.handler.codec.http.cookie.Cookie> cookies = request.getCookies();
 for (final io.netty.handler.codec.http.cookie.Cookie cookie : cookies) {
  final Cookie newCookie = new Cookie(cookie.name(), cookie.value());
  newCookie.setDomain(cookie.domain());
  newCookie.setPath(cookie.path());
  newCookie.setMaxAge((int) cookie.maxAge());
  newCookie.setSecure(cookie.isSecure());
  newCookie.setHttpOnly(cookie.isHttpOnly());
  newCookies.add(newCookie);
 }
 return newCookies;
}
origin: apache/knox

@Override
public void set(WebContext context, String key, Object value) {
  logger.debug("Save in session: {} = {}", key, value);
  final Cookie cookie = new Cookie(PAC4J_SESSION_PREFIX + key, compressEncryptBase64(value));
  try {
    String domain = Urls.getDomainName(context.getFullRequestURL(), this.domainSuffix);
    if (domain == null) {
      domain = context.getServerName();
    }
    cookie.setDomain(domain);
  } catch (final Exception e) {
    throw new TechnicalException(e);
  }
  cookie.setHttpOnly(true);
  cookie.setSecure(ContextHelper.isHttpsOrSecure(context));
  context.addResponseCookie(cookie);
}
origin: pac4j/vertx-pac4j

@Override
public Collection<Cookie> getRequestCookies() {
  return routingContext.cookies().stream().map(cookie -> {
    final Cookie p4jCookie = new Cookie(cookie.getName(), cookie.getValue());
    p4jCookie.setDomain(cookie.getDomain());
    p4jCookie.setPath(cookie.getPath());
    return p4jCookie;
  }).collect(Collectors.toList());
}
origin: org.pac4j/vertx-pac4j

@Override
public void addResponseCookie(Cookie cookie) {
  routingContext.addCookie(io.vertx.ext.web.Cookie.cookie(cookie.getName(), cookie.getValue()));
}
origin: org.apache.knox/gateway-provider-security-pac4j

public Object get(WebContext context, String key) {
  final Cookie cookie = ContextHelper.getCookie(context, PAC4J_SESSION_PREFIX + key);
  Object value = null;
  if (cookie != null) {
    value = uncompressDecryptBase64(cookie.getValue());
  }
  logger.debug("Get from session: {} = {}", key, value);
  return value;
}
origin: jooby-project/jooby

@Override public void addResponseCookie(Cookie cookie) {
 org.jooby.Cookie.Definition c = new org.jooby.Cookie.Definition(cookie.getName(),
   cookie.getValue());
 Optional.ofNullable(cookie.getDomain()).ifPresent(c::domain);
 Optional.ofNullable(cookie.getPath()).ifPresent(c::path);
 c.httpOnly(cookie.isHttpOnly());
 c.maxAge(cookie.getMaxAge());
 c.secure(cookie.isSecure());
 rsp.cookie(c);
}
origin: pac4j/undertow-pac4j

@Override
public Collection<Cookie> getRequestCookies() {
  final Collection<io.undertow.server.handlers.Cookie> uCookies = exchange.getRequestCookies().values();
  final List<Cookie> cookies = new ArrayList<>(uCookies.size());
  for (final io.undertow.server.handlers.Cookie uCookie : uCookies) {
    final Cookie cookie = new Cookie(uCookie.getName(), uCookie.getValue());
    cookie.setComment(uCookie.getComment());
    cookie.setDomain(uCookie.getDomain());
    cookie.setPath(uCookie.getPath());
    cookie.setMaxAge(uCookie.getMaxAge() == null ? -1 : uCookie.getMaxAge());
    cookie.setSecure(uCookie.isSecure());
    cookie.setHttpOnly(uCookie.isHttpOnly());
    cookies.add(cookie);
  }
  return cookies;
}
origin: jooby-project/jooby

@Override
public Collection<Cookie> getRequestCookies() {
 return req.cookies().stream().map(c -> {
  Cookie cookie = new Cookie(c.name(), c.value().orElse(null));
  c.domain().ifPresent(cookie::setDomain);
  c.path().ifPresent(cookie::setPath);
  cookie.setHttpOnly(c.httpOnly());
  cookie.setSecure(c.secure());
  return cookie;
 }).collect(Collectors.toList());
}
origin: pac4j/vertx-pac4j

@Override
public void addResponseCookie(Cookie cookie) {
  routingContext.addCookie(io.vertx.ext.web.Cookie.cookie(cookie.getName(), cookie.getValue()));
}
origin: pippo-java/pippo

@Override
public void addResponseCookie(Cookie cookie) {
  getResponse().cookie(cookie.getPath(),
    cookie.getDomain(),
    cookie.getName(),
    cookie.getValue(),
    cookie.getMaxAge(),
    cookie.isSecure()
  );
  javax.servlet.http.Cookie addedCookie = getResponse().getCookie(cookie.getName());
  addedCookie.setHttpOnly(cookie.isHttpOnly());
  addedCookie.setComment(cookie.getComment());
}
origin: org.pac4j/play-pac4j-java

@Override
public Collection<Cookie> getRequestCookies() {
  final List<Cookie> cookies = new ArrayList<>();
  final Http.Cookies httpCookies = request.cookies();
  httpCookies.forEach(httpCookie -> {
    final Cookie cookie = new Cookie(httpCookie.name(), httpCookie.value());
    cookie.setDomain(httpCookie.domain());
    cookie.setHttpOnly(httpCookie.httpOnly());
    cookie.setMaxAge(httpCookie.maxAge());
    cookie.setPath(httpCookie.path());
    cookie.setSecure(httpCookie.secure());
    cookies.add(cookie);
  });
  return cookies;
}
org.pac4j.core.contextCookie

Most used methods

  • <init>
  • getValue
  • getName
  • setDomain
  • setHttpOnly
  • setSecure
  • getDomain
  • getMaxAge
  • getPath
  • isHttpOnly
  • isSecure
  • setPath
  • isSecure,
  • setPath,
  • setMaxAge,
  • getComment,
  • setComment,
  • setVersion,
  • getVersion

Popular in Java

  • Making http requests using okhttp
  • setContentView (Activity)
  • getContentResolver (Context)
  • onCreateOptionsMenu (Activity)
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • Top PhpStorm plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now