PolicyAssertion tokenAssertion = (PolicyAssertion)token;
SecurityPolicyVersion spVersion = SecurityPolicyUtil.getSPVersion(tokenAssertion);
if(PolicyUtil.isX509Token(tokenAssertion, spVersion)){
AuthenticationTokenPolicy.X509CertificateBinding x509CB =new AuthenticationTokenPolicy.X509CertificateBinding();
// (AuthenticationTokenPolicy.X509CertificateBinding)policy.newX509CertificateKeyBinding();
X509Token x509Token = (X509Token)tokenAssertion;
x509CB.setUUID(token.getTokenId());
tokenProcessor.setTokenValueType(x509CB, tokenAssertion);
tokenProcessor.setTokenInclusion(x509CB,(Token) tokenAssertion);
//x509CB.setPolicyToken((Token) tokenAssertion);
tokenProcessor.setX509TokenRefType(x509CB, x509Token);
if(x509Token.getIssuer() != null){
Address addr = x509Token.getIssuer().getAddress();
if(addr != null)
x509CB.setIssuer(addr.getURI().toString());
} else if(x509Token.getIssuerName() != null){
x509CB.setIssuer(x509Token.getIssuerName().getIssuerName());
}
if(x509Token.getClaims() != null){
x509CB.setClaims(x509Token.getClaims().getClaimsAsBytes());
}
if(x509Token.isRequireDerivedKeys()){
DerivedTokenKeyBinding dtKB = new DerivedTokenKeyBinding();
skb.setKeyBinding(x509CB);
policy.setKeyBinding(dtKB);
dtKB.setOriginalKeyBinding(skb);
dtKB.setUUID(pid.generateID());