In my Spring Boot app i need to call to:
System.setProperty("java.security.auth.login.config", authConf);
where authConf seems to be expected as an absolute path to the file.
the problem is, my Spring Boot app is packaged and executed as a jar and i want to package the file inside the jar.
The answer provided in this question might work only when a WAR is deployed in a server. It doesn't seem to work when we run JARs with embedded container.
is there way i could set a relative path to java.security.auth.login.config to refer to my conf file packaged within my jar ?
I know that the answer is about 6 years too late, but I recently faced the same issue and found and answer. Maybe my answer will at least help the next dev who will face this issue.
I was able to solve it is by first creating a javax.security.auth.login.Configuration
of type JavaLoginConfig
and then use the Configuration.setConfiguration(configuration method)
of the same Configuration class. Using this method I was able to bundle our jaas.conf
inside the jar and use a relative path to it.
To give a concrete example:
URL configLocation=YourClass.getClassLoader().getResource("resources/jaas.conf);"
Configuration secConfig=Configuration.getInstance("JavaLoginConf", new URIParameter(configLocation.toURI());
Configuration.setConfiguration(secConfig);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.