Home | History | Annotate | Download | only in xfa
      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/cfxjse_value.h"
     12 #include "fxjs/js_resources.h"
     13 #include "xfa/fxfa/parser/cscript_signaturepseudomodel.h"
     14 
     15 const CJX_MethodSpec CJX_SignaturePseudoModel::MethodSpecs[] = {
     16     {"verify", verifySignature_static},
     17     {"sign", sign_static},
     18     {"enumerate", enumerate_static},
     19     {"clear", clear_static}};
     20 
     21 CJX_SignaturePseudoModel::CJX_SignaturePseudoModel(
     22     CScript_SignaturePseudoModel* model)
     23     : CJX_Object(model) {
     24   DefineMethods(MethodSpecs, FX_ArraySize(MethodSpecs));
     25 }
     26 
     27 CJX_SignaturePseudoModel::~CJX_SignaturePseudoModel() {}
     28 
     29 CJS_Return CJX_SignaturePseudoModel::verifySignature(
     30     CJS_V8* runtime,
     31     const std::vector<v8::Local<v8::Value>>& params) {
     32   if (params.empty() || params.size() > 4)
     33     return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
     34   return CJS_Return(runtime->NewNumber(0));
     35 }
     36 
     37 CJS_Return CJX_SignaturePseudoModel::sign(
     38     CJS_V8* runtime,
     39     const std::vector<v8::Local<v8::Value>>& params) {
     40   if (params.size() < 3 || params.size() > 7)
     41     return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
     42   return CJS_Return(runtime->NewBoolean(false));
     43 }
     44 
     45 CJS_Return CJX_SignaturePseudoModel::enumerate(
     46     CJS_V8* runtime,
     47     const std::vector<v8::Local<v8::Value>>& params) {
     48   if (!params.empty())
     49     return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
     50   return CJS_Return(true);
     51 }
     52 
     53 CJS_Return CJX_SignaturePseudoModel::clear(
     54     CJS_V8* runtime,
     55     const std::vector<v8::Local<v8::Value>>& params) {
     56   if (params.empty() || params.size() > 2)
     57     return CJS_Return(JSGetStringFromID(JSMessage::kParamError));
     58   return CJS_Return(runtime->NewBoolean(false));
     59 }
     60