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/NameIDAttribute.h
24 * An Attribute whose values are derived from or mappable to a SAML NameID.
27 #ifndef __shibsp_nameidattr_h__
28 #define __shibsp_nameidattr_h__
30 #include <shibsp/attribute/Attribute.h>
34 #if defined (_MSC_VER)
35 #pragma warning( push )
36 #pragma warning( disable : 4251 )
39 /** Default serialization format for NameIDs */
40 #define DEFAULT_NAMEID_FORMATTER "$Name!!$NameQualifier!!$SPNameQualifier"
43 * An Attribute whose values are derived from or mappable to a SAML NameID.
45 class SHIBSP_API NameIDAttribute : public Attribute
51 * @param ids array with primary identifier in first position, followed by any aliases
52 * @param formatter template for serialization of tuple
53 * @param hashAlg hash algorithm to apply in producing serialized values
55 NameIDAttribute(const std::vector<std::string>& ids, const char* formatter=DEFAULT_NAMEID_FORMATTER, const char* hashAlg=nullptr);
58 * Constructs based on a remoted NameIDAttribute.
60 * @param in input object containing marshalled NameIDAttribute
62 NameIDAttribute(DDF& in);
64 virtual ~NameIDAttribute();
67 * Holds all the fields associated with a NameID.
69 struct SHIBSP_API Value
73 std::string m_NameQualifier;
74 std::string m_SPNameQualifier;
75 std::string m_SPProvidedID;
79 * Returns the set of values encoded as UTF-8 strings.
81 * @return a mutable vector of the values
83 std::vector<Value>& getValues();
86 * Returns the set of values encoded as UTF-8 strings.
88 * @return an immutable vector of the values
90 const std::vector<Value>& getValues() const;
92 // Virtual function overrides.
93 size_t valueCount() const;
94 void clearSerializedValues();
95 const char* getString(size_t index) const;
96 const char* getScope(size_t index) const;
97 void removeValue(size_t index);
98 const std::vector<std::string>& getSerializedValues() const;
102 std::vector<Value> m_values;
103 std::string m_formatter,m_hashAlg;
106 #if defined (_MSC_VER)
107 #pragma warning( pop )
112 #endif /* __shibsp_nameidattr_h__ */