return operations;
}
public static void handleOutbound(CommonMessageContext ctx) throws SOAPException, SOAPFaultException
{
WSSecurityConfiguration config = getSecurityConfig(ctx);
SOAPMessageImpl soapMessage = (SOAPMessageImpl)ctx.getSOAPMessage();
OperationMetaData opMetaData = ctx.getOperationMetaData();
String operation = opMetaData.getQName().toString();
String port = opMetaData.getEndpointMetaData().getPortName().getLocalPart();
Config operationConfig = getConfig(config, port, operation);
log.debug("WS-Security config: " + operationConfig);
// Nothing to process
if (operationConfig == null)
return;
ArrayList<OperationDescription<EncodingOperation>> operations = new ArrayList<OperationDescription<EncodingOperation>>();
Timestamp timestamp = operationConfig.getTimestamp();
if (timestamp != null)
{
operations.add(new OperationDescription<EncodingOperation>(TimestampOperation.class, null, null, timestamp.getTtl(), null));
}
if (operationConfig.getUsername() != null)
{
Object user = ctx.get(Stub.USERNAME_PROPERTY);
Object pass = ctx.get(Stub.PASSWORD_PROPERTY);
if (user == null && pass == null)
{
user = ctx.get(BindingProvider.USERNAME_PROPERTY);
pass = ctx.get(BindingProvider.PASSWORD_PROPERTY);
}
if (user != null && pass != null)
{
operations.add(new OperationDescription<EncodingOperation>(SendUsernameOperation.class, null, user.toString(), pass.toString(), null));
ctx.put(StubExt.PROPERTY_AUTH_TYPE, StubExt.PROPERTY_AUTH_TYPE_WSSE);
}
}
Sign sign = operationConfig.getSign();
if (sign != null)
{
List<Target> targets = convertTargets(sign.getTargets());
if (sign.isIncludeTimestamp())
{
if (timestamp == null)
operations.add(new OperationDescription<EncodingOperation>(TimestampOperation.class, null, null, null, null));
if (targets != null && targets.size() > 0)
targets.add(new WsuIdTarget("timestamp"));
}
operations.add(new OperationDescription<EncodingOperation>(SignatureOperation.class, targets, sign.getAlias(), null, null));
}
Encrypt encrypt = operationConfig.getEncrypt();
if (encrypt != null)
{
List<Target> targets = convertTargets(encrypt.getTargets());
operations.add(new OperationDescription<EncodingOperation>(EncryptionOperation.class, targets, encrypt.getAlias(), null, encrypt.getAlgorithm()));
}
if (operations.size() == 0)
return;
if(log.isDebugEnabled()) log.debug("Encoding Message:\n" + DOMWriter.printNode(soapMessage.getSOAPPart(), true));
try
{
SecurityStore securityStore = new SecurityStore(config.getKeyStoreURL(), config.getKeyStoreType(), config.getKeyStorePassword(), config.getKeyPasswords() , config.getTrustStoreURL(),
config.getTrustStoreType(), config.getTrustStorePassword());
SecurityEncoder encoder = new SecurityEncoder(operations, securityStore);
encoder.encode(soapMessage.getSOAPPart());
}
catch (WSSecurityException e)
{