2 * Copyright 2001-2006 Internet2
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
18 * XMLSecSignatureImpl.cpp
\r
20 * Signature class for XMLSec-based signature-handling
\r
23 #include "internal.h"
\r
24 #include "AbstractElementProxy.h"
\r
25 #include "exceptions.h"
\r
26 #include "io/AbstractXMLObjectMarshaller.h"
\r
27 #include "io/AbstractXMLObjectUnmarshaller.h"
\r
28 #include "signature/impl/KeyInfoImpl.h"
\r
29 #include "util/NDC.h"
\r
30 #include "util/XMLHelper.h"
\r
31 #include "validation/AbstractValidatingXMLObject.h"
\r
33 #include <log4cpp/Category.hh>
\r
35 using namespace xmltooling;
\r
36 using namespace log4cpp;
\r
37 using namespace std;
\r
39 #if defined (_MSC_VER)
\r
40 #pragma warning( push )
\r
41 #pragma warning( disable : 4250 4251 )
\r
44 namespace xmltooling {
\r
46 class XMLTOOL_DLLLOCAL KeyInfoImpl : public KeyInfo, public AbstractDOMCachingXMLObject, public AbstractElementProxy,
\r
47 public AbstractValidatingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller
\r
50 virtual ~KeyInfoImpl() {}
\r
52 KeyInfoImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
\r
53 : AbstractXMLObject(nsURI, localName, prefix, schemaType), m_Id(NULL) {}
\r
55 KeyInfoImpl(const KeyInfoImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src),
\r
56 AbstractElementProxy(src), AbstractValidatingXMLObject(src), m_Id(XMLString::replicate(src.m_Id)) {
\r
57 for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
\r
58 getXMLObjects().push_back((*i) ? (*i)->clone() : NULL);
\r
62 IMPL_XMLOBJECT_ATTRIB(Id);
\r
63 IMPL_XMLOBJECT_CLONE(KeyInfo);
\r
66 void marshallAttributes(DOMElement* domElement) const {
\r
68 domElement->setAttributeNS(NULL, ID_ATTRIB_NAME, getId());
\r
69 domElement->setIdAttributeNS(NULL, ID_ATTRIB_NAME);
\r
73 void marshallElementContent(DOMElement* domElement) const {
\r
74 if(getTextContent()) {
\r
75 domElement->appendChild(domElement->getOwnerDocument()->createTextNode(getTextContent()));
\r
79 void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
\r
80 getXMLObjects().push_back(childXMLObject);
\r
83 void processAttribute(const DOMAttr* attribute) {
\r
84 if (XMLHelper::isNodeNamed(attribute, NULL, ID_ATTRIB_NAME))
\r
85 setId(attribute->getValue());
\r
88 void processElementContent(const XMLCh* elementContent) {
\r
89 setTextContent(elementContent);
\r
95 #if defined (_MSC_VER)
\r
96 #pragma warning( pop )
\r
99 KeyInfo* KeyInfoBuilderImpl::buildObject(
\r
100 const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType
\r
103 return new KeyInfoImpl(nsURI,localName,prefix,schemaType);
\r