01: /*
02: * $HeadURL:https://svn.apache.org/repos/asf/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/cookie/CookieOrigin.java $
03: * $Revision:400312 $
04: * $Date:2006-05-06 14:49:41 +0200 (Sat, 06 May 2006) $
05: *
06: * ====================================================================
07: *
08: * Licensed to the Apache Software Foundation (ASF) under one or more
09: * contributor license agreements. See the NOTICE file distributed with
10: * this work for additional information regarding copyright ownership.
11: * The ASF licenses this file to You under the Apache License, Version 2.0
12: * (the "License"); you may not use this file except in compliance with
13: * the License. You may obtain a copy of the License at
14: *
15: * http://www.apache.org/licenses/LICENSE-2.0
16: *
17: * Unless required by applicable law or agreed to in writing, software
18: * distributed under the License is distributed on an "AS IS" BASIS,
19: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20: * See the License for the specific language governing permissions and
21: * limitations under the License.
22: * ====================================================================
23: *
24: * This software consists of voluntary contributions made by many
25: * individuals on behalf of the Apache Software Foundation. For more
26: * information on the Apache Software Foundation, please see
27: * <http://www.apache.org/>.
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,
48: boolean secure) {
49: super ();
50: if (host == null) {
51: throw new IllegalArgumentException(
52: "Host of origin may not be null");
53: }
54: if (host.trim().equals("")) {
55: throw new IllegalArgumentException(
56: "Host of origin may not be blank");
57: }
58: if (port < 0) {
59: throw new IllegalArgumentException("Invalid port: " + port);
60: }
61: if (path == null) {
62: throw new IllegalArgumentException(
63: "Path of origin may not be null.");
64: }
65: this .host = host;
66: this .port = port;
67: this .path = path;
68: this .secure = secure;
69: }
70:
71: public String getHost() {
72: return this .host;
73: }
74:
75: public String getPath() {
76: return this .path;
77: }
78:
79: public int getPort() {
80: return this .port;
81: }
82:
83: public boolean isSecure() {
84: return this.secure;
85: }
86:
87: }
|