< prev index next >

src/java.base/share/classes/java/security/Signature.java

Print this page
rev 52979 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: TBD


 343      *
 344      * @throws IllegalArgumentException if the provider name is {@code null}
 345      *         or empty
 346      *
 347      * @throws NoSuchAlgorithmException if a {@code SignatureSpi}
 348      *         implementation for the specified algorithm is not
 349      *         available from the specified provider
 350      *
 351      * @throws NoSuchProviderException if the specified provider is not
 352      *         registered in the security provider list
 353      *
 354      * @throws NullPointerException if {@code algorithm} is {@code null}
 355      *
 356      * @see Provider
 357      */
 358     public static Signature getInstance(String algorithm, String provider)
 359             throws NoSuchAlgorithmException, NoSuchProviderException {
 360         Objects.requireNonNull(algorithm, "null algorithm name");
 361         if (algorithm.equalsIgnoreCase(RSA_SIGNATURE)) {
 362             // exception compatibility with existing code
 363             if ((provider == null) || (provider.length() == 0)) {
 364                 throw new IllegalArgumentException("missing provider");
 365             }
 366             Provider p = Security.getProvider(provider);
 367             if (p == null) {
 368                 throw new NoSuchProviderException
 369                     ("no such provider: " + provider);
 370             }
 371             return getInstanceRSA(p);
 372         }
 373         Instance instance = GetInstance.getInstance
 374                 ("Signature", SignatureSpi.class, algorithm, provider);
 375         return getInstance(instance, algorithm);
 376     }
 377 
 378     /**
 379      * Returns a Signature object that implements the specified
 380      * signature algorithm.
 381      *
 382      * <p> A new Signature object encapsulating the
 383      * SignatureSpi implementation from the specified Provider




 343      *
 344      * @throws IllegalArgumentException if the provider name is {@code null}
 345      *         or empty
 346      *
 347      * @throws NoSuchAlgorithmException if a {@code SignatureSpi}
 348      *         implementation for the specified algorithm is not
 349      *         available from the specified provider
 350      *
 351      * @throws NoSuchProviderException if the specified provider is not
 352      *         registered in the security provider list
 353      *
 354      * @throws NullPointerException if {@code algorithm} is {@code null}
 355      *
 356      * @see Provider
 357      */
 358     public static Signature getInstance(String algorithm, String provider)
 359             throws NoSuchAlgorithmException, NoSuchProviderException {
 360         Objects.requireNonNull(algorithm, "null algorithm name");
 361         if (algorithm.equalsIgnoreCase(RSA_SIGNATURE)) {
 362             // exception compatibility with existing code
 363             if (provider == null || provider.isEmpty()) {
 364                 throw new IllegalArgumentException("missing provider");
 365             }
 366             Provider p = Security.getProvider(provider);
 367             if (p == null) {
 368                 throw new NoSuchProviderException
 369                     ("no such provider: " + provider);
 370             }
 371             return getInstanceRSA(p);
 372         }
 373         Instance instance = GetInstance.getInstance
 374                 ("Signature", SignatureSpi.class, algorithm, provider);
 375         return getInstance(instance, algorithm);
 376     }
 377 
 378     /**
 379      * Returns a Signature object that implements the specified
 380      * signature algorithm.
 381      *
 382      * <p> A new Signature object encapsulating the
 383      * SignatureSpi implementation from the specified Provider


< prev index next >