Examples of Cookie


Examples of javax.servlet.http.Cookie

            AbstractTokenService tokenService = AbstractTokenService.getInstance(CookieTokenService.class);
            String cookieToken = tokenService.createToken(credentials);

            log.debug("Found a remember me request parameter, created a persistent token " + cookieToken + " for it and set it up " +
               "in the next response");
            Cookie cookie = new Cookie(InitiateLoginServlet.COOKIE_NAME, cookieToken);
            cookie.setPath(req.getContextPath());
            cookie.setMaxAge((int)tokenService.getValidityTime() / 1000);
            resp.addCookie(cookie);
         }
      }

      //
View Full Code Here

Examples of javax.servlet.http.Cookie

      doGet(req, resp);
   }

   private void clearTokenCookie(HttpServletRequest req, HttpServletResponse resp)
   {
      Cookie cookie = new Cookie(InitiateLoginServlet.COOKIE_NAME, "");
      cookie.setPath(req.getContextPath());
      cookie.setMaxAge(0);
      resp.addCookie(cookie);
   }
View Full Code Here

Examples of javax.servlet.http.Cookie

            {
               log.debug("Login initiated with no credentials in session but found token an invalid " + token + " " +
                  "that will be cleared in next response");

               // We clear the cookie in the next response as it was not valid
               Cookie cookie = new Cookie(InitiateLoginServlet.COOKIE_NAME, "");
               cookie.setPath(req.getContextPath());
               cookie.setMaxAge(0);
               resp.addCookie(cookie);

               // This allows the customer to define another login page without
               // changing the portal
               showLoginForm(req, resp);
View Full Code Here

Examples of javax.servlet.http.Cookie

          reqSessionValue = sessionCookieValue;
        } catch (IllegalStateException ise) {
        } catch (NullPointerException npe) {
        }
      } else {
        Cookie c;
        inCookies.addElement(c = new Cookie(name, value));
        if (path != null) {
          c.setPath(path);
          if (domain != null)
            c.setDomain(domain);
        }
      }
    }
View Full Code Here

Examples of javax.servlet.http.Cookie

            out.println();
          }
        }
        StringBuffer sb = null;
        StringBuffer sb2 = null;
        Cookie cc = null;
        // add session cookie
        if (sessionValue != null) {
          HttpSession session = serve.getSession(sessionValue);
          if (session != null) {
            if (((AcmeSession) session).isValid()) {
              if (session.isNew()) {
                cc = new Cookie(SESSION_COOKIE_NAME,
                    sessionValue);
                if (serve.expiredIn < 0)
                  cc.setMaxAge(Math.abs(serve.expiredIn) * 60);
                ServletContext sc = ((AcmeSession) session)
                    .getServletContext();
                try {
                  String cp = (String) sc
                      .getClass()
                      .getMethod("getContextPath",
                          Utils.EMPTY_CLASSES)
                      .invoke(sc, Utils.EMPTY_OBJECTS);
                  if (cp.length() == 0)
                    cp = "/";
                  cc.setPath(cp);
                } catch (Exception e) {

                }

                addCookie(cc);
              }
            } else {
              cc = new Cookie(SESSION_COOKIE_NAME, "");
              cc.setMaxAge(0);
              addCookie(cc);
            }
          }
        }

        // how to remove a cookie
        // cc = new Cookie(cookieName, "");
        // cc.setMaxAge(0);
        //
        for (int i = 0; outCookies != null && i < outCookies.size(); i++) {
          cc = (Cookie) outCookies.elementAt(i);
          if (cc.getSecure() && isSecure() == false)
            continue;
          int version = cc.getVersion();
          String token;
          if (version > 1) {
            if (sb2 == null)
              sb2 = new StringBuffer(SETCOOKIE + "2: ");
            else
              sb2.append(',');
            sb2.append(cc.getName());
            sb2.append("=\"");
            sb2.append(cc.getValue()).append('"');
            token = cc.getComment();
            if (token != null)
              sb2.append("; Comment=\"").append(token)
                  .append('"');
            token = cc.getDomain();
            if (token != null)
              sb2.append("; Domain=\"").append(token).append('"');
            if (cc.getMaxAge() >= 0)
              sb2.append("; Max-Age=\"").append(cc.getMaxAge())
                  .append('"');
            token = cc.getPath();
            if (token != null)
              sb2.append("; Path=\"").append(token).append('"');
            if (cc.getSecure()) {
              sb2.append("; Secure");
            }
            sb2.append("; Version=\"").append(version).append('"');
          } else {
            if (sb == null)
              sb = new StringBuffer(SETCOOKIE + ": ");
            else
              // sb.append(',');
              sb.append("\r\n" + SETCOOKIE + ": "); // for IE not
            sb.append(cc.getName());
            sb.append('=');
            sb.append(cc.getValue());// .append('"');
            if (cc.getDomain() != null
                && cc.getDomain().length() > 0) {
              sb.append("; domain=" + cc.getDomain());
            }
            if (cc.getMaxAge() >= 0) {
              sb.append("; expires=");
              sb.append(expdatefmt.format(new Date(new Date()
                  .getTime() + 1000l * cc.getMaxAge())));
            }
            if (cc.getPath() != null && cc.getPath().length() > 0) {
              sb.append("; path=" + cc.getPath());
            }
            if (cc.getSecure()) {
              sb.append("; secure");
            }
          }
        }
        if (sb != null) {
View Full Code Here

Examples of javax.servlet.http.Cookie

   * @return
   */
  public static String getDlogSessionId(HttpServletRequest req){
    //���ȴ�Cookie�л�ȡssn_idֵ
    String ssn_id = null;
    Cookie cok = RequestUtils.getCookie(req, Globals.SESSION_ID_KEY_IN_COOKIE);
    if(cok != null){
      ssn_id = cok.getValue();
    }
    if(StringUtils.isEmpty(ssn_id)){
      //���Cookie�ò�����ӷ������ĻỰ�ж�ȡ
      HttpSession ssn = req.getSession(false);
      if (ssn != null)
View Full Code Here

Examples of javax.servlet.http.Cookie

   * ���FCKUpload���������ɵ�Cookie
   * @param req
   * @param res
   */
  public static void clearDlogSessionId(HttpServletRequest req, HttpServletResponse res){
    Cookie cok = RequestUtils.getCookie(req, Globals.SESSION_ID_KEY_IN_COOKIE);
    if(cok != null){
      cok.setMaxAge(0);
      res.addCookie(cok);
    }
  }
View Full Code Here

Examples of javax.servlet.http.Cookie

   * @param value
   * @param maxAge
   */
  public static void setCookie(HttpServletRequest request, HttpServletResponse response, String name,
      String value, int maxAge) {
    Cookie cookie = new Cookie(name, value);
    cookie.setMaxAge(maxAge);
    String serverName = request.getServerName();
    String domain = getDomainOfServerName(serverName);
    if(domain!=null && domain.indexOf('.')!=-1){
      cookie.setDomain('.' + domain);
    }
    cookie.setPath("/");
    response.addCookie(cookie);
  }
View Full Code Here

Examples of javax.servlet.http.Cookie

   * @param path
   * @param response
   */
  public static void storeCookie(String id, String value,String path,
      HttpServletResponse response) {
    Cookie cookie = new Cookie(id, value);
    cookie.setPath(path);
    response.addCookie(cookie);
  }
View Full Code Here

Examples of javax.servlet.http.Cookie

     * @param name the name of the cookie.
     * @return the Cookie object if it exists, otherwise null.
     */
    public static Cookie getCookie(HttpServletRequest request, String name)
    {
        Cookie cookies[] = request.getCookies();
        if (cookies == null || name == null || name.length() == 0)
        {
            return null;
        }
        //Otherwise, we have to do a linear scan for the cookie.
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.