summaryrefslogtreecommitdiff
path: root/tests/test-req.html
blob: ee3fd53fa4c0b46974513f1daeb0311844246a36 (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
<!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 certificate request test</title>
<script type="text/javascript">

var output;
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 init() {
    output = document.getElementById('output');
    
    plugin = document.getElementById('plugin');
    
    // init 1
    setPar('KeySize', '1024');
    setPar('KeyUsage', 'digitalSignature');
    // SubjectDN can be omitted(!)
    setPar('SubjectDN', 'CN=TEST PERSON,OID.2.5.4.41=(090102 12.30) TEST PERSON - BankID på fil,SN=197711223334,G=TEST,S=PERSON');
    
    setPar('MinLen', '12');
    setPar('MaxLen', '30');
    setPar('MinChars', '4');
    setPar('MinDigits', '1');
    
    output.value += "InitRequest('pkcs10')\n";
    output.value += "    retval = "+plugin.InitRequest('pkcs10');
    output.value += "    GetLastError() = "+plugin.GetLastError()+"\n";
    
    // init 2
    setPar('KeyUsage', 'nonRepudiation');
    //setPar('SubjectDN', 'CN=TEST PXXXX,OID.2.5.4.41=(090102 12.30) TEST PYYYY - BankID på fil,SN=222221223334,G=TEST,S=PZZZZZ');
    //setPar('SubjectDN', 'CN=TEST PERSON,OID.2.5.4.41=(090102 12.30) TEST PERSON - BankID på fil,SN=197711223334,G=TEST,S=PERSON');
    output.value += "InitRequest('pkcs10')\n";
    output.value += "    retval = "+plugin.InitRequest('pkcs10');
    output.value += "    GetLastError() = "+plugin.GetLastError()+"\n";
    
    // init 3
    setPar('OneTimePassword', 'Not Applicable');
    setPar('rfc2797cmcoid', 'true');
    output.value += "InitRequest('cmc')\n";
    output.value += "    retval = "+plugin.InitRequest('cmc');
    output.value += "    GetLastError() = "+plugin.GetLastError()+"\n";
    
    // create
    output.value += "CreateRequest()\n";
    output.value += "    retval = "+plugin.CreateRequest()+"\n";
    output.value += "    GetLastError() = "+plugin.GetLastError()+"\n";
    
    /* gives this output (this appears to be a P7S or DER file):
    
    MIID7AYJKoZIhvcNAQcCoIID3TCCA9kCAQExADCCA84GCCsGAQUFBwwCoIIDwDC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+e8w6Tn/ZKCZZRigOa3aIbNVCgqyX/BIO4MJjOUovlVJDVRKm4hIm+PU9Kts3FHWH9bpD759aC93LU2zaXxuaPqouMDsZIHbqsEnQ3a5JXyQopM/M9XnnG+Ai++nCKMzpi6sfuWqHQBvPdeydFO6pEYALv/+MAAwITAfAgQBAAABBgcqhXAkBAEBFg5Ob3QgQXBwbGljYWJsZTEA
    
    This data is sent to the server. Then the server sends our newly created certificates:
    
        plugin.StoreCertificates('p7c','MIINcAYJ'...)
        plugin.StoreCertificates('p7c','MIINcAYJ'...)
    
    */
}

</script>
</head>
<body onload="init()" style="background: #FFFFDD">
<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>

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

<div>
<object id="pluginVersion" type="application/x-personal-version"></object>
<object id="plugin" type="application/x-personal-regutil"></object>
</div>

</body>
</html>