}
}
public void encodeMessage(WSSecurityConfiguration configuration, SOAPMessage message, Config operationConfig, String user, String password) throws SOAPException
{
Config config = getActualConfig(configuration, operationConfig);
log.debug("WS-Security config: " + config);
boolean fault = message.getSOAPBody().getFault() != null;
// Nothing to process
if (config == null || (fault && !config.includesFaults()))
return;
ArrayList<EncodingOperation> operations = new ArrayList<EncodingOperation>();
Timestamp timestamp = config.getTimestamp();
if (timestamp != null)
{
operations.add(new TimestampOperation(timestamp.getTtl()));
}
Username username = config.getUsername();
if (username != null && user != null && password != null)
{
NonceFactory factory = Util.loadFactory(NonceFactory.class, configuration.getNonceFactory(), DefaultNonceFactory.class);
operations.add(new SendUsernameOperation(user, password, username.isDigestPassword(), username.isUseNonce(), username.isUseCreated(), factory.getGenerator()));
}
Sign sign = config.getSign();
if (sign != null && (!fault || sign.isIncludeFaults()))
{
List<Target> targets = convertTargets(sign.getTargets());
if (sign.isIncludeTimestamp())
{
if (timestamp == null)
operations.add(new TimestampOperation(null));
if (targets != null && targets.size() > 0)
targets.add(new WsuIdTarget("timestamp"));
}
operations.add(new SignatureOperation(targets, sign.getAlias(), sign.getTokenRefType(), sign.getSecurityDomainAliasLabel()));
}
Encrypt encrypt = config.getEncrypt();
if (encrypt != null && (!fault || encrypt.isIncludeFaults()))
{
List<Target> targets = convertTargets(encrypt.getTargets());
operations.add(new EncryptionOperation(targets, encrypt.getAlias(), encrypt.getAlgorithm(), encrypt.getWrap(), encrypt.getTokenRefType(), encrypt
.getSecurityDomainAliasLabel()));