while (i.hasNext()) {
SecurityPolicy primaryPolicy = (SecurityPolicy) i.next();
if(PolicyTypeUtil.signaturePolicy(primaryPolicy)){
SignaturePolicy sigPolicy = (SignaturePolicy)primaryPolicy;
IntegrityAssertionProcessor iAP = new IntegrityAssertionProcessor(scp.getAlgorithmSuite(), true);
SignatureTargetCreator stc = iAP.getTargetCreator();
SignatureTarget sigTarget = stc.newURISignatureTarget(sigPolicy.getUUID());
SecurityPolicyUtil.setName(sigTarget, sigPolicy);
spFB.addTargetBinding(sigTarget);
spFB.isEndorsingSignature(true);
addedSigTarget = true;
break;
}
}
// If no primary signature (e.g. TransportBinding), sign the
// TimeStamp.
if (!addedSigTarget){
List sList = policy.getSecondaryPolicies();
Iterator j = sList.iterator();
while (j.hasNext()) {
SecurityPolicy secPolicy = (SecurityPolicy) j.next();
if(PolicyTypeUtil.timestampPolicy(secPolicy)){
TimestampPolicy tsPolicy = (TimestampPolicy)secPolicy;
IntegrityAssertionProcessor iAP = new IntegrityAssertionProcessor(scp.getAlgorithmSuite(), true);
SignatureTargetCreator stc = iAP.getTargetCreator();
SignatureTarget sigTarget = stc.newURISignatureTarget(tsPolicy.getUUID());
SecurityPolicyUtil.setName(sigTarget, tsPolicy);
spFB.addTargetBinding(sigTarget);
spFB.isEndorsingSignature(true);
addedSigTarget = true;
break;