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/attribute/AttributeDecoder.h
24 * Decodes SAML NameID/Attribute objects into resolved Attributes.
27 #ifndef __shibsp_attrdecoder_h__
28 #define __shibsp_attrdecoder_h__
30 #include <shibsp/base.h>
35 namespace xmltooling {
36 class XMLTOOL_API GenericRequest;
37 class XMLTOOL_API QName;
38 class XMLTOOL_API XMLObject;
43 class SHIBSP_API Attribute;
46 * Decodes XML objects into resolved Attributes.
48 class SHIBSP_API AttributeDecoder
50 MAKE_NONCOPYABLE(AttributeDecoder);
55 * @param e root of DOM to configure the decoder
57 AttributeDecoder(const xercesc::DOMElement* e);
59 /** Flag for case sensitivity of decoded attributes. */
62 /** Flag for hiding attributes from CGI export. */
65 /** Flag for language aware decoding. */
68 /** Hash algorithm to apply to decoded values. */
69 std::string m_hashAlg;
72 * Helper method to handle base class decoding housekeeping.
74 * @param attr the new Attribute object being created
75 * @return the attr parameter
77 virtual Attribute* _decode(Attribute* attr) const;
80 * Helper method that returns a range of objects the decoder should operate on,
81 * based on the language settings of the decoder and the client request.
83 * @param request the client request, if any
84 * @param objects the objects to examine
85 * @return a pair of iterators representing the range of objects to examine
87 virtual std::pair<std::vector<xmltooling::XMLObject*>::const_iterator,std::vector<xmltooling::XMLObject*>::const_iterator> valueRange(
88 const xmltooling::GenericRequest* request, const std::vector<xmltooling::XMLObject*>& objects
92 virtual ~AttributeDecoder();
95 * Decodes an XMLObject into a resolved Attribute.
97 * @param request request triggering the decode, if any
98 * @param ids array containing primary identifier in first position, followed by any aliases
99 * @param xmlObject XMLObject to decode
100 * @param assertingParty name of the party asserting the attribute
101 * @param relyingParty name of the party relying on the attribute
102 * @return a resolved Attribute, or nullptr
104 virtual Attribute* decode(
105 const xmltooling::GenericRequest* request,
106 const std::vector<std::string>& ids,
107 const xmltooling::XMLObject* xmlObject,
108 const char* assertingParty=nullptr,
109 const char* relyingParty=nullptr
114 * Decodes an XMLObject into a resolved Attribute.
116 * @param ids array containing primary identifier in first position, followed by any aliases
117 * @param xmlObject XMLObject to decode
118 * @param assertingParty name of the party asserting the attribute
119 * @param relyingParty name of the party relying on the attribute
120 * @return a resolved Attribute, or nullptr
122 virtual Attribute* decode(
123 const std::vector<std::string>& ids,
124 const xmltooling::XMLObject* xmlObject,
125 const char* assertingParty=nullptr,
126 const char* relyingParty=nullptr
131 /** Decodes into a SimpleAttribute. */
132 extern SHIBSP_API xmltooling::QName StringAttributeDecoderType;
134 /** Decodes scoped and NameID attributes into a ScopedAttribute. */
135 extern SHIBSP_API xmltooling::QName ScopedAttributeDecoderType;
137 /** Decodes NameID information into a NameIDAttribute. */
138 extern SHIBSP_API xmltooling::QName NameIDAttributeDecoderType;
140 /** Decodes scoped attributes into a NameIDAttribute. */
141 extern SHIBSP_API xmltooling::QName NameIDFromScopedAttributeDecoderType;
143 /** Decodes KeyInfo information into a SimpleAttribute. */
144 extern SHIBSP_API xmltooling::QName KeyInfoAttributeDecoderType;
146 /** Decodes arbitrary DOM information into an ExtensibleAttribute. */
147 extern SHIBSP_API xmltooling::QName DOMAttributeDecoderType;
149 /** Decodes arbitrary XML into an XMLAttribute. */
150 extern SHIBSP_API xmltooling::QName XMLAttributeDecoderType;
152 /** Decodes base64-encoded data into a SimpleAttribute. */
153 extern SHIBSP_API xmltooling::QName Base64AttributeDecoderType;
155 /** Registers built-in AttributeDecoders into the runtime. */
156 void registerAttributeDecoders();
159 #endif /* __shibsp_attrdecoder_h__ */