-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCompatAPIs.cpp
More file actions
64 lines (55 loc) · 1.99 KB
/
CompatAPIs.cpp
File metadata and controls
64 lines (55 loc) · 1.99 KB
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
/*
* esteid-browser-plugin - a browser plugin for Estonian EID card
*
* Copyright (C) 2010 Antti Andreimann
*
* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "CompatAPIs.h"
#include "JSUtil.h"
// #define REGISTER_RO_PROPERTY(a) JS_REGISTER_RO_PROPERTY(CertificateAPI, a)
#ifdef SUPPORT_OLD_APIS
/* SK leakplugin */
SKCertificateAPI::SKCertificateAPI(FB::BrowserHostPtr host, ByteVec bv)
: CertificateAPI(host, bv)
{
JS_REGISTER_RO_PROPERTY(SKCertificateAPI, id);
}
std::string SKCertificateAPI::get_id()
{
return MAGIC_ID2;
}
std::string SKCertificateAPI::get_cert()
{
RTERROR_TO_SCRIPT(return m_cert.getHex());
}
std::string SKCertificateAPI::ToString() {
/* Return "compatible" JSON */
std::ostringstream buf;
buf << "({certificates:[{";
buf << "id:'" << MAGIC_ID << "',";
buf << "cert:'";
buf << get_certificateAsHex();
buf << "',";
buf << "CN:'" << get_CN() << "',";
buf << "issuerCN:'" << get_issuerCN() << "',";
// JS using this old API expects the exact string "Non-Repudiation"
buf << "keyUsage:'Non-Repudiation',";
buf << "validFrom: new Date(),"; // TODO: Date(YYYY,MM,DD,HH,mm,SS)
buf << "validTo: new Date()}],"; // TODO: Date(YYYY,MM,DD,HH,mm,SS)
buf << "returnCode:0})";
return buf.str();
}
#endif //SUPPORT_OLD_APIS