Open ttomsu opened 8 years ago
I agree that making that name better is a good idea. However, I think that Travis is asking about the keystore.storeFilePath
property, rather than the metadataFilePath
property. I think that one is currently only available via the classpath.
@ttomsu When you say any file, do you mean an arbitrary location on the file system where the app is deployed?
Correct - the keystore had to be on the classpath, and the metadata.xml had to either be on the classpath or available via HTTP.
@markthemarkest - I meant just as you've explained: any file means an arbitrary location on the file system. Sorry for the unclear description.
@markthemarkest and my thoughts on this: we could overload the function to allow it to take a file or a url (whichever java class is relevant for each; I'm sure there's a File.java type thing, for instance).
@ttomsu No code change is necessary for this. Simply prefix the path with "file:" and it will be resolved correctly, either to an absolute path or relative to the project directory.
If your metadata.xml file reside in classpath then prefixing with "file:" doesn't work. Either we will have to place it outside classpath or have to override the method
When file reside in classpath: java.io.FileNotFoundException: class path resource [saml/metadata.xml] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/dummy/abc.jar!/saml/metadata.xml
It would be much better if we make respective change: "If you would like to load a file from classpath in a Spring Boot JAR, then you have to use the resource.getInputStream() method to retrieve it as a InputStream. If you try to use resource.getFile() you will receive an error, because Spring tries to access a file system path, but it can not access a path in your JAR."
The "file://" path works well for the metadata.xml when it's not on classpath. And no URL prefix or classpath: if you want to load it from classpath. But, for some reason, it doesn't work with the keystore (even if the resource loader should handle it). I've done a modification in my working copy, I'll do a pull request with this fix.
This already exists, but is a little unclear. @markthemarkest let's see if we can maybe make this more clear with an overloaded function, a sample, or a better name than
metadataFilePath
(I think that's what we had ended on?).