Package org.simpleframework.http

Examples of org.simpleframework.http.Cookie


    *
    * @return a session associated with the provided entity
    */
   public Session getSession(Entity entity, boolean create) throws LeaseException {
      Header header = entity.getHeader();
      Cookie cookie = header.getSession(create);

      if(cookie == null) {
         return null;
      }
      return getSession(cookie, create);
View Full Code Here


public class SecurePolicyTest extends TestCase {
  
   public void testPolicy() {
      Header header = new RequestConsumer();
      Policy policy = new SecurePolicy(header);
      Cookie cookie = policy.getSession(false);
     
      assertNull(cookie);
     
      cookie = policy.getSession(true);
     
      assertNotNull(cookie);
      assertEquals(cookie.getName(), "JSESSIONID");
      assertNotNull(cookie.getValue());
      assertEquals(cookie, policy.getSession(false));
      assertEquals(cookie, policy.getSession(true));
     
      System.out.println(cookie);
      System.out.println(cookie.toClientString());
   }
View Full Code Here

    *
    * @exception IOException thrown if there was a problem writing
    */
   public void commit() throws IOException {
      if(!committed) {      
         Cookie cookie = header.getSession(false);
        
         if(cookie != null) {
            setSession(cookie);
         }
         byte[] message = getMessage();
View Full Code Here

    *
    * @param session this is the session cookie that is to be set
    */
   private void setSession(Cookie session) {
      String name = session.getName();
      Cookie cookie = getCookie(name);
     
      if(cookie == null) {
         cookie = session;
      }
      if(cookie.isNew()) {
         setCookie(cookie);
      }
   }
View Full Code Here

        this.response = response;
    }

    @Override
    public RestxResponse addCookie(String cookie, String value, Duration expiration) {
        Cookie c = new Cookie(cookie, value, "/");
        c.setExpiry(expiration.getStandardSeconds() > 0 ? (int) expiration.getStandardSeconds() : -1);
        response.setCookie(c);
        return this;
    }
View Full Code Here

        return this;
    }

    @Override
    public RestxResponse clearCookie(String cookie) {
        Cookie c = new Cookie(cookie, "");
        c.setPath("/");
        c.setExpiry(0);
        response.setCookie(c);
        return this;
    }
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.