in xsec/dsig/DSIGSignedInfo.cpp [200:329]
void DSIGSignedInfo::load() {
if (mp_signedInfoNode == 0) {
// Attempt to load an empty signature element
throw XSECException(XSECException::LoadEmptySignedInfo);
}
if (!strEquals(getDSIGLocalName(mp_signedInfoNode), "SignedInfo")) {
throw XSECException(XSECException::LoadNonSignedInfo);
}
DOMNode* tmpSI = mp_signedInfoNode->getFirstChild();
// Check for CanonicalizationMethod
while (tmpSI != 0 && (tmpSI->getNodeType() != DOMNode::ELEMENT_NODE)) {
if (tmpSI->getNodeType() == DOMNode::ENTITY_REFERENCE_NODE) {
throw XSECException(XSECException::ExpectedDSIGChildNotFound,
"EntityReference nodes in <SignedInfo> are unsupported.");
}
// Skip text and comments
tmpSI = tmpSI->getNextSibling();
}
if (tmpSI == 0 || !strEquals(getDSIGLocalName(tmpSI), "CanonicalizationMethod")) {
throw XSECException(XSECException::ExpectedDSIGChildNotFound,
"Expected <CanonicalizationMethod> as first child of <SignedInfo>");
}
// Determine what the canonicalization method is
DOMNamedNodeMap* tmpAtts = tmpSI->getAttributes();
DOMNode* algorithm = tmpAtts->getNamedItem(DSIGConstants::s_unicodeStrAlgorithm);
if (algorithm == 0) {
throw XSECException(XSECException::ExpectedDSIGChildNotFound,
"Expected Algorithm attribute in <CanonicalizationMethod>");
}
mp_canonicalizationMethod = algorithm->getNodeValue();
// Now load the SignatureMethod
tmpSI = tmpSI->getNextSibling();
while (tmpSI != 0 && (tmpSI->getNodeType() != DOMNode::ELEMENT_NODE)) {
if (tmpSI->getNodeType() == DOMNode::ENTITY_REFERENCE_NODE) {
throw XSECException(XSECException::ExpectedDSIGChildNotFound,
"EntityReference nodes in <SignedInfo> are unsupported.");
}
// Skip text and comments
tmpSI = tmpSI->getNextSibling();
}
if (tmpSI == 0 || !strEquals(getDSIGLocalName(tmpSI), "SignatureMethod")) {
throw XSECException(XSECException::ExpectedDSIGChildNotFound,
"Expected <SignatureMethod> as child of <SignedInfo>");
}
// Determine the algorithms used to sign this document
tmpAtts = tmpSI->getAttributes();
algorithm = tmpAtts->getNamedItem(DSIGConstants::s_unicodeStrAlgorithm);
if (algorithm == 0) {
throw XSECException(XSECException::ExpectedDSIGChildNotFound,
"Expected Algorithm attribute in <SignatureMethod>");
}
mp_algorithmURI = algorithm->getNodeValue();
/* NOTE - as of version 1.3.1 all code relating to parsing the algorithm
* has been removed. This should all be handled inside the algorithm mappers.
* Having code here restricts available algorithms, as this code is not extended for
* new algorithms.
*/
/* Look for maximum output value. Really only applies to HMACs, but as we no
* longer know at this point if this is an HMAC, we need to check. */
DOMNode *tmpSOV = tmpSI->getFirstChild();
while (tmpSOV != NULL &&
(tmpSOV->getNodeType() != DOMNode::ELEMENT_NODE || !strEquals(getDSIGLocalName(tmpSOV), "HMACOutputLength"))) {
if (tmpSOV->getNodeType() == DOMNode::ENTITY_REFERENCE_NODE) {
throw XSECException(XSECException::ExpectedDSIGChildNotFound,
"EntityReference nodes in <SignedInfo> are unsupported.");
}
tmpSOV = tmpSOV->getNextSibling();
}
if (tmpSOV != NULL) {
// Have a max output value!
tmpSOV = tmpSOV->getFirstChild();
while (tmpSOV != NULL && tmpSOV->getNodeType() != DOMNode::TEXT_NODE)
tmpSOV = tmpSOV->getNextSibling();
if (tmpSOV != NULL) {
safeBuffer val;
val << (*mp_formatter << tmpSOV->getNodeValue());
m_HMACOutputLength = atoi((char *) val.rawBuffer());
}
}
// Now look at references....
tmpSI = tmpSI->getNextSibling();
// Run through the rest of the elements until done
while (tmpSI != 0 && (tmpSI->getNodeType() != DOMNode::ELEMENT_NODE)) {
if (tmpSI->getNodeType() == DOMNode::ENTITY_REFERENCE_NODE) {
throw XSECException(XSECException::ExpectedDSIGChildNotFound,
"EntityReference nodes in <SignedInfo> are unsupported.");
}
// Skip text and comments
tmpSI = tmpSI->getNextSibling();
}
if (tmpSI != NULL) {
// Have an element node - should be a reference, so let's load the list
mp_referenceList = DSIGReference::loadReferenceListFromXML(mp_env, tmpSI);
}
}