...
- Complex type to extend:
BaseDataConnectorType
Example Extension
Extension Class
Code Block |
---|
public class MyDataConnector extends BaseDataConnector {
private String lookupUrl; //This is an example custom field, yours may vary (if any)
public MyDataConnector(String url) {
this.lookupUrl = url;
}
public Map<String, BaseAttribute> resolve(ShibbolethResolutionContext resolutionContext)
throws AttributeResolutionException {
Map<String, BaseAttribute> result = new HashMap<String, BaseAttribute>();
String username = resolutionContext.getAttributeRequestContext().getPrincipalName();
// add BasicAttributes to the result here.
return result;
}
}
|
Extension Schema
Code Block | ||||
---|---|---|---|---|
| ||||
<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="urn:example.org:shibboleth:2.0: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="UserLookup">
<annotation>
<documentation>
Description of your data connector.
</documentation>
</annotation>
<complexContent>
<extension base="resolver:BaseDataConnectorType">
<attribute name="lookupUrl" type="string" use="required">
<annotation>
<documentation>
This is an example of a custom attribute called "lookupUrl".
Look in the shib-common.jar at schema/shibboleth-2.0-attribute-resolver-dc.xml
for more examples of how to define custom attributes and elements.
</documentation>
</annotation>
</attribute>
</extension>
</complexContent>
</complexType>
</schema>
|
Bean Definition Parser
Code Block |
---|
public class MyDataConnectorBeanDefinitionParser extends BaseDataConnectorBeanDefinitionParser {
public static final QName QNAME = new QName(MyDataConnectorNamespaceHandler.NAMESPACE, "UserLookup");
protected Class getBeanClass(Element element) {
return MyDataConnectorFactoryBean.class;
}
protected void doParse(Element element, BeanDefinitionBuilder builder) {
super.doParse(element, builder);
String lookupUrl = pluginConfig.getAttributeNS(null, "lookupUrl");
builder.addPropertyValue("lookupUrl", lookupUrl);
}
}
|
Bean Factory
Code Block |
---|
public class MyDataConnectorFactoryBean extends BaseDataConnectorFactoryBean {
private String lookupUrl;
public Class getObjectType() {
return MyDataConnector.class;
}
protected Object createInstance() throws Exception {
MyDataConnector connector = new MyDataConnector(getLookupUrl());
populateDataConnector(connector);
return connector;
}
public void setLookupUrl(String url) { this.lookupUrl = url; }
public String getLookupUrl() { return this.lookupUrl; }
}
|
Namespace Handler
Code Block |
---|
public class MyDataConnectorNamespaceHandler extends BaseSpringNamespaceHandler {
public static String NAMESPACE = "urn:example.org:shibboleth:2.0:resolver";
public void init() {
registerBeanDefinitionParser(MyDataConnectorBeanDefinitionParser.QNAME,
new MyDataConnectorBeanDefinitionParser());
}
}
|
spring.schemas File
Code Block |
---|
urn\:example.org\:shibboleth\:2.0\:resolver = schema/myConnectors.xsd
|
spring.handler File
Code Block |
---|
urn\:example.org\:shibboleth\:2.0\:resolver = com.example.shibboleth.MyDataConnectorNamespaceHandler
|