Tagging 2.4RC1 release.
[shibboleth/sp.git] / shibsp / attribute / AttributeDecoder.h
1 /*
2  *  Copyright 2001-2010 Internet2
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 /**
18  * @file shibsp/attribute/AttributeDecoder.h
19  *
20  * Decodes SAML NameID/Attribute objects into resolved Attributes.
21  */
22
23 #ifndef __shibsp_attrdecoder_h__
24 #define __shibsp_attrdecoder_h__
25
26 #include <shibsp/base.h>
27
28 #include <string>
29 #include <vector>
30
31 namespace xmltooling {
32     class XMLTOOL_API QName;
33     class XMLTOOL_API XMLObject;
34 };
35
36 namespace shibsp {
37
38     class SHIBSP_API Attribute;
39
40     /**
41      * Decodes XML objects into resolved Attributes.
42      */
43     class SHIBSP_API AttributeDecoder
44     {
45         MAKE_NONCOPYABLE(AttributeDecoder);
46     protected:
47         /**
48          * Constructor.
49          *
50          * @param e root of DOM to configure the decoder
51          */
52         AttributeDecoder(const xercesc::DOMElement* e);
53
54         /** Flag for case sensitivity of decoded attributes. */
55         bool m_caseSensitive;
56
57         /** Flag for hiding attributes from CGI export. */
58         bool m_internal;
59
60         /** Hash algorithm to apply to decoded values. */
61         std::string m_hashAlg;
62
63         /**
64          * Helper method to handle base class decoding housekeeping.
65          *
66          * @param attr  the new Attribute object being created
67          * @return  the attr parameter
68          */
69         virtual Attribute* _decode(Attribute* attr) const;
70
71     public:
72         virtual ~AttributeDecoder();
73
74         /**
75          * Decodes an XMLObject into a resolved Attribute.
76          *
77          * @param ids               array containing primary identifier in first position, followed by any aliases
78          * @param xmlObject         XMLObject to decode
79          * @param assertingParty    name of the party asserting the attribute
80          * @param relyingParty      name of the party relying on the attribute
81          * @return a resolved Attribute, or nullptr
82          */
83         virtual Attribute* decode(
84             const std::vector<std::string>& ids,
85             const xmltooling::XMLObject* xmlObject,
86             const char* assertingParty=nullptr,
87             const char* relyingParty=nullptr
88             ) const=0;
89     };
90
91
92     /** Decodes into a SimpleAttribute. */
93     extern SHIBSP_API xmltooling::QName StringAttributeDecoderType;
94
95     /** Decodes scoped and NameID attributes into a ScopedAttribute. */
96     extern SHIBSP_API xmltooling::QName ScopedAttributeDecoderType;
97
98     /** Decodes NameID information into a NameIDAttribute. */
99     extern SHIBSP_API xmltooling::QName NameIDAttributeDecoderType;
100
101     /** Decodes scoped attributes into a NameIDAttribute. */
102     extern SHIBSP_API xmltooling::QName NameIDFromScopedAttributeDecoderType;
103
104     /** Decodes KeyInfo information into a SimpleAttribute. */
105     extern SHIBSP_API xmltooling::QName KeyInfoAttributeDecoderType;
106
107     /** Decodes arbitrary DOM information into an ExtensibleAttribute. */
108     extern SHIBSP_API xmltooling::QName DOMAttributeDecoderType;
109
110     /** Decodes arbitrary XML into an XMLAttribute. */
111     extern SHIBSP_API xmltooling::QName XMLAttributeDecoderType;
112
113     /** Decodes base64-encoded data into a SimpleAttribute. */
114     extern SHIBSP_API xmltooling::QName Base64AttributeDecoderType;
115
116     /** Registers built-in AttributeDecoders into the runtime. */
117     void registerAttributeDecoders();
118 };
119
120 #endif /* __shibsp_attrdecoder_h__ */