author | ascarpino |
Mon, 19 Oct 2015 17:35:18 -0700 | |
changeset 33241 | 27eb2d6abda9 |
parent 30506 | 1998a5644f50 |
child 35302 | e4d2275861c3 |
permissions | -rw-r--r-- |
30506
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
1 |
/* |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
4 |
* |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
10 |
* |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
15 |
* accompanied this code). |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
16 |
* |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
20 |
* |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
23 |
* questions. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
24 |
*/ |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
25 |
|
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
26 |
package java.security.cert; |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
27 |
|
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
28 |
import java.net.URI; |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
29 |
|
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
30 |
/** |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
31 |
* Parameters used as input for {@code CertStore} algorithms which use |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
32 |
* information contained in a URI to retrieve certificates and CRLs. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
33 |
* <p> |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
34 |
* This class is used to provide necessary configuration parameters |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
35 |
* through a URI as defined in RFC 5280 to implementations of |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
36 |
* {@code CertStore} algorithms. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
37 |
* <p> |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
38 |
* <b>Concurrent Access</b> |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
39 |
* <p> |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
40 |
* Unless otherwise specified, the methods defined in this class are not |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
41 |
* thread-safe. Multiple threads that need to access a single |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
42 |
* object concurrently should synchronize amongst themselves and |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
43 |
* provide the necessary locking. Multiple threads each manipulating |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
44 |
* separate objects need not synchronize. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
45 |
* |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
46 |
* @since 1.9 |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
47 |
* @see CertStore |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
48 |
* @see java.net.URI |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
49 |
*/ |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
50 |
public final class URICertStoreParameters implements CertStoreParameters { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
51 |
|
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
52 |
/** |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
53 |
* The uri, cannot be null |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
54 |
*/ |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
55 |
private final URI uri; |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
56 |
|
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
57 |
/* |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
58 |
* Hash code for this parameters. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
59 |
*/ |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
60 |
private int myhash = -1; |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
61 |
|
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
62 |
/** |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
63 |
* Creates an instance of {@code URICertStoreParameters} with the |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
64 |
* specified URI. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
65 |
* |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
66 |
* @param uri the URI which contains configuration information. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
67 |
* @throws NullPointerException if {@code uri} is null |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
68 |
*/ |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
69 |
public URICertStoreParameters(URI uri) { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
70 |
if (uri == null) { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
71 |
throw new NullPointerException(); |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
72 |
} |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
73 |
this.uri = uri; |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
74 |
} |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
75 |
|
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
76 |
/** |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
77 |
* Returns the URI used to construct this |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
78 |
* {@code URICertStoreParameters} object. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
79 |
* |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
80 |
* @return the URI. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
81 |
*/ |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
82 |
public URI getURI() { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
83 |
return uri; |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
84 |
} |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
85 |
|
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
86 |
/** |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
87 |
* Returns a copy of this object. Changes to the copy will not affect |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
88 |
* the original and vice versa. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
89 |
* |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
90 |
* @return the copy |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
91 |
*/ |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
92 |
@Override |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
93 |
public URICertStoreParameters clone() { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
94 |
try { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
95 |
return new URICertStoreParameters(uri); |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
96 |
} catch (NullPointerException e) { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
97 |
/* Cannot happen */ |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
98 |
throw new InternalError(e.toString(), e); |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
99 |
} |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
100 |
} |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
101 |
|
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
102 |
/** |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
103 |
* Returns a hash code value for this parameters object. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
104 |
* The hash code is generated using the URI supplied at construction. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
105 |
* |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
106 |
* @return a hash code value for this parameters. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
107 |
*/ |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
108 |
@Override |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
109 |
public int hashCode() { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
110 |
if (myhash == -1) { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
111 |
myhash = uri.hashCode()*7; |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
112 |
} |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
113 |
return myhash; |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
114 |
} |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
115 |
|
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
116 |
/** |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
117 |
* Compares the specified object with this parameters object for equality. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
118 |
* Two URICertStoreParameters are considered equal if the URIs used |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
119 |
* to construct them are equal. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
120 |
* |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
121 |
* @param p the object to test for equality with this parameters. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
122 |
* |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
123 |
* @return true if the specified object is equal to this parameters object. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
124 |
*/ |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
125 |
@Override |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
126 |
public boolean equals(Object p) { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
127 |
if (p == null || (!(p instanceof URICertStoreParameters))) { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
128 |
return false; |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
129 |
} |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
130 |
|
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
131 |
if (p == this) { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
132 |
return true; |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
133 |
} |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
134 |
|
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
135 |
URICertStoreParameters other = (URICertStoreParameters)p; |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
136 |
return uri.equals(other.getURI()); |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
137 |
} |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
138 |
|
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
139 |
/** |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
140 |
* Returns a formatted string describing the parameters |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
141 |
* including the URI used to construct this object. |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
142 |
* |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
143 |
* @return a formatted string describing the parameters |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
144 |
*/ |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
145 |
@Override |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
146 |
public String toString() { |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
147 |
return "URICertStoreParameters: " + uri.toString(); |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
148 |
} |
1998a5644f50
8038084: CertStore needs a way to add new CertStore types
valeriep
parents:
diff
changeset
|
149 |
} |