< prev index next >

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

Print this page
rev 15967 : [mq]: GetInstance


 150      * KeyFactorySpi implementation from the first
 151      * Provider that supports the specified algorithm is returned.
 152      *
 153      * <p> Note that the list of registered providers may be retrieved via
 154      * the {@link Security#getProviders() Security.getProviders()} method.
 155      *
 156      * @implNote
 157      * The JDK Reference Implementation additionally uses the
 158      * {@code jdk.security.provider.preferred}
 159      * {@link Security#getProperty(String) Security} property to determine
 160      * the preferred provider order for the specified algorithm. This
 161      * may be different than the order of providers returned by
 162      * {@link Security#getProviders() Security.getProviders()}.
 163      *
 164      * @param algorithm the name of the requested key algorithm.
 165      * See the KeyFactory section in the <a href=
 166      * "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyFactory">
 167      * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
 168      * for information about standard algorithm names.
 169      *
 170      * @return the new KeyFactory object.
 171      *
 172      * @exception NoSuchAlgorithmException if no Provider supports a
 173      *          KeyFactorySpi implementation for the
 174      *          specified algorithm.


 175      *
 176      * @see Provider
 177      */
 178     public static KeyFactory getInstance(String algorithm)
 179             throws NoSuchAlgorithmException {

 180         return new KeyFactory(algorithm);
 181     }
 182 
 183     /**
 184      * Returns a KeyFactory object that converts
 185      * public/private keys of the specified algorithm.
 186      *
 187      * <p> A new KeyFactory object encapsulating the
 188      * KeyFactorySpi implementation from the specified provider
 189      * is returned.  The specified provider must be registered
 190      * in the security provider list.
 191      *
 192      * <p> Note that the list of registered providers may be retrieved via
 193      * the {@link Security#getProviders() Security.getProviders()} method.
 194      *
 195      * @param algorithm the name of the requested key algorithm.
 196      * See the KeyFactory section in the <a href=
 197      * "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyFactory">
 198      * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
 199      * for information about standard algorithm names.
 200      *
 201      * @param provider the name of the provider.
 202      *
 203      * @return the new KeyFactory object.



 204      *
 205      * @exception NoSuchAlgorithmException if a KeyFactorySpi
 206      *          implementation for the specified algorithm is not
 207      *          available from the specified provider.
 208      *
 209      * @exception NoSuchProviderException if the specified provider is not
 210      *          registered in the security provider list.
 211      *
 212      * @exception IllegalArgumentException if the provider name is null
 213      *          or empty.
 214      *
 215      * @see Provider
 216      */
 217     public static KeyFactory getInstance(String algorithm, String provider)
 218             throws NoSuchAlgorithmException, NoSuchProviderException {

 219         Instance instance = GetInstance.getInstance("KeyFactory",
 220             KeyFactorySpi.class, algorithm, provider);
 221         return new KeyFactory((KeyFactorySpi)instance.impl,
 222             instance.provider, algorithm);
 223     }
 224 
 225     /**
 226      * Returns a KeyFactory object that converts
 227      * public/private keys of the specified algorithm.
 228      *
 229      * <p> A new KeyFactory object encapsulating the
 230      * KeyFactorySpi implementation from the specified Provider
 231      * object is returned.  Note that the specified Provider object
 232      * does not have to be registered in the provider list.
 233      *
 234      * @param algorithm the name of the requested key algorithm.
 235      * See the KeyFactory section in the <a href=
 236      * "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyFactory">
 237      * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
 238      * for information about standard algorithm names.
 239      *
 240      * @param provider the provider.
 241      *
 242      * @return the new KeyFactory object.



 243      *
 244      * @exception NoSuchAlgorithmException if a KeyFactorySpi
 245      *          implementation for the specified algorithm is not available
 246      *          from the specified Provider object.
 247      *
 248      * @exception IllegalArgumentException if the specified provider is null.
 249      *
 250      * @see Provider
 251      *
 252      * @since 1.4
 253      */
 254     public static KeyFactory getInstance(String algorithm, Provider provider)
 255             throws NoSuchAlgorithmException {

 256         Instance instance = GetInstance.getInstance("KeyFactory",
 257             KeyFactorySpi.class, algorithm, provider);
 258         return new KeyFactory((KeyFactorySpi)instance.impl,
 259             instance.provider, algorithm);
 260     }
 261 
 262     /**
 263      * Returns the provider of this key factory object.
 264      *
 265      * @return the provider of this key factory object
 266      */
 267     public final Provider getProvider() {
 268         synchronized (lock) {
 269             // disable further failover after this call
 270             serviceIterator = null;
 271             return provider;
 272         }
 273     }
 274 
 275     /**




 150      * KeyFactorySpi implementation from the first
 151      * Provider that supports the specified algorithm is returned.
 152      *
 153      * <p> Note that the list of registered providers may be retrieved via
 154      * the {@link Security#getProviders() Security.getProviders()} method.
 155      *
 156      * @implNote
 157      * The JDK Reference Implementation additionally uses the
 158      * {@code jdk.security.provider.preferred}
 159      * {@link Security#getProperty(String) Security} property to determine
 160      * the preferred provider order for the specified algorithm. This
 161      * may be different than the order of providers returned by
 162      * {@link Security#getProviders() Security.getProviders()}.
 163      *
 164      * @param algorithm the name of the requested key algorithm.
 165      * See the KeyFactory section in the <a href=
 166      * "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyFactory">
 167      * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
 168      * for information about standard algorithm names.
 169      *
 170      * @return the new {@code KeyFactory} object
 171      *
 172      * @throws NoSuchAlgorithmException if no {@code Provider} supports a
 173      *         {@code KeyFactorySpi} implementation for the
 174      *         specified algorithm
 175      *
 176      * @throws NullPointerException if {@code algorithm} is {@code null}
 177      *
 178      * @see Provider
 179      */
 180     public static KeyFactory getInstance(String algorithm)
 181             throws NoSuchAlgorithmException {
 182         Objects.requireNonNull(algorithm, "null algorithm name");
 183         return new KeyFactory(algorithm);
 184     }
 185 
 186     /**
 187      * Returns a KeyFactory object that converts
 188      * public/private keys of the specified algorithm.
 189      *
 190      * <p> A new KeyFactory object encapsulating the
 191      * KeyFactorySpi implementation from the specified provider
 192      * is returned.  The specified provider must be registered
 193      * in the security provider list.
 194      *
 195      * <p> Note that the list of registered providers may be retrieved via
 196      * the {@link Security#getProviders() Security.getProviders()} method.
 197      *
 198      * @param algorithm the name of the requested key algorithm.
 199      * See the KeyFactory section in the <a href=
 200      * "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyFactory">
 201      * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
 202      * for information about standard algorithm names.
 203      *
 204      * @param provider the name of the provider.
 205      *
 206      * @return the new {@code KeyFactory} object
 207      *
 208      * @throws IllegalArgumentException if the provider name is {@code null}
 209      *         or empty
 210      *
 211      * @throws NoSuchAlgorithmException if a {@code KeyFactorySpi}
 212      *         implementation for the specified algorithm is not
 213      *         available from the specified provider
 214      *
 215      * @throws NoSuchProviderException if the specified provider is not
 216      *         registered in the security provider list
 217      *
 218      * @throws NullPointerException if {@code algorithm} is {@code null}

 219      *
 220      * @see Provider
 221      */
 222     public static KeyFactory getInstance(String algorithm, String provider)
 223             throws NoSuchAlgorithmException, NoSuchProviderException {
 224         Objects.requireNonNull(algorithm, "null algorithm name");
 225         Instance instance = GetInstance.getInstance("KeyFactory",
 226             KeyFactorySpi.class, algorithm, provider);
 227         return new KeyFactory((KeyFactorySpi)instance.impl,
 228             instance.provider, algorithm);
 229     }
 230 
 231     /**
 232      * Returns a KeyFactory object that converts
 233      * public/private keys of the specified algorithm.
 234      *
 235      * <p> A new KeyFactory object encapsulating the
 236      * KeyFactorySpi implementation from the specified Provider
 237      * object is returned.  Note that the specified Provider object
 238      * does not have to be registered in the provider list.
 239      *
 240      * @param algorithm the name of the requested key algorithm.
 241      * See the KeyFactory section in the <a href=
 242      * "{@docRoot}/../technotes/guides/security/StandardNames.html#KeyFactory">
 243      * Java Cryptography Architecture Standard Algorithm Name Documentation</a>
 244      * for information about standard algorithm names.
 245      *
 246      * @param provider the provider.
 247      *
 248      * @return the new {@code KeyFactory} object
 249      *
 250      * @throws IllegalArgumentException if the specified provider is
 251      *         {@code null}
 252      *
 253      * @throws NoSuchAlgorithmException if a {@code KeyFactorySpi}
 254      *         implementation for the specified algorithm is not available
 255      *         from the specified {@code Provider} object
 256      *
 257      * @throws NullPointerException if {@code algorithm} is {@code null}
 258      *
 259      * @see Provider
 260      *
 261      * @since 1.4
 262      */
 263     public static KeyFactory getInstance(String algorithm, Provider provider)
 264             throws NoSuchAlgorithmException {
 265         Objects.requireNonNull(algorithm, "null algorithm name");
 266         Instance instance = GetInstance.getInstance("KeyFactory",
 267             KeyFactorySpi.class, algorithm, provider);
 268         return new KeyFactory((KeyFactorySpi)instance.impl,
 269             instance.provider, algorithm);
 270     }
 271 
 272     /**
 273      * Returns the provider of this key factory object.
 274      *
 275      * @return the provider of this key factory object
 276      */
 277     public final Provider getProvider() {
 278         synchronized (lock) {
 279             // disable further failover after this call
 280             serviceIterator = null;
 281             return provider;
 282         }
 283     }
 284 
 285     /**


< prev index next >