KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > java > security > cert > CollectionCertStoreParameters


1 /*
2  * @(#)CollectionCertStoreParameters.java 1.8 04/05/05
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package java.security.cert;
9
10 import java.io.Serializable JavaDoc;
11 import java.util.Collection JavaDoc;
12 import java.util.Collections JavaDoc;
13
14 /**
15  * Parameters used as input for the Collection <code>CertStore</code>
16  * algorithm.
17  * <p>
18  * This class is used to provide necessary configuration parameters
19  * to implementations of the Collection <code>CertStore</code>
20  * algorithm. The only parameter included in this class is the
21  * <code>Collection</code> from which the <code>CertStore</code> will
22  * retrieve certificates and CRLs.
23  * <p>
24  * <b>Concurrent Access</b>
25  * <p>
26  * Unless otherwise specified, the methods defined in this class are not
27  * thread-safe. Multiple threads that need to access a single
28  * object concurrently should synchronize amongst themselves and
29  * provide the necessary locking. Multiple threads each manipulating
30  * separate objects need not synchronize.
31  *
32  * @version 1.8 05/05/04
33  * @since 1.4
34  * @author Steve Hanna
35  * @see java.util.Collection
36  * @see CertStore
37  */

38 public class CollectionCertStoreParameters
39     implements CertStoreParameters JavaDoc {
40
41     private Collection JavaDoc coll;
42
43     /**
44      * Creates an instance of <code>CollectionCertStoreParameters</code>
45      * which will allow certificates and CRLs to be retrieved from the
46      * specified <code>Collection</code>. If the specified
47      * <code>Collection</code> contains an object that is not a
48      * <code>Certificate</code> or <code>CRL</code>, that object will be
49      * ignored by the Collection <code>CertStore</code>.
50      * <p>
51      * The <code>Collection</code> is <b>not</b> copied. Instead, a
52      * reference is used. This allows the caller to subsequently add or
53      * remove <code>Certificates</code> or <code>CRL</code>s from the
54      * <code>Collection</code>, thus changing the set of
55      * <code>Certificates</code> or <code>CRL</code>s available to the
56      * Collection <code>CertStore</code>. The Collection <code>CertStore</code>
57      * will not modify the contents of the <code>Collection</code>.
58      * <p>
59      * If the <code>Collection</code> will be modified by one thread while
60      * another thread is calling a method of a Collection <code>CertStore</code>
61      * that has been initialized with this <code>Collection</code>, the
62      * <code>Collection</code> must have fail-fast iterators.
63      *
64      * @param collection a <code>Collection</code> of
65      * <code>Certificate</code>s and <code>CRL</code>s
66      * @exception NullPointerException if <code>collection</code> is
67      * <code>null</code>
68      */

69     public CollectionCertStoreParameters(Collection JavaDoc<?> collection) {
70         if (collection == null)
71             throw new NullPointerException JavaDoc();
72         coll = collection;
73     }
74
75     /**
76      * Creates an instance of <code>CollectionCertStoreParameters</code> with
77      * the default parameter values (an empty and immutable
78      * <code>Collection</code>).
79      */

80     public CollectionCertStoreParameters() {
81         coll = Collections.EMPTY_SET;
82     }
83
84     /**
85      * Returns the <code>Collection</code> from which <code>Certificate</code>s
86      * and <code>CRL</code>s are retrieved. This is <b>not</b> a copy of the
87      * <code>Collection</code>, it is a reference. This allows the caller to
88      * subsequently add or remove <code>Certificates</code> or
89      * <code>CRL</code>s from the <code>Collection</code>.
90      *
91      * @return the <code>Collection</code> (never null)
92      */

93     public Collection JavaDoc<?> getCollection() {
94         return coll;
95     }
96
97     /**
98      * Returns a copy of this object. Note that only a reference to the
99      * <code>Collection</code> is copied, and not the contents.
100      *
101      * @return the copy
102      */

103     public Object JavaDoc clone() {
104         try {
105             return super.clone();
106         } catch (CloneNotSupportedException JavaDoc e) {
107             /* Cannot happen */
108             throw new InternalError JavaDoc(e.toString());
109         }
110     }
111
112     /**
113      * Returns a formatted string describing the parameters.
114      *
115      * @return a formatted string describing the parameters
116      */

117     public String JavaDoc toString() {
118         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
119         sb.append("CollectionCertStoreParameters: [\n");
120         sb.append(" collection: " + coll + "\n");
121         sb.append("]");
122         return sb.toString();
123     }
124 }
125
Popular Tags