Reputation: 20069
I'm integrating OpenSAML 3.3 in my application, and instead of hard-coding all the urls etc, I would like to be able to use the configuration XMLs.
I was given such an XML file for a adfs instance, it is 'FederationMetadata.xml'
This is the snippet I used to read it:
InitializationService.initialize();
FilesystemMetadataResolver idpMetaDataProvider = new FilesystemMetadataResolver( new File("/home/raudenaerde/sso/FederationMetadata.xml") );
idpMetaDataProvider.setRequireValidMetadata(true);
idpMetaDataProvider.setParserPool(new BasicParserPool());
idpMetaDataProvider.initialize();
However, this gave me this error:
> Exception in thread "main" > net.shibboleth.utilities.java.support.component.ComponentInitializationException: > Component identifier can not be null
Using an github project (https://github.com/coveo/saml-client) that uses OpenSAML 2.6.4 I had no problems reading it, but I'd like to stick with the newest version 3.3.
Am I missing some basic set-up?
Upvotes: 0
Views: 1330
Reputation: 20069
There are 2 things that needed to be fixed:
setId(String)
must be called before initialize()
BasicParserPool
needs to be initialized as well.Complete working code:
InitializationService.initialize();
FilesystemMetadataResolver idpMetaDataProvider = new FilesystemMetadataResolver( new File( "/home/raudenaerde/sso/FederationMetadata.xml" ) );
idpMetaDataProvider.setRequireValidMetadata( true );
idpMetaDataProvider.setId( "myId" );
BasicParserPool pool = new BasicParserPool();
pool.initialize();
idpMetaDataProvider.setParserPool( pool );
idpMetaDataProvider.initialize();
for ( EntityDescriptor idpEntityDescriptor : idpMetaDataProvider )
{
System.out.println( idpEntityDescriptor.getID() );
for ( SingleSignOnService sss : idpEntityDescriptor.getIDPSSODescriptor( SAMLConstants.SAML20P_NS ).getSingleSignOnServices() )
{
if ( sss.getBinding().equals( SAMLConstants.SAML2_REDIRECT_BINDING_URI ) )
{
System.out.println( sss.getLocation() );
}
}
for ( ArtifactResolutionService ars : idpEntityDescriptor.getIDPSSODescriptor( SAMLConstants.SAML20P_NS ).getArtifactResolutionServices() )
{
if ( ars.getBinding().equals( SAMLConstants.SAML2_SOAP11_BINDING_URI ) )
{
System.out.println( ars.getLocation() );
}
}
}
Upvotes: 1