我很努力實現WS-Security進程ABL。實現WS-Security進行中ABL
似乎有可能,這個知識庫:http://knowledgebase.progress.com/articles/Article/P88147狀態:
- 對於傳出的WS-Security,創建一個包含使用OpenEdge Web服務客戶端手動WS-Security的內容SOAP頭。所有的
首先,我與創建base64編碼的掙扎和SHA1消化密碼哈希。
根據WS-Security規範的密碼摘要。 Source.
Password_Digest = Base64 (SHA-1 (nonce + created + password))
的Nonce是特定長度的任意的字符串,可以基本上是一個UUID。該隨機數是Base64編碼的(它在肥皂標題中發送編碼)。
創建是格式爲「YYYY-MM-DDTHH:MM:SS.SSSZ」的日期。毫秒是可選的。 Z格林尼治標準時間應始終設置。
密碼是由Web服務提供商給出的密碼。
試圖模仿的SO這樣的回答: Working algorithm for PasswordDigest in WS-Security
PROCEDURE generatePassHash:
DEFINE INPUT PARAMETER pcNonce AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER pcCreated AS CHARACTER NO-UNDO.
DEFINE INPUT PARAMETER pcPassword AS CHARACTER NO-UNDO.
DEFINE OUTPUT PARAMETER pcHash AS CHARACTER NO-UNDO.
DEFINE VARIABLE mBytes AS MEMPTR NO-UNDO.
DEFINE VARIABLE cNonceDecoded AS CHARACTER NO-UNDO.
/* Base64-decode the nonce since it's in encoded format */
ASSIGN
cNonceDecoded = STRING(BASE64-DECODE(pcNonce)).
/* Set size of mempointer */
SET-SIZE(mBytes) = LENGTH(cNonceDecoded) + LENGTH(pcCreated) + LENGTH(pcPassword) + 1.
/* Put the decoded nonce first */
PUT-STRING(mBytes, 1) = cNonceDecoded.
/* Add create time */
PUT-STRING(mBytes, 1 + LENGTH(cNonceDecoded)) = pcCreated.
/* Add password */
PUT-STRING(mBytes, 1 + LENGTH(cNonceDecoded) + LENGTH(pcCreated)) = pcPassword.
/* Create out-data */
pcHash = STRING(BASE64-ENCODE(SHA1-DIGEST(mBytes))).
/* Clean up mempointer */
SET-SIZE(mBytes) = 0.
END PROCEDURE.
DEFINE VARIABLE cNonce AS CHARACTER NO-UNDO.
DEFINE VARIABLE cTimeStamp AS CHARACTER NO-UNDO.
DEFINE VARIABLE cClearPass AS CHARACTER NO-UNDO.
DEFINE VARIABLE cRightAnswer AS CHARACTER NO-UNDO.
ASSIGN
cNonce = "UIYifr1SPoNlrmmKGSVOug=="
cTimeStamp = "2009-12-03T16:14:49Z"
cClearPass = "test8"
cRightAnswer = "yf2yatQzoaNaC8BflCMatVch/B8=".
RUN generatePassHash(cNonce, cTimeStamp, cClearPass, OUTPUT cHash).
MESSAGE "Is:" SKIP cHash SKIP(2)
"Should be:" SKIP
cRightAnswer
VIEW-AS ALERT-BOX INFORMATION TITLE "OK?".
我猜測,這可能與做任何我搞亂了mempointer處理或事實,一切都應該是UTF-8?
NB
在引用的問題與這種簡單代碼中提到上述我很容易產生同樣的錯誤哈希:
MESSAGE STRING(BASE64-ENCODE(SHA1-DIGEST("UIYifr1SPoNlrmmKGSVOug==" + "2009-12-03T16:14:49Z" + "test8"))) VIEW-AS ALERT-BOX
工程就像一個魅力!我有一個想法,它是這樣的,我記得NULL已經咬我之前... – Jensd 2014-10-01 05:47:56
但是,它不適用於我收到的其他示例。像這樣的: 'ASSIGN cNonce = 「VVBXZ0xIVW4 =」 cTimeStamp = 「2014-10-01T07:20:26:660Z」 cClearPass = 「AMADEUS」 cRightAnswer = 「OljgJAghr3NZdXJaQNPRCbJg + XE =」' 它。產生另一個散列(bLj ...)。可能需要處理輸入數據的不同格式(base64等)? – Jensd 2014-10-01 10:42:09
如果我對它有正確的理解,只要你一致 - 但07:20:26:660Z看起來很奇怪 - 不應該是07:20:26.660Z嗎?你怎麼確定你收到/正確的例子? – 2014-10-01 20:40:22