jdk/src/java.base/share/classes/java/security/KeyPairGenerator.java
changeset 41826 b35ee9b35b09
parent 40789 43b42538af90
child 45118 e4258d800b54
equal deleted inserted replaced
41825:6dd7bb19cef2 41826:b35ee9b35b09
   207      * See the KeyPairGenerator section in the <a href=
   207      * See the KeyPairGenerator section in the <a href=
   208      * "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyPairGenerator">
   208      * "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyPairGenerator">
   209      * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
   209      * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
   210      * for information about standard algorithm names.
   210      * for information about standard algorithm names.
   211      *
   211      *
   212      * @return the new KeyPairGenerator object.
   212      * @return the new {@code KeyPairGenerator} object
   213      *
   213      *
   214      * @exception NoSuchAlgorithmException if no Provider supports a
   214      * @throws NoSuchAlgorithmException if no {@code Provider} supports a
   215      *          KeyPairGeneratorSpi implementation for the
   215      *         {@code KeyPairGeneratorSpi} implementation for the
   216      *          specified algorithm.
   216      *         specified algorithm
       
   217      *
       
   218      * @throws NullPointerException if {@code algorithm} is {@code null}
   217      *
   219      *
   218      * @see Provider
   220      * @see Provider
   219      */
   221      */
   220     public static KeyPairGenerator getInstance(String algorithm)
   222     public static KeyPairGenerator getInstance(String algorithm)
   221             throws NoSuchAlgorithmException {
   223             throws NoSuchAlgorithmException {
       
   224         Objects.requireNonNull(algorithm, "null algorithm name");
   222         List<Service> list =
   225         List<Service> list =
   223                 GetInstance.getServices("KeyPairGenerator", algorithm);
   226                 GetInstance.getServices("KeyPairGenerator", algorithm);
   224         Iterator<Service> t = list.iterator();
   227         Iterator<Service> t = list.iterator();
   225         if (t.hasNext() == false) {
   228         if (t.hasNext() == false) {
   226             throw new NoSuchAlgorithmException
   229             throw new NoSuchAlgorithmException
   265      * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
   268      * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
   266      * for information about standard algorithm names.
   269      * for information about standard algorithm names.
   267      *
   270      *
   268      * @param provider the string name of the provider.
   271      * @param provider the string name of the provider.
   269      *
   272      *
   270      * @return the new KeyPairGenerator object.
   273      * @return the new {@code KeyPairGenerator} object
   271      *
   274      *
   272      * @exception NoSuchAlgorithmException if a KeyPairGeneratorSpi
   275      * @throws IllegalArgumentException if the provider name is {@code null}
   273      *          implementation for the specified algorithm is not
   276      *         or empty
   274      *          available from the specified provider.
   277      *
   275      *
   278      * @throws NoSuchAlgorithmException if a {@code KeyPairGeneratorSpi}
   276      * @exception NoSuchProviderException if the specified provider is not
   279      *         implementation for the specified algorithm is not
   277      *          registered in the security provider list.
   280      *         available from the specified provider
   278      *
   281      *
   279      * @exception IllegalArgumentException if the provider name is null
   282      * @throws NoSuchProviderException if the specified provider is not
   280      *          or empty.
   283      *         registered in the security provider list
       
   284      *
       
   285      * @throws NullPointerException if {@code algorithm} is {@code null}
   281      *
   286      *
   282      * @see Provider
   287      * @see Provider
   283      */
   288      */
   284     public static KeyPairGenerator getInstance(String algorithm,
   289     public static KeyPairGenerator getInstance(String algorithm,
   285             String provider)
   290             String provider)
   286             throws NoSuchAlgorithmException, NoSuchProviderException {
   291             throws NoSuchAlgorithmException, NoSuchProviderException {
       
   292         Objects.requireNonNull(algorithm, "null algorithm name");
   287         Instance instance = GetInstance.getInstance("KeyPairGenerator",
   293         Instance instance = GetInstance.getInstance("KeyPairGenerator",
   288                 KeyPairGeneratorSpi.class, algorithm, provider);
   294                 KeyPairGeneratorSpi.class, algorithm, provider);
   289         return getInstance(instance, algorithm);
   295         return getInstance(instance, algorithm);
   290     }
   296     }
   291 
   297 
   304      * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
   310      * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
   305      * for information about standard algorithm names.
   311      * for information about standard algorithm names.
   306      *
   312      *
   307      * @param provider the provider.
   313      * @param provider the provider.
   308      *
   314      *
   309      * @return the new KeyPairGenerator object.
   315      * @return the new {@code KeyPairGenerator} object
   310      *
   316      *
   311      * @exception NoSuchAlgorithmException if a KeyPairGeneratorSpi
   317      * @throws IllegalArgumentException if the specified provider is
   312      *          implementation for the specified algorithm is not available
   318      *         {@code null}
   313      *          from the specified Provider object.
   319      *
   314      *
   320      * @throws NoSuchAlgorithmException if a {@code KeyPairGeneratorSpi}
   315      * @exception IllegalArgumentException if the specified provider is null.
   321      *         implementation for the specified algorithm is not available
       
   322      *         from the specified {@code Provider} object
       
   323      *
       
   324      * @throws NullPointerException if {@code algorithm} is {@code null}
   316      *
   325      *
   317      * @see Provider
   326      * @see Provider
   318      *
   327      *
   319      * @since 1.4
   328      * @since 1.4
   320      */
   329      */
   321     public static KeyPairGenerator getInstance(String algorithm,
   330     public static KeyPairGenerator getInstance(String algorithm,
   322             Provider provider) throws NoSuchAlgorithmException {
   331             Provider provider) throws NoSuchAlgorithmException {
       
   332         Objects.requireNonNull(algorithm, "null algorithm name");
   323         Instance instance = GetInstance.getInstance("KeyPairGenerator",
   333         Instance instance = GetInstance.getInstance("KeyPairGenerator",
   324                 KeyPairGeneratorSpi.class, algorithm, provider);
   334                 KeyPairGeneratorSpi.class, algorithm, provider);
   325         return getInstance(instance, algorithm);
   335         return getInstance(instance, algorithm);
   326     }
   336     }
   327 
   337