2 * Licensed to the University Corporation for Advanced Internet
3 * Development, Inc. (UCAID) under one or more contributor license
4 * agreements. See the NOTICE file distributed with this work for
5 * additional information regarding copyright ownership.
7 * UCAID licenses this file to you under the Apache License,
8 * Version 2.0 (the "License"); you may not use this file except
9 * in compliance with the License. You may obtain a copy of the
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17 * either express or implied. See the License for the specific
18 * language governing permissions and limitations under the License.
24 * Implementation classes for Shibboleth metadata extensions schema.
28 #include "exceptions.h"
29 #include "metadata/MetadataExt.h"
31 #include <xmltooling/AbstractComplexElement.h>
32 #include <xmltooling/AbstractSimpleElement.h>
33 #include <xmltooling/impl/AnyElement.h>
34 #include <xmltooling/io/AbstractXMLObjectMarshaller.h>
35 #include <xmltooling/io/AbstractXMLObjectUnmarshaller.h>
36 #include <xmltooling/signature/KeyInfo.h>
37 #include <xmltooling/util/XMLHelper.h>
39 using namespace shibsp;
40 using namespace xmlsignature;
41 using namespace xmltooling;
44 using xmlconstants::XMLSIG_NS;
45 using xmlconstants::XML_BOOL_NULL;
46 using shibspconstants::SHIBMD_NS;
48 #if defined (_MSC_VER)
49 #pragma warning( push )
50 #pragma warning( disable : 4250 4251 )
55 class SHIBSP_DLLLOCAL ScopeImpl : public virtual Scope,
56 public AbstractSimpleElement,
57 public AbstractDOMCachingXMLObject,
58 public AbstractXMLObjectMarshaller,
59 public AbstractXMLObjectUnmarshaller
62 m_Regexp=XML_BOOL_NULL;
67 ScopeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType)
68 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
72 ScopeImpl(const ScopeImpl& src)
73 : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) {
78 IMPL_XMLOBJECT_CLONE(Scope);
79 IMPL_BOOLEAN_ATTRIB(Regexp);
82 void marshallAttributes(DOMElement* domElement) const {
83 MARSHALL_BOOLEAN_ATTRIB(Regexp,REGEXP,nullptr);
86 void processAttribute(const DOMAttr* attribute) {
87 PROC_BOOLEAN_ATTRIB(Regexp,REGEXP,nullptr);
88 AbstractXMLObjectUnmarshaller::processAttribute(attribute);
92 class SHIBSP_DLLLOCAL KeyAuthorityImpl : public virtual KeyAuthority,
93 public AbstractComplexElement,
94 public AbstractAttributeExtensibleXMLObject,
95 public AbstractDOMCachingXMLObject,
96 public AbstractXMLObjectMarshaller,
97 public AbstractXMLObjectUnmarshaller
100 m_VerifyDepth=nullptr;
103 virtual ~KeyAuthorityImpl() {
104 XMLString::release(&m_VerifyDepth);
107 KeyAuthorityImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType)
108 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
112 KeyAuthorityImpl(const KeyAuthorityImpl& src)
113 : AbstractXMLObject(src), AbstractComplexElement(src),
114 AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
116 setVerifyDepth(src.m_VerifyDepth);
117 VectorOf(KeyInfo) v=getKeyInfos();
118 for (vector<KeyInfo*>::const_iterator i=src.m_KeyInfos.begin(); i!=src.m_KeyInfos.end(); ++i)
119 v.push_back((*i)->cloneKeyInfo());
122 IMPL_XMLOBJECT_CLONE(KeyAuthority);
123 IMPL_INTEGER_ATTRIB(VerifyDepth);
124 IMPL_TYPED_CHILDREN(KeyInfo,m_children.end());
127 void setAttribute(const xmltooling::QName& qualifiedName, const XMLCh* value, bool ID=false) {
128 if (!qualifiedName.hasNamespaceURI()) {
129 if (XMLString::equals(qualifiedName.getLocalPart(),VERIFYDEPTH_ATTRIB_NAME)) {
130 setVerifyDepth(value);
134 AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value, ID);
138 void marshallAttributes(DOMElement* domElement) const {
139 MARSHALL_INTEGER_ATTRIB(VerifyDepth,VERIFYDEPTH,nullptr);
140 marshallExtensionAttributes(domElement);
143 void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
144 PROC_TYPED_CHILDREN(KeyInfo,XMLSIG_NS,false);
145 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
148 void processAttribute(const DOMAttr* attribute) {
149 unmarshallExtensionAttribute(attribute);
155 #if defined (_MSC_VER)
156 #pragma warning( pop )
159 // Builder Implementations
161 IMPL_XMLOBJECTBUILDER(Scope);
162 IMPL_XMLOBJECTBUILDER(KeyAuthority);
164 const XMLCh Scope::LOCAL_NAME[] = UNICODE_LITERAL_5(S,c,o,p,e);
165 const XMLCh Scope::REGEXP_ATTRIB_NAME[] = UNICODE_LITERAL_6(r,e,g,e,x,p);
166 const XMLCh KeyAuthority::LOCAL_NAME[] = UNICODE_LITERAL_12(K,e,y,A,u,t,h,o,r,i,t,y);
167 const XMLCh KeyAuthority::VERIFYDEPTH_ATTRIB_NAME[] = UNICODE_LITERAL_11(V,e,r,i,f,y,D,e,p,t,h);