Thomas Thomas - 2 years ago 579
Java Question

Sample SAML Java Config. Project, Broken From the Start

I pulled in the example Java configuration project for Spring's SAML extension. No commits seem to have been made to the project for about six months as of my writing this question. I have not done anything to this project except for run

maven package
against it.

I then run the application in Spring Tool Suite as a Spring Boot Application and the application runs; however, the application does not run without error and the application endpoint is inaccessible (resulting in am error message): "ERROR: Something went wrong in the authentication process".

I haven't registered any certificates, etc (and may very well need to). There are no instructions provided with the GitHub project for starting or working with the application. I have intentionally not posted the guts of the project as I have left it unmodified.


From Chrome Dev. Tools, I can see a
500 Internal Server Error
returned from the request to the
application. So, the issue is definitely with the sample application (or something that I have not done).

The following error is logged to the console on application deployment (I've included both an image and the text as the text is proving difficult to format):

Error logged to console


[2015-08-20 14:41:40.551] boot - 9908 INFO [localhost-startStop-1]
--- HttpMethodDirector: I/O exception ( caught when processing
request: SSL peer failed hostname validation for name:

[2015-08-20 14:41:40.551] boot - 9908 INFO [localhost-startStop-1]
--- HttpMethodDirector: Retrying request

[2015-08-20 14:41:40.795] boot - 9908 ERROR [localhost-startStop-1] --- HTTPMetadataProvider:
Error retrieving metadata from SSL peer failed hostname
validation for name:



I have visited the url endpoint provided by ssocircle and the metadata is exposed.

If I visit the
endpoint of the service provider and get some helpful information: an
exception. The description if which is "No IDP was configured, please update included metadata with at least one IDP"; however, the source of this may be the above described error.


Am I missing something that is readily apparent to start the example application? In other words, what does this error tell me that I need to be investigating? Or, as it is "non-breaking", do I ignore it?


The documentation surrounding the deployment of the Sample Java Configuration application is minimal (as in "non-existant"). The self-documentation only provides "hints", such as the following:

// IDP Metadata configuration - paths to metadata of IDPs in circle of trust is here
// Do no forget to call initialize method on providers
public CachingMetadataManager metadata() throws MetadataProviderException {
List<MetadataProvider> providers = new ArrayList<MetadataProvider>();
return new CachingMetadataManager(providers);

I am certain there is something I am not doing, particularly since I have not done anything in the deployment of the application except for the run of the
mvn package
, described above.

Answer Source

The problem occurs due to the sample application's utilization of a deprecated constructor - a deprecation whose warning was explicitly suppressed - for the HTTPMetadataProvider (a fix I will commit, shortly). In configuring the ExtendedMetadataDelegate, the two-parametered constructor is utilized:

    public ExtendedMetadataDelegate ssoCircleExtendedMetadataProvider() throws MetadataProviderException {  
        @SuppressWarnings({ "deprecation"})
        HTTPMetadataProvider httpMetadataProvider = new HTTPMetadataProvider("", 5000);
        // other config.s...

If replaced with the non-deprecated constructor that takes a java.util.Timer and an org.apache.commons.httpclient.HttpClient (in addition to the metadata url), the sample application works, beautifully, and no errors are logged.

Additional Non-OP-related Information

I had to do the below to get the Sample SAML app to run

After removing the deprecated constructor, I recommend doing two things:

  1. Follow the steps outlined in 4.2.6 of the documentation, i.e. treat the application during setup as the XML-configured application. All the steps need to be taken to "register" the metada.The application will be unable to register its metadata with the current Java configuration (see below; point no. 2)
  2. Change the default configurations in class WebSecurityConfig (read detail, below)

Configuration Change

In the configuration of the ExtendedMetadataDelegate bean ssoCircleExtendedMetadataProvider, change the ExtendedMetadataDelegate's property values as follows:

// code....
// code....

In the ExtendedMetadata bean (different from above), change the property values as below:

// code....
// code....


Whether or not this should be used in production, I do not know; however, it seems to better reflect both the XML-based configuration and resulting metadata of the XML-configured Service Provider example referenced in the SAML Spring Documentation

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download