565
szerkesztés
Módosítások
→Integration
== Integration ==
You can integrate Attribute Conversion and Filtering into your Bridging Element by using these java code snippets. (Of course, edugain.jar and converter.jar need to be placed on the classpath)
=== Initialization time ===
This code is need to be invoked in BE initialization time.
<source lang="java">
// get a reference to the AttributeConverterFactory singleton object
AttributeConverterFactory factory = AttributeConverterFactory.getInstance();
// set the configuration file paths (which paths can be set in web.xml for example)
factory.setAttributeConverterFilePath("path-to-converter.xml");
factory.setAttributeFilterFilePath("path-to-filter.xml");
factory.setAttributeNameMapperFilePath("path-to-namemapper.xml");
// create converter and filter objects
try {
AttributeConverter converter = factory.createAttributeConverter();
AttributeFilter filter = factory.createAttributeFilter();
} catch (ConfigurationException ex) {
// handle configuration errors (missing files, not valid xmls and more issues)
log.error(ex);
}
</source>
=== Runtime ===
This code is invoked in BE runtime
<source lang="java">
String remote = "remote-federation-peer-identifier";
String local = "local-federation-peer-identifier";
// get Attributes from the assertion
List<AttributeValues> input = ...;
// call attribute converter
List<AttributeValues> output = converter.process(input, remote, local);
// call attribute filter
output = filter.process(output, remote, local);
// process output here, create new assertion, etc.
</source>
== Testing ==