我必须设计一个 DMS(文档管理系统),我决定使用 Spring 作为我要构建的平台的基础框架。我正在设计一个由 2 个主要应用程序组成的平台:引擎应用程序和门户应用程序。两者都是基于 Spring MVC 的 Web 应用程序;引擎基本上是一组休息服务,门户是应用程序的主要前端。由于引擎应用程序是一组服务,我计划将这些服务公开给其他人。
该引擎应该能够连接到其他 DMS,例如 Alfresco 或 IBM FileNET P8。
当然,引擎必须得到保护,我决定使用 Spring Security 来灵活选择如何在每次安装时保护引擎(即 saas usign Oauth、LDAP、自定义数据库......)
也就是说,这就是我想要实现的目标:
- 门户应用程序有一个带有自定义登录模块的 Jaas 提供程序
- 引擎应用程序有一个带有自定义登录模块的 Jaas 提供程序(与门户相同)
两个应用程序都使用独立工作,但是当我登录到门户应用程序然后调用引擎时,使用 Controller 方法中的 RestTemplate ,不传递 jaas 凭据,并且引擎的方法返回登录页面而不是 json 结果。
如果我登录到门户应用程序,我希望登录将传递给其他应用程序,例如 SSO。
我认为我在 RestTemplate 中遗漏了一些东西来将 jaas 主题从一个应用程序传递到另一个应用程序,也许是请求中的某种标头。
这两个应用程序具有相同的弹簧安全配置:
<http auto-config="true" use-expressions="true" jaas-api-provision="true">
<intercept-url pattern="/api/**" access="hasRole('TESTROLE')" />
</http>
<authentication-manager>
<authentication-provider ref="jaasAuthProvider" />
</authentication-manager>
<beans:bean id="jaasAuthProvider" class="org.springframework.security.authentication.jaas.DefaultJaasAuthenticationProvider">
<beans:property name="configuration">
<beans:bean class="org.springframework.security.authentication.jaas.memory.InMemoryConfiguration">
<beans:constructor-arg>
<beans:map>
<beans:entry key="SPRINGSECURITY">
<beans:array>
<beans:bean class="javax.security.auth.login.AppConfigurationEntry">
<beans:constructor-arg value="it.besolutions.aegis.testloginmodule.Login" />
<beans:constructor-arg>
<util:constant static-field="javax.security.auth.login.AppConfigurationEntry$LoginModuleControlFlag.REQUIRED" />
</beans:constructor-arg>
<beans:constructor-arg>
<beans:map></beans:map>
</beans:constructor-arg>
</beans:bean>
</beans:array>
</beans:entry>
</beans:map>
</beans:constructor-arg>
</beans:bean>
</beans:property>
<beans:property name="authorityGranters">
<beans:list>
<beans:bean class="it.besolutions.aegis.testloginmodule.RoleGranter" />
</beans:list>
</beans:property>
</beans:bean>
虽然门户应用程序控制器中的 RestTemplate 调用如下所示:
RestTemplate restClient = new RestTemplate();
ResponseEntity<DocumentCollection> result = restClient.getForEntity("http://localhost:8084/TestAegisRest/api/v1/documents", DocumentCollection.class);
为了测试,我使用的是 Tomcat。
提前致谢。