Fix reference to providerId.
authorcantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Wed, 2 May 2007 19:07:53 +0000 (19:07 +0000)
committercantor <cantor@cb58f699-b61c-0410-a6fe-9272a202ed29>
Wed, 2 May 2007 19:07:53 +0000 (19:07 +0000)
Propagate special attribute properties.
Add back NameID extraction to SSO handlers.

git-svn-id: https://svn.middleware.georgetown.edu/cpp-sp/trunk@2229 cb58f699-b61c-0410-a6fe-9272a202ed29

shibsp/attribute/NameIDAttribute.h
shibsp/attribute/ScopedAttribute.h
shibsp/attribute/ScopedAttributeDecoder.cpp
shibsp/handler/impl/SAML1Consumer.cpp
shibsp/handler/impl/SAML2Consumer.cpp
shibsp/handler/impl/SAML2SessionInitiator.cpp

index b2fbfc9..d2decee 100644 (file)
@@ -57,8 +57,13 @@ namespace shibsp {
          * @param in    input object containing marshalled NameIDAttribute
          */
         NameIDAttribute(DDF& in) : Attribute(in) {
+            DDF val = in["_formatter"];
+            if (val.isstring())
+                m_formatter = val.string();
+            else
+                m_formatter = DEFAULT_NAMEID_FORMATTER;
             const char* pch;
-            DDF val = in.first().first();
+            val = in.first().first();
             while (val.name()) {
                 m_values.push_back(Value());
                 Value& v = m_values.back();
@@ -136,6 +141,7 @@ namespace shibsp {
         DDF marshall() const {
             DDF ddf = Attribute::marshall();
             ddf.name("NameID");
+            ddf.addmember("_formatter").string(m_formatter.c_str());
             DDF vlist = ddf.first();
             for (std::vector<Value>::const_iterator i=m_values.begin(); i!=m_values.end(); ++i) {
                 DDF val = DDF(i->m_Name.c_str()).structure();
index 7adfaec..4baab6e 100644 (file)
@@ -48,17 +48,21 @@ namespace shibsp {
         /**
          * Constructor
          * 
-         * @param id    Attribute identifier
+         * @param id        Attribute identifier
+         * @param delimeter value/scope delimeter when serializing
          */
-        ScopedAttribute(const char* id) : Attribute(id) {}
+        ScopedAttribute(const char* id, char delimeter='@') : Attribute(id), m_delimeter(delimeter) {}
 
         /**
          * Constructs based on a remoted ScopedAttribute.
          * 
          * @param in    input object containing marshalled ScopedAttribute
          */
-        ScopedAttribute(DDF& in) : Attribute(in) {
-            DDF val = in.first().first();
+        ScopedAttribute(DDF& in) : Attribute(in), m_delimeter('@') {
+            DDF val = in["_delimeter"];
+            if (val.isint())
+                m_delimeter = static_cast<char>(val.integer());
+            val = in.first().first();
             while (val.name() && val.string()) {
                 m_values.push_back(std::make_pair(val.name(), val.string()));
                 val = in.first().next();
@@ -89,7 +93,7 @@ namespace shibsp {
         const std::vector<std::string>& getSerializedValues() const {
             if (m_serialized.empty()) {
                 for (std::vector< std::pair<std::string,std::string> >::const_iterator i=m_values.begin(); i!=m_values.end(); ++i)
-                    m_serialized.push_back(i->first + '@' + i->second);
+                    m_serialized.push_back(i->first + m_delimeter + i->second);
             }
             return Attribute::getSerializedValues();
         }
@@ -97,6 +101,8 @@ namespace shibsp {
         DDF marshall() const {
             DDF ddf = Attribute::marshall();
             ddf.name("Scoped");
+            if (m_delimeter != '@')
+                ddf.addmember("_delimeter").integer(m_delimeter);
             DDF vlist = ddf.first();
             for (std::vector< std::pair<std::string,std::string> >::const_iterator i=m_values.begin(); i!=m_values.end(); ++i) {
                 DDF val = DDF(i->first.c_str()).string(i->second.c_str());
@@ -106,6 +112,7 @@ namespace shibsp {
         }
     
     private:
+        char m_delimeter;
         std::vector< std::pair<std::string,std::string> > m_values;
     };
 
index 464f482..48652ce 100644 (file)
@@ -74,7 +74,7 @@ shibsp::Attribute* ScopedAttributeDecoder::decode(
     char* scope;\r
     const XMLCh* xmlscope;\r
     QName scopeqname(NULL,Scope);\r
-    auto_ptr<ScopedAttribute> scoped(new ScopedAttribute(id));\r
+    auto_ptr<ScopedAttribute> scoped(new ScopedAttribute(id,m_delimeter));\r
     scoped->setCaseSensitive(m_caseSensitive);\r
     vector< pair<string,string> >& dest = scoped->getValues();\r
     vector<XMLObject*>::const_iterator v,stop;\r
index c3df16b..c7caeb9 100644 (file)
@@ -184,12 +184,23 @@ string SAML1Consumer::implementProtocol(
 
     m_log.debug("SSO profile processing completed successfully");
 
+    NameIdentifier* n = ssoStatement->getSubject()->getNameIdentifier();
+
     // We've successfully "accepted" at least one SSO token, along with any additional valid tokens.
     // To complete processing, we need to extract and resolve attributes and then create the session.
     multimap<string,Attribute*> resolvedAttributes;
     AttributeExtractor* extractor = application.getAttributeExtractor();
     if (extractor) {
+        m_log.debug("extracting pushed attributes...");
         Locker extlocker(extractor);
+        if (n) {
+            try {
+                extractor->extractAttributes(application, policy.getIssuerMetadata(), *n, resolvedAttributes);
+            }
+            catch (exception& ex) {
+                m_log.error("caught exception extracting attributes: %s", ex.what());
+            }
+        }
         for (vector<const opensaml::Assertion*>::const_iterator t = tokens.begin(); t!=tokens.end(); ++t) {
             try {
                 extractor->extractAttributes(application, policy.getIssuerMetadata(), *(*t), resolvedAttributes);
@@ -201,7 +212,6 @@ string SAML1Consumer::implementProtocol(
     }
 
     // First, normalize the SAML 1.x NameIdentifier...
-    NameIdentifier* n = ssoStatement->getSubject()->getNameIdentifier();
     auto_ptr<NameID> nameid(n ? NameIDBuilder::buildNameID() : NULL);
     if (n) {
         nameid->setName(n->getName());
index b63dbb9..d1a0f27 100644 (file)
@@ -315,7 +315,14 @@ string SAML2Consumer::implementProtocol(
     multimap<string,Attribute*> resolvedAttributes;
     AttributeExtractor* extractor = application.getAttributeExtractor();
     if (extractor) {
+        m_log.debug("extracting pushed attributes...");
         Locker extlocker(extractor);
+        try {
+            extractor->extractAttributes(application, policy.getIssuerMetadata(), *ssoName, resolvedAttributes);
+        }
+        catch (exception& ex) {
+            m_log.error("caught exception extracting attributes: %s", ex.what());
+        }
         for (vector<const opensaml::Assertion*>::const_iterator t = tokens.begin(); t!=tokens.end(); ++t) {
             try {
                 extractor->extractAttributes(application, policy.getIssuerMetadata(), *(*t), resolvedAttributes);
index ae09b9b..160be51 100644 (file)
@@ -437,7 +437,7 @@ pair<bool,long> SAML2SessionInitiator::doRequest(
     if (!req->getIssuer()) {
         Issuer* issuer = IssuerBuilder::buildIssuer();
         req->setIssuer(issuer);
-        issuer->setName(app.getXMLString("providerId").second);
+        issuer->setName(app.getXMLString("entityID").second);
     }
     if (!req->getNameIDPolicy()) {
         NameIDPolicy* namepol = NameIDPolicyBuilder::buildNameIDPolicy();