public static final QName ENCRYPTION_USER = new QName("http://ws.apache.org/rampart/policy",
ENCRYPTION_USER_LN);
public Assertion build(OMElement element, AssertionBuilderFactory factory)
throws IllegalArgumentException {
X509Token x509Token = new X509Token(SPConstants.SP_V12);
OMElement policyElement = element.getFirstElement();
//Process token inclusion
OMAttribute includeAttr = element.getAttribute(SP12Constants.INCLUDE_TOKEN);
if(includeAttr != null) {
int inclusion = SP12Constants.getInclusionFromAttributeValue(includeAttr.getAttributeValue());
x509Token.setInclusion(inclusion);
}
if (policyElement != null) {
if (policyElement.getFirstChildWithName(SP12Constants.REQUIRE_DERIVED_KEYS) != null) {
x509Token.setDerivedKeys(true);
} else if (policyElement.getFirstChildWithName(SP12Constants.REQUIRE_IMPLIED_DERIVED_KEYS) != null) {
x509Token.setImpliedDerivedKeys(true);
} else if (policyElement.getFirstChildWithName(SP12Constants.REQUIRE_EXPLICIT_DERIVED_KEYS) != null) {
x509Token.setExplicitDerivedKeys(true);
}
Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
policy = (Policy) policy.normalize(false);
for (Iterator iterator = policy.getAlternatives(); iterator
.hasNext();) {
processAlternative((List) iterator.next(), x509Token);
/*
* since there should be only one alternative
*/
break;
}
}
if (x509Token != null && policyElement != null) {
OMElement ramp = null;
ramp = policyElement.getFirstChildWithName(RAMPART_CONFIG);
if (ramp != null) {
OMElement child = null;
if ((child = ramp.getFirstChildWithName(USER_CERT_ALIAS)) != null) {
x509Token.setUserCertAlias(child.getText());
}
if ((child = ramp.getFirstChildWithName(ENCRYPTION_USER)) != null) {
x509Token.setEncryptionUser(child.getText());
}
}
}
return x509Token;