db

package
v1.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//CERT_CONTENT_NAME table name
	CERT_CONTENT_NAME = "cert_content"
	//CERT_INFO_NAME table name
	CERT_INFO_NAME = "cert_info"
	//KEY_PAIR_NAME table name
	KEY_PAIR_NAME = "key_pair"
	//REVOKED_CERT_NAME table name
	REVOKED_CERT_NAME = "revoked_cert"
	//ACCESS_CONTROL table name
	ACCESS_CONTROL = "app_info"
)

Variables

View Source
var AccessRole2NameMap = map[AccessRole]string{
	ADMIN: "admin",
	USER:  "user",
}

AccessRole2NameMap .

View Source
var CertUsage2NameMap = map[CertUsage]string{
	SIGN:     "sign",
	TLS:      "tls",
	TLS_SIGN: "tls-sign",
	TLS_ENC:  "tls-enc",
}

CertUsage2NameMap .

View Source
var DB *gorm.DB

DB database

View Source
var Name2AccessRoleMap = map[string]AccessRole{
	"admin": ADMIN,
	"user":  USER,
}

Name2AccessRoleMap .

View Source
var Name2CertUsageMap = map[string]CertUsage{
	"sign":     SIGN,
	"tls":      TLS,
	"tls-sign": TLS_SIGN,
	"tls-enc":  TLS_ENC,
}

Name2CertUsageMap .

View Source
var Name2UserTypeMap = map[string]UserType{
	"root":      ROOT_CA,
	"ca":        INTERMRDIARY_CA,
	"admin":     USER_ADMIN,
	"client":    USER_CLIENT,
	"consensus": NODE_CONSENSUS,
	"common":    NODE_COMMON,
}

Name2UserTypeMap string name to cert type

View Source
var UserType2NameMap = map[UserType]string{
	ROOT_CA:         "root",
	INTERMRDIARY_CA: "ca",
	USER_ADMIN:      "admin",
	USER_CLIENT:     "client",
	NODE_CONSENSUS:  "consensus",
	NODE_COMMON:     "common",
}

UserType2NameMap CertType to string name

Functions

func GormInit

func GormInit()

DbInit db init

Types

type AccessRole

type AccessRole int
const (
	//ADMIN admin
	ADMIN AccessRole = iota + 1
	//USER user
	USER
)

type AppInfo

type AppInfo struct {
	TableModel
	AppId   string `gorm:"uniqueIndex"`
	AppKey  string
	AppRole AccessRole
}

func (*AppInfo) TableName

func (*AppInfo) TableName() string

type CertContent

type CertContent struct {
	TableModel
	SerialNumber       int64  `gorm:"uniqueIndex"`
	Content            string `gorm:"type:longtext"`
	Signature          string `gorm:"type:longtext"`
	Country            string
	Locality           string
	Province           string
	Organization       string
	OrganizationalUnit string
	CommonName         string
	Ski                string
	Aki                string
	KeyUsage           int
	ExtKeyUsage        string
	CsrContent         string `gorm:"type:longtext"`
	IsCa               bool
	IssueDate          int64
	ExpirationDate     int64
}

CertContent The initiatively populated field in the program & the final generated certificate file

func (*CertContent) TableName

func (*CertContent) TableName() string

Table name function

type CertInfo

type CertInfo struct {
	TableModel
	SerialNumber int64
	PrivateKeyId string
	IssuerSn     int64
	P2pNodeId    string
	OrgId        string    `gorm:"index: orgid_usertype_certusage_userid_index,unique"`
	UserType     UserType  `gorm:"index: orgid_usertype_certusage_userid_index,unique"`
	CertUsage    CertUsage `gorm:"index: orgid_usertype_certusage_userid_index,unique"`
	UserId       string    `gorm:"index: orgid_usertype_certusage_userid_index,unique"`
}

CertInfo Other relevant information

func (*CertInfo) TableName

func (*CertInfo) TableName() string

type CertUsage

type CertUsage int

CertUsage

const (
	//SIGN sign
	SIGN CertUsage = iota + 1
	//TLS tls
	TLS
	//TLS_SIGN tls-sign
	TLS_SIGN
	//TLS_ENC tls-enc
	TLS_ENC
)

type KeyPair

type KeyPair struct {
	TableModel
	Ski        string `gorm:"uniqueIndex"`
	PrivateKey string `gorm:"type:longtext"`
	PublicKey  string `gorm:"type:longtext"`
	HashType   crypto.HashType
	KeyType    crypto.KeyType
}

KeyPair public/private key pair informations

func (*KeyPair) TableName

func (*KeyPair) TableName() string

type RevokedCert

type RevokedCert struct {
	TableModel
	RevokedCertSN    int64 `gorm:"uniqueIndex"`
	Reason           string
	RevokedStartTime int64
	RevokedEndTime   int64
	RevokedBy        int64
	OrgId            string
}

RevokedCert revoked cert

func (*RevokedCert) TableName

func (*RevokedCert) TableName() string

type TableModel

type TableModel struct {
	Id        int `gorm:"primaryKey;autoIncrement"`
	CreatedAt int
	UpdatedAt int
}

type UserType

type UserType int

CertType

const (
	//ROOT_CA root ca
	ROOT_CA UserType = iota + 1
	//INTERMRDIARY_CA intermediatry ca
	INTERMRDIARY_CA
	//USER_ADMIN admin
	USER_ADMIN
	//USER_CLIENT client
	USER_CLIENT
	//NODE_CONSENSUS consensus
	NODE_CONSENSUS
	//NODE_COMMON common
	NODE_COMMON
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL