jdk/src/java.base/share/classes/java/security/cert/CertStore.java
author martin
Tue, 15 Sep 2015 21:56:04 -0700
changeset 32649 2ee9017c7597
parent 30033 b9c86c17164a
child 33241 27eb2d6abda9
permissions -rw-r--r--
8136583: Core libraries should use blessed modifier order Summary: Run blessed-modifier-order script (see bug) Reviewed-by: psandoz, chegar, alanb, plevart
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
     2
 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.security.cert;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.security.AccessController;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.security.InvalidAlgorithmParameterException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.security.NoSuchAlgorithmException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.security.NoSuchProviderException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.security.PrivilegedAction;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.security.Provider;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.security.Security;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.util.Collection;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import sun.security.jca.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import sun.security.jca.GetInstance.Instance;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
/**
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
    41
 * A class for retrieving {@code Certificate}s and {@code CRL}s
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * from a repository.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * This class uses a provider-based architecture.
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
    45
 * To create a {@code CertStore}, call one of the static
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
    46
 * {@code getInstance} methods, passing in the type of
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
    47
 * {@code CertStore} desired, any applicable initialization parameters
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * and optionally the name of the provider desired.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * <p>
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
    50
 * Once the {@code CertStore} has been created, it can be used to
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
    51
 * retrieve {@code Certificate}s and {@code CRL}s by calling its
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * {@link #getCertificates(CertSelector selector) getCertificates} and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * {@link #getCRLs(CRLSelector selector) getCRLs} methods.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * Unlike a {@link java.security.KeyStore KeyStore}, which provides access
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * to a cache of private keys and trusted certificates, a
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
    57
 * {@code CertStore} is designed to provide access to a potentially
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * vast repository of untrusted certificates and CRLs. For example, an LDAP
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
    59
 * implementation of {@code CertStore} provides access to certificates
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * and CRLs stored in one or more directories using the LDAP protocol and the
8152
94e5966bdf22 5001004: Required Security Algorithms need to be defined
mullan
parents: 5506
diff changeset
    61
 * schema as defined in the RFC service attribute.
94e5966bdf22 5001004: Required Security Algorithms need to be defined
mullan
parents: 5506
diff changeset
    62
 *
94e5966bdf22 5001004: Required Security Algorithms need to be defined
mullan
parents: 5506
diff changeset
    63
 * <p> Every implementation of the Java platform is required to support the
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
    64
 * following standard {@code CertStore} type:
8152
94e5966bdf22 5001004: Required Security Algorithms need to be defined
mullan
parents: 5506
diff changeset
    65
 * <ul>
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
    66
 * <li>{@code Collection}</li>
8152
94e5966bdf22 5001004: Required Security Algorithms need to be defined
mullan
parents: 5506
diff changeset
    67
 * </ul>
94e5966bdf22 5001004: Required Security Algorithms need to be defined
mullan
parents: 5506
diff changeset
    68
 * This type is described in the <a href=
94e5966bdf22 5001004: Required Security Algorithms need to be defined
mullan
parents: 5506
diff changeset
    69
 * "{@docRoot}/../technotes/guides/security/StandardNames.html#CertStore">
94e5966bdf22 5001004: Required Security Algorithms need to be defined
mullan
parents: 5506
diff changeset
    70
 * CertStore section</a> of the
94e5966bdf22 5001004: Required Security Algorithms need to be defined
mullan
parents: 5506
diff changeset
    71
 * Java Cryptography Architecture Standard Algorithm Name Documentation.
94e5966bdf22 5001004: Required Security Algorithms need to be defined
mullan
parents: 5506
diff changeset
    72
 * Consult the release documentation for your implementation to see if any
94e5966bdf22 5001004: Required Security Algorithms need to be defined
mullan
parents: 5506
diff changeset
    73
 * other types are supported.
94e5966bdf22 5001004: Required Security Algorithms need to be defined
mullan
parents: 5506
diff changeset
    74
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * <b>Concurrent Access</b>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * <p>
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
    78
 * All public methods of {@code CertStore} objects must be thread-safe.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * That is, multiple threads may concurrently invoke these methods on a
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
    80
 * single {@code CertStore} object (or more than one) with no
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
    81
 * ill effects. This allows a {@code CertPathBuilder} to search for a
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * CRL while simultaneously searching for further certificates, for instance.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * The static methods of this class are also guaranteed to be thread-safe.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * Multiple threads may concurrently invoke the static methods defined in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * this class with no ill effects.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * @since       1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * @author      Sean Mullan, Steve Hanna
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
public class CertStore {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     * Constant to lookup in the Security properties file to determine
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     * the default certstore type. In the Security properties file, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
     * default certstore type is given as:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
     * certstore.type=LDAP
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    private static final String CERTSTORE_TYPE = "certstore.type";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    private CertStoreSpi storeSpi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    private Provider provider;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    private String type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    private CertStoreParameters params;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    /**
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   107
     * Creates a {@code CertStore} object of the given type, and
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * encapsulates the given provider implementation (SPI object) in it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * @param storeSpi the provider implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * @param provider the provider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * @param type the type
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   113
     * @param params the initialization parameters (may be {@code null})
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    protected CertStore(CertStoreSpi storeSpi, Provider provider,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
                        String type, CertStoreParameters params) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        this.storeSpi = storeSpi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        this.provider = provider;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        this.type = type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        if (params != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            this.params = (CertStoreParameters) params.clone();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    /**
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   125
     * Returns a {@code Collection} of {@code Certificate}s that
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   126
     * match the specified selector. If no {@code Certificate}s
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   127
     * match the selector, an empty {@code Collection} will be returned.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * <p>
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   129
     * For some {@code CertStore} types, the resulting
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   130
     * {@code Collection} may not contain <b>all</b> of the
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   131
     * {@code Certificate}s that match the selector. For instance,
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   132
     * an LDAP {@code CertStore} may not search all entries in the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * directory. Instead, it may just search entries that are likely to
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   134
     * contain the {@code Certificate}s it is looking for.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * <p>
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   136
     * Some {@code CertStore} implementations (especially LDAP
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   137
     * {@code CertStore}s) may throw a {@code CertStoreException}
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   138
     * unless a non-null {@code CertSelector} is provided that
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * includes specific criteria that can be used to find the certificates.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * Issuer and/or subject names are especially useful criteria.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     *
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   142
     * @param selector A {@code CertSelector} used to select which
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   143
     *  {@code Certificate}s should be returned. Specify {@code null}
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   144
     *  to return all {@code Certificate}s (if supported).
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   145
     * @return A {@code Collection} of {@code Certificate}s that
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   146
     *         match the specified selector (never {@code null})
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * @throws CertStoreException if an exception occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    public final Collection<? extends Certificate> getCertificates
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            (CertSelector selector) throws CertStoreException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        return storeSpi.engineGetCertificates(selector);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    /**
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   155
     * Returns a {@code Collection} of {@code CRL}s that
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   156
     * match the specified selector. If no {@code CRL}s
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   157
     * match the selector, an empty {@code Collection} will be returned.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * <p>
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   159
     * For some {@code CertStore} types, the resulting
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   160
     * {@code Collection} may not contain <b>all</b> of the
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   161
     * {@code CRL}s that match the selector. For instance,
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   162
     * an LDAP {@code CertStore} may not search all entries in the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
     * directory. Instead, it may just search entries that are likely to
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   164
     * contain the {@code CRL}s it is looking for.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * <p>
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   166
     * Some {@code CertStore} implementations (especially LDAP
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   167
     * {@code CertStore}s) may throw a {@code CertStoreException}
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   168
     * unless a non-null {@code CRLSelector} is provided that
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * includes specific criteria that can be used to find the CRLs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * Issuer names and/or the certificate to be checked are especially useful.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     *
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   172
     * @param selector A {@code CRLSelector} used to select which
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   173
     *  {@code CRL}s should be returned. Specify {@code null}
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   174
     *  to return all {@code CRL}s (if supported).
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   175
     * @return A {@code Collection} of {@code CRL}s that
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   176
     *         match the specified selector (never {@code null})
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     * @throws CertStoreException if an exception occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
    public final Collection<? extends CRL> getCRLs(CRLSelector selector)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            throws CertStoreException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        return storeSpi.engineGetCRLs(selector);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    /**
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   185
     * Returns a {@code CertStore} object that implements the specified
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   186
     * {@code CertStore} type and is initialized with the specified
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * <p> This method traverses the list of registered security Providers,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * starting with the most preferred Provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * A new CertStore object encapsulating the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     * CertStoreSpi implementation from the first
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * Provider that supports the specified type is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     * <p> Note that the list of registered providers may be retrieved via
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * the {@link Security#getProviders() Security.getProviders()} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     *
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   198
     * <p>The {@code CertStore} that is returned is initialized with the
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   199
     * specified {@code CertStoreParameters}. The type of parameters
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   200
     * needed may vary between different types of {@code CertStore}s.
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   201
     * Note that the specified {@code CertStoreParameters} object is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     * cloned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     *
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   204
     * @param type the name of the requested {@code CertStore} type.
8152
94e5966bdf22 5001004: Required Security Algorithms need to be defined
mullan
parents: 5506
diff changeset
   205
     * See the CertStore section in the <a href=
94e5966bdf22 5001004: Required Security Algorithms need to be defined
mullan
parents: 5506
diff changeset
   206
     * "{@docRoot}/../technotes/guides/security/StandardNames.html#CertStore">
94e5966bdf22 5001004: Required Security Algorithms need to be defined
mullan
parents: 5506
diff changeset
   207
     * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
94e5966bdf22 5001004: Required Security Algorithms need to be defined
mullan
parents: 5506
diff changeset
   208
     * for information about standard types.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     *
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   210
     * @param params the initialization parameters (may be {@code null}).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     *
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   212
     * @return a {@code CertStore} object that implements the specified
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   213
     *          {@code CertStore} type.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * @throws NoSuchAlgorithmException if no Provider supports a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     *          CertStoreSpi implementation for the specified type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * @throws InvalidAlgorithmParameterException if the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     *          initialization parameters are inappropriate for this
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   220
     *          {@code CertStore}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * @see java.security.Provider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    public static CertStore getInstance(String type, CertStoreParameters params)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            throws InvalidAlgorithmParameterException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
            NoSuchAlgorithmException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
            Instance instance = GetInstance.getInstance("CertStore",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                CertStoreSpi.class, type, params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            return new CertStore((CertStoreSpi)instance.impl,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                instance.provider, type, params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        } catch (NoSuchAlgorithmException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            return handleException(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    private static CertStore handleException(NoSuchAlgorithmException e)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            throws NoSuchAlgorithmException, InvalidAlgorithmParameterException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        Throwable cause = e.getCause();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        if (cause instanceof InvalidAlgorithmParameterException) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
            throw (InvalidAlgorithmParameterException)cause;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        throw e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    /**
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   247
     * Returns a {@code CertStore} object that implements the specified
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   248
     * {@code CertStore} type.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * <p> A new CertStore object encapsulating the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * CertStoreSpi implementation from the specified provider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * is returned.  The specified provider must be registered
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * in the security provider list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * <p> Note that the list of registered providers may be retrieved via
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * the {@link Security#getProviders() Security.getProviders()} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     *
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   258
     * <p>The {@code CertStore} that is returned is initialized with the
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   259
     * specified {@code CertStoreParameters}. The type of parameters
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   260
     * needed may vary between different types of {@code CertStore}s.
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   261
     * Note that the specified {@code CertStoreParameters} object is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * cloned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     *
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   264
     * @param type the requested {@code CertStore} type.
8152
94e5966bdf22 5001004: Required Security Algorithms need to be defined
mullan
parents: 5506
diff changeset
   265
     * See the CertStore section in the <a href=
94e5966bdf22 5001004: Required Security Algorithms need to be defined
mullan
parents: 5506
diff changeset
   266
     * "{@docRoot}/../technotes/guides/security/StandardNames.html#CertStore">
94e5966bdf22 5001004: Required Security Algorithms need to be defined
mullan
parents: 5506
diff changeset
   267
     * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
94e5966bdf22 5001004: Required Security Algorithms need to be defined
mullan
parents: 5506
diff changeset
   268
     * for information about standard types.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     *
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   270
     * @param params the initialization parameters (may be {@code null}).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * @param provider the name of the provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     *
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   274
     * @return a {@code CertStore} object that implements the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     *          specified type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * @throws NoSuchAlgorithmException if a CertStoreSpi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     *          implementation for the specified type is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     *          available from the specified provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * @throws InvalidAlgorithmParameterException if the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     *          initialization parameters are inappropriate for this
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   283
     *          {@code CertStore}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * @throws NoSuchProviderException if the specified provider is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     *          registered in the security provider list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     *
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   288
     * @exception IllegalArgumentException if the {@code provider} is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     *          null or empty.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * @see java.security.Provider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    public static CertStore getInstance(String type,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
            CertStoreParameters params, String provider)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            throws InvalidAlgorithmParameterException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
            NoSuchAlgorithmException, NoSuchProviderException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
            Instance instance = GetInstance.getInstance("CertStore",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
                CertStoreSpi.class, type, params, provider);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
            return new CertStore((CertStoreSpi)instance.impl,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                instance.provider, type, params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        } catch (NoSuchAlgorithmException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
            return handleException(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    /**
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   308
     * Returns a {@code CertStore} object that implements the specified
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   309
     * {@code CertStore} type.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * <p> A new CertStore object encapsulating the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     * CertStoreSpi implementation from the specified Provider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * object is returned.  Note that the specified Provider object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * does not have to be registered in the provider list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     *
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   316
     * <p>The {@code CertStore} that is returned is initialized with the
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   317
     * specified {@code CertStoreParameters}. The type of parameters
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   318
     * needed may vary between different types of {@code CertStore}s.
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   319
     * Note that the specified {@code CertStoreParameters} object is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * cloned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     *
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   322
     * @param type the requested {@code CertStore} type.
8152
94e5966bdf22 5001004: Required Security Algorithms need to be defined
mullan
parents: 5506
diff changeset
   323
     * See the CertStore section in the <a href=
94e5966bdf22 5001004: Required Security Algorithms need to be defined
mullan
parents: 5506
diff changeset
   324
     * "{@docRoot}/../technotes/guides/security/StandardNames.html#CertStore">
94e5966bdf22 5001004: Required Security Algorithms need to be defined
mullan
parents: 5506
diff changeset
   325
     * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
94e5966bdf22 5001004: Required Security Algorithms need to be defined
mullan
parents: 5506
diff changeset
   326
     * for information about standard types.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     *
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   328
     * @param params the initialization parameters (may be {@code null}).
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     * @param provider the provider.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     *
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   332
     * @return a {@code CertStore} object that implements the
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     *          specified type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     * @exception NoSuchAlgorithmException if a CertStoreSpi
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     *          implementation for the specified type is not available
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     *          from the specified Provider object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * @throws InvalidAlgorithmParameterException if the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     *          initialization parameters are inappropriate for this
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   341
     *          {@code CertStore}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     *
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   343
     * @exception IllegalArgumentException if the {@code provider} is
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     *          null.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * @see java.security.Provider
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    public static CertStore getInstance(String type, CertStoreParameters params,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
            Provider provider) throws NoSuchAlgorithmException,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
            InvalidAlgorithmParameterException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
            Instance instance = GetInstance.getInstance("CertStore",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                CertStoreSpi.class, type, params, provider);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
            return new CertStore((CertStoreSpi)instance.impl,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
                instance.provider, type, params);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        } catch (NoSuchAlgorithmException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
            return handleException(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    /**
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   362
     * Returns the parameters used to initialize this {@code CertStore}.
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   363
     * Note that the {@code CertStoreParameters} object is cloned before
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
     * it is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
     *
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   366
     * @return the parameters used to initialize this {@code CertStore}
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   367
     * (may be {@code null})
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    public final CertStoreParameters getCertStoreParameters() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        return (params == null ? null : (CertStoreParameters) params.clone());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    /**
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   374
     * Returns the type of this {@code CertStore}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     *
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   376
     * @return the type of this {@code CertStore}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    public final String getType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        return this.type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
    /**
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   383
     * Returns the provider of this {@code CertStore}.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     *
18551
882a3948c6e6 8017325: Cleanup of the javadoc <code> tag in java.security.cert
juh
parents: 14775
diff changeset
   385
     * @return the provider of this {@code CertStore}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    public final Provider getProvider() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        return this.provider;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    /**
14775
2ed01c760aea 8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents: 9035
diff changeset
   392
     * Returns the default {@code CertStore} type as specified by the
2ed01c760aea 8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents: 9035
diff changeset
   393
     * {@code certstore.type} security property, or the string
2ed01c760aea 8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents: 9035
diff changeset
   394
     * {@literal "LDAP"} if no such property exists.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     *
14775
2ed01c760aea 8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents: 9035
diff changeset
   396
     * <p>The default {@code CertStore} type can be used by applications
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * that do not want to use a hard-coded type when calling one of the
14775
2ed01c760aea 8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents: 9035
diff changeset
   398
     * {@code getInstance} methods, and want to provide a default
2ed01c760aea 8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents: 9035
diff changeset
   399
     * {@code CertStore} type in case a user does not specify its own.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     *
14775
2ed01c760aea 8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents: 9035
diff changeset
   401
     * <p>The default {@code CertStore} type can be changed by setting
2ed01c760aea 8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents: 9035
diff changeset
   402
     * the value of the {@code certstore.type} security property to the
2ed01c760aea 8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents: 9035
diff changeset
   403
     * desired type.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     *
14775
2ed01c760aea 8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents: 9035
diff changeset
   405
     * @see java.security.Security security properties
2ed01c760aea 8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents: 9035
diff changeset
   406
     * @return the default {@code CertStore} type as specified by the
2ed01c760aea 8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents: 9035
diff changeset
   407
     * {@code certstore.type} security property, or the string
2ed01c760aea 8004064: Downgrade normative references to ${java.home}/lib/security/java.security
mullan
parents: 9035
diff changeset
   408
     * {@literal "LDAP"} if no such property exists.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     */
32649
2ee9017c7597 8136583: Core libraries should use blessed modifier order
martin
parents: 30033
diff changeset
   410
    public static final String getDefaultType() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        String cstype;
30033
b9c86c17164a 8078468: Update security libraries to use diamond with anonymous classes
darcy
parents: 25859
diff changeset
   412
        cstype = AccessController.doPrivileged(new PrivilegedAction<>() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
            public String run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
                return Security.getProperty(CERTSTORE_TYPE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        });
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        if (cstype == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
            cstype = "LDAP";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        return cstype;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
}