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.
22 * @file shibsp/util/DOMPropertySet.h
24 * DOM-based property set implementation.
27 #ifndef __shibsp_dompropset_h__
28 #define __shibsp_dompropset_h__
30 #include <shibsp/util/PropertySet.h>
32 #include <boost/shared_ptr.hpp>
33 #include <xmltooling/logging.h>
38 * DOM-based property set implementation.
40 class SHIBSP_API DOMPropertySet : public virtual PropertySet
45 virtual ~DOMPropertySet();
47 const PropertySet* getParent() const;
48 void setParent(const PropertySet* parent);
49 std::pair<bool,bool> getBool(const char* name, const char* ns=nullptr) const;
50 std::pair<bool,const char*> getString(const char* name, const char* ns=nullptr) const;
51 std::pair<bool,const XMLCh*> getXMLString(const char* name, const char* ns=nullptr) const;
52 std::pair<bool,unsigned int> getUnsignedInt(const char* name, const char* ns=nullptr) const;
53 std::pair<bool,int> getInt(const char* name, const char* ns=nullptr) const;
54 void getAll(std::map<std::string,const char*>& properties) const;
55 const PropertySet* getPropertySet(const char* name, const char* ns=shibspconstants::ASCII_SHIB2SPCONFIG_NS) const;
56 const xercesc::DOMElement* getElement() const;
59 * Loads the property set from a DOM element.
61 * @param e root element of property set
62 * @param log optional log object for tracing
63 * @param filter optional filter controls what child elements to include as nested PropertySets
64 * @param remapper optional map of property rename rules for legacy property support
67 const xercesc::DOMElement* e,
68 xmltooling::logging::Category* log=nullptr,
69 xercesc::DOMNodeFilter* filter=nullptr,
70 const std::map<std::string,std::string>* remapper=nullptr
75 * Post-load injection of a property, for use by subclasses.
77 * @param name property name
78 * @param val property value
79 * @param ns property namespace
80 * @return true iff the property was successfully set
82 bool setProperty(const char* name, const char* val, const char* ns=nullptr);
85 const PropertySet* m_parent;
86 const xercesc::DOMElement* m_root;
87 std::map<std::string,std::pair<char*,const XMLCh*> > m_map;
88 std::map< std::string,boost::shared_ptr<DOMPropertySet> > m_nested;
89 std::vector<xmltooling::xstring> m_injected;
94 #endif /* __shibsp_dompropset_h__ */