forked from eXist-db/expath-crypto-module
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAwsRestRequest.xq
51 lines (47 loc) · 1.63 KB
/
AwsRestRequest.xq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
(:
: eXist-db EXPath Cryptographic library
: eXist-db wrapper for EXPath Cryptographic Java library
: Copyright (C) 2016 Claudius Teodorescu
:
: This library is free software; you can redistribute it and/or
: modify it under the terms of the GNU Lesser General Public License
: as published by the Free Software Foundation; either version 2.1
: of the License, or (at your option) any later version.
:
: This library is distributed in the hope that it will be useful,
: but WITHOUT ANY WARRANTY; without even the implied warranty of
: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
: GNU Lesser General Public License for more details.
:
: You should have received a copy of the GNU Lesser General Public License
: along with this library; if not, write to the Free Software Foundation,
: Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
:)
xquery version "3.0";
import module "http://expath.org/ns/crypto";
let $string-to-hash := 'PUT
c8fdb181845a4ca6b8fec737b3581d76
text/html
Thu, 17 Nov 2005 18:49:58 GMT
x-amz-magic:password
x-amz-meta-author:[email protected]
/quotes/nelson'
let $expected-result :=
<expected-result>jZNOcbfWmD/A/f3hSvVzXZjM2HU=</expected-result>
let $private-key :='OtxrzxIsfpFjA7SwPzILwy8Bw21TLhquhboDYROV'
let $actual-result :=
<actual-result>
{crypto:hmac($string-to-hash, $private-key, "HMAC-SHA-1", "base64")}
</actual-result>
let $condition := normalize-space($expected-result/text()) = normalize-space($actual-result/text())
return
<result>
{
(
if ($condition)
then <result-token>passed</result-token>
else <result-token>failed</result-token>
, $actual-result
)
}
</result>