[英]Create a spring bean only once even though called multiple times
We have two applications communicating with each other. 我们有两个相互通信的应用程序。 When the user is authenticated in the 1st application, we want to pass the user context to the other one. 在第一个应用程序中对用户进行身份验证后,我们希望将用户上下文传递给另一个应用程序。
I want to create the user context for the other application and pass the same to the application but i want to limit the user context creation to only once. 我想为其他应用程序创建用户上下文,并将其传递给应用程序,但我想将用户上下文创建限制为一次。 Can this be achieved by specifying scope="singleton"
? 是否可以通过指定scope="singleton"
来实现? Only thing is i will have to do this programatically since, my bean will only be instantiated once the first application authenticates the user. 唯一的事情是我将必须以编程方式执行此操作,因为仅当第一个应用程序对用户进行身份验证后,我的bean才会实例化。
All my services will be calling the 2nd application from the first application and i want to ensure that the user context (spring bean) for the 2nd application is created only once. 我所有的服务都将从第一个应用程序调用第二个应用程序,我想确保第二个应用程序的用户上下文(spring bean)仅创建一次。
Secondly, when a session time-out happens, i will have to freshly create the user context for the 2nd application. 其次,当会话超时发生时,我将不得不为第二个应用程序重新创建用户上下文。
Can someone guide me on this ? 有人可以指导我吗?
I don't think you'd want to pass the user context bean itself but exchange some sort of token. 我认为您不希望传递用户上下文Bean本身,而是交换某种令牌。 Spring uses SAML for single sign on, maybe take a look at that: http://docs.spring.io/spring-security-saml/docs/current/reference/html/configuration-sso.html Spring使用SAML进行单点登录,也许可以看看: http : //docs.spring.io/spring-security-saml/docs/current/reference/html/configuration-sso.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.