2 * Copyright 2001-2009 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/signature/KeyInfo.h>
33 #include <xmltooling/util/XMLHelper.h>
35 using namespace shibsp;
36 using namespace xmlsignature;
37 using namespace xmltooling;
40 using xmlconstants::XMLSIG_NS;
41 using xmlconstants::XML_BOOL_NULL;
42 using shibspconstants::SHIBMD_NS;
44 #if defined (_MSC_VER)
45 #pragma warning( push )
46 #pragma warning( disable : 4250 4251 )
51 class SHIBSP_DLLLOCAL ScopeImpl : public virtual Scope,
52 public AbstractSimpleElement,
53 public AbstractDOMCachingXMLObject,
54 public AbstractXMLObjectMarshaller,
55 public AbstractXMLObjectUnmarshaller
58 m_Regexp=XML_BOOL_NULL;
63 ScopeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType)
64 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
68 ScopeImpl(const ScopeImpl& src)
69 : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) {
74 IMPL_XMLOBJECT_CLONE(Scope);
75 IMPL_BOOLEAN_ATTRIB(Regexp);
78 void marshallAttributes(DOMElement* domElement) const {
79 MARSHALL_BOOLEAN_ATTRIB(Regexp,REGEXP,NULL);
82 void processAttribute(const DOMAttr* attribute) {
83 PROC_BOOLEAN_ATTRIB(Regexp,REGEXP,NULL);
84 AbstractXMLObjectUnmarshaller::processAttribute(attribute);
88 class SHIBSP_DLLLOCAL KeyAuthorityImpl : public virtual KeyAuthority,
89 public AbstractComplexElement,
90 public AbstractAttributeExtensibleXMLObject,
91 public AbstractDOMCachingXMLObject,
92 public AbstractXMLObjectMarshaller,
93 public AbstractXMLObjectUnmarshaller
99 virtual ~KeyAuthorityImpl() {
100 XMLString::release(&m_VerifyDepth);
103 KeyAuthorityImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType)
104 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
108 KeyAuthorityImpl(const KeyAuthorityImpl& src)
109 : AbstractXMLObject(src), AbstractComplexElement(src),
110 AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
112 setVerifyDepth(src.m_VerifyDepth);
113 VectorOf(KeyInfo) v=getKeyInfos();
114 for (vector<KeyInfo*>::const_iterator i=src.m_KeyInfos.begin(); i!=src.m_KeyInfos.end(); ++i)
115 v.push_back((*i)->cloneKeyInfo());
118 IMPL_XMLOBJECT_CLONE(KeyAuthority);
119 IMPL_INTEGER_ATTRIB(VerifyDepth);
120 IMPL_TYPED_CHILDREN(KeyInfo,m_children.end());
123 void setAttribute(const xmltooling::QName& qualifiedName, const XMLCh* value, bool ID=false) {
124 if (!qualifiedName.hasNamespaceURI()) {
125 if (XMLString::equals(qualifiedName.getLocalPart(),VERIFYDEPTH_ATTRIB_NAME)) {
126 setVerifyDepth(value);
130 AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value, ID);
134 void marshallAttributes(DOMElement* domElement) const {
135 MARSHALL_INTEGER_ATTRIB(VerifyDepth,VERIFYDEPTH,NULL);
136 marshallExtensionAttributes(domElement);
139 void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
140 PROC_TYPED_CHILDREN(KeyInfo,XMLSIG_NS,false);
141 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
144 void processAttribute(const DOMAttr* attribute) {
145 unmarshallExtensionAttribute(attribute);
151 #if defined (_MSC_VER)
152 #pragma warning( pop )
155 // Builder Implementations
157 IMPL_XMLOBJECTBUILDER(Scope);
158 IMPL_XMLOBJECTBUILDER(KeyAuthority);
160 const XMLCh Scope::LOCAL_NAME[] = UNICODE_LITERAL_5(S,c,o,p,e);
161 const XMLCh Scope::REGEXP_ATTRIB_NAME[] = UNICODE_LITERAL_6(r,e,g,e,x,p);
162 const XMLCh KeyAuthority::LOCAL_NAME[] = UNICODE_LITERAL_12(K,e,y,A,u,t,h,o,r,i,t,y);
163 const XMLCh KeyAuthority::VERIFYDEPTH_ATTRIB_NAME[] = UNICODE_LITERAL_11(V,e,r,i,f,y,D,e,p,t,h);