2014-02-19 88 views
2

我是一名大學生,試圖在java中爲WebSSO實現一個服務提供者插件。我正在使用Shibboleth IdP作爲身份提供者。我已經能夠將身份驗證請求發送給IdP,並且正在通過servlet成功接收來自IdP的響應。我嘗試解碼響應,並能夠獲得XMLObject。現在的問題是響應被加密。所以當我使用如何解密從Shibboleth收到的SAMLResponse IdP

Assertion assertion = response.getAssertions().get(0); 

它基本上返回null。但是當我使用

Assertion assertion = response.getEncryptedAssertions().get(0); 

它不爲空。所以它基本上意味着響應被加密。現在我不知道如何解密SAMLReponse的流程。任何指針,代碼或建議是受歡迎的。

回答

1

您可以使用像這樣(與你的Credential對象替換yourCredential):

StaticKeyInfoCredentialResolver keyresolver = 
    new StaticKeyInfoCredentialResolver(yourCredential); 

Decrypter samlDecrypter = new Decrypter(null, keyresolver, new InlineEncryptedKeyResolver()); 

Assertion assertion = samlDecrypter.decrypt(response.getEncryptedAssertions().get(0)); 

如果你的情況是更復雜,更詳細的例子可以在這裏找到Shibboleth口令的wiki:Link

+0

嘿感謝回覆。但我現在還有一個問題。我試圖尋找憑證信息,但我沒有得到準確的信息。 .pem文件信息或什麼?這是我在配置文件中發現的唯一一種接近Credential類信息的配置文件。非常感謝。 :) :) –

+0

你可以閱讀如何在這裏創建憑據:https://wiki.shibboleth.net/confluence/display/SHIB2/IdPCredentials – Durandal

相關問題