Skip to Content.
Sympa Menu

shibboleth-dev - Re: [Shib-Dev] How enable a DataConnector to get all attribute definitions

Subject: Shibboleth Developers

List archive

Re: [Shib-Dev] How enable a DataConnector to get all attribute definitions


Chronological Thread 
  • From: Markus Ludwig Grandpre <>
  • To:
  • Subject: Re: [Shib-Dev] How enable a DataConnector to get all attribute definitions
  • Date: Mon, 20 Apr 2009 13:29:57 +0200

Hi Chad,

> Have you defined the attribute definitions and data connectors upon
> which yours depends as actual dependencies?

There's a problem with dependencies. If I try to get them, null is returned:

List<String> dependencies = getDependencyIds();

if (dependencies == null || dependencies.isEmpty())
{
log.error("no dependencies found for " + getId());
}
else
{
for (String dependency : dependencies)
{
log.debug("Dependency id: " + dependency);
}
}

Result:

ERROR MyShibbolethDataConnector.java(93): no dependencies found for myShibboleth

What I've done so far is:

1) setting up attribute-resolver.xml
2) setting up DataConnectorBeanDefinitionParser
3) setting up FactoryBean
4) setting up NamespaceHandler
5) implementing DataConnector
6) setting up xml schema definition
7) setting up spring.handler configuration file
8) Setting up spring.schmema configuration file

(corresponding code snippets attached below)

Maybe you like to look through the attached code snippets. I only can guess but I'm not able to find the error.

Thank you in advance,
Markus

--- ATTACHED CODE SNIPPETS ---

1) setting up attribute-resolver.xml:

<resolver:AttributeDefinition
id="eduPersonEntitlement"
...
<resolver:Dependency ref="myShibboleth" />
...
</resolver:AttributeDefinition>

<resolver:AttributeDefinition
id="eduPersonPrincipalName"
...
<resolver:Dependency ref="myShibboleth" />
...
</resolver:AttributeDefinition>

<resolver:AttributeDefinition
id="eduPersonAffiliation"
...
<resolver:Dependency ref="myShibboleth" />
...
</resolver:AttributeDefinition>

<resolver:DataConnector
id="myShibboleth"
xsi:type="MyShibbolethDataConnector"
xmlns="urn:mace:unikn:shibboleth:resolver"
attr1="test"/>

2) setting up DataConnectorBeanDefinitionParser

public class MyShibbolethDataConnectorBeanDefinitionParser
extends BaseDataConnectorBeanDefinitionParser
{
private static final Logger log =
Logger.getLogger(MyShibbolethDataConnectorBeanDefinitionParser.class);

public static final QName QNAME =
new QName(MyShibbolethDataConnectorNamespaceHandler.NAMESPACE, "MyShibbolethDataConnector");

@Override
protected Class getBeanClass(Element element)
{
return MyShibbolethDataConnectorFactoryBean.class;
}

@Override
protected void doParse(Element element, BeanDefinitionBuilder builder)
{
super.doParse(element, builder);
String attr = element.getAttributeNS(null, "attr1");
builder.addPropertyValue("attr1", attr);
}

}

3) setting up FactoryBean

public class MyShibbolethDataConnectorFactoryBean extends BaseDataConnectorFactoryBean
{
private String attribute;

public String getAttribute()
{
return this.attribute;
}

public void setAttribute(String attribute)
{
this.attribute = attribute;
}

public Class getObjectType()
{
return MyShibbolethDataConnector.class;
}

protected Object createInstance() throws Exception
{
MyShibbolethDataConnector connector =
new MyShibbolethDataConnector(getAttribute());
populateDataConnector(connector);
return connector;
}
}

4) setting up NamespaceHandler

public class MyShibbolethDataConnectorNamespaceHandler
extends BaseSpringNamespaceHandler
{
public static String NAMESPACE = "urn:mace:unikn:shibboleth:resolver";

public void init()
{
registerBeanDefinitionParser(
MyShibbolethDataConnectorBeanDefinitionParser.QNAME,
new MyShibbolethDataConnectorBeanDefinitionParser());
}
}

5) implementing DataConnector:

public class MyShibbolethDataConnector extends BaseDataConnector
{
...

private static final Logger log =
Logger.getLogger(MyShibbolethDataConnector.class);

String param;

public MyShibbolethDataConnector(String param)
{
this.param = param;
log.debug("MyShibbolethDataConnector started with param " + param);
}

public Map<String, BaseAttribute> resolve(
ShibbolethResolutionContext resolutionContext)
throws AttributeResolutionException
{
Map<String, BaseAttribute> result = new HashMap<String, BaseAttribute>();
String username = resolutionContext.getAttributeRequestContext().
getPrincipalName();

Map<String, ResolutionPlugIn> r = resolutionContext.getResolvedPlugins();
Collection<ResolutionPlugIn> values = r.values();

for (Iterator i = values.iterator(); i.hasNext();)
{
ResolutionPlugIn plugin = (ResolutionPlugIn) i.next();

if (plugin instanceof DataConnector)
{
log.debug("Found DataConnector: " + plugin.getId());
}

if (plugin instanceof AttributeDefinition)
{
log.debug("Found AttributeDefinition: " + plugin.getId());
}
}

Set<Entry<String, ResolutionPlugIn>> s = r.entrySet();

for (Entry<String, ResolutionPlugIn> ein : s)
{
log.debug("Key: " + ein.getKey());
log.debug("Value: " + ein.getValue());
}

List<String> dependencies = getDependencyIds();

if (dependencies == null || dependencies.isEmpty())
{
log.error("no dependencies found for " + getId());
}
else
{
for (String dependency : dependencies)
{
log.debug("Dependency id: " + dependency);
}
}

Map<String, AttributeDefinition> map = resolutionContext.
getResolvedAttributeDefinitions();

if (map == null || map.isEmpty())
{
log.error("no attribute defnitions found for " + getId());
}
else
{
for (Iterator<String> it = map.keySet().iterator(); it.hasNext();)
{
AttributeDefinition ad = map.get(it.next());
log.debug(ad.toString());
}
}

/*
BasicAttribute<String> attribute = new BasicAttribute<String>();
attribute.setId(getGeneratedAttributeId());
attribute.getValues().add(persistentId);
*/
return result;

}

public void validate() throws AttributeResolutionException
{
throw new UnsupportedOperationException("Not supported yet.");
}
}

6) setting up xml schema definition:

<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="urn:mace:unikn:shibboleth:resolver"
xmlns="http://www.w3.org/2001/XMLSchema";
xmlns:resolver="urn:mace:shibboleth:2.0:resolver"
elementFormDefault="qualified">

<import namespace="urn:mace:shibboleth:2.0:resolver"

schemaLocation="classpath:/schema/shibboleth-2.0-attribute-resolver.xsd" />

<complexType name="MyShibbolethDataConnector">
<annotation>
<documentation>
Description of your data connector.
</documentation>
</annotation>
<complexContent>
<extension base="resolver:BaseDataConnectorType">
<attribute name="attr1" type="string" use="optional"/>
</extension>
</complexContent>
</complexType>
</schema>

7) Setting up spring.handler configuration file

urn\:mace\:unikn\:shibboleth\:resolver=de.unikn.rz.myshibboleth.dataconnector.config.MyShibbolethDataConnectorNamespaceHandler

8) Setting up spring.schmema configuration file

urn\:mace\:uni-kn\:shibboleth\:resolver=schema/MyShibbolethDataConnector.xsd





Archive powered by MHonArc 2.6.16.

Top of Page