Better handling when attribute PlugIns are mislabeled as DataConnector PlugIns. ...
authorwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Thu, 8 May 2003 18:08:55 +0000 (18:08 +0000)
committerwassa <wassa@ab3bd59b-922f-494d-bb5f-6f0a3c29deca>
Thu, 8 May 2003 18:08:55 +0000 (18:08 +0000)
git-svn-id: https://subversion.switch.ch/svn/shibboleth/java-idp/trunk@593 ab3bd59b-922f-494d-bb5f-6f0a3c29deca

data/resolver10.xml [new file with mode: 0644]
data/resolver11.xml [new file with mode: 0644]
src/edu/internet2/middleware/shibboleth/aa/attrresolv/AttributeResolver.java
tests/edu/internet2/middleware/shibboleth/aa/attrresolv/ResolverTests.java

diff --git a/data/resolver10.xml b/data/resolver10.xml
new file mode 100644 (file)
index 0000000..f4e72ca
--- /dev/null
@@ -0,0 +1,14 @@
+<AttributeResolver xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:mace:shibboleth:resolver:1.0" xsi:schemaLocation="urn:mace:shibboleth:resolver:1.0 shibboleth-resolver-1.0.xsd">
+       
+       <SimpleAttributeDefinition id="urn:mace:eduPerson:1.0:eduPersonScopedAffiliation" smartScope="example.edu">
+               <DataConnectorDependency requires="urn:mace:eduPerson:1.0:eduPersonAffiliation"/>
+       </SimpleAttributeDefinition>
+
+       <SimpleAttributeDefinition id="urn:mace:eduPerson:1.0:eduPersonAffiliation">
+               <DataConnectorDependency requires="echo"/>
+       </SimpleAttributeDefinition>
+       
+       <CustomDataConnector id="echo" cacheTime="1800000"
+               class="edu.internet2.middleware.shibboleth.aa.attrresolv.provider.SampleConnector" />
+
+</AttributeResolver>
\ No newline at end of file
diff --git a/data/resolver11.xml b/data/resolver11.xml
new file mode 100644 (file)
index 0000000..fc86d32
--- /dev/null
@@ -0,0 +1,10 @@
+<AttributeResolver xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:mace:shibboleth:resolver:1.0" xsi:schemaLocation="urn:mace:shibboleth:resolver:1.0 shibboleth-resolver-1.0.xsd">
+       
+       <SimpleAttributeDefinition id="urn:mace:eduPerson:1.0:eduPersonAffiliation">
+               <AttributeDependency requires="echo"/>
+       </SimpleAttributeDefinition>
+       
+       <CustomDataConnector id="echo" cacheTime="1800000"
+               class="edu.internet2.middleware.shibboleth.aa.attrresolv.provider.SampleConnector" />
+
+</AttributeResolver>
\ No newline at end of file
index 29935f7..fbd6d56 100644 (file)
@@ -250,6 +250,18 @@ public class AttributeResolver {
                                inconsistent.add(plugIn.getId());
                                return;
                        }
+                       
+                       ResolutionPlugIn dependent = lookupPlugIn(key);
+                       if (!(dependent instanceof DataConnectorPlugIn)) {
+                               log.error(
+                                       "The PlugIn ("
+                                               + plugIn.getId()
+                                               + ") is inconsistent.  It depends on a PlugIn ("
+                                               + key
+                                               + ") that is mislabeled as an DataConnectorPlugIn.");
+                               inconsistent.add(plugIn.getId());
+                               return;
+                       }
                }
 
                //Recursively go through all AttributeDefinition dependencies and make sure all are registered and consistent.
index 1891bba..3a1fbc3 100644 (file)
@@ -354,6 +354,67 @@ public class ResolverTests extends TestCase {
                        fail("Error creating SAML Attribute: " + e.getMessage());
                }
        }
+       
+       public void testMisLabeledDataConnector() {
+
+               try {
+                       Properties props = new Properties();
+                       File file = new File("data/resolver11.xml");
+                       props.setProperty(
+                               "edu.internet2.middleware.shibboleth.aa.attrresolv.AttributeResolver.ResolverConfig",
+                               file.toURL().toString());
+
+                       AttributeResolver ar = new AttributeResolver(props);
+
+                       AAAttributeSet inputAttributes =
+                               new AAAttributeSet(
+                                       new AAAttribute[] { new AAAttribute("urn:mace:eduPerson:1.0:eduPersonScopedAffiliation")});
+
+                       AAAttributeSet outputAttributes = new AAAttributeSet();
+
+                       ar.resolveAttributes(new PrincipalImpl("mytestuser"), "shar.example.edu", inputAttributes);
+
+                       assertEquals("Attribute Resolver returned unexpected attribute set.", inputAttributes, outputAttributes);
+
+               } catch (AttributeResolverException e) {
+                       fail("Couldn't load attribute resolver: " + e.getMessage());
+               } catch (MalformedURLException e) {
+                       fail("Error in test specification: " + e.getMessage());
+               } catch (SAMLException e) {
+                       fail("Error creating SAML Attribute: " + e.getMessage());
+               }
+       }
+
+       public void testMisLabeledAttributeDefinition() {
+
+               try {
+                       Properties props = new Properties();
+                       File file = new File("data/resolver10.xml");
+                       props.setProperty(
+                               "edu.internet2.middleware.shibboleth.aa.attrresolv.AttributeResolver.ResolverConfig",
+                               file.toURL().toString());
+
+                       AttributeResolver ar = new AttributeResolver(props);
+
+                       AAAttributeSet inputAttributes =
+                               new AAAttributeSet(
+                                       new AAAttribute[] { new AAAttribute("urn:mace:eduPerson:1.0:eduPersonScopedAffiliation")});
+
+                       AAAttributeSet outputAttributes = new AAAttributeSet();
+
+                       ar.resolveAttributes(new PrincipalImpl("mytestuser"), "shar.example.edu", inputAttributes);
+
+                       assertEquals("Attribute Resolver returned unexpected attribute set.", inputAttributes, outputAttributes);
+               } catch (ClassCastException e) {
+                       fail("Failed to detect that an Attribute Definition was mislabeled as a Data Connector: " + e.getMessage());
+               } catch (AttributeResolverException e) {
+                       fail("Couldn't load attribute resolver: " + e.getMessage());
+               } catch (MalformedURLException e) {
+                       fail("Error in test specification: " + e.getMessage());
+               } catch (SAMLException e) {
+                       fail("Error creating SAML Attribute: " + e.getMessage());
+               }
+       }
 
 
 }