Resolver that can issue SAML 2 queries to entities listed in configuration or pulled...
[shibboleth/cpp-sp.git] / shibsp / attribute / NameIDAttribute.h
index d2decee..1b8d247 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2001-2007 Internet2
+ *  Copyright 2001-2009 Internet2
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
 /**
  * @file shibsp/attribute/NameIDAttribute.h
  * 
- * An Attribute whose values are relations of a value and a scope.
+ * An Attribute whose values are derived from or mappable to a SAML NameID.
  */
 
 #ifndef __shibsp_nameidattr_h__
@@ -43,12 +43,13 @@ namespace shibsp {
     {
     public:
         /**
-         * Constructor
+         * Constructor.
          * 
-         * @param id    Attribute identifier
+         * @param ids       array with primary identifier in first position, followed by any aliases
+         * @param formatter template for serialization of tuple
          */
-        NameIDAttribute(const char* id, const char* formatter=DEFAULT_NAMEID_FORMATTER)
-            : Attribute(id), m_formatter(formatter) {
+        NameIDAttribute(const std::vector<std::string>& ids, const char* formatter=DEFAULT_NAMEID_FORMATTER)
+            : Attribute(ids), m_formatter(formatter) {
         }
 
         /**
@@ -101,14 +102,21 @@ namespace shibsp {
         /**
          * Returns the set of values encoded as UTF-8 strings.
          * 
-         * <p>Each compound value is a pair containing the simple value and the scope. 
-         * 
          * @return  a mutable vector of the values
          */
         std::vector<Value>& getValues() {
             return m_values;
         }
-        
+
+        /**
+         * Returns the set of values encoded as UTF-8 strings.
+         * 
+         * @return  an immutable vector of the values
+         */
+        const std::vector<Value>& getValues() const {
+            return m_values;
+        }
+
         size_t valueCount() const {
             return m_values.size();
         }
@@ -116,7 +124,21 @@ namespace shibsp {
         void clearSerializedValues() {
             m_serialized.clear();
         }
-        
+
+        const char* getString(size_t index) const {
+            return m_values[index].m_Name.c_str();
+        }
+
+        const char* getScope(size_t index) const {
+            return m_values[index].m_NameQualifier.c_str();
+        }
+
+        void removeValue(size_t index) {
+            Attribute::removeValue(index);
+            if (index < m_values.size())
+                m_values.erase(m_values.begin() + index);
+        }
+
         const std::vector<std::string>& getSerializedValues() const {
             if (m_serialized.empty()) {
                 for (std::vector<Value>::const_iterator i=m_values.begin(); i!=m_values.end(); ++i) {