Get default AuthType added when custom types are used.
[shibboleth/cpp-sp.git] / shibsp / attribute / NameIDAttribute.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/NameIDAttribute.h
23  * 
24  * An Attribute whose values are derived from or mappable to a SAML NameID.
25  */
26
27 #ifndef __shibsp_nameidattr_h__
28 #define __shibsp_nameidattr_h__
29
30 #include <shibsp/attribute/Attribute.h>
31
32 namespace shibsp {
33
34 #if defined (_MSC_VER)
35     #pragma warning( push )
36     #pragma warning( disable : 4251 )
37 #endif
38
39     /** Default serialization format for NameIDs */
40     #define DEFAULT_NAMEID_FORMATTER    "$Name!!$NameQualifier!!$SPNameQualifier"
41
42     /**
43      * An Attribute whose values are derived from or mappable to a SAML NameID.
44      */
45     class SHIBSP_API NameIDAttribute : public Attribute
46     {
47     public:
48         /**
49          * Constructor.
50          * 
51          * @param ids       array with primary identifier in first position, followed by any aliases
52          * @param formatter template for serialization of tuple
53          */
54         NameIDAttribute(const std::vector<std::string>& ids, const char* formatter=DEFAULT_NAMEID_FORMATTER);
55
56         /**
57          * Constructs based on a remoted NameIDAttribute.
58          * 
59          * @param in    input object containing marshalled NameIDAttribute
60          */
61         NameIDAttribute(DDF& in);
62         
63         virtual ~NameIDAttribute();
64         
65         /**
66          * Holds all the fields associated with a NameID.
67          */
68         struct SHIBSP_API Value
69         {
70             std::string m_Name;
71             std::string m_Format;
72             std::string m_NameQualifier;
73             std::string m_SPNameQualifier;
74             std::string m_SPProvidedID;
75         };
76         
77         /**
78          * Returns the set of values encoded as UTF-8 strings.
79          * 
80          * @return  a mutable vector of the values
81          */
82         std::vector<Value>& getValues();
83
84         /**
85          * Returns the set of values encoded as UTF-8 strings.
86          * 
87          * @return  an immutable vector of the values
88          */
89         const std::vector<Value>& getValues() const;
90
91         // Virtual function overrides.
92         size_t valueCount() const;
93         void clearSerializedValues();
94         const char* getString(size_t index) const;
95         const char* getScope(size_t index) const;
96         void removeValue(size_t index);
97         const std::vector<std::string>& getSerializedValues() const;
98         DDF marshall() const;
99     
100     private:
101         std::vector<Value> m_values;
102         std::string m_formatter;
103     };
104
105 #if defined (_MSC_VER)
106     #pragma warning( pop )
107 #endif
108
109 };
110
111 #endif /* __shibsp_nameidattr_h__ */