Package juzu.impl.bridge.spi.servlet

Examples of juzu.impl.bridge.spi.servlet.ServletWebBridge


  private final static String DOMAIN_ATTRIBUTE_NAME = "Domain";

  public static void rememberSerialized() {
    HttpContext context = Request.getCurrent().getHttpContext();
    if (context instanceof ServletWebBridge) {
      ServletWebBridge bridge = (ServletWebBridge) context;
 
      // base 64 encode it and store as a cookie:
      DefaultSerializer<PrincipalCollection> serializer = new DefaultSerializer<PrincipalCollection>();
      byte[] serialized = serializer.serialize(SecurityUtils.getSubject().getPrincipals());
      serialized = encrypt(serialized);
      String base64 = Base64.encodeToString(serialized);

      String name = DEFAULT_REMEMBER_ME_COOKIE_NAME;
      String value = base64;
      String domain = context.getServerName();
      String path = context.getContextPath();
      int maxAge = ONE_YEAR; // always zero for deletion
      final String headerValue = buildHeaderValue(name, value, domain.trim(), path.trim(), maxAge);
      bridge.getResponse().setHeader(COOKIE_HEADER_NAME, headerValue);
    }
  }
View Full Code Here


  }

  public static void forgetIdentity() {
    HttpContext context = Request.getCurrent().getHttpContext();
    if (context instanceof ServletWebBridge) {
      ServletWebBridge bridge = (ServletWebBridge) context;
     
      String name = DEFAULT_REMEMBER_ME_COOKIE_NAME;
      String value = DELETED_COOKIE_VALUE;
      String domain = context.getServerName();
      String path = context.getContextPath();
      int maxAge = 0; // always zero for deletion
      final String headerValue = buildHeaderValue(name, value, domain.trim(), path.trim(), maxAge);
      bridge.getResponse().setHeader(COOKIE_HEADER_NAME, headerValue);
    }
  }
View Full Code Here

TOP

Related Classes of juzu.impl.bridge.spi.servlet.ServletWebBridge

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.