Skip to content

Make SamlResponse more extensible#318

Merged
pitbulk merged 2 commits into
SAML-Toolkits:masterfrom
mauromol:make-samlresponse-more-extensible
Apr 30, 2021
Merged

Make SamlResponse more extensible#318
pitbulk merged 2 commits into
SAML-Toolkits:masterfrom
mauromol:make-samlresponse-more-extensible

Conversation

@mauromol

@mauromol mauromol commented Apr 1, 2021

Copy link
Copy Markdown
Contributor

The query and queryAssertion methods are really useful when creating
extensions of SamlResponse that need to expose other information that
the plain java-saml library does not (like the response issue instant,
or any custom contents of the AuthnContext in the assertion auth
statement). Having these two methods private forces the extender to
reimplement them from scratch, probably by copy-and-paste, which is
clearly sub-optimal.

A concrete example: the Italian SPID authentication system expects the "authentication level" to be specified within the AuthnContextClassRef element. Also, it recommends to track the response issue instant, so when using java-saml to implement a SPID SP, these two pieces of information should be extracted from the response.

Please note I also removed a clear repetition in the query method implementation, by delegating to getSAMLResponseDocument() to retrieve the non-encrypted Document instance.

mauromol added 2 commits April 1, 2021 11:37
The query and queryAssertion methods are really useful when creating
extensions of SamlResponse that need to expose other information that
the plain java-saml library does not (like the response issue instant,
or any custom contents of the AuthnContext in the assertion auth
statement). Having these two methods private forces the extender to
reimplement them from scratch, probably by copy-and-paste, which is
clearly sub-optimal.
If a subclass needs to extend isValid(String), it must be able to set
the validation exception. In fact, overriding any of the non-private
validateXXX methods is trivial, because a ValidationError can simply be
thrown, but if additional validation is required, which is not covered
by any of those validateXXX methods, a subclass may need to override
isValid(String) directly, and this does not throw ValidationError, but
rather catches it so that it can be subsequently returned by
getValidationException() to the consumer. Hence, a setter with at least
protected visibility is needed for subclasses to do the same.
@pitbulk pitbulk merged commit 5e53592 into SAML-Toolkits:master Apr 30, 2021
@mauromol mauromol deleted the make-samlresponse-more-extensible branch May 5, 2021 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants