< prev index next >
src/java.base/share/classes/java/security/MessageDigest.java
Print this page
rev 15967 : [mq]: GetInstance
*** 24,40 ****
*/
package java.security;
import java.util.*;
- import java.lang.*;
- import java.io.IOException;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
- import java.io.InputStream;
- import java.io.ByteArrayInputStream;
- import java.security.InvalidKeyException;
import java.nio.ByteBuffer;
import sun.security.util.Debug;
import sun.security.util.MessageDigestSpi2;
--- 24,35 ----
*** 161,180 ****
* See the MessageDigest section in the <a href=
* "{@docRoot}/../technotes/guides/security/StandardNames.html#MessageDigest">
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names.
*
! * @return a Message Digest object that implements the specified algorithm.
*
! * @exception NoSuchAlgorithmException if no Provider supports a
! * MessageDigestSpi implementation for the
! * specified algorithm.
*
* @see Provider
*/
public static MessageDigest getInstance(String algorithm)
throws NoSuchAlgorithmException {
try {
MessageDigest md;
Object[] objs = Security.getImpl(algorithm, "MessageDigest",
(String)null);
if (objs[0] instanceof MessageDigest) {
--- 156,179 ----
* See the MessageDigest section in the <a href=
* "{@docRoot}/../technotes/guides/security/StandardNames.html#MessageDigest">
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names.
*
! * @return a {@code MessageDigest} object that implements the
! * specified algorithm
*
! * @throws NoSuchAlgorithmException if no {@code Provider} supports a
! * {@code MessageDigestSpi} implementation for the
! * specified algorithm
! *
! * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*/
public static MessageDigest getInstance(String algorithm)
throws NoSuchAlgorithmException {
+ Objects.requireNonNull(algorithm, "null algorithm name");
try {
MessageDigest md;
Object[] objs = Security.getImpl(algorithm, "MessageDigest",
(String)null);
if (objs[0] instanceof MessageDigest) {
*** 214,240 ****
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names.
*
* @param provider the name of the provider.
*
! * @return a MessageDigest object that implements the specified algorithm.
*
! * @exception NoSuchAlgorithmException if a MessageDigestSpi
* implementation for the specified algorithm is not
! * available from the specified provider.
*
! * @exception NoSuchProviderException if the specified provider is not
! * registered in the security provider list.
*
! * @exception IllegalArgumentException if the provider name is null
! * or empty.
*
* @see Provider
*/
public static MessageDigest getInstance(String algorithm, String provider)
throws NoSuchAlgorithmException, NoSuchProviderException
{
if (provider == null || provider.length() == 0)
throw new IllegalArgumentException("missing provider");
Object[] objs = Security.getImpl(algorithm, "MessageDigest", provider);
if (objs[0] instanceof MessageDigest) {
MessageDigest md = (MessageDigest)objs[0];
--- 213,243 ----
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names.
*
* @param provider the name of the provider.
*
! * @return a {@code MessageDigest} object that implements the
! * specified algorithm
! *
! * @throws IllegalArgumentException if the provider name is {@code null}
! * or empty
*
! * @throws NoSuchAlgorithmException if a {@code MessageDigestSpi}
* implementation for the specified algorithm is not
! * available from the specified provider
*
! * @throws NoSuchProviderException if the specified provider is not
! * registered in the security provider list
*
! * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*/
public static MessageDigest getInstance(String algorithm, String provider)
throws NoSuchAlgorithmException, NoSuchProviderException
{
+ Objects.requireNonNull(algorithm, "null algorithm name");
if (provider == null || provider.length() == 0)
throw new IllegalArgumentException("missing provider");
Object[] objs = Security.getImpl(algorithm, "MessageDigest", provider);
if (objs[0] instanceof MessageDigest) {
MessageDigest md = (MessageDigest)objs[0];
*** 263,288 ****
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names.
*
* @param provider the provider.
*
! * @return a MessageDigest object that implements the specified algorithm.
*
! * @exception NoSuchAlgorithmException if a MessageDigestSpi
* implementation for the specified algorithm is not available
! * from the specified Provider object.
*
! * @exception IllegalArgumentException if the specified provider is null.
*
* @see Provider
*
* @since 1.4
*/
public static MessageDigest getInstance(String algorithm,
Provider provider)
throws NoSuchAlgorithmException
{
if (provider == null)
throw new IllegalArgumentException("missing provider");
Object[] objs = Security.getImpl(algorithm, "MessageDigest", provider);
if (objs[0] instanceof MessageDigest) {
MessageDigest md = (MessageDigest)objs[0];
--- 266,296 ----
* Java Cryptography Architecture Standard Algorithm Name Documentation</a>
* for information about standard algorithm names.
*
* @param provider the provider.
*
! * @return a {@code MessageDigest} object that implements the
! * specified algorithm
! *
! * @throws IllegalArgumentException if the specified provider is
! * {@code null}
*
! * @throws NoSuchAlgorithmException if a {@code MessageDigestSpi}
* implementation for the specified algorithm is not available
! * from the specified {@code Provider} object
*
! * @throws NullPointerException if {@code algorithm} is {@code null}
*
* @see Provider
*
* @since 1.4
*/
public static MessageDigest getInstance(String algorithm,
Provider provider)
throws NoSuchAlgorithmException
{
+ Objects.requireNonNull(algorithm, "null algorithm name");
if (provider == null)
throw new IllegalArgumentException("missing provider");
Object[] objs = Security.getImpl(algorithm, "MessageDigest", provider);
if (objs[0] instanceof MessageDigest) {
MessageDigest md = (MessageDigest)objs[0];
< prev index next >