*/
public void process(JAXBFilterProcessingContext context) throws XWSSecurityException{
boolean ekRefList = false;
String referenceType = null;
String x509TokenId = null;
WSSElementFactory elementFactory = new WSSElementFactory(context.getSOAPVersion());
X509Certificate _x509Cert = null;
KeyInfoStrategy keyInfoStrategy = null;
String symmetricKeyName = null;
AuthenticationTokenPolicy.X509CertificateBinding certificateBinding = null;
((NamespaceContextEx)context.getNamespaceContext()).addEncryptionNS();
((NamespaceContextEx)context.getNamespaceContext()).addSignatureNS();
ReferenceList dataRefList = null;
EncryptedKeyType ekt = null;
WSSPolicy wssPolicy = (WSSPolicy)context.getSecurityPolicy();
EncryptionPolicy.FeatureBinding featureBinding =(EncryptionPolicy.FeatureBinding) wssPolicy.getFeatureBinding();
WSSPolicy keyBinding = (WSSPolicy)wssPolicy.getKeyBinding();
EncryptedKey ek = null;
KeyInfo edKeyInfo = null;
if(logger.isLoggable(Level.FINEST)){
logger.log(Level.FINEST, LogStringsMessages.WSS_1952_ENCRYPTION_KEYBINDING_VALUE(keyBinding));
}
if(PolicyTypeUtil.derivedTokenKeyBinding(keyBinding)){
DerivedTokenKeyBinding dtk = (DerivedTokenKeyBinding)keyBinding.clone();
WSSPolicy originalKeyBinding = dtk.getOriginalKeyBinding();
if (PolicyTypeUtil.x509CertificateBinding(originalKeyBinding)){
AuthenticationTokenPolicy.X509CertificateBinding ckBindingClone =
(AuthenticationTokenPolicy.X509CertificateBinding)originalKeyBinding.clone();
//create a symmetric key binding and set it as original key binding of dkt
SymmetricKeyBinding skb = new SymmetricKeyBinding();
skb.setKeyBinding(ckBindingClone);
// set the x509 binding as key binding of symmetric binding
dtk.setOriginalKeyBinding(skb);
//keyBinding = dtk;
EncryptionPolicy ep = (EncryptionPolicy)wssPolicy.clone();
ep.setKeyBinding(dtk);
context.setSecurityPolicy(ep);
wssPolicy = ep;
}
}
TokenProcessor tp = new TokenProcessor((EncryptionPolicy) wssPolicy, context);
BuilderResult tokenInfo = tp.process();
Key dataEncKey = null;
Key dkEncKey = null;
dataEncKey = tokenInfo.getDataProtectionKey();
ek = tokenInfo.getEncryptedKey();
ArrayList targets = featureBinding.getTargetBindings();
Iterator targetItr = targets.iterator();
ETHandler edBuilder = new ETHandler(context.getSOAPVersion());
EncryptionPolicy.FeatureBinding binding = (FeatureBinding) wssPolicy.getFeatureBinding();
dataRefList = new ReferenceList();
if(ek == null || binding.getUseStandAloneRefList()){
edKeyInfo = tokenInfo.getKeyInfo();
}
boolean refAdded = false;
while (targetItr.hasNext()) {
EncryptionTarget target = (EncryptionTarget)targetItr.next();
boolean contentOnly = target.getContentOnly();
//target.getDataEncryptionAlgorithm();
//target.getCipherReferenceTransforms();//TODO support this
List edList = edBuilder.buildEDList( (EncryptionPolicy)wssPolicy,target ,context, dataEncKey,edKeyInfo);
for(int i =0;i< edList.size();i++){
JAXBElement<ReferenceType> rt = elementFactory.createDataReference((SecurityElement)edList.get(i));
dataRefList.getDataReferenceOrKeyReference().add(rt);
refAdded = true;
}
}
if(refAdded){
if(ek == null || (binding.getUseStandAloneRefList())){
context.getSecurityHeader().add(elementFactory.createGSHeaderElement(dataRefList));
}else{
ek.setReferenceList(dataRefList);
}
}
}