public PolicyAssertion build(Element element)
throws IllegalArgumentException {
SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI())
? SP11Constants.INSTANCE : SP12Constants.INSTANCE;
X509Token x509Token = new X509Token(consts);
x509Token.setOptional(PolicyConstants.isOptional(element));
Element policyElement = DOMUtils.getFirstElement(element);
// Process token inclusion
String includeAttr = DOMUtils.getAttribute(element, consts.getIncludeToken());
if (includeAttr != null) {
SPConstants.IncludeTokenType inclusion
= consts.getInclusionFromAttributeValue(includeAttr);
x509Token.setInclusion(inclusion);
}
if (policyElement != null) {
if (DOMUtils.getFirstChildWithName(policyElement, consts.getRequiredDerivedKeys()) != null) {
x509Token.setDerivedKeys(true);
} else if (DOMUtils.getFirstChildWithName(policyElement,
SP12Constants.REQUIRE_IMPLIED_DERIVED_KEYS) != null) {
x509Token.setImpliedDerivedKeys(true);
} else if (DOMUtils.getFirstChildWithName(policyElement,
SP12Constants.REQUIRE_EXPLICIT_DERIVED_KEYS) != null) {
x509Token.setExplicitDerivedKeys(true);
}
Policy policy = builder.getPolicy(DOMUtils.getFirstElement(element));
policy = (Policy)policy.normalize(builder.getPolicyRegistry(), false);