log.log(Level.SEVERE, "WSS1222.unsupported.KeyBinding.EncryptionPolicy");
throw new XWSSecurityException("Unsupported Key Binding for EncryptionPolicy");
}
XMLCipher _keyEncryptor = null;
XMLCipher _dataEncryptor = null;
Cipher _attachmentEncryptor = null;
Cipher _dataCipher = null;
try {
// lazy n static instantiation can happen
//TODO :: Algorithms -- Venu
if(log.isLoggable(Level.FINEST)){
log.log(Level.FINEST, "KeyEncryption algorithm is "+keyEncAlgo);
}
if (_x509Cert != null) {
//prepare for keytransport
_keyEncryptor = XMLCipher.getInstance(keyEncAlgo);
_keyEncryptor.init(XMLCipher.WRAP_MODE, _x509Cert.getPublicKey());
} else if (samlkey != null) {
//prepare for keytransport
_keyEncryptor = XMLCipher.getInstance(keyEncAlgo);
_keyEncryptor.init(XMLCipher.WRAP_MODE, samlkey);
}else if( keyEncSK != null){
//prepare for keywrap
_keyEncryptor = XMLCipher.getInstance(keyEncAlgo);
_keyEncryptor.init(XMLCipher.WRAP_MODE, keyEncSK);
}
if(log.isLoggable(Level.FINEST)){
log.log(Level.FINEST, "Data encryption algorithm is "+dataEncAlgo);
}
String dataAlgorithm = JCEMapper.translateURItoJCEID(dataEncAlgo);
_dataCipher = Cipher.getInstance(dataAlgorithm);
_dataEncryptor = XMLCipher.getInstance(dataEncAlgo,_dataCipher);
_dataCipher.init(XMLCipher.ENCRYPT_MODE, _symmetricKey);
_dataEncryptor.init(XMLCipher.ENCRYPT_MODE, _symmetricKey);
} catch (Exception xee) {
log.log(Level.SEVERE, "WSS1205.unableto.initialize.xml.cipher",xee);
throw new XWSSecurityException(
"Unable to initialize XML Cipher", xee);