}
public PolicyAssertion build(Element element)
throws IllegalArgumentException {
SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI())
? SP11Constants.INSTANCE : SP12Constants.INSTANCE;
SecureConversationToken conversationToken = new SecureConversationToken(consts);
String attribute = DOMUtils.getAttribute(element, consts.getIncludeToken());
if (attribute == null) {
throw new IllegalArgumentException("SecurityContextToken doesn't contain "
+ "any sp:IncludeToken attribute");
}
String inclusionValue = attribute.trim();
conversationToken.setInclusion(consts.getInclusionFromAttributeValue(inclusionValue));
Element issuer = DOMUtils.getFirstChildWithName(element, consts.getNamespace(), SPConstants.ISSUER);
if (issuer != null) {
conversationToken.setIssuerEpr(DOMUtils.getFirstElement(issuer));
}
element = DOMUtils.getFirstChildWithName(element, SPConstants.POLICY);
if (element != null) {
if (DOMUtils.getFirstChildWithName(element,
consts.getNamespace(),
SPConstants.REQUIRE_DERIVED_KEYS) != null) {
conversationToken.setDerivedKeys(true);
} else if (DOMUtils.getFirstChildWithName(element,
SP12Constants.REQUIRE_IMPLIED_DERIVED_KEYS) != null) {
conversationToken.setImpliedDerivedKeys(true);
} else if (DOMUtils.getFirstChildWithName(element,
SP12Constants.REQUIRE_EXPLICIT_DERIVED_KEYS) != null) {
conversationToken.setExplicitDerivedKeys(true);
}
if (DOMUtils.getFirstChildWithName(element,
consts.getNamespace(),
SPConstants.REQUIRE_EXTERNAL_URI_REFERNCE) != null) {
conversationToken.setRequireExternalUriRef(true);
}
if (DOMUtils.getFirstChildWithName(element,
consts.getNamespace(),
SPConstants.SC10_SECURITY_CONTEXT_TOKEN) != null) {
conversationToken.setSc10SecurityContextToken(true);
}
Element bootstrapPolicyElement = DOMUtils.getFirstChildWithName(element,
consts.getNamespace(),
SPConstants.BOOTSTRAP_POLICY);
if (bootstrapPolicyElement != null) {
Policy policy = builder.getPolicy(DOMUtils.getFirstElement(bootstrapPolicyElement));
conversationToken.setBootstrapPolicy(policy);
}