135 * Provider that supports the specified algorithm is returned.
136 *
137 * <p> Note that the list of registered providers may be retrieved via
138 * the {@link Security#getProviders() Security.getProviders()} method.
139 *
140 * @implNote
141 * The JDK Reference Implementation additionally uses the
142 * {@code jdk.security.provider.preferred}
143 * {@link Security#getProperty(String) Security} property to determine
144 * the preferred provider order for the specified algorithm. This
145 * may be different than the order of providers returned by
146 * {@link Security#getProviders() Security.getProviders()}.
147 *
148 * @param algorithm the standard name of the requested secret-key
149 * algorithm.
150 * See the SecretKeyFactory section in the <a href=
151 * "{@docRoot}/../technotes/guides/security/StandardNames.html#SecretKeyFactory">
152 * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
153 * for information about standard algorithm names.
154 *
155 * @return the new {@code SecretKeyFactory} object.
156 *
157 * @exception NullPointerException if the specified algorithm
158 * is null.
159 *
160 * @exception NoSuchAlgorithmException if no Provider supports a
161 * SecretKeyFactorySpi implementation for the
162 * specified algorithm.
163 *
164 * @see java.security.Provider
165 */
166 public static final SecretKeyFactory getInstance(String algorithm)
167 throws NoSuchAlgorithmException {
168 return new SecretKeyFactory(algorithm);
169 }
170
171 /**
172 * Returns a {@code SecretKeyFactory} object that converts
173 * secret keys of the specified algorithm.
174 *
175 * <p> A new SecretKeyFactory object encapsulating the
176 * SecretKeyFactorySpi implementation from the specified provider
177 * is returned. The specified provider must be registered
178 * in the security provider list.
179 *
180 * <p> Note that the list of registered providers may be retrieved via
181 * the {@link Security#getProviders() Security.getProviders()} method.
182 *
183 * @param algorithm the standard name of the requested secret-key
184 * algorithm.
185 * See the SecretKeyFactory section in the <a href=
186 * "{@docRoot}/../technotes/guides/security/StandardNames.html#SecretKeyFactory">
187 * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
188 * for information about standard algorithm names.
189 *
190 * @param provider the name of the provider.
191 *
192 * @return the new {@code SecretKeyFactory} object.
193 *
194 * @exception NoSuchAlgorithmException if a SecretKeyFactorySpi
195 * implementation for the specified algorithm is not
196 * available from the specified provider.
197 *
198 * @exception NullPointerException if the specified algorithm
199 * is null.
200 *
201 * @throws NoSuchProviderException if the specified provider is not
202 * registered in the security provider list.
203 *
204 * @exception IllegalArgumentException if the {@code provider}
205 * is null or empty.
206 *
207 * @see java.security.Provider
208 */
209 public static final SecretKeyFactory getInstance(String algorithm,
210 String provider) throws NoSuchAlgorithmException,
211 NoSuchProviderException {
212 Instance instance = JceSecurity.getInstance("SecretKeyFactory",
213 SecretKeyFactorySpi.class, algorithm, provider);
214 return new SecretKeyFactory((SecretKeyFactorySpi)instance.impl,
215 instance.provider, algorithm);
216 }
217
218 /**
219 * Returns a {@code SecretKeyFactory} object that converts
220 * secret keys of the specified algorithm.
221 *
222 * <p> A new SecretKeyFactory object encapsulating the
223 * SecretKeyFactorySpi implementation from the specified Provider
224 * object is returned. Note that the specified Provider object
225 * does not have to be registered in the provider list.
226 *
227 * @param algorithm the standard name of the requested secret-key
228 * algorithm.
229 * See the SecretKeyFactory section in the <a href=
230 * "{@docRoot}/../technotes/guides/security/StandardNames.html#SecretKeyFactory">
231 * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
232 * for information about standard algorithm names.
233 *
234 * @param provider the provider.
235 *
236 * @return the new {@code SecretKeyFactory} object.
237 *
238 * @exception NullPointerException if the specified algorithm
239 * is null.
240 *
241 * @exception NoSuchAlgorithmException if a SecretKeyFactorySpi
242 * implementation for the specified algorithm is not available
243 * from the specified Provider object.
244 *
245 * @exception IllegalArgumentException if the {@code provider}
246 * is null.
247 *
248 * @see java.security.Provider
249 */
250 public static final SecretKeyFactory getInstance(String algorithm,
251 Provider provider) throws NoSuchAlgorithmException {
252 Instance instance = JceSecurity.getInstance("SecretKeyFactory",
253 SecretKeyFactorySpi.class, algorithm, provider);
254 return new SecretKeyFactory((SecretKeyFactorySpi)instance.impl,
255 instance.provider, algorithm);
256 }
257
258 /**
259 * Returns the provider of this {@code SecretKeyFactory} object.
260 *
261 * @return the provider of this {@code SecretKeyFactory} object
262 */
263 public final Provider getProvider() {
264 synchronized (lock) {
265 // disable further failover after this call
266 serviceIterator = null;
267 return provider;
268 }
269 }
270
271 /**
|
135 * Provider that supports the specified algorithm is returned.
136 *
137 * <p> Note that the list of registered providers may be retrieved via
138 * the {@link Security#getProviders() Security.getProviders()} method.
139 *
140 * @implNote
141 * The JDK Reference Implementation additionally uses the
142 * {@code jdk.security.provider.preferred}
143 * {@link Security#getProperty(String) Security} property to determine
144 * the preferred provider order for the specified algorithm. This
145 * may be different than the order of providers returned by
146 * {@link Security#getProviders() Security.getProviders()}.
147 *
148 * @param algorithm the standard name of the requested secret-key
149 * algorithm.
150 * See the SecretKeyFactory section in the <a href=
151 * "{@docRoot}/../technotes/guides/security/StandardNames.html#SecretKeyFactory">
152 * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
153 * for information about standard algorithm names.
154 *
155 * @return the new {@code SecretKeyFactory} object
156 *
157 * @throws NoSuchAlgorithmException if no {@code Provider} supports a
158 * {@code SecretKeyFactorySpi} implementation for the
159 * specified algorithm
160 *
161 * @throws NullPointerException if {@code algorithm} is {@code null}
162 *
163 * @see java.security.Provider
164 */
165 public static final SecretKeyFactory getInstance(String algorithm)
166 throws NoSuchAlgorithmException {
167 Objects.requireNonNull(algorithm, "null algorithm name");
168 return new SecretKeyFactory(algorithm);
169 }
170
171 /**
172 * Returns a {@code SecretKeyFactory} object that converts
173 * secret keys of the specified algorithm.
174 *
175 * <p> A new SecretKeyFactory object encapsulating the
176 * SecretKeyFactorySpi implementation from the specified provider
177 * is returned. The specified provider must be registered
178 * in the security provider list.
179 *
180 * <p> Note that the list of registered providers may be retrieved via
181 * the {@link Security#getProviders() Security.getProviders()} method.
182 *
183 * @param algorithm the standard name of the requested secret-key
184 * algorithm.
185 * See the SecretKeyFactory section in the <a href=
186 * "{@docRoot}/../technotes/guides/security/StandardNames.html#SecretKeyFactory">
187 * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
188 * for information about standard algorithm names.
189 *
190 * @param provider the name of the provider.
191 *
192 * @return the new {@code SecretKeyFactory} object
193 *
194 * @throws IllegalArgumentException if the {@code provider}
195 * is {@code null} or empty
196 *
197 * @throws NoSuchAlgorithmException if a {@code SecretKeyFactorySpi}
198 * implementation for the specified algorithm is not
199 * available from the specified provider
200 *
201 * @throws NoSuchProviderException if the specified provider is not
202 * registered in the security provider list
203 *
204 * @throws NullPointerException if {@code algorithm} is {@code null}
205 *
206 * @see java.security.Provider
207 */
208 public static final SecretKeyFactory getInstance(String algorithm,
209 String provider) throws NoSuchAlgorithmException,
210 NoSuchProviderException {
211 Objects.requireNonNull(algorithm, "null algorithm name");
212 Instance instance = JceSecurity.getInstance("SecretKeyFactory",
213 SecretKeyFactorySpi.class, algorithm, provider);
214 return new SecretKeyFactory((SecretKeyFactorySpi)instance.impl,
215 instance.provider, algorithm);
216 }
217
218 /**
219 * Returns a {@code SecretKeyFactory} object that converts
220 * secret keys of the specified algorithm.
221 *
222 * <p> A new SecretKeyFactory object encapsulating the
223 * SecretKeyFactorySpi implementation from the specified Provider
224 * object is returned. Note that the specified Provider object
225 * does not have to be registered in the provider list.
226 *
227 * @param algorithm the standard name of the requested secret-key
228 * algorithm.
229 * See the SecretKeyFactory section in the <a href=
230 * "{@docRoot}/../technotes/guides/security/StandardNames.html#SecretKeyFactory">
231 * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
232 * for information about standard algorithm names.
233 *
234 * @param provider the provider.
235 *
236 * @return the new {@code SecretKeyFactory} object
237 *
238 * @throws IllegalArgumentException if the {@code provider}
239 * is {@code null}
240 *
241 * @throws NoSuchAlgorithmException if a {@code SecretKeyFactorySpi}
242 * implementation for the specified algorithm is not available
243 * from the specified {@code Provider} object
244 *
245 * @throws NullPointerException if {@code algorithm} is {@code null}
246 *
247 * @see java.security.Provider
248 */
249 public static final SecretKeyFactory getInstance(String algorithm,
250 Provider provider) throws NoSuchAlgorithmException {
251 Objects.requireNonNull(algorithm, "null algorithm name");
252 Instance instance = JceSecurity.getInstance("SecretKeyFactory",
253 SecretKeyFactorySpi.class, algorithm, provider);
254 return new SecretKeyFactory((SecretKeyFactorySpi)instance.impl,
255 instance.provider, algorithm);
256 }
257
258 /**
259 * Returns the provider of this {@code SecretKeyFactory} object.
260 *
261 * @return the provider of this {@code SecretKeyFactory} object
262 */
263 public final Provider getProvider() {
264 synchronized (lock) {
265 // disable further failover after this call
266 serviceIterator = null;
267 return provider;
268 }
269 }
270
271 /**
|