2013-02-14 52 views
0

我有一個cassified的Spring應用程序(帶有過濾器並正常運行)。登錄後取回CAS門票

此應用程序必須通過REST查詢多個外部服務(Bonita,W4等)。這些其他服務也是一樣。

好的。

現在,我需要從Spring應用程序恢復CAS TICKET來爲這些其他服務生成代理門票,但我不知道如何獲得門票。我想申請單使用此URL這些服務:

https://[cas-service]/login?service=[service]&gateway=true 

此命令將返回票(通過重定向),但Spring應用程序攔截該重定向的CAS過濾器和我不能得到參數返回。

http://[service-url]?ticket=ST-.... 

重定向到

http://[service-url] 

如何取回車票驗證當前用戶到另一個服務?

謝謝!

PD:對不起,我的英語有限... :)

+0

您是否參閱過討論如何操作? static.springsource.org/spring-security/site/docs/3.1.x/reference/cas.html#cas-pt-client請注意,有一個示例應用程序演示了樣本中包含的代理票證的使用https:// github.com/SpringSource/spring-security/tree/master/samples/cas/。 – 2013-02-14 16:36:06

回答

1
SecurityContext ctx=SecurityContextHolder.getContext(); 
CasAuthenticationToken casToken=(CasAuthenticationToken) ctx.getAuthentication(); 
Assertion assertion=casToken.getAssertion(); 
user_fullName=(String) assertion.getAttributes().get("FullName"); 

從安全上下文可以獲取認證的CAS令牌對象。其中有SAML響應。 CAS標記對象具有SAML響應的詳細信息。您可以查詢CAS標記對象以獲取ASSERTION,並且可以在您的應用程序中使用它。

+0

我正在使用.net CAS並需要做與上面顯示的相同的事情,但我不確定這些類位於何處。你使用的是什麼引用的dll,以及哪些命名空間?儘管我不確定這是否正確,但我在System.Security.SecurityContext中找到了SecurityContext。我不確定其他人。這裏的任何幫助表示讚賞! – RichieMN 2014-02-26 17:50:04