EncryptedKeyResolverpublic class EncryptedKeyResolver extends KeyResolverSpi The EncryptedKeyResolver is not a generic resolver. It can
only be for specific instantiations, as the key being unwrapped will
always be of a particular type and will always have been wrapped by
another key which needs to be recursively resolved.
The EncryptedKeyResolver can therefore only be instantiated
with an algorithm. It can also be instantiated with a key (the KEK) or
will search the static KeyResolvers to find the appropriate key. |
Fields Summary |
---|
static Logger | log{@link java.util.logging} logging facility | Key | _key | Key | _kek | String | _algorithm |
Constructors Summary |
---|
public EncryptedKeyResolver(String algorithm)Constructor for use when a KEK needs to be derived from a KeyInfo
list
_key = null;
_kek = null;
_algorithm=algorithm;
| public EncryptedKeyResolver(String algorithm, Key kek)Constructor used for when a KEK has been set
_key = null;
_algorithm = algorithm;
_kek = kek;
|
Methods Summary |
---|
public boolean | engineCanResolve(org.w3c.dom.Element element, java.lang.String BaseURI, com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver storage)Method engineCanResolve
if (true)
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "EncryptedKeyResolver - Can I resolve " + element.getTagName());
if (element == null) {
return false;
}
boolean isEncryptedKey = XMLUtils.elementIsInEncryptionSpace(element,
EncryptionConstants._TAG_ENCRYPTEDKEY);
if (isEncryptedKey) {
if (log.isLoggable(java.util.logging.Level.FINE)) log.log(java.util.logging.Level.FINE, "Passed an Encrypted Key");
try {
XMLCipher cipher = XMLCipher.getInstance();
cipher.init(XMLCipher.UNWRAP_MODE, _kek);
EncryptedKey ek = cipher.loadEncryptedKey(element);
_key = cipher.decryptKey(ek, _algorithm);
}
catch (Exception e) {}
}
return (_key != null);
| public java.security.PublicKey | engineResolvePublicKey(org.w3c.dom.Element element, java.lang.String BaseURI, com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver storage)
return null;
| public javax.crypto.SecretKey | engineResolveSecretKey(org.w3c.dom.Element element, java.lang.String BaseURI, com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver storage)
return (SecretKey) _key;
| public java.security.cert.X509Certificate | engineResolveX509Certificate(org.w3c.dom.Element element, java.lang.String BaseURI, com.sun.org.apache.xml.internal.security.keys.storage.StorageResolver storage)
return null;
|
|