Package org.simpleframework.http

Examples of org.simpleframework.http.Cookie


    * @param value the value that the <code>Cookie</code> contains
    *
    * @return the <code>Cookie</code> that was just parsed
    */
   private Cookie getCookie(String name, String value) {
      Cookie cookie = new Cookie(name, value, false);
     
      if(domain.len > 0) {
         cookie.setDomain(domain.toString());
      }
      if(path.len > 0) {
         cookie.setPath(path.toString());
      }
      cookie.setVersion(version);
      return cookie;
   }
View Full Code Here


    * @param value this is the cookie value that is to be used
    *
    * @return returns the cookie that has been set in the response
    */
   public Cookie setCookie(String name, String value) {
      return setCookie(new Cookie(name, value, true));
   }
View Full Code Here

      this.login = oldSession.login;
      expirationTimeMillis = System.currentTimeMillis() + sessionExpirationAgeMillis;
    }
   
    public Cookie asCookie(String name) {
      Cookie res = new Cookie(name, id.toString());
      res.setExpiry((int)((expirationTimeMillis - System.currentTimeMillis()) / 1000));
      return res;
    }
View Full Code Here

      sendJson(new APIErrorResponse(APIErrorResponse.CODE_INCORRECT_REQUEST, "Login and password should be present"));
    }
  }
 
  private void responseAPILogout() throws IOException {
    Cookie sessionIdCookie = request.getCookie(COOKIE_SESSION_ID);
    if (sessionIdCookie != null) {
      Session session = main.sessionManager.fromCookie(sessionIdCookie);
      if (session != null) {
        main.sessionManager.eraseSession(session);
      }
View Full Code Here

  private void responseAPIAddMessage() throws IOException {
    String text = request.getParameter("text");
    Session session;
    final User user;
   
    Cookie sessionIdCookie = request.getCookie(COOKIE_SESSION_ID);
    if (sessionIdCookie != null && (session = main.sessionManager.fromCookie(sessionIdCookie)) != null) {
      // Session is open
      session = main.sessionManager.renewSession(session);
      user = main.dataConnector.getUser(session.login);
      if (user != null) {
View Full Code Here

    responseHeaders(ResponseFormat.JSON, 403);
    sendJson(new APIErrorResponse(APIErrorResponse.CODE_LOGIN_REQUIRED, "You should login to write messages"));
  }

  private void responseAPIGetMessages() throws IOException {
    Cookie sessionIdCookie = request.getCookie(COOKIE_SESSION_ID);
    if (sessionIdCookie != null) {
      Session session = main.sessionManager.fromCookie(sessionIdCookie);
      if (session != null) {
        Message[] messages = main.dataConnector.getMessages();
        sendJson(messages);
View Full Code Here

  private void responseUIRoot() throws IOException {
    Session session;
    final User user;
   
    Cookie sessionIdCookie = request.getCookie(COOKIE_SESSION_ID);
    if (sessionIdCookie != null && (session = main.sessionManager.fromCookie(sessionIdCookie)) != null) {
      // Session is open
      session = main.sessionManager.renewSession(session);
      user = main.dataConnector.getUser(session.login);       
    } else {
View Full Code Here

    * @param value the value that the <code>Cookie</code> contains
    *
    * @return the <code>Cookie</code> that was just parsed
    */
   private Cookie getCookie(String name, String value) {
      Cookie cookie = new Cookie(name, value, false);
     
      if(domain.len > 0) {
         cookie.setDomain(domain.toString());
      }
      if(path.len > 0) {
         cookie.setPath(path.toString());
      }
      cookie.setVersion(version);
      return cookie;
   }
View Full Code Here

    */
   private Cookie getCookie(String name) {
      UUID identity = UUID.randomUUID();
      String value = identity.toString();
     
      return new Cookie(name, value, true);
   }
View Full Code Here

    * @param value this is the cookie value that is to be used
    *
    * @return returns the cookie that has been set in the response
    */
   public Cookie setCookie(String name, String value) {
      return setCookie(new Cookie(name, value, true));
   }
View Full Code Here

TOP

Related Classes of org.simpleframework.http.Cookie

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.