Package juzu.request

Examples of juzu.request.HttpContext


  /** . */
  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


      bridge.getResponse().setHeader(COOKIE_HEADER_NAME, headerValue);
    }
  }

  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

    }
    return base64;
  }

  private String readCookieValue(String name) {
    HttpContext context = Request.getCurrent().getBridge().getHttpContext();
    Cookie[] cookies = context.getCookies();
    if (cookies != null) {
      for (Cookie cookie : cookies) {
        if (cookie.getName().equals(name)) {
          return cookie.getValue();
        }
View Full Code Here

TOP

Related Classes of juzu.request.HttpContext

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.