Search code examples
spring-securityspring-saml

FilesystemMetadataProvider: get metadata file


In our multi-tenant environment, we cannot configure our MetadataProvider's in the spring file and have to create/retrieve/etc them at runtime. I am basically trying to persist MetadataProvider's so that I can load them back on application restart. For HttpMetadataProvider, I can get the URL from getMetadataURI() method. However, I don't see a way of getting the location from a FilesystemMetadataProvider. Is there a way, else, I'll have to resort to reflections.


Solution

  • You can extend the FilesystemMetadataProvider class and override method getMetadataIdentifier with the following signature, in order to make it public:

     public String getMetadataIdentifier() {
         return super.getMetadataIdentifier();
     }
    

    The method is returning absolute path to the metadata file. Then when defining your metadata, instead of using the original class you can use the new one and fetch the file name as you want.