in xsec/dsig/DSIGSignature.cpp [573:674]
void DSIGSignature::load() {
// Load all the information from the source document into local variables for easier
// manipulation by the other functions in the class
if (mp_sigNode == NULL) {
// Attempt to load an empty signature element
throw XSECException(XSECException::LoadEmptySignature);
}
if (!strEquals(getDSIGLocalName(mp_sigNode), "Signature")) {
throw XSECException(XSECException::LoadNonSignature);
}
m_loaded = true;
// Find the prefix being used so that we can later use it to manipulate the signature
mp_env->setDSIGNSPrefix(mp_sigNode->getPrefix());
// Now check for SignedInfo
DOMNode*tmpElt = mp_sigNode->getFirstChild();
while (tmpElt != 0 && (tmpElt->getNodeType() != DOMNode::ELEMENT_NODE))
// Skip text and comments
tmpElt = tmpElt->getNextSibling();
if (tmpElt == 0 || !strEquals(getDSIGLocalName(tmpElt), "SignedInfo")) {
throw XSECException(XSECException::ExpectedDSIGChildNotFound,
"Expected <SignedInfo> as first child of <Signature>");
}
// Have a signed info
XSECnew(mp_signedInfo, DSIGSignedInfo(mp_doc, mp_formatter, tmpElt, mp_env));
mp_signedInfo->load();
// Look at Signature Value
tmpElt = findNextElementChild(tmpElt);
if (tmpElt == 0 || !strEquals(getDSIGLocalName(tmpElt), "SignatureValue")) {
throw XSECException(XSECException::ExpectedDSIGChildNotFound,
"Expected <SignatureValue> node");
}
DOMNode*tmpSV = tmpElt->getFirstChild();
while (tmpSV != 0 && tmpSV->getNodeType() != DOMNode::TEXT_NODE)
tmpSV = tmpSV->getNextSibling();
if (tmpSV == 0)
throw XSECException(XSECException::ExpectedDSIGChildNotFound,
"Expected TEXT child of <SignatureValue>");
mp_signatureValueNode = tmpElt;
// The signature value is transcoded to local code page, as it is easier
// to work with, and should be low ASCII in any case (Base64)
m_signatureValueSB.sbTranscodeIn(tmpSV->getNodeValue());
// Now look at KeyInfo
tmpElt = findNextElementChild(tmpElt);
if (tmpElt != 0 && strEquals(getDSIGLocalName(tmpElt), "KeyInfo")) {
// Have a keyInfo
mp_KeyInfoNode = tmpElt; // In case we later want to manipulate it
m_keyInfoList.loadListFromXML(tmpElt);
tmpElt = findNextElementChild(tmpElt);
}
while (tmpElt != 0 && strEquals(getDSIGLocalName(tmpElt), "Object")) {
DSIGObject* obj;
XSECnew(obj, DSIGObject(mp_env, tmpElt));
obj->load();
m_objects.push_back(obj);
tmpElt = findNextElementChild(tmpElt);
}
/*
* Strictly speaking, this should remain, but it causes too many problems with non
* conforming signatures
if (tmpElt != 0) {
throw XSECException(XSECException::ExpectedDSIGChildNotFound,
"DSIGSignature::load - Unexpected (non Object) Element found at end of signature");
}
*/
}