if(encryptionPolicy == null){
encryptionPolicy = new EncryptionPolicy();
}
EncryptionPolicy.FeatureBinding eFB = (EncryptionPolicy.FeatureBinding )
encryptionPolicy.getFeatureBinding();
EncryptionTarget encTarget = new EncryptionTarget();
//target.addCipherReferenceTransform(transform
encTarget.setDataEncryptionAlgorithm(algorithm);
encTarget.setContentOnly(contentOnly);
if(isAttachment){
encTarget.addCipherReferenceTransform(type);
}
if(encryptedAttachment != null){
encTarget.setValue(encryptedAttachment.getContentId());
}else{
String id = actualEncrypted.getAttribute("Id");
if("".equals(id)){
id = actualEncrypted.getAttributeNS(MessageConstants.WSU_NS, "Id");
}
encTarget.setValue(id);
}
encTarget.setType(Target.TARGET_TYPE_VALUE_URI);
encTarget.setElementData(actualEncrypted);
Iterator transformItr = xencEncryptedData.getTransforms();
if(transformItr != null){
while(transformItr.hasNext()){
encTarget.addCipherReferenceTransform((String)transformItr.next());
}
}
eFB.addTargetBinding(encTarget);
return null;
}else if(context.getMode() == FilterProcessingContext.ADHOC ||
context.getMode() == FilterProcessingContext.DEFAULT){
if(isAttachment){
return new AttachmentData(encryptedAttachment.getContentId(),contentOnly);
}
EncryptedElement encryptedElement = new EncryptedElement(actualEncrypted, contentOnly);
return encryptedElement;
} else if(context.getMode() == FilterProcessingContext.WSDL_POLICY){
QName qname = new QName(actualEncrypted.getNamespaceURI(), actualEncrypted.getLocalName());
EncryptionPolicy.FeatureBinding featureBinding =
(EncryptionPolicy.FeatureBinding)inferredWsdlEncPolicy.getFeatureBinding();
EncryptionTarget target = new EncryptionTarget();
if(actualEncrypted.getNamespaceURI() != null && (actualEncrypted.getNamespaceURI().equals(MessageConstants.WSSE_NS) ||
actualEncrypted.getNamespaceURI().equals(MessageConstants.WSSE11_NS) ||
actualEncrypted.getNamespaceURI().equals(MessageConstants.WSSC_NS) ||
actualEncrypted.getNamespaceURI().equals(MessageConstants.WSU_NS))){
String id = actualEncrypted.getAttribute("Id");
if("".equals(id)){
id = actualEncrypted.getAttributeNS(MessageConstants.WSU_NS, "Id");
}
target.setValue(id);
target.setType(EncryptionTarget.TARGET_TYPE_VALUE_URI);
} else{
target.setQName(qname);
target.setType(EncryptionTarget.TARGET_TYPE_VALUE_QNAME);
}
target.setDataEncryptionAlgorithm(algorithm);
target.setContentOnly(contentOnly);
featureBinding.addTargetBinding(target);
if (qname.getLocalPart().equals("Assertion")) {
//TODO: check NS URI also
featureBinding.encryptsIssuedToken(true);
}