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 <boost/lambda/bind.hpp>
33 #include <boost/lambda/if.hpp>
34 #include <boost/lambda/lambda.hpp>
35 #include <xmltooling/AbstractComplexElement.h>
36 #include <xmltooling/AbstractSimpleElement.h>
37 #include <xmltooling/impl/AnyElement.h>
38 #include <xmltooling/io/AbstractXMLObjectMarshaller.h>
39 #include <xmltooling/io/AbstractXMLObjectUnmarshaller.h>
40 #include <xmltooling/signature/KeyInfo.h>
41 #include <xmltooling/util/XMLHelper.h>
43 using namespace shibsp;
44 using namespace xmlsignature;
45 using namespace xmltooling;
48 using xmlconstants::XMLSIG_NS;
49 using xmlconstants::XML_BOOL_NULL;
50 using shibspconstants::SHIBMD_NS;
52 #if defined (_MSC_VER)
53 #pragma warning( push )
54 #pragma warning( disable : 4250 4251 )
59 class SHIBSP_DLLLOCAL ScopeImpl : public virtual Scope,
60 public AbstractSimpleElement,
61 public AbstractDOMCachingXMLObject,
62 public AbstractXMLObjectMarshaller,
63 public AbstractXMLObjectUnmarshaller
66 m_Regexp=XML_BOOL_NULL;
71 ScopeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType)
72 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
76 ScopeImpl(const ScopeImpl& src)
77 : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src) {
79 IMPL_CLONE_BOOLEAN_ATTRIB(Regexp);
82 IMPL_XMLOBJECT_CLONE(Scope);
83 IMPL_BOOLEAN_ATTRIB(Regexp);
86 void marshallAttributes(DOMElement* domElement) const {
87 MARSHALL_BOOLEAN_ATTRIB(Regexp,REGEXP,nullptr);
90 void processAttribute(const DOMAttr* attribute) {
91 PROC_BOOLEAN_ATTRIB(Regexp,REGEXP,nullptr);
92 AbstractXMLObjectUnmarshaller::processAttribute(attribute);
96 class SHIBSP_DLLLOCAL KeyAuthorityImpl : public virtual KeyAuthority,
97 public AbstractComplexElement,
98 public AbstractAttributeExtensibleXMLObject,
99 public AbstractDOMCachingXMLObject,
100 public AbstractXMLObjectMarshaller,
101 public AbstractXMLObjectUnmarshaller
104 m_VerifyDepth=nullptr;
107 virtual ~KeyAuthorityImpl() {
108 XMLString::release(&m_VerifyDepth);
111 KeyAuthorityImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const xmltooling::QName* schemaType)
112 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
116 KeyAuthorityImpl(const KeyAuthorityImpl& src)
117 : AbstractXMLObject(src), AbstractComplexElement(src),
118 AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
120 IMPL_CLONE_INTEGER_ATTRIB(VerifyDepth);
121 IMPL_CLONE_TYPED_CHILDREN(KeyInfo);
124 IMPL_XMLOBJECT_CLONE(KeyAuthority);
125 IMPL_INTEGER_ATTRIB(VerifyDepth);
126 IMPL_TYPED_CHILDREN(KeyInfo,m_children.end());
129 void setAttribute(const xmltooling::QName& qualifiedName, const XMLCh* value, bool ID=false) {
130 if (!qualifiedName.hasNamespaceURI()) {
131 if (XMLString::equals(qualifiedName.getLocalPart(),VERIFYDEPTH_ATTRIB_NAME)) {
132 setVerifyDepth(value);
136 AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value, ID);
140 void marshallAttributes(DOMElement* domElement) const {
141 MARSHALL_INTEGER_ATTRIB(VerifyDepth,VERIFYDEPTH,nullptr);
142 marshallExtensionAttributes(domElement);
145 void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
146 PROC_TYPED_CHILDREN(KeyInfo,XMLSIG_NS,false);
147 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
150 void processAttribute(const DOMAttr* attribute) {
151 unmarshallExtensionAttribute(attribute);
157 #if defined (_MSC_VER)
158 #pragma warning( pop )
161 // Builder Implementations
163 IMPL_XMLOBJECTBUILDER(Scope);
164 IMPL_XMLOBJECTBUILDER(KeyAuthority);
166 const XMLCh Scope::LOCAL_NAME[] = UNICODE_LITERAL_5(S,c,o,p,e);
167 const XMLCh Scope::REGEXP_ATTRIB_NAME[] = UNICODE_LITERAL_6(r,e,g,e,x,p);
168 const XMLCh KeyAuthority::LOCAL_NAME[] = UNICODE_LITERAL_12(K,e,y,A,u,t,h,o,r,i,t,y);
169 const XMLCh KeyAuthority::VERIFYDEPTH_ATTRIB_NAME[] = UNICODE_LITERAL_11(V,e,r,i,f,y,D,e,p,t,h);