Switch from entity to role during metadata attribute extraction.
authorScott Cantor <cantor.2@osu.edu>
Mon, 25 May 2009 17:49:12 +0000 (17:49 +0000)
committerScott Cantor <cantor.2@osu.edu>
Mon, 25 May 2009 17:49:12 +0000 (17:49 +0000)
shibsp/attribute/resolver/impl/KeyDescriptorAttributeExtractor.cpp
shibsp/attribute/resolver/impl/XMLAttributeExtractor.cpp
shibsp/handler/impl/AssertionConsumerService.cpp

index 50aa8f8..56f8626 100644 (file)
@@ -109,12 +109,12 @@ void KeyDescriptorExtractor::extractAttributes(
     const Application& application, const RoleDescriptor* issuer, const XMLObject& xmlObject, vector<Attribute*>& attributes
     ) const
 {
-    const EntityDescriptor* entity = dynamic_cast<const EntityDescriptor*>(&xmlObject);
-    if (!entity || !issuer)
+    const RoleDescriptor* role = dynamic_cast<const RoleDescriptor*>(&xmlObject);
+    if (!role)
         return;
 
     vector<const Credential*> creds;
-    MetadataCredentialCriteria mcc(*issuer);
+    MetadataCredentialCriteria mcc(*role);
 
     if (!m_signingId.empty()) {
         mcc.setUsage(Credential::SIGNING_CREDENTIAL);
index 1b8a7de..dbf41dd 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.
@@ -833,7 +833,8 @@ void XMLExtractor::extractAttributes(
 
     // Check for metadata.
     if (XMLString::equals(xmlObject.getElementQName().getNamespaceURI(), samlconstants::SAML20MD_NS)) {
-        const EntityDescriptor* entityToExtract = dynamic_cast<const EntityDescriptor*>(&xmlObject);
+        const RoleDescriptor* roleToExtract = dynamic_cast<const RoleDescriptor*>(&xmlObject);
+        const EntityDescriptor* entityToExtract = roleToExtract ? dynamic_cast<const EntityDescriptor*>(roleToExtract->getParent()) : NULL;
         if (!entityToExtract)
             throw AttributeExtractionException("Unable to extract attributes, unknown metadata object type.");
         const Extensions* ext = entityToExtract->getExtensions();
index 9a52104..52f747b 100644 (file)
@@ -289,20 +289,18 @@ ResolutionContext* AssertionConsumerService::resolveAttributes(
     const vector<const Assertion*>* tokens
     ) const
 {
-    const saml2md::EntityDescriptor* entity = issuer ? dynamic_cast<const saml2md::EntityDescriptor*>(issuer->getParent()) : NULL;
-
     // First we do the extraction of any pushed information, including from metadata.
     vector<Attribute*> resolvedAttributes;
     AttributeExtractor* extractor = application.getAttributeExtractor();
     if (extractor) {
         Locker extlocker(extractor);
-        if (entity) {
+        if (issuer) {
             pair<bool,const char*> mprefix = application.getString("metadataAttributePrefix");
             if (mprefix.first) {
                 m_log.debug("extracting metadata-derived attributes...");
                 try {
                     // We pass NULL for "issuer" because the IdP isn't the one asserting metadata-based attributes.
-                    extractor->extractAttributes(application, NULL, *entity, resolvedAttributes);
+                    extractor->extractAttributes(application, NULL, *issuer, resolvedAttributes);
                     for (vector<Attribute*>::iterator a = resolvedAttributes.begin(); a != resolvedAttributes.end(); ++a) {
                         vector<string>& ids = (*a)->getAliases();
                         for (vector<string>::iterator id = ids.begin(); id != ids.end(); ++id)
@@ -367,7 +365,7 @@ ResolutionContext* AssertionConsumerService::resolveAttributes(
             auto_ptr<ResolutionContext> ctx(
                 resolver->createResolutionContext(
                     application,
-                    entity,
+                    issuer ? dynamic_cast<const saml2md::EntityDescriptor*>(issuer->getParent()) : NULL,
                     protocol,
                     nameid,
                     authncontext_class,