2 * Copyright 2001-2007 Internet2
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 * Implementation classes for Shibboleth metadata extensions schema
24 #include "exceptions.h"
25 #include "metadata/MetadataExt.h"
27 #include <xmltooling/AbstractComplexElement.h>
28 #include <xmltooling/AbstractSimpleElement.h>
29 #include <xmltooling/impl/AnyElement.h>
30 #include <xmltooling/io/AbstractXMLObjectMarshaller.h>
31 #include <xmltooling/io/AbstractXMLObjectUnmarshaller.h>
32 #include <xmltooling/util/XMLHelper.h>
34 using namespace shibsp;
35 using namespace xmlsignature;
36 using namespace xmltooling;
39 using xmlconstants::XMLSIG_NS;
40 using xmlconstants::XML_BOOL_NULL;
41 using shibspconstants::SHIBMD_NS;
43 #if defined (_MSC_VER)
44 #pragma warning( push )
45 #pragma warning( disable : 4250 4251 )
50 class SHIBSP_DLLLOCAL ScopeImpl : public virtual Scope,
51 public AbstractSimpleElement,
52 public AbstractDOMCachingXMLObject,
53 public AbstractXMLObjectMarshaller,
54 public AbstractXMLObjectUnmarshaller
57 m_Regexp=XML_BOOL_NULL;
62 ScopeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType)
63 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
67 ScopeImpl(const ScopeImpl& src)
68 : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) {
73 IMPL_XMLOBJECT_CLONE(Scope);
74 IMPL_BOOLEAN_ATTRIB(Regexp);
77 void marshallAttributes(DOMElement* domElement) const {
78 MARSHALL_BOOLEAN_ATTRIB(Regexp,REGEXP,NULL);
81 void processAttribute(const DOMAttr* attribute) {
82 PROC_BOOLEAN_ATTRIB(Regexp,REGEXP,NULL);
83 AbstractXMLObjectUnmarshaller::processAttribute(attribute);
87 class SHIBSP_DLLLOCAL KeyAuthorityImpl : public virtual KeyAuthority,
88 public AbstractComplexElement,
89 public AbstractAttributeExtensibleXMLObject,
90 public AbstractDOMCachingXMLObject,
91 public AbstractXMLObjectMarshaller,
92 public AbstractXMLObjectUnmarshaller
98 virtual ~KeyAuthorityImpl() {
99 XMLString::release(&m_VerifyDepth);
102 KeyAuthorityImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType)
103 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
107 KeyAuthorityImpl(const KeyAuthorityImpl& src)
108 : AbstractXMLObject(src), AbstractComplexElement(src),
109 AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
111 setVerifyDepth(src.m_VerifyDepth);
112 VectorOf(KeyInfo) v=getKeyInfos();
113 for (vector<KeyInfo*>::const_iterator i=src.m_KeyInfos.begin(); i!=src.m_KeyInfos.end(); ++i)
114 v.push_back((*i)->cloneKeyInfo());
117 IMPL_XMLOBJECT_CLONE(KeyAuthority);
118 IMPL_INTEGER_ATTRIB(VerifyDepth);
119 IMPL_TYPED_CHILDREN(KeyInfo,m_children.end());
122 void setAttribute(const xmltooling::QName& qualifiedName, const XMLCh* value, bool ID=false) {
123 if (!qualifiedName.hasNamespaceURI()) {
124 if (XMLString::equals(qualifiedName.getLocalPart(),VERIFYDEPTH_ATTRIB_NAME)) {
125 setVerifyDepth(value);
129 AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value, ID);
133 void marshallAttributes(DOMElement* domElement) const {
134 MARSHALL_INTEGER_ATTRIB(VerifyDepth,VERIFYDEPTH,NULL);
135 marshallExtensionAttributes(domElement);
138 void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
139 PROC_TYPED_CHILDREN(KeyInfo,XMLSIG_NS,false);
140 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
143 void processAttribute(const DOMAttr* attribute) {
144 unmarshallExtensionAttribute(attribute);
150 #if defined (_MSC_VER)
151 #pragma warning( pop )
154 // Builder Implementations
156 IMPL_XMLOBJECTBUILDER(Scope);
157 IMPL_XMLOBJECTBUILDER(KeyAuthority);
159 const XMLCh Scope::LOCAL_NAME[] = UNICODE_LITERAL_5(S,c,o,p,e);
160 const XMLCh Scope::REGEXP_ATTRIB_NAME[] = UNICODE_LITERAL_6(r,e,g,e,x,p);
161 const XMLCh KeyAuthority::LOCAL_NAME[] = UNICODE_LITERAL_12(K,e,y,A,u,t,h,o,r,i,t,y);
162 const XMLCh KeyAuthority::VERIFYDEPTH_ATTRIB_NAME[] = UNICODE_LITERAL_11(V,e,r,i,f,y,D,e,p,t,h);