Creating a new SAML Object requires creating an interface and four classes: a concrete implementation, a builder, a marshaller, and an unmarshaller. The OpenSAML code serve as good examples of these items. Once you have written these items you should refer to the Configuration File section of the manual to see how to configure them for usage.
The first thing you should do is create an interface for your object. This will allow people to extend/replace your implementation in the future without breaking existing code. Here are the rules we use internally when creating our interfaces:
Attribute
, then the interface name is Attribute.Next you need to create a concrete implementation of your interface. Here are some suggestions for doing that:
org.opensaml.common.impl.AbstractSAMLObject
or org.opensaml.common.impl.AbstractSignableSAMLObject
(for elements that can be digitally signed). These classes provide a significant amount of boiler plate code.prepareForAssignment()
methods when assigning values to fields so that this cached DOM is improperly invalidated when changes occurorg.opensaml.xml.util.XMLObjectChildrenList
as the backing List implementation when you need to store a single type of multi-value childrenorg.opensaml.xml.util.IndexedXMLObjectChildrenList
as the backing List implementation when you need to store multiple types of multi-value children. Use the subList() method expose views of the List that only contain SAMLObjects of with a certain element QName or schema type. As an example you may wish to look at org.opensaml.saml2.metadata.impl.EntityDescriptorImpl and how it handles RoleDescriptor children.Create a class that:
If your class requires additional configuration information this can be provided in the OpenSAML configuration file; refer to the Extending the !ObjectProvider section for more information.
Next you will need to create a marshaller and unmarshaller for your new object. See the following sections in this manual to do that: