211 * See the Signature section in the <a href= |
211 * See the Signature section in the <a href= |
212 * "{@docRoot}/../technotes/guides/security/StandardNames.html#Signature"> |
212 * "{@docRoot}/../technotes/guides/security/StandardNames.html#Signature"> |
213 * Java Cryptography Architecture Standard Algorithm Name Documentation</a> |
213 * Java Cryptography Architecture Standard Algorithm Name Documentation</a> |
214 * for information about standard algorithm names. |
214 * for information about standard algorithm names. |
215 * |
215 * |
216 * @return the new Signature object. |
216 * @return the new {@code Signature} object |
217 * |
217 * |
218 * @exception NoSuchAlgorithmException if no Provider supports a |
218 * @throws NoSuchAlgorithmException if no {@code Provider} supports a |
219 * Signature implementation for the |
219 * {@code Signature} implementation for the |
220 * specified algorithm. |
220 * specified algorithm |
|
221 * |
|
222 * @throws NullPointerException if {@code algorithm} is {@code null} |
221 * |
223 * |
222 * @see Provider |
224 * @see Provider |
223 */ |
225 */ |
224 public static Signature getInstance(String algorithm) |
226 public static Signature getInstance(String algorithm) |
225 throws NoSuchAlgorithmException { |
227 throws NoSuchAlgorithmException { |
|
228 Objects.requireNonNull(algorithm, "null algorithm name"); |
226 List<Service> list; |
229 List<Service> list; |
227 if (algorithm.equalsIgnoreCase(RSA_SIGNATURE)) { |
230 if (algorithm.equalsIgnoreCase(RSA_SIGNATURE)) { |
228 list = GetInstance.getServices(rsaIds); |
231 list = GetInstance.getServices(rsaIds); |
229 } else { |
232 } else { |
230 list = GetInstance.getServices("Signature", algorithm); |
233 list = GetInstance.getServices("Signature", algorithm); |
333 * Java Cryptography Architecture Standard Algorithm Name Documentation</a> |
336 * Java Cryptography Architecture Standard Algorithm Name Documentation</a> |
334 * for information about standard algorithm names. |
337 * for information about standard algorithm names. |
335 * |
338 * |
336 * @param provider the name of the provider. |
339 * @param provider the name of the provider. |
337 * |
340 * |
338 * @return the new Signature object. |
341 * @return the new {@code Signature} object |
339 * |
342 * |
340 * @exception NoSuchAlgorithmException if a SignatureSpi |
343 * @throws IllegalArgumentException if the provider name is {@code null} |
341 * implementation for the specified algorithm is not |
344 * or empty |
342 * available from the specified provider. |
345 * |
343 * |
346 * @throws NoSuchAlgorithmException if a {@code SignatureSpi} |
344 * @exception NoSuchProviderException if the specified provider is not |
347 * implementation for the specified algorithm is not |
345 * registered in the security provider list. |
348 * available from the specified provider |
346 * |
349 * |
347 * @exception IllegalArgumentException if the provider name is null |
350 * @throws NoSuchProviderException if the specified provider is not |
348 * or empty. |
351 * registered in the security provider list |
|
352 * |
|
353 * @throws NullPointerException if {@code algorithm} is {@code null} |
349 * |
354 * |
350 * @see Provider |
355 * @see Provider |
351 */ |
356 */ |
352 public static Signature getInstance(String algorithm, String provider) |
357 public static Signature getInstance(String algorithm, String provider) |
353 throws NoSuchAlgorithmException, NoSuchProviderException { |
358 throws NoSuchAlgorithmException, NoSuchProviderException { |
|
359 Objects.requireNonNull(algorithm, "null algorithm name"); |
354 if (algorithm.equalsIgnoreCase(RSA_SIGNATURE)) { |
360 if (algorithm.equalsIgnoreCase(RSA_SIGNATURE)) { |
355 // exception compatibility with existing code |
361 // exception compatibility with existing code |
356 if ((provider == null) || (provider.length() == 0)) { |
362 if ((provider == null) || (provider.length() == 0)) { |
357 throw new IllegalArgumentException("missing provider"); |
363 throw new IllegalArgumentException("missing provider"); |
358 } |
364 } |
383 * Java Cryptography Architecture Standard Algorithm Name Documentation</a> |
389 * Java Cryptography Architecture Standard Algorithm Name Documentation</a> |
384 * for information about standard algorithm names. |
390 * for information about standard algorithm names. |
385 * |
391 * |
386 * @param provider the provider. |
392 * @param provider the provider. |
387 * |
393 * |
388 * @return the new Signature object. |
394 * @return the new {@code Signature} object |
389 * |
395 * |
390 * @exception NoSuchAlgorithmException if a SignatureSpi |
396 * @throws IllegalArgumentException if the provider is {@code null} |
391 * implementation for the specified algorithm is not available |
397 * |
392 * from the specified Provider object. |
398 * @throws NoSuchAlgorithmException if a {@code SignatureSpi} |
393 * |
399 * implementation for the specified algorithm is not available |
394 * @exception IllegalArgumentException if the provider is null. |
400 * from the specified {@code Provider} object |
|
401 * |
|
402 * @throws NullPointerException if {@code algorithm} is {@code null} |
395 * |
403 * |
396 * @see Provider |
404 * @see Provider |
397 * |
405 * |
398 * @since 1.4 |
406 * @since 1.4 |
399 */ |
407 */ |
400 public static Signature getInstance(String algorithm, Provider provider) |
408 public static Signature getInstance(String algorithm, Provider provider) |
401 throws NoSuchAlgorithmException { |
409 throws NoSuchAlgorithmException { |
|
410 Objects.requireNonNull(algorithm, "null algorithm name"); |
402 if (algorithm.equalsIgnoreCase(RSA_SIGNATURE)) { |
411 if (algorithm.equalsIgnoreCase(RSA_SIGNATURE)) { |
403 // exception compatibility with existing code |
412 // exception compatibility with existing code |
404 if (provider == null) { |
413 if (provider == null) { |
405 throw new IllegalArgumentException("missing provider"); |
414 throw new IllegalArgumentException("missing provider"); |
406 } |
415 } |