< prev index next >

src/java.base/share/classes/java/security/cert/CertPathBuilder.java

Print this page
rev 15967 : [mq]: GetInstance


  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.security.AccessController;
  29 import java.security.InvalidAlgorithmParameterException;
  30 import java.security.NoSuchAlgorithmException;
  31 import java.security.NoSuchProviderException;
  32 import java.security.PrivilegedAction;
  33 import java.security.Provider;
  34 import java.security.Security;
  35 import sun.security.util.Debug;
  36 
  37 import sun.security.jca.*;
  38 import sun.security.jca.GetInstance.Instance;
  39 
  40 /**
  41  * A class for building certification paths (also known as certificate chains).
  42  * <p>
  43  * This class uses a provider-based architecture.
  44  * To create a {@code CertPathBuilder}, call
  45  * one of the static {@code getInstance} methods, passing in the
  46  * algorithm name of the {@code CertPathBuilder} desired and optionally
  47  * the name of the provider desired.
  48  *
  49  * <p>Once a {@code CertPathBuilder} object has been created, certification
  50  * paths can be constructed by calling the {@link #build build} method and
  51  * passing it an algorithm-specific set of parameters. If successful, the
  52  * result (including the {@code CertPath} that was built) is returned
  53  * in an object that implements the {@code CertPathBuilderResult}
  54  * interface.
  55  *


 140      * Provider that supports the specified algorithm is returned.
 141      *
 142      * <p> Note that the list of registered providers may be retrieved via
 143      * the {@link Security#getProviders() Security.getProviders()} method.
 144      *
 145      * @implNote
 146      * The JDK Reference Implementation additionally uses the
 147      * {@code jdk.security.provider.preferred}
 148      * {@link Security#getProperty(String) Security} property to determine
 149      * the preferred provider order for the specified algorithm. This
 150      * may be different than the order of providers returned by
 151      * {@link Security#getProviders() Security.getProviders()}.
 152      *
 153      * @param algorithm the name of the requested {@code CertPathBuilder}
 154      *  algorithm.  See the CertPathBuilder section in the <a href=
 155      *  "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathBuilder">
 156      * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
 157      * for information about standard algorithm names.
 158      *
 159      * @return a {@code CertPathBuilder} object that implements the
 160      *          specified algorithm.
 161      *
 162      * @throws NoSuchAlgorithmException if no Provider supports a
 163      *          CertPathBuilderSpi implementation for the
 164      *          specified algorithm.


 165      *
 166      * @see java.security.Provider
 167      */
 168     public static CertPathBuilder getInstance(String algorithm)
 169             throws NoSuchAlgorithmException {

 170         Instance instance = GetInstance.getInstance("CertPathBuilder",
 171             CertPathBuilderSpi.class, algorithm);
 172         return new CertPathBuilder((CertPathBuilderSpi)instance.impl,
 173             instance.provider, algorithm);
 174     }
 175 
 176     /**
 177      * Returns a {@code CertPathBuilder} object that implements the
 178      * specified algorithm.
 179      *
 180      * <p> A new CertPathBuilder object encapsulating the
 181      * CertPathBuilderSpi implementation from the specified provider
 182      * is returned.  The specified provider must be registered
 183      * in the security provider list.
 184      *
 185      * <p> Note that the list of registered providers may be retrieved via
 186      * the {@link Security#getProviders() Security.getProviders()} method.
 187      *
 188      * @param algorithm the name of the requested {@code CertPathBuilder}
 189      *  algorithm.  See the CertPathBuilder section in the <a href=
 190      *  "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathBuilder">
 191      * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
 192      * for information about standard algorithm names.
 193      *
 194      * @param provider the name of the provider.
 195      *
 196      * @return a {@code CertPathBuilder} object that implements the
 197      *          specified algorithm.
 198      *
 199      * @throws NoSuchAlgorithmException if a CertPathBuilderSpi



 200      *          implementation for the specified algorithm is not
 201      *          available from the specified provider.
 202      *
 203      * @throws NoSuchProviderException if the specified provider is not
 204      *          registered in the security provider list.
 205      *
 206      * @exception IllegalArgumentException if the {@code provider} is
 207      *          null or empty.
 208      *
 209      * @see java.security.Provider
 210      */
 211     public static CertPathBuilder getInstance(String algorithm, String provider)
 212            throws NoSuchAlgorithmException, NoSuchProviderException {

 213         Instance instance = GetInstance.getInstance("CertPathBuilder",
 214             CertPathBuilderSpi.class, algorithm, provider);
 215         return new CertPathBuilder((CertPathBuilderSpi)instance.impl,
 216             instance.provider, algorithm);
 217     }
 218 
 219     /**
 220      * Returns a {@code CertPathBuilder} object that implements the
 221      * specified algorithm.
 222      *
 223      * <p> A new CertPathBuilder object encapsulating the
 224      * CertPathBuilderSpi implementation from the specified Provider
 225      * object is returned.  Note that the specified Provider object
 226      * does not have to be registered in the provider list.
 227      *
 228      * @param algorithm the name of the requested {@code CertPathBuilder}
 229      *  algorithm.  See the CertPathBuilder section in the <a href=
 230      *  "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathBuilder">
 231      * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
 232      * for information about standard algorithm names.
 233      *
 234      * @param provider the provider.
 235      *
 236      * @return a {@code CertPathBuilder} object that implements the
 237      *          specified algorithm.



 238      *
 239      * @exception NoSuchAlgorithmException if a CertPathBuilderSpi
 240      *          implementation for the specified algorithm is not available
 241      *          from the specified Provider object.
 242      *
 243      * @exception IllegalArgumentException if the {@code provider} is
 244      *          null.
 245      *
 246      * @see java.security.Provider
 247      */
 248     public static CertPathBuilder getInstance(String algorithm,
 249             Provider provider) throws NoSuchAlgorithmException {

 250         Instance instance = GetInstance.getInstance("CertPathBuilder",
 251             CertPathBuilderSpi.class, algorithm, provider);
 252         return new CertPathBuilder((CertPathBuilderSpi)instance.impl,
 253             instance.provider, algorithm);
 254     }
 255 
 256     /**
 257      * Returns the provider of this {@code CertPathBuilder}.
 258      *
 259      * @return the provider of this {@code CertPathBuilder}
 260      */
 261     public final Provider getProvider() {
 262         return this.provider;
 263     }
 264 
 265     /**
 266      * Returns the name of the algorithm of this {@code CertPathBuilder}.
 267      *
 268      * @return the name of the algorithm of this {@code CertPathBuilder}
 269      */




  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.security.AccessController;
  29 import java.security.InvalidAlgorithmParameterException;
  30 import java.security.NoSuchAlgorithmException;
  31 import java.security.NoSuchProviderException;
  32 import java.security.PrivilegedAction;
  33 import java.security.Provider;
  34 import java.security.Security;
  35 import java.util.Objects;
  36 
  37 import sun.security.jca.*;
  38 import sun.security.jca.GetInstance.Instance;
  39 
  40 /**
  41  * A class for building certification paths (also known as certificate chains).
  42  * <p>
  43  * This class uses a provider-based architecture.
  44  * To create a {@code CertPathBuilder}, call
  45  * one of the static {@code getInstance} methods, passing in the
  46  * algorithm name of the {@code CertPathBuilder} desired and optionally
  47  * the name of the provider desired.
  48  *
  49  * <p>Once a {@code CertPathBuilder} object has been created, certification
  50  * paths can be constructed by calling the {@link #build build} method and
  51  * passing it an algorithm-specific set of parameters. If successful, the
  52  * result (including the {@code CertPath} that was built) is returned
  53  * in an object that implements the {@code CertPathBuilderResult}
  54  * interface.
  55  *


 140      * Provider that supports the specified algorithm is returned.
 141      *
 142      * <p> Note that the list of registered providers may be retrieved via
 143      * the {@link Security#getProviders() Security.getProviders()} method.
 144      *
 145      * @implNote
 146      * The JDK Reference Implementation additionally uses the
 147      * {@code jdk.security.provider.preferred}
 148      * {@link Security#getProperty(String) Security} property to determine
 149      * the preferred provider order for the specified algorithm. This
 150      * may be different than the order of providers returned by
 151      * {@link Security#getProviders() Security.getProviders()}.
 152      *
 153      * @param algorithm the name of the requested {@code CertPathBuilder}
 154      *  algorithm.  See the CertPathBuilder section in the <a href=
 155      *  "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathBuilder">
 156      * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
 157      * for information about standard algorithm names.
 158      *
 159      * @return a {@code CertPathBuilder} object that implements the
 160      *         specified algorithm
 161      *
 162      * @throws NoSuchAlgorithmException if no {@code Provider} supports a
 163      *         {@code CertPathBuilderSpi} implementation for the
 164      *         specified algorithm
 165      *
 166      * @throws NullPointerException if {@code algorithm} is {@code null}
 167      *
 168      * @see java.security.Provider
 169      */
 170     public static CertPathBuilder getInstance(String algorithm)
 171             throws NoSuchAlgorithmException {
 172         Objects.requireNonNull(algorithm, "null algorithm name");
 173         Instance instance = GetInstance.getInstance("CertPathBuilder",
 174             CertPathBuilderSpi.class, algorithm);
 175         return new CertPathBuilder((CertPathBuilderSpi)instance.impl,
 176             instance.provider, algorithm);
 177     }
 178 
 179     /**
 180      * Returns a {@code CertPathBuilder} object that implements the
 181      * specified algorithm.
 182      *
 183      * <p> A new CertPathBuilder object encapsulating the
 184      * CertPathBuilderSpi implementation from the specified provider
 185      * is returned.  The specified provider must be registered
 186      * in the security provider list.
 187      *
 188      * <p> Note that the list of registered providers may be retrieved via
 189      * the {@link Security#getProviders() Security.getProviders()} method.
 190      *
 191      * @param algorithm the name of the requested {@code CertPathBuilder}
 192      *  algorithm.  See the CertPathBuilder section in the <a href=
 193      *  "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathBuilder">
 194      * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
 195      * for information about standard algorithm names.
 196      *
 197      * @param provider the name of the provider.
 198      *
 199      * @return a {@code CertPathBuilder} object that implements the
 200      *         specified algorithm
 201      *
 202      * @throws IllegalArgumentException if the {@code provider} is
 203      *         {@code null} or empty
 204      *
 205      * @throws NoSuchAlgorithmException if a {@code CertPathBuilderSpi}
 206      *         implementation for the specified algorithm is not
 207      *         available from the specified provider
 208      *
 209      * @throws NoSuchProviderException if the specified provider is not
 210      *         registered in the security provider list
 211      *
 212      * @throws NullPointerException if {@code algorithm} is {@code null}

 213      *
 214      * @see java.security.Provider
 215      */
 216     public static CertPathBuilder getInstance(String algorithm, String provider)
 217            throws NoSuchAlgorithmException, NoSuchProviderException {
 218         Objects.requireNonNull(algorithm, "null algorithm name");
 219         Instance instance = GetInstance.getInstance("CertPathBuilder",
 220             CertPathBuilderSpi.class, algorithm, provider);
 221         return new CertPathBuilder((CertPathBuilderSpi)instance.impl,
 222             instance.provider, algorithm);
 223     }
 224 
 225     /**
 226      * Returns a {@code CertPathBuilder} object that implements the
 227      * specified algorithm.
 228      *
 229      * <p> A new CertPathBuilder object encapsulating the
 230      * CertPathBuilderSpi implementation from the specified Provider
 231      * object is returned.  Note that the specified Provider object
 232      * does not have to be registered in the provider list.
 233      *
 234      * @param algorithm the name of the requested {@code CertPathBuilder}
 235      *  algorithm.  See the CertPathBuilder section in the <a href=
 236      *  "{@docRoot}/../technotes/guides/security/StandardNames.html#CertPathBuilder">
 237      * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
 238      * for information about standard algorithm names.
 239      *
 240      * @param provider the provider.
 241      *
 242      * @return a {@code CertPathBuilder} object that implements the
 243      *         specified algorithm
 244      *
 245      * @throws IllegalArgumentException if the {@code provider} is
 246      *         {@code null}
 247      *
 248      * @throws NoSuchAlgorithmException if a {@code CertPathBuilderSpi}
 249      *         implementation for the specified algorithm is not available
 250      *         from the specified {@code Provider} object
 251      *
 252      * @throws NullPointerException if {@code algorithm} is {@code null}

 253      *
 254      * @see java.security.Provider
 255      */
 256     public static CertPathBuilder getInstance(String algorithm,
 257             Provider provider) throws NoSuchAlgorithmException {
 258         Objects.requireNonNull(algorithm, "null algorithm name");
 259         Instance instance = GetInstance.getInstance("CertPathBuilder",
 260             CertPathBuilderSpi.class, algorithm, provider);
 261         return new CertPathBuilder((CertPathBuilderSpi)instance.impl,
 262             instance.provider, algorithm);
 263     }
 264 
 265     /**
 266      * Returns the provider of this {@code CertPathBuilder}.
 267      *
 268      * @return the provider of this {@code CertPathBuilder}
 269      */
 270     public final Provider getProvider() {
 271         return this.provider;
 272     }
 273 
 274     /**
 275      * Returns the name of the algorithm of this {@code CertPathBuilder}.
 276      *
 277      * @return the name of the algorithm of this {@code CertPathBuilder}
 278      */


< prev index next >