2 * Copyright 2001-2007 Internet2
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file shibsp/attribute/Attribute.h
20 * A resolved attribute.
23 #ifndef __shibsp_attribute_h__
24 #define __shibsp_attribute_h__
26 #include <shibsp/remoting/ddf.h>
34 * A resolved attribute.
36 * <p>Resolved attributes are a neutral construct that represent both simple and
37 * complex attribute data structures that might be found in SAML assertions
38 * or obtained from other sources.
40 * <p>Attributes consist of an id/name that is locally unique (that is, unique to a
41 * configuration at any given point in time) and zero or more values. Values can
42 * be of any type or structure, but will generally be made available to applications
43 * only if a serialized string form exists. More complex values can be used with
44 * access control plugins that understand them, however.
46 class SHIBSP_API Attribute
48 MAKE_NONCOPYABLE(Attribute);
53 * @param id Attribute identifier
55 Attribute(const char* id) : m_id(id) {}
58 * Maintains a copy of serialized attribute values, when possible.
60 * <p>Implementations should maintain the array when values are added or removed.
62 mutable std::vector<std::string> m_serialized;
65 virtual ~Attribute() {}
68 * Returns the Attribute identifier.
70 * @return Attribute identifier
72 const char* getId() const {
77 * Returns the number of values.
79 * @return number of values
81 virtual size_t valueCount() const {
82 return m_serialized.size();
86 * Returns serialized attribute values encoded as UTF-8 strings.
88 * @return an immutable vector of values
90 virtual const std::vector<std::string>& getSerializedValues() const {
95 * Informs the attribute that values have changed and any serializations
98 virtual void clearSerializedValues()=0;
101 * Marshalls an Attribute for remoting.
103 * This allows Attribute objects to be communicated across process boundaries
104 * without excess XML parsing. The DDF returned must be a struct containing
105 * a string member called "id" and a list called "values". The name of the struct
106 * should contain the registered name of the Attribute implementation.
108 virtual DDF marshall() const {
110 ddf.structure().addmember("id").string(m_id.c_str());
120 #endif /* __shibsp_attribute_h__ */