1 // Copyright 2017 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "fxjs/xfa/cjx_signaturepseudomodel.h"
8
9 #include <vector>
10
11 #include "fxjs/cfx_v8.h"
12 #include "fxjs/js_resources.h"
13 #include "fxjs/xfa/cfxjse_value.h"
14 #include "xfa/fxfa/parser/cscript_signaturepseudomodel.h"
15
16 const CJX_MethodSpec CJX_SignaturePseudoModel::MethodSpecs[] = {
17 {"verify", verifySignature_static},
18 {"sign", sign_static},
19 {"enumerate", enumerate_static},
20 {"clear", clear_static}};
21
CJX_SignaturePseudoModel(CScript_SignaturePseudoModel * model)22 CJX_SignaturePseudoModel::CJX_SignaturePseudoModel(
23 CScript_SignaturePseudoModel* model)
24 : CJX_Object(model) {
25 DefineMethods(MethodSpecs);
26 }
27
~CJX_SignaturePseudoModel()28 CJX_SignaturePseudoModel::~CJX_SignaturePseudoModel() {}
29
DynamicTypeIs(TypeTag eType) const30 bool CJX_SignaturePseudoModel::DynamicTypeIs(TypeTag eType) const {
31 return eType == static_type__ || ParentType__::DynamicTypeIs(eType);
32 }
33
verifySignature(CFX_V8 * runtime,const std::vector<v8::Local<v8::Value>> & params)34 CJS_Result CJX_SignaturePseudoModel::verifySignature(
35 CFX_V8* runtime,
36 const std::vector<v8::Local<v8::Value>>& params) {
37 if (params.empty() || params.size() > 4)
38 return CJS_Result::Failure(JSMessage::kParamError);
39
40 return CJS_Result::Success(runtime->NewNumber(0));
41 }
42
sign(CFX_V8 * runtime,const std::vector<v8::Local<v8::Value>> & params)43 CJS_Result CJX_SignaturePseudoModel::sign(
44 CFX_V8* runtime,
45 const std::vector<v8::Local<v8::Value>>& params) {
46 if (params.size() < 3 || params.size() > 7)
47 return CJS_Result::Failure(JSMessage::kParamError);
48
49 return CJS_Result::Success(runtime->NewBoolean(false));
50 }
51
enumerate(CFX_V8 * runtime,const std::vector<v8::Local<v8::Value>> & params)52 CJS_Result CJX_SignaturePseudoModel::enumerate(
53 CFX_V8* runtime,
54 const std::vector<v8::Local<v8::Value>>& params) {
55 if (!params.empty())
56 return CJS_Result::Failure(JSMessage::kParamError);
57
58 return CJS_Result::Success();
59 }
60
clear(CFX_V8 * runtime,const std::vector<v8::Local<v8::Value>> & params)61 CJS_Result CJX_SignaturePseudoModel::clear(
62 CFX_V8* runtime,
63 const std::vector<v8::Local<v8::Value>>& params) {
64 if (params.empty() || params.size() > 2)
65 return CJS_Result::Failure(JSMessage::kParamError);
66
67 return CJS_Result::Success(runtime->NewBoolean(false));
68 }
69