public void addKeyBinding(Binding binding,WSSPolicy policy, Token token,boolean ignoreDK) throws PolicyException{
PolicyAssertion tokenAssertion = (PolicyAssertion)token;
SecurityPolicyVersion spVersion = SecurityPolicyUtil.getSPVersion(tokenAssertion);
if(PolicyUtil.isUsernameToken(tokenAssertion, spVersion)){
AuthenticationTokenPolicy.UsernameTokenBinding untBinding =new AuthenticationTokenPolicy.UsernameTokenBinding();
UsernameToken unToken = (UsernameToken)tokenAssertion;
untBinding.setUUID(token.getTokenId());
setUsernameTokenRefType(untBinding,unToken);
//this code need not be called for UT
setTokenInclusion(untBinding,(Token) tokenAssertion);
setTokenValueType(untBinding, tokenAssertion);
untBinding.isOptional(tokenAssertion.isOptional());
if(unToken.getIssuer() != null){
Address addr = unToken.getIssuer().getAddress();
if(addr != null)
untBinding.setIssuer(addr.getURI().toString());
} else if(unToken.getIssuerName() != null){
untBinding.setIssuer(unToken.getIssuerName().getIssuerName());
}
if(unToken.getClaims() != null){
untBinding.setClaims(unToken.getClaims().getClaimsAsBytes());
}
untBinding.setUseCreated(unToken.useCreated());
untBinding.setUseNonce(unToken.useNonce());
if (!ignoreDK && unToken.isRequireDerivedKeys()) {
DerivedTokenKeyBinding dtKB = new DerivedTokenKeyBinding();
//Support for PasswordDerivedKeys
if ((binding instanceof AsymmetricBinding) && (((AsymmetricBinding) binding).getInitiatorToken() != null)) {
skb.setKeyBinding(untBinding);
dtKB.setOriginalKeyBinding(skb);
policy.setKeyBinding(dtKB);
} else {
dtKB.setOriginalKeyBinding(untBinding);
policy.setKeyBinding(dtKB);
}
dtKB.setUUID(pid.generateID());
} else if (unToken.isRequireDerivedKeys()) {
DerivedTokenKeyBinding dtKB = new DerivedTokenKeyBinding();
if ((binding instanceof AsymmetricBinding) && (((AsymmetricBinding) binding).getInitiatorToken() != null)) {
skb.setKeyBinding(untBinding);
dtKB.setOriginalKeyBinding(skb);
policy.setKeyBinding(dtKB);