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 <boost/lexical_cast.hpp>
32 #include <xmltooling/AbstractComplexElement.h>
33 #include <xmltooling/AbstractSimpleElement.h>
34 #include <xmltooling/impl/AnyElement.h>
35 #include <xmltooling/io/AbstractXMLObjectMarshaller.h>
36 #include <xmltooling/io/AbstractXMLObjectUnmarshaller.h>
37 #include <xmltooling/signature/KeyInfo.h>
38 #include <xmltooling/util/XMLHelper.h>
40 using namespace shibsp;
41 using namespace xmlsignature;
42 using namespace xmltooling;
45 using xmlconstants::XMLSIG_NS;
46 using xmlconstants::XML_BOOL_NULL;
47 using shibspconstants::SHIBMD_NS;
49 #if defined (_MSC_VER)
50 #pragma warning( push )
51 #pragma warning( disable : 4250 4251 )
56 class SHIBSP_DLLLOCAL ScopeImpl : public virtual Scope,
57 public AbstractSimpleElement,
58 public AbstractDOMCachingXMLObject,
59 public AbstractXMLObjectMarshaller,
60 public AbstractXMLObjectUnmarshaller
63 m_Regexp=XML_BOOL_NULL;
68 ScopeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType)
69 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
73 ScopeImpl(const ScopeImpl& src)
74 : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) {
79 IMPL_XMLOBJECT_CLONE(Scope);
80 IMPL_BOOLEAN_ATTRIB(Regexp);
83 void marshallAttributes(DOMElement* domElement) const {
84 MARSHALL_BOOLEAN_ATTRIB(Regexp,REGEXP,nullptr);
87 void processAttribute(const DOMAttr* attribute) {
88 PROC_BOOLEAN_ATTRIB(Regexp,REGEXP,nullptr);
89 AbstractXMLObjectUnmarshaller::processAttribute(attribute);
93 class SHIBSP_DLLLOCAL KeyAuthorityImpl : public virtual KeyAuthority,
94 public AbstractComplexElement,
95 public AbstractAttributeExtensibleXMLObject,
96 public AbstractDOMCachingXMLObject,
97 public AbstractXMLObjectMarshaller,
98 public AbstractXMLObjectUnmarshaller
101 m_VerifyDepth=nullptr;
104 virtual ~KeyAuthorityImpl() {
105 XMLString::release(&m_VerifyDepth);
108 KeyAuthorityImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType)
109 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
113 KeyAuthorityImpl(const KeyAuthorityImpl& src)
114 : AbstractXMLObject(src), AbstractComplexElement(src),
115 AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
117 setVerifyDepth(src.m_VerifyDepth);
118 VectorOf(KeyInfo) v=getKeyInfos();
119 for (vector<KeyInfo*>::const_iterator i=src.m_KeyInfos.begin(); i!=src.m_KeyInfos.end(); ++i)
120 v.push_back((*i)->cloneKeyInfo());
123 IMPL_XMLOBJECT_CLONE(KeyAuthority);
124 IMPL_INTEGER_ATTRIB(VerifyDepth);
125 IMPL_TYPED_CHILDREN(KeyInfo,m_children.end());
128 void setAttribute(const xmltooling::QName& qualifiedName, const XMLCh* value, bool ID=false) {
129 if (!qualifiedName.hasNamespaceURI()) {
130 if (XMLString::equals(qualifiedName.getLocalPart(),VERIFYDEPTH_ATTRIB_NAME)) {
131 setVerifyDepth(value);
135 AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value, ID);
139 void marshallAttributes(DOMElement* domElement) const {
140 MARSHALL_INTEGER_ATTRIB(VerifyDepth,VERIFYDEPTH,nullptr);
141 marshallExtensionAttributes(domElement);
144 void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
145 PROC_TYPED_CHILDREN(KeyInfo,XMLSIG_NS,false);
146 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
149 void processAttribute(const DOMAttr* attribute) {
150 unmarshallExtensionAttribute(attribute);
156 #if defined (_MSC_VER)
157 #pragma warning( pop )
160 // Builder Implementations
162 IMPL_XMLOBJECTBUILDER(Scope);
163 IMPL_XMLOBJECTBUILDER(KeyAuthority);
165 const XMLCh Scope::LOCAL_NAME[] = UNICODE_LITERAL_5(S,c,o,p,e);
166 const XMLCh Scope::REGEXP_ATTRIB_NAME[] = UNICODE_LITERAL_6(r,e,g,e,x,p);
167 const XMLCh KeyAuthority::LOCAL_NAME[] = UNICODE_LITERAL_12(K,e,y,A,u,t,h,o,r,i,t,y);
168 const XMLCh KeyAuthority::VERIFYDEPTH_ATTRIB_NAME[] = UNICODE_LITERAL_11(V,e,r,i,f,y,D,e,p,t,h);