Adding Attribute Statements
The SAMLTokenProvider has a "List<AttributeStatementProvider> attributeStatementProviders" property, which can be used to add AttributeStatments to the generated assertion. Each object in the list adds a single attribute statement. The AttributeStatementProvider contains a single method to return an AttributeStatementBean given the TokenProviderParameters object. This contains a SubjectBean (for SAML 1.1 assertions), and a list of AttributeBeans. The AttributeBean object holds the attribute name/qualified-name/name-format, and a list of attribute values, amongst other properties.
If no statement provider is configured in the SAMLTokenProvider, then the DefaultAttributeStatementProvider is invoked to create an Attribute statement to add to the assertion. It creates a default authenticated attribute, and also creates separate attributes for any OnBehalfOf or ActAs elements that were received in the request. If the received OnBehalfOf/ActAs element was a UsernameToken, then the username is added as an attribute. If the received element was a SAML Assertion, then the subject name is added as an attribute.