2016-07-13 22 views
1

Ich habe mit Digest-Value-Berechnung gekämpft und jetzt habe ich keine Ideen mehr. Hier ist xml Beispiel und Digest-Wert von SoapUI generiert:XML-Signatur, ORACLE PLSQL, SHA1-Digest-Wert-Berechnung

<ds:Reference URI="#TS-5C3C8278F62662ED251468430162870278"> 
    <ds:Transforms> 
     <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"> 
     <ec:InclusiveNamespaces PrefixList="wsse soapenv xsi" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/> 
     </ds:Transform> 
    </ds:Transforms> 
    <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/> 
    <ds:DigestValue>FP+KnVZ5S8C/RW6sBvulTUYYKAA=</ds:DigestValue> 
</ds:Reference> 

Referenz:

<wsu:Timestamp wsu:Id="TS-5C3C8278F62662ED251468430162870278"> 
    <wsu:Created>2016-07-13T17:16:02.870Z</wsu:Created> 
    <wsu:Expires>2016-07-13T17:21:02.870Z</wsu:Expires> 
</wsu:Timestamp> 

Hier ist mein Orakel Code:

declare 
    l_clob clob; 
    l_hash raw(20); 
begin 
    select 
    xmlSerialize(
    document extract(
     xmlType('<wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="TS-5C3C8278F62662ED251468429256802268"> 
     <wsu:Created>2016-07-13T17:00:56.802Z</wsu:Created> 
     <wsu:Expires>2016-07-13T17:05:56.802Z</wsu:Expires> 
     </wsu:Timestamp>'), '/*')) 
    into 
    l_clob 
    from 
    dual; 

    l_hash := dbms_crypto.Hash(
    l_clob, 
    DBMS_CRYPTO.HASH_SH1); 

    dbms_output.put_line(
    utl_raw.cast_to_varchar2(
     utl_encode.base64_encode(
     l_hash))); 
end; 
/

Ausgang: 5SiW/yo1nYIujurXbp5Ob9z6Mbs =

Hinweis dass ich WSU-Namespace zu XML hinzugefügt habe, da ohne es ich nicht kanonisiert werden kann.

Ohne WSU-Namespace und canonilization:

declare 
    l_clob clob := '<wsu:Timestamp wsu:Id="TS-5C3C8278F62662ED251468429256802268"><wsu:Created>2016-07-13T17:00:56.802Z</wsu:Created><wsu:Expires>2016-07-13T17:05:56.802Z</wsu:Expires></wsu:Timestamp>'; 
    l_hash raw(20); 
begin 
    l_hash := dbms_crypto.Hash(
    l_clob, 
    DBMS_CRYPTO.HASH_SH1); 

    dbms_output.put_line(
    utl_raw.cast_to_varchar2(
     utl_encode.base64_encode(
     l_hash))); 
end; 
/

Ausgang: tV9e2gUBqG9tgUXXwuc2M9/C798 =

Irgendwelche Ideen, was ich falsch mache?

Antwort

0

Dargestellt, dass inklusive Namespaces zu Element hinzugefügt werden müssen, in diesem Beispiel "wsse soapenv xsi" und dann müssen sie bestellt werden, dh "< ... soapenv: ... wsse: ... wsu: ... xsi: ... wsu: Id = ...> ... < ... /> "nur dann kann man den Digest-Wert berechnen.