Methods Summary |
---|
public final java.security.PrivateKey | generatePrivate(java.security.spec.KeySpec keySpec)Generates a private key object from the provided key specification
(key material).
if (serviceIterator == null) {
return spi.engineGeneratePrivate(keySpec);
}
Exception failure = null;
KeyFactorySpi mySpi = spi;
do {
try {
return mySpi.engineGeneratePrivate(keySpec);
} catch (Exception e) {
if (failure == null) {
failure = e;
}
mySpi = nextSpi(mySpi);
}
} while (mySpi != null);
if (failure instanceof RuntimeException) {
throw (RuntimeException)failure;
}
if (failure instanceof InvalidKeySpecException) {
throw (InvalidKeySpecException)failure;
}
throw new InvalidKeySpecException
("Could not generate private key", failure);
|
public final java.security.PublicKey | generatePublic(java.security.spec.KeySpec keySpec)Generates a public key object from the provided key specification
(key material).
if (serviceIterator == null) {
return spi.engineGeneratePublic(keySpec);
}
Exception failure = null;
KeyFactorySpi mySpi = spi;
do {
try {
return mySpi.engineGeneratePublic(keySpec);
} catch (Exception e) {
if (failure == null) {
failure = e;
}
mySpi = nextSpi(mySpi);
}
} while (mySpi != null);
if (failure instanceof RuntimeException) {
throw (RuntimeException)failure;
}
if (failure instanceof InvalidKeySpecException) {
throw (InvalidKeySpecException)failure;
}
throw new InvalidKeySpecException
("Could not generate public key", failure);
|
public final java.lang.String | getAlgorithm()Gets the name of the algorithm
associated with this KeyFactory.
return this.algorithm;
|
public static java.security.KeyFactory | getInstance(java.lang.String algorithm)Generates a KeyFactory object that implements the specified
algorithm. If the default provider package
provides an implementation of the requested algorithm,
an instance of KeyFactory containing that implementation is returned.
If the algorithm is not available in the default
package, other packages are searched.
return new KeyFactory(algorithm);
|
public static java.security.KeyFactory | getInstance(java.lang.String algorithm, java.lang.String provider)Generates a KeyFactory object for the specified algorithm from the
specified provider.
Instance instance = GetInstance.getInstance("KeyFactory",
KeyFactorySpi.class, algorithm, provider);
return new KeyFactory((KeyFactorySpi)instance.impl,
instance.provider, algorithm);
|
public static java.security.KeyFactory | getInstance(java.lang.String algorithm, java.security.Provider provider)Generates a KeyFactory object for the specified algorithm from the
specified provider. Note: the provider doesn't have
to be registered.
Instance instance = GetInstance.getInstance("KeyFactory",
KeyFactorySpi.class, algorithm, provider);
return new KeyFactory((KeyFactorySpi)instance.impl,
instance.provider, algorithm);
|
public final T | getKeySpec(java.security.Key key, java.lang.Class keySpec)Returns a specification (key material) of the given key object.
keySpec identifies the specification class in which
the key material should be returned. It could, for example, be
DSAPublicKeySpec.class , to indicate that the
key material should be returned in an instance of the
DSAPublicKeySpec class.
if (serviceIterator == null) {
return spi.engineGetKeySpec(key, keySpec);
}
Exception failure = null;
KeyFactorySpi mySpi = spi;
do {
try {
return mySpi.engineGetKeySpec(key, keySpec);
} catch (Exception e) {
if (failure == null) {
failure = e;
}
mySpi = nextSpi(mySpi);
}
} while (mySpi != null);
if (failure instanceof RuntimeException) {
throw (RuntimeException)failure;
}
if (failure instanceof InvalidKeySpecException) {
throw (InvalidKeySpecException)failure;
}
throw new InvalidKeySpecException
("Could not get key spec", failure);
|
public final java.security.Provider | getProvider()Returns the provider of this key factory object.
synchronized (lock) {
// disable further failover after this call
serviceIterator = null;
return provider;
}
|
private java.security.KeyFactorySpi | nextSpi(java.security.KeyFactorySpi oldSpi)Update the active KeyFactorySpi of this class and return the next
implementation for failover. If no more implemenations are
available, this method returns null. However, the active spi of
this class is never set to null.
synchronized (lock) {
// somebody else did a failover concurrently
// try that spi now
if ((oldSpi != null) && (oldSpi != spi)) {
return spi;
}
if (serviceIterator == null) {
return null;
}
while (serviceIterator.hasNext()) {
Service s = serviceIterator.next();
try {
Object obj = s.newInstance(null);
if (obj instanceof KeyFactorySpi == false) {
continue;
}
KeyFactorySpi spi = (KeyFactorySpi)obj;
provider = s.getProvider();
this.spi = spi;
return spi;
} catch (NoSuchAlgorithmException e) {
// ignore
}
}
serviceIterator = null;
return null;
}
|
public final java.security.Key | translateKey(java.security.Key key)Translates a key object, whose provider may be unknown or potentially
untrusted, into a corresponding key object of this key factory.
if (serviceIterator == null) {
return spi.engineTranslateKey(key);
}
Exception failure = null;
KeyFactorySpi mySpi = spi;
do {
try {
return mySpi.engineTranslateKey(key);
} catch (Exception e) {
if (failure == null) {
failure = e;
}
mySpi = nextSpi(mySpi);
}
} while (mySpi != null);
if (failure instanceof RuntimeException) {
throw (RuntimeException)failure;
}
if (failure instanceof InvalidKeyException) {
throw (InvalidKeyException)failure;
}
throw new InvalidKeyException
("Could not translate key", failure);
|