Package javax.ws.rs.core

Examples of javax.ws.rs.core.NewCookie


      int maxage = javax.ws.rs.core.NewCookie.DEFAULT_MAX_AGE;
      int version = 1;
      boolean secure = false;

      Cookie ck1 = new Cookie(name, value);
      NewCookie nck1 = new NewCookie(ck1);

      name = "name_2";
      value = "value_2";
      String path = "/acme";
      String domain = "";

      Cookie ck2 = new Cookie(name, value, path, domain);
      NewCookie nck2 = new NewCookie(ck2);

      name = "name_3";
      value = "value_3";
      path = "";
      domain = "y.x.foo.com";

      Cookie ck3 = new Cookie(name, value, path, domain);
      NewCookie nck3 = new NewCookie(ck3);

      List<String> cookies = Arrays.asList(nck1.toString().toLowerCase(),
              nck2.toString().toLowerCase(),
              nck3.toString().toLowerCase());

      Response resp = Response.status(status).cookie(nck1, nck2, nck3).build();
      String tmp = verifyResponse(resp, null, status, null, null, null, null,
              null, cookies);
      if (tmp.endsWith("false"))
View Full Code Here


      List<String> lang = Arrays.asList("en_US", "en_GB", "zh_CN");

      String name = "name_1";
      String value = "value_1";
      Cookie ck1 = new Cookie(name, value);
      NewCookie nck1 = new NewCookie(ck1);

      List<String> cookies = Arrays.asList(nck1.toString().toLowerCase());

      Response resp = Response.status(status).header("Content-type",
              "text/plain").header("Content-type", "text/html").header("Content-Language", "en_US").
              header("Content-Language", "en_GB").header("Content-Language",
              "zh_CN").header("Cache-Control", "no-transform").
View Full Code Here

   {
      @Path("/set")
      @GET
      public Response set()
      {
         return Response.ok("content").cookie(new NewCookie("meaning", "42")).build();
      }
View Full Code Here

         Map<String, NewCookie> cookies = responseContext.getCookies();
         setEntity(collectionToString(cookies.keySet()));
      }

      public void getCookiesIsReadOnly() {
         NewCookie cookie = new NewCookie(COOKIENAME, COOKIENAME);
         Map<String, NewCookie> cookies = responseContext.getCookies();
         if (assertTrue(!cookies.containsKey(COOKIENAME), COOKIENAME,
                 "is already present"))
            return;
         try {
View Full Code Here

      String output = "Created customer <a href=\"customers/" + customer.getId() + "\">" + customer.getId() + "</a>";
      String lastVisit = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG).format(new Date());
      URI location = URI.create("/customers/" + customer.getId());
      return Response.created(location)
              .entity(output)
              .cookie(new NewCookie("last-visit", lastVisit))
              .build();

   }
View Full Code Here

      String output = "User-Agent: " + userAgent + "\r\n";
      output += "Last visit: " + date + "\r\n\r\n";
      output += "Customer: " + customer.getFirstName() + " " + customer.getLastName();
      String lastVisit = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG).format(new Date());
      return Response.ok(output)
              .cookie(new NewCookie("last-visit", lastVisit))
              .build();
   }
View Full Code Here

                cookieValue = value;
            }

        }

        return new NewCookie(cookieName, cookieValue, path, domain, version, comment, maxAge, expiry, secure, httpOnly);

    }
View Full Code Here

            while (it.hasNext())
            {
               Object next = it.next();
               if (next instanceof NewCookie)
               {
                  NewCookie cookie = (NewCookie) next;
                  response.addNewCookie(cookie);
                  it.remove();
               }
            }
            if (cookies.size() < 1)
View Full Code Here

            cookieName = name;
            cookieValue = value;
         }
      }

      return new NewCookie(cookieName, cookieValue, path, domain, version, comment, maxAge, secure);

   }
View Full Code Here

      }
   }

   public String toString(Object value)
   {
      NewCookie cookie = (NewCookie) value;
      StringBuilder b = new StringBuilder();

      b.append(cookie.getName()).append('=');
      quote(b, cookie.getValue());

      b.append(";").append("Version=").append(cookie.getVersion());

      if (cookie.getComment() != null)
      {
         b.append(";Comment=");
         quote(b, cookie.getComment());
      }
      if (cookie.getDomain() != null)
      {
         b.append(";Domain=");
         quote(b, cookie.getDomain());
      }
      if (cookie.getPath() != null)
      {
         b.append(";Path=");
         quote(b, cookie.getPath());
      }
      if (cookie.getMaxAge() != -1)
      {
         b.append(";Max-Age=");
         b.append(cookie.getMaxAge());
      }
      if (cookie.isSecure())
         b.append(";Secure");
      return b.toString();
   }
View Full Code Here

TOP

Related Classes of javax.ws.rs.core.NewCookie

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.