1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 package org.apache.commons.httpclient.cookie;
31
32 /***
33 * CookieOrigin class incapsulates details of an origin server that
34 * are relevant when parsing, validating or matching HTTP cookies.
35 *
36 * @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
37 *
38 * @since 3.1
39 */
40 public final class CookieOrigin {
41
42 private final String host;
43 private final int port;
44 private final String path;
45 private final boolean secure;
46
47 public CookieOrigin(final String host, int port, final String path, boolean secure) {
48 super();
49 if (host == null) {
50 throw new IllegalArgumentException(
51 "Host of origin may not be null");
52 }
53 if (host.trim().equals("")) {
54 throw new IllegalArgumentException(
55 "Host of origin may not be blank");
56 }
57 if (port < 0) {
58 throw new IllegalArgumentException("Invalid port: " + port);
59 }
60 if (path == null) {
61 throw new IllegalArgumentException(
62 "Path of origin may not be null.");
63 }
64 this.host = host;
65 this.port = port;
66 this.path = path;
67 this.secure = secure;
68 }
69
70 public String getHost() {
71 return this.host;
72 }
73
74 public String getPath() {
75 return this.path;
76 }
77
78 public int getPort() {
79 return this.port;
80 }
81
82 public boolean isSecure() {
83 return this.secure;
84 }
85
86 }