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