Clean up file locations, and remove unneeded headers.
[shibboleth/cpp-sp.git] / shibsp / attribute / AttributeDecoder.h
1 /**
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.
6  *
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
10  * License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  */
20
21 /**
22  * @file shibsp/attribute/AttributeDecoder.h
23  *
24  * Decodes SAML NameID/Attribute objects into resolved Attributes.
25  */
26
27 #ifndef __shibsp_attrdecoder_h__
28 #define __shibsp_attrdecoder_h__
29
30 #include <shibsp/base.h>
31
32 #include <string>
33 #include <vector>
34
35 namespace xmltooling {
36     class XMLTOOL_API QName;
37     class XMLTOOL_API XMLObject;
38 };
39
40 namespace shibsp {
41
42     class SHIBSP_API Attribute;
43
44     /**
45      * Decodes XML objects into resolved Attributes.
46      */
47     class SHIBSP_API AttributeDecoder
48     {
49         MAKE_NONCOPYABLE(AttributeDecoder);
50     protected:
51         /**
52          * Constructor.
53          *
54          * @param e root of DOM to configure the decoder
55          */
56         AttributeDecoder(const xercesc::DOMElement* e);
57
58         /** Flag for case sensitivity of decoded attributes. */
59         bool m_caseSensitive;
60
61         /** Flag for hiding attributes from CGI export. */
62         bool m_internal;
63
64         /** Hash algorithm to apply to decoded values. */
65         std::string m_hashAlg;
66
67         /**
68          * Helper method to handle base class decoding housekeeping.
69          *
70          * @param attr  the new Attribute object being created
71          * @return  the attr parameter
72          */
73         virtual Attribute* _decode(Attribute* attr) const;
74
75     public:
76         virtual ~AttributeDecoder();
77
78         /**
79          * Decodes an XMLObject into a resolved Attribute.
80          *
81          * @param ids               array containing primary identifier in first position, followed by any aliases
82          * @param xmlObject         XMLObject to decode
83          * @param assertingParty    name of the party asserting the attribute
84          * @param relyingParty      name of the party relying on the attribute
85          * @return a resolved Attribute, or nullptr
86          */
87         virtual Attribute* decode(
88             const std::vector<std::string>& ids,
89             const xmltooling::XMLObject* xmlObject,
90             const char* assertingParty=nullptr,
91             const char* relyingParty=nullptr
92             ) const=0;
93     };
94
95
96     /** Decodes into a SimpleAttribute. */
97     extern SHIBSP_API xmltooling::QName StringAttributeDecoderType;
98
99     /** Decodes scoped and NameID attributes into a ScopedAttribute. */
100     extern SHIBSP_API xmltooling::QName ScopedAttributeDecoderType;
101
102     /** Decodes NameID information into a NameIDAttribute. */
103     extern SHIBSP_API xmltooling::QName NameIDAttributeDecoderType;
104
105     /** Decodes scoped attributes into a NameIDAttribute. */
106     extern SHIBSP_API xmltooling::QName NameIDFromScopedAttributeDecoderType;
107
108     /** Decodes KeyInfo information into a SimpleAttribute. */
109     extern SHIBSP_API xmltooling::QName KeyInfoAttributeDecoderType;
110
111     /** Decodes arbitrary DOM information into an ExtensibleAttribute. */
112     extern SHIBSP_API xmltooling::QName DOMAttributeDecoderType;
113
114     /** Decodes arbitrary XML into an XMLAttribute. */
115     extern SHIBSP_API xmltooling::QName XMLAttributeDecoderType;
116
117     /** Decodes base64-encoded data into a SimpleAttribute. */
118     extern SHIBSP_API xmltooling::QName Base64AttributeDecoderType;
119
120     /** Registers built-in AttributeDecoders into the runtime. */
121     void registerAttributeDecoders();
122 };
123
124 #endif /* __shibsp_attrdecoder_h__ */