}
}
Data data = null;
if(obj instanceof SOAPBody){
data = new SSBData((SOAPBody)obj,true, context.getNamespaceContext());
SecurityHeaderElement ed = (SecurityHeaderElement) wsf.createEncryptedData(context.generateID(),data,dataEncAlg,ki,key,true);
edList.add(ed);
SOAPBody sb =(SOAPBody) message.getBody();
SOAPBody nsb = new SOAPBody(ed,context.getSOAPVersion());
nsb.setId(sb.getId());
message.replaceBody(nsb);
}else if(obj instanceof SecurityElement){
data = new SSEData((SecurityElement)obj, true, context.getNamespaceContext(), props);
SecurityHeaderElement ed = (SecurityHeaderElement) wsf.createEncryptedData(context.generateID(),data,dataEncAlg,ki,key,true);
edList.add(ed);
SOAPBody nsb = new SOAPBody(ed,context.getSOAPVersion());
nsb.setId(((SecurityElement)obj).getId());
message.replaceBody(nsb);
}
return edList;
}
// Look for Id or wsu:Id attribute in all elements
java.util.Iterator headers = null;
if(name.getNamespaceURI().equals(MessageConstants.ADDRESSING_MEMBER_SUBMISSION_NAMESPACE) ||
name.getNamespaceURI().equals(MessageConstants.ADDRESSING_W3C_NAMESPACE)){
if(!"".equals(name.getLocalPart()))
headers = message.getHeaders(name.getLocalPart(), null);
else{
headers = message.getHeaders(MessageConstants.ADDRESSING_MEMBER_SUBMISSION_NAMESPACE);
if(!headers.hasNext())
headers = message.getHeaders(MessageConstants.ADDRESSING_W3C_NAMESPACE);
}
} else {
if(!"".equals(name.getLocalPart()))
headers = message.getHeaders(name.getLocalPart(), name.getNamespaceURI());
else
headers = message.getHeaders(name.getNamespaceURI());
}
while(headers.hasNext()){
Object header = headers.next();
SecurityHeaderElement ed = toMessageHeader(policy,target,context,key,header,ki, true);
edList.add(ed);
}
if(!edList.isEmpty()){
return edList;
}
SecurityHeader sh = context.getSecurityHeader();
Iterator itr = sh.getHeaders(name.getLocalPart(),name.getNamespaceURI());
while(itr.hasNext()){
SecurityHeaderElement hdr = (SecurityHeaderElement)itr.next();
if(hdr != null){
SecurityHeaderElement ed = toMessageHeader(policy,target,context,key,hdr,ki, false);
edList.add(ed);
}
}
return edList;
}else if(target.getType() == Target.TARGET_TYPE_VALUE_URI){
if(MessageConstants.PROCESS_ALL_ATTACHMENTS.equals(target.getValue())){
handleAttachments(context, edList, key,ki ,target);
} else{
SecurityHeaderElement se = handleURI(policy,target,context,key,ki);
edList.add(se);
}
return edList;
//TODO
// throw new UnsupportedOperationException("Target Type "+target.getType() +" is not supported by EncryptionProcessor");