1 /*
2 * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
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
131 */
132 protected MessageDigest(String algorithm) {
133 this.algorithm = algorithm;
134 }
135
136 /**
137 * Returns a MessageDigest object that implements the specified digest
138 * algorithm.
139 *
140 * <p> This method traverses the list of registered security Providers,
141 * starting with the most preferred Provider.
142 * A new MessageDigest object encapsulating the
143 * MessageDigestSpi implementation from the first
144 * Provider that supports the specified algorithm is returned.
145 *
146 * <p> Note that the list of registered providers may be retrieved via
147 * the {@link Security#getProviders() Security.getProviders()} method.
148 *
149 * @implNote
150 * The JDK Reference Implementation additionally uses the
151 * {@code jdk.security.provider.preferred} property to determine
152 * the preferred provider order for the specified algorithm. This
153 * may be different than the order of providers returned by
154 * {@link Security#getProviders() Security.getProviders()}.
155 *
156 * @param algorithm the name of the algorithm requested.
157 * See the MessageDigest section in the <a href=
158 * "{@docRoot}/../technotes/guides/security/StandardNames.html#MessageDigest">
159 * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
160 * for information about standard algorithm names.
161 *
162 * @return a Message Digest object that implements the specified algorithm.
163 *
164 * @exception NoSuchAlgorithmException if no Provider supports a
165 * MessageDigestSpi implementation for the
166 * specified algorithm.
167 *
168 * @see Provider
169 */
170 public static MessageDigest getInstance(String algorithm)
171 throws NoSuchAlgorithmException {
|
1 /*
2 * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
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
131 */
132 protected MessageDigest(String algorithm) {
133 this.algorithm = algorithm;
134 }
135
136 /**
137 * Returns a MessageDigest object that implements the specified digest
138 * algorithm.
139 *
140 * <p> This method traverses the list of registered security Providers,
141 * starting with the most preferred Provider.
142 * A new MessageDigest object encapsulating the
143 * MessageDigestSpi implementation from the first
144 * Provider that supports the specified algorithm is returned.
145 *
146 * <p> Note that the list of registered providers may be retrieved via
147 * the {@link Security#getProviders() Security.getProviders()} method.
148 *
149 * @implNote
150 * The JDK Reference Implementation additionally uses the
151 * {@code jdk.security.provider.preferred}
152 * {@link Security#getProperty(String) Security} property to determine
153 * the preferred provider order for the specified algorithm. This
154 * may be different than the order of providers returned by
155 * {@link Security#getProviders() Security.getProviders()}.
156 *
157 * @param algorithm the name of the algorithm requested.
158 * See the MessageDigest section in the <a href=
159 * "{@docRoot}/../technotes/guides/security/StandardNames.html#MessageDigest">
160 * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
161 * for information about standard algorithm names.
162 *
163 * @return a Message Digest object that implements the specified algorithm.
164 *
165 * @exception NoSuchAlgorithmException if no Provider supports a
166 * MessageDigestSpi implementation for the
167 * specified algorithm.
168 *
169 * @see Provider
170 */
171 public static MessageDigest getInstance(String algorithm)
172 throws NoSuchAlgorithmException {
|