-
Notifications
You must be signed in to change notification settings - Fork 109
/
factory.go
33 lines (26 loc) · 841 Bytes
/
factory.go
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
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package core
import (
"errors"
ty "github.com/33cn/plugin/plugin/dapp/cert/types"
)
// GetLocalValidator 根据类型获取校验器
func GetLocalValidator(authConfig *AuthConfig, signType int) (Validator, error) {
var lclValidator Validator
var err error
if signType == ty.AuthECDSA {
lclValidator = NewEcdsaValidator()
} else if signType == ty.AuthSM2 {
lclValidator = NewGmValidator()
} else {
return nil, ty.ErrUnknowAuthSignType
}
err = lclValidator.Setup(authConfig)
if err != nil {
authLogger.Error("Failed to set up local validator config", "Error", err)
return nil, errors.New("Failed to initialize local validator")
}
return lclValidator, nil
}