summaryrefslogtreecommitdiffhomepage
path: root/tests/test-authsig.html
blob: b7bffe28ea27c61532d7b5c9aebaab3e975ecc58 (plain)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<!--

  Copyright (c) 2009-2010 Samuel Lidén Borell <samuel@kodafritt.se>
 
  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  copies of the Software, and to permit persons to whom the Software is
  furnished to do so, subject to the following conditions:
  
  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.
  
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  THE SOFTWARE.

-->
<title>BankID signing test</title>
<script type="text/javascript">

var output;
var pluginVersion;
var plugin;

function getPar(key) {
    output = document.getElementById('output');
    value = plugin.GetParam(key);
    output.value += "GetParam(\""+key+"\") (error: "+plugin.GetLastError()+") = "+value+" ("+typeof(value)+")\n";
}

function setPar(key, value) {
    output = document.getElementById('output');
    plugin.SetParam(key, value);
    output.value += "SetParam(\""+key+"\", \""+value+"\") (error: "+plugin.GetLastError()+")\n";
}

function test(sign, visibleText, nonVisibleText) {
    output = document.getElementById('output');
    pluginVersion = document.getElementById('pluginVersion');
    output.value = "Version: \""+pluginVersion.GetVersion()+"\"\n\n";
    
    plugin = document.getElementById(sign ? 'pluginSign' : 'pluginAuth');
    
    setPar((sign ? "Nonce" : "Challenge"), "MTIzNDU2Nzg5");
    setPar("TextToBeSigned", visibleText);
    setPar("NonVisibleData", nonVisibleText);
    setPar("ServerTime", "1290536889");
    setPar("Policys", "MS4yLjc1Mi43OC4xLjE7MS4yLjc1Mi43OC4xLjI7MS4yLjMuNC41OzEuMi4zLjQuMTA=");
    setPar("OnlyAcceptMRU", "true");
    setPar("OnlyAcceptMRU", "True");
    setPar("OnlyAcceptMRU", "TRUE");
/*    setPar("OnlyAcceptMRU", "true ");
    setPar("OnlyAcceptMRU", " TrUe ");
    setPar("OnlyAcceptMRU", "1");
    setPar("OnlyAcceptMRU", "2");
    setPar("OnlyAcceptMRU", "-1");
    setPar("OnlyAcceptMRU", " 1 ");
    setPar("OnlyAcceptMRU", "true");*/
    setPar("OnlyAcceptMRU", "false");
    
    output.value += "\n";
    var params = [
        "Challenge", "Nonce", "ServerTime", "Policys", "TextCharacterEncoding",
        "TextToBeSigned", "NonVisibleData", "Subjects", "Signature"
    ];
    
    for (var i = 0; i < params.length; i++) {
        getPar(params[i]);
    }
    
    command = (sign ? "Sign" : "Authenticate");
    output.value += "\nInvoking PerformAction("+command+"):\n";
    output.value += "    return value = "+plugin.PerformAction(command)+"\n";
    output.value += "    GetLastError() = "+plugin.GetLastError()+"\n";
    
    output.value += "\n";
    getPar("Signature");
}

function testWithDefaults(sign) {
    test(sign, "U3lubGlnIHRleHQgMTIzNA==", "T3N5bmxpZyBkYXRh");
}

</script>
</head>
<body style="background: #FFFFDD">

<p>You can use this file to verify that FriBID works. To do so,
put this file on an SSL-enabled server and open it in a web browser
(you can use a self-signed SSL-certificate).</p>

<p> Plugin installed:
<script type="text/javascript">
var pluginInstalled = false;

var pluginInstalled = 
   (navigator.mimeTypes &&
    navigator.mimeTypes["application/x-personal-version"] &&
    navigator.mimeTypes["application/x-personal-version"].enabledPlugin);

document.write(pluginInstalled ? "Yes" : "No");
</script>
</p>

<p><input type="button" value="Test authentication" onclick="testWithDefaults(false);" /></p>
<p><input type="button" value="Test signing" onclick="testWithDefaults(true);" /></p>

<div>
<textarea cols="80" rows="30" id="output">
</textarea>
</div>

<div>
<object id="pluginVersion" type="application/x-personal-version"></object>
<object id="pluginAuth" type="application/x-personal-authentication"></object>
<object id="pluginSign" type="application/x-personal-signer2"></object>
</div>

</body>
</html>