SPConstants consts = SP11Constants.SP_NS.equals(element.getNamespaceURI())
? SP11Constants.INSTANCE : SP12Constants.INSTANCE;
IssuedToken issuedToken = new IssuedToken(consts);
String includeAttr = DOMUtils.getAttribute(element, consts.getIncludeToken());
if (includeAttr != null) {
issuedToken.setInclusion(consts.getInclusionFromAttributeValue(includeAttr));
}
// Extract Issuer
Element issuerElem = DOMUtils.getFirstChildWithName(element, SP11Constants.ISSUER);
if (issuerElem != null) {
Element issuerEpr = DOMUtils
.getFirstChildWithName(issuerElem,
new QName(WSA_NAMESPACE, "Address"));
// try the other addressing namespace
if (issuerEpr == null) {
issuerEpr = DOMUtils
.getFirstChildWithName(issuerElem,
new QName(WSA_NAMESPACE_SUB,
"Address"));
}
issuedToken.setIssuerEpr(issuerEpr);
}
// TODO check why this returns an Address element
// iter = issuerElem.getChildrenWithLocalName("Metadata");
if (issuerElem != null) {
Element issuerMex = DOMUtils
.getFirstChildWithName(issuerElem,
new QName(WSA_NAMESPACE, "Metadata"));
// try the other addressing namespace
if (issuerMex == null) {
issuerMex = DOMUtils
.getFirstChildWithName(issuerElem,
new QName(WSA_NAMESPACE_SUB,
"Metadata"));
}
issuedToken.setIssuerMex(issuerMex);
}
// Extract RSTTemplate
Element rstTmplElem = DOMUtils.getFirstChildWithName(element,
SP11Constants.REQUEST_SECURITY_TOKEN_TEMPLATE);
if (rstTmplElem != null) {
issuedToken.setRstTemplate(rstTmplElem);
}
Element policyElement = DOMUtils.getFirstChildWithName(element,
org.apache.neethi.Constants.Q_ELEM_POLICY);