View Javadoc

1   /*
2    * $HeadURL:https://svn.apache.org/repos/asf/jakarta/commons/proper/httpclient/trunk/src/java/org/apache/commons/httpclient/cookie/CookieOrigin.java $
3    * $Revision:400312 $
4    * $Date:2006-05-06 14:49:41 +0200 (Sat, 06 May 2006) $
5    *
6    * ====================================================================
7    *
8    *  Copyright 1999-2004 The Apache Software Foundation
9    *
10   *  Licensed under the Apache License, Version 2.0 (the "License");
11   *  you may not use this file except in compliance with the License.
12   *  You may obtain a copy of the License at
13   *
14   *      http://www.apache.org/licenses/LICENSE-2.0
15   *
16   *  Unless required by applicable law or agreed to in writing, software
17   *  distributed under the License is distributed on an "AS IS" BASIS,
18   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19   *  See the License for the specific language governing permissions and
20   *  limitations under the License.
21   * ====================================================================
22   *
23   * This software consists of voluntary contributions made by many
24   * individuals on behalf of the Apache Software Foundation.  For more
25   * information on the Apache Software Foundation, please see
26   * <http://www.apache.org/>.
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  }