src/share/classes/java/security/cert/CollectionCertStoreParameters.java

Print this page




  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.security.cert;
  27 
  28 import java.io.Serializable;
  29 import java.util.Collection;
  30 import java.util.Collections;
  31 
  32 /**
  33  * Parameters used as input for the Collection <code>CertStore</code>
  34  * algorithm.
  35  * <p>
  36  * This class is used to provide necessary configuration parameters
  37  * to implementations of the Collection <code>CertStore</code>
  38  * algorithm. The only parameter included in this class is the
  39  * <code>Collection</code> from which the <code>CertStore</code> will
  40  * retrieve certificates and CRLs.
  41  * <p>
  42  * <b>Concurrent Access</b>
  43  * <p>
  44  * Unless otherwise specified, the methods defined in this class are not
  45  * thread-safe. Multiple threads that need to access a single
  46  * object concurrently should synchronize amongst themselves and
  47  * provide the necessary locking. Multiple threads each manipulating
  48  * separate objects need not synchronize.
  49  *
  50  * @since       1.4
  51  * @author      Steve Hanna
  52  * @see         java.util.Collection
  53  * @see         CertStore
  54  */
  55 public class CollectionCertStoreParameters
  56     implements CertStoreParameters {
  57 
  58     private Collection<?> coll;
  59 
  60     /**
  61      * Creates an instance of <code>CollectionCertStoreParameters</code>
  62      * which will allow certificates and CRLs to be retrieved from the
  63      * specified <code>Collection</code>. If the specified
  64      * <code>Collection</code> contains an object that is not a
  65      * <code>Certificate</code> or <code>CRL</code>, that object will be
  66      * ignored by the Collection <code>CertStore</code>.
  67      * <p>
  68      * The <code>Collection</code> is <b>not</b> copied. Instead, a
  69      * reference is used. This allows the caller to subsequently add or
  70      * remove <code>Certificates</code> or <code>CRL</code>s from the
  71      * <code>Collection</code>, thus changing the set of
  72      * <code>Certificates</code> or <code>CRL</code>s available to the
  73      * Collection <code>CertStore</code>. The Collection <code>CertStore</code>
  74      * will not modify the contents of the <code>Collection</code>.
  75      * <p>
  76      * If the <code>Collection</code> will be modified by one thread while
  77      * another thread is calling a method of a Collection <code>CertStore</code>
  78      * that has been initialized with this <code>Collection</code>, the
  79      * <code>Collection</code> must have fail-fast iterators.
  80      *
  81      * @param collection a <code>Collection</code> of
  82      *        <code>Certificate</code>s and <code>CRL</code>s
  83      * @exception NullPointerException if <code>collection</code> is
  84      * <code>null</code>
  85      */
  86     public CollectionCertStoreParameters(Collection<?> collection) {
  87         if (collection == null)
  88             throw new NullPointerException();
  89         coll = collection;
  90     }
  91 
  92     /**
  93      * Creates an instance of <code>CollectionCertStoreParameters</code> with
  94      * the default parameter values (an empty and immutable
  95      * <code>Collection</code>).
  96      */
  97     public CollectionCertStoreParameters() {
  98         coll = Collections.EMPTY_SET;
  99     }
 100 
 101     /**
 102      * Returns the <code>Collection</code> from which <code>Certificate</code>s
 103      * and <code>CRL</code>s are retrieved. This is <b>not</b> a copy of the
 104      * <code>Collection</code>, it is a reference. This allows the caller to
 105      * subsequently add or remove <code>Certificates</code> or
 106      * <code>CRL</code>s from the <code>Collection</code>.
 107      *
 108      * @return the <code>Collection</code> (never null)
 109      */
 110     public Collection<?> getCollection() {
 111         return coll;
 112     }
 113 
 114     /**
 115      * Returns a copy of this object. Note that only a reference to the
 116      * <code>Collection</code> is copied, and not the contents.
 117      *
 118      * @return the copy
 119      */
 120     public Object clone() {
 121         try {
 122             return super.clone();
 123         } catch (CloneNotSupportedException e) {
 124             /* Cannot happen */
 125             throw new InternalError(e.toString(), e);
 126         }
 127     }
 128 
 129     /**
 130      * Returns a formatted string describing the parameters.
 131      *
 132      * @return a formatted string describing the parameters
 133      */
 134     public String toString() {
 135         StringBuffer sb = new StringBuffer();
 136         sb.append("CollectionCertStoreParameters: [\n");


  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package java.security.cert;
  27 
  28 import java.io.Serializable;
  29 import java.util.Collection;
  30 import java.util.Collections;
  31 
  32 /**
  33  * Parameters used as input for the Collection {@code CertStore}
  34  * algorithm.
  35  * <p>
  36  * This class is used to provide necessary configuration parameters
  37  * to implementations of the Collection {@code CertStore}
  38  * algorithm. The only parameter included in this class is the
  39  * {@code Collection} from which the {@code CertStore} will
  40  * retrieve certificates and CRLs.
  41  * <p>
  42  * <b>Concurrent Access</b>
  43  * <p>
  44  * Unless otherwise specified, the methods defined in this class are not
  45  * thread-safe. Multiple threads that need to access a single
  46  * object concurrently should synchronize amongst themselves and
  47  * provide the necessary locking. Multiple threads each manipulating
  48  * separate objects need not synchronize.
  49  *
  50  * @since       1.4
  51  * @author      Steve Hanna
  52  * @see         java.util.Collection
  53  * @see         CertStore
  54  */
  55 public class CollectionCertStoreParameters
  56     implements CertStoreParameters {
  57 
  58     private Collection<?> coll;
  59 
  60     /**
  61      * Creates an instance of {@code CollectionCertStoreParameters}
  62      * which will allow certificates and CRLs to be retrieved from the
  63      * specified {@code Collection}. If the specified
  64      * {@code Collection} contains an object that is not a
  65      * {@code Certificate} or {@code CRL}, that object will be
  66      * ignored by the Collection {@code CertStore}.
  67      * <p>
  68      * The {@code Collection} is <b>not</b> copied. Instead, a
  69      * reference is used. This allows the caller to subsequently add or
  70      * remove {@code Certificates} or {@code CRL}s from the
  71      * {@code Collection}, thus changing the set of
  72      * {@code Certificates} or {@code CRL}s available to the
  73      * Collection {@code CertStore}. The Collection {@code CertStore}
  74      * will not modify the contents of the {@code Collection}.
  75      * <p>
  76      * If the {@code Collection} will be modified by one thread while
  77      * another thread is calling a method of a Collection {@code CertStore}
  78      * that has been initialized with this {@code Collection}, the
  79      * {@code Collection} must have fail-fast iterators.
  80      *
  81      * @param collection a {@code Collection} of
  82      *        {@code Certificate}s and {@code CRL}s
  83      * @exception NullPointerException if {@code collection} is
  84      * {@code null}
  85      */
  86     public CollectionCertStoreParameters(Collection<?> collection) {
  87         if (collection == null)
  88             throw new NullPointerException();
  89         coll = collection;
  90     }
  91 
  92     /**
  93      * Creates an instance of {@code CollectionCertStoreParameters} with
  94      * the default parameter values (an empty and immutable
  95      * {@code Collection}).
  96      */
  97     public CollectionCertStoreParameters() {
  98         coll = Collections.EMPTY_SET;
  99     }
 100 
 101     /**
 102      * Returns the {@code Collection} from which {@code Certificate}s
 103      * and {@code CRL}s are retrieved. This is <b>not</b> a copy of the
 104      * {@code Collection}, it is a reference. This allows the caller to
 105      * subsequently add or remove {@code Certificates} or
 106      * {@code CRL}s from the {@code Collection}.
 107      *
 108      * @return the {@code Collection} (never null)
 109      */
 110     public Collection<?> getCollection() {
 111         return coll;
 112     }
 113 
 114     /**
 115      * Returns a copy of this object. Note that only a reference to the
 116      * {@code Collection} is copied, and not the contents.
 117      *
 118      * @return the copy
 119      */
 120     public Object clone() {
 121         try {
 122             return super.clone();
 123         } catch (CloneNotSupportedException e) {
 124             /* Cannot happen */
 125             throw new InternalError(e.toString(), e);
 126         }
 127     }
 128 
 129     /**
 130      * Returns a formatted string describing the parameters.
 131      *
 132      * @return a formatted string describing the parameters
 133      */
 134     public String toString() {
 135         StringBuffer sb = new StringBuffer();
 136         sb.append("CollectionCertStoreParameters: [\n");