2017-07-26 16 views
4

RFC 3161時間戳響應我有一個SOAP請求,這需要重新設計,因爲SoapUI不能正確處理二進制響應。我決定讓它基於Java。我發現this真的很有用,但不確定,函數是如何在代碼片段中出現的。我有驗證與PKIStatus值

  • 的DigestValue
  • 的SignatureValue
  • X509證書

SOAP要求定義,不知道如何把這些信息發送請求給我tsendpint。 我試過TSAClientBouncyCastle過,但不知道爲什麼,我們需要登錄憑據。我留空這些領域,但它完成所有的時間

TSAClientBouncyCastle @ 1f0e140b

消息。

我打電話從Main與構造TSAClientBouncyCastle類。

這是主要的組成部分,應該對數據進行解碼。

// Get TSA response as a byte array 
    InputStream inp = tsaConnection.getInputStream(); 
    ByteArrayOutputStream baos = new ByteArrayOutputStream(); 
    byte[] buffer = new byte[1024]; 
    int bytesRead = 0; 
    while ((bytesRead = inp.read(buffer, 0, buffer.length)) >= 0) { 
     baos.write(buffer, 0, bytesRead); 
    } 
    byte[] respBytes = baos.toByteArray(); 

    String encoding = tsaConnection.getContentEncoding(); 
    if (encoding != null && encoding.equalsIgnoreCase("base64")) { 
     respBytes = Base64.decode(new String(respBytes)); 
    } 
+0

我不取消了解你的問題的元素之間的關係。 1)肥皂請求不需要RFC3161時間戳。 2)你想驗證時間戳(問題標題)3)但是你正在使用TSAClient來請求一個新的時間戳4)錯誤來自哪裏?什麼數據是你的時間戳?顯示你的代碼 – pedrofb

+0

@pedrofb:對不起,是的,它不是很清楚。我有一個已定義的請求,爲此,SoapUI中的回答不可用於人員閱讀。原始響應也包含問號和矩形,所以我認爲我無法使用SoapUI獲取一些基於ascii的信息。我必須得到PKIStatus的價值。這就是我所說的驗證。我需要一個TSAClient,我可以從tsendpoint的響應中獲得可能的ASCII信息。 – plaidshirt

+1

時間戳管理局(TSA)產生一個證明,一個數據一個特定的時間之前就已經存在。它使用RFC3161中定義的協議和格式。如果這是你的意圖,你不能用TSA驗證另一條消息。如果你看到奇怪的字符,那是因爲你的信息是二進制的,而不是文本。可能TSA正在返回內容類型爲「application/timestamp-reply」的錯誤。我仍然不明白你的用例。我幫不了你 – pedrofb

回答

1

時間戳管理局(TSA)生成一個證據,證明某個數據在特定時間之前存在。它使用RFC3161中定義的協議和格式。

甲時間戳響應如下(見RFC3161-section 2.4.2):

TimeStampResp ::= SEQUENCE { 
    status     PKIStatusInfo, 
    timeStampToken   TimeStampToken  OPTIONAL } 

可以分析內容類型的響應application/timestamp-replyBouncyCastle獲得PKIStatusInfo

TimeStampResponse response = new TimeStampResponse(tsaInputStream); 
int status = response.getStatus(); 

可能的值是

PKIStatus ::= INTEGER { 
    granted    (0), 
    -- when the PKIStatus contains the value zero a TimeStampToken, as 
    requested, is present. 
    grantedWithMods  (1), 
    -- when the PKIStatus contains the value one a TimeStampToken, 
    with modifications, is present. 
    rejection    (2), 
    waiting    (3), 
    revocationWarning  (4), 
    -- this message contains a warning that a revocation is 
    -- imminent 
    revocationNotification (5) 
    -- notification that a revocation has occurred } 
+0

謝謝!我在我的問題中鏈接的解決方案也使用此庫,但我沒有用戶憑據,只有X509Data。 – plaidshirt