How to dynamically switch application context in Spring Security?

笑着哭i 提交于 2019-12-10 13:58:28

问题


I am using Spring security in my web application and I am using Javaconfig for it. Recently we have also added Spring SAML authentication in the application and finally got it working after some hurdles. Inside the WebApplicationInitializer's onStartUp() I am loading SpringSecurity configuration or SpringSaml configuration based on some pre condition.

Now how can I do this dynamically ? Actually I will introduce a button and once admin clicks on this button admin and all users will be logged out and context should be reloaded. At this point of time its ok if system is inaccessible for sometime and it re initializes application context (which is actually my goal) ?

In other words how can I call the onStartUp() method of WebApplicationInitializer ?


回答1:


You use Spring Environment Profiles to control which security configuration is loaded.

To switch profile, you then update the configuration file listing the active profiles, and reload the app.

See Spring Boot Reference Guide - 25. Profiles.



来源:https://stackoverflow.com/questions/46422271/how-to-dynamically-switch-application-context-in-spring-security

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!