utils

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BaseURL = "http://127.0.0.1:1317"
)

Variables

This section is empty.

Functions

func BuildURL

func BuildURL(uri string) string

func GetCertifiedModel

func GetCertifiedModel(vid uint16, pid uint16, softwareVersion uint32,
	certificationType compliance.CertificationType) (compliance.ComplianceInfoInState, int)

func GetComplianceInfo

func GetComplianceInfo(vid uint16, pid uint16, softwareVersion uint32,
	certificationType compliance.CertificationType) (compliance.ComplianceInfo, int)

func GetModel

func GetModel(vid uint16, pid uint16) (model.Model, int)

func GetModelVersion

func GetModelVersion(vid uint16, pid uint16, softwareVersion uint32) (model.ModelVersion, int)

func GetProposedX509RootCert

func GetProposedX509RootCert(subject string, subjectKeyID string) (pki.ProposedCertificate, int)

func GetProposedX509RootCertToRevoke

func GetProposedX509RootCertToRevoke(subject string, subjectKeyID string) (pki.ProposedCertificateRevocation, int)

func GetRevokedModel

func GetRevokedModel(vid uint16, pid uint16, softwareVersion uint32,
	certificationType compliance.CertificationType) (compliance.ComplianceInfoInState, int)

func GetRevokedX509Cert

func GetRevokedX509Cert(subject string, subjectKeyID string) (pki.Certificate, int)

func GetTestingResult

func GetTestingResult(vid uint16, pid uint16, softwareVersion uint32) (compliancetest.TestingResults, int)

func GetVendorModels

func GetVendorModels(vid uint16) (model.VendorProducts, int)

func GetX509Cert

func GetX509Cert(subject string, subjectKeyID string) (pki.Certificate, int)

func GetX509CertChain

func GetX509CertChain(subject string, subjectKeyID string) (pki.Certificates, int)

func NewMsgAddModel

func NewMsgAddModel(owner sdk.AccAddress, vid uint16) model.MsgAddModel

func NewMsgAddModelVersion

func NewMsgAddModelVersion(vid uint16, pid uint16,
	softwareVersion uint32, softwareVersionString string, owner sdk.AccAddress) model.MsgAddModelVersion

func NewMsgAddTestingResult

func NewMsgAddTestingResult(vid uint16, pid uint16,
	softwareVersion uint32, softwareVersionString string,
	owner sdk.AccAddress) compliancetest.MsgAddTestingResult

func NewMsgUpdateModel

func NewMsgUpdateModel(vid uint16, pid uint16, owner sdk.AccAddress) model.MsgUpdateModel

func NewMsgUpdateModelVersion

func NewMsgUpdateModelVersion(vid uint16, pid uint16,
	softwareVersion uint32, softwareVersionString string, owner sdk.AccAddress) model.MsgUpdateModelVersion

func ParseUint

func ParseUint(num string) uint64

func PrepareAddModelTransaction

func PrepareAddModelTransaction(model model.MsgAddModel) (types.StdTx, int)

func PrepareAddModelVersionTransaction

func PrepareAddModelVersionTransaction(modelVersion model.MsgAddModelVersion) (types.StdTx, int)

func PrepareAddX509CertTransaction

func PrepareAddX509CertTransaction(addX509Cert pki.MsgAddX509Cert) (types.StdTx, int)

func PrepareApproveAddX509RootCertTransaction

func PrepareApproveAddX509RootCertTransaction(
	approveAddX509RootCert pki.MsgApproveAddX509RootCert) (types.StdTx, int)

func PrepareApproveRevokeX509RootCertTransaction

func PrepareApproveRevokeX509RootCertTransaction(
	approveRevokeX509RootCert pki.MsgApproveRevokeX509RootCert) (types.StdTx, int)

func PrepareCertifiedModelTransaction

func PrepareCertifiedModelTransaction(certifyModel compliance.MsgCertifyModel) (types.StdTx, int)

func PrepareProposeAddX509RootCertTransaction

func PrepareProposeAddX509RootCertTransaction(proposeAddX509RootCert pki.MsgProposeAddX509RootCert) (types.StdTx, int)

func PrepareProposeRevokeX509RootCertTransaction

func PrepareProposeRevokeX509RootCertTransaction(
	proposeRevokeX509RootCert pki.MsgProposeRevokeX509RootCert) (types.StdTx, int)

func PrepareRevokeX509CertTransaction

func PrepareRevokeX509CertTransaction(revokeX509Cert pki.MsgRevokeX509Cert) (types.StdTx, int)

func PrepareRevokedModelTransaction

func PrepareRevokedModelTransaction(revokeModel compliance.MsgRevokeModel) (types.StdTx, int)

func PrepareTestingResultTransaction

func PrepareTestingResultTransaction(testingResult compliancetest.MsgAddTestingResult) (types.StdTx, int)

func PrepareUpdateModelTransaction

func PrepareUpdateModelTransaction(model model.MsgUpdateModel) (types.StdTx, int)

func PrepareUpdateModelVersionTransaction

func PrepareUpdateModelVersionTransaction(modelVersion model.MsgUpdateModelVersion) (types.StdTx, int)

func RandString

func RandString() string

func ReadResponseBody

func ReadResponseBody(resp *http.Response) []byte

func SendAddModelRequest

func SendAddModelRequest(msgAddModel model.MsgAddModel, account string) ([]byte, int)

func SendAddModelVersionRequest

func SendAddModelVersionRequest(msgAddModelVersion model.MsgAddModelVersion, account string) ([]byte, int)

func SendAddX509CertRequest

func SendAddX509CertRequest(addX509Cert pki.MsgAddX509Cert, account string, passphrase string) ([]byte, int)

func SendApproveAddX509RootCertRequest

func SendApproveAddX509RootCertRequest(approveAddX509RootCert pki.MsgApproveAddX509RootCert,
	account string, passphrase string) ([]byte, int)

func SendApproveRevokeX509RootCertRequest

func SendApproveRevokeX509RootCertRequest(approveRevokeX509RootCert pki.MsgApproveRevokeX509RootCert,
	account string, passphrase string) ([]byte, int)

func SendCertifiedModelRequest

func SendCertifiedModelRequest(certifyModel compliance.MsgCertifyModel, name string) ([]byte, int)

func SendDeleteRequest

func SendDeleteRequest(uri string, body []byte, account string, passphrase string) ([]byte, int)

func SendGetRequest

func SendGetRequest(uri string) ([]byte, int)

func SendPatchRequest

func SendPatchRequest(uri string, body []byte, account string, passphrase string) ([]byte, int)

func SendPostRequest

func SendPostRequest(uri string, body []byte, account string, passphrase string) ([]byte, int)

func SendProposeAddX509RootCertRequest

func SendProposeAddX509RootCertRequest(proposeAddX509RootCert pki.MsgProposeAddX509RootCert,
	account string, passphrase string) ([]byte, int)

func SendProposeRevokeX509RootCertRequest

func SendProposeRevokeX509RootCertRequest(proposeRevokeX509RootCert pki.MsgProposeRevokeX509RootCert,
	account string, passphrase string) ([]byte, int)

func SendPutRequest

func SendPutRequest(uri string, body []byte, account string, passphrase string) ([]byte, int)

func SendRevokeX509CertRequest

func SendRevokeX509CertRequest(revokeX509Cert pki.MsgRevokeX509Cert, account string, passphrase string) ([]byte, int)

func SendRevokedModelRequest

func SendRevokedModelRequest(revokeModel compliance.MsgRevokeModel, name string) ([]byte, int)

func SendTestingResultRequest

func SendTestingResultRequest(testingResult compliancetest.MsgAddTestingResult, name string) ([]byte, int)

func SendUpdateModelRequest

func SendUpdateModelRequest(msgUpdateModel model.MsgUpdateModel, account string) ([]byte, int)

func SendUpdateModelVersionRequest

func SendUpdateModelVersionRequest(msgUpdateModelVersion model.MsgUpdateModelVersion, account string) ([]byte, int)

func SignMessage

func SignMessage(sender KeyInfo, txn types.StdTx) (json.RawMessage, int)

Types

type AccountHeadersResult

type AccountHeadersResult struct {
	Total string        `json:"total"`
	Items []AccountInfo `json:"items"`
}

func GetAccounts

func GetAccounts() (AccountHeadersResult, int)

type AccountInfo

type AccountInfo struct {
	Address       sdk.AccAddress    `json:"address"`
	AccountNumber string            `json:"account_number"`
	Sequence      string            `json:"sequence"`
	Roles         auth.AccountRoles `json:"roles"`
}

func GetAccount

func GetAccount(address sdk.AccAddress) (AccountInfo, int)

type CertificatesHeadersResult

type CertificatesHeadersResult struct {
	Total string            `json:"total"`
	Items []pki.Certificate `json:"items"`
}

func GetAllRevokedX509Certs

func GetAllRevokedX509Certs() (CertificatesHeadersResult, int)

func GetAllRevokedX509RootCerts

func GetAllRevokedX509RootCerts() (CertificatesHeadersResult, int)

func GetAllSubjectX509Certs

func GetAllSubjectX509Certs(subject string) (CertificatesHeadersResult, int)

func GetAllX509Certs

func GetAllX509Certs() (CertificatesHeadersResult, int)

func GetAllX509RootCerts

func GetAllX509RootCerts() (CertificatesHeadersResult, int)

type ComplianceInfosHeadersResult

type ComplianceInfosHeadersResult struct {
	Total string                      `json:"total"`
	Items []compliance.ComplianceInfo `json:"items"`
}

func GetAllCertifiedModels

func GetAllCertifiedModels() (ComplianceInfosHeadersResult, int)

func GetAllComplianceInfos

func GetAllComplianceInfos(state string) (ComplianceInfosHeadersResult, int)

func GetAllRevokedModels

func GetAllRevokedModels() (ComplianceInfosHeadersResult, int)

func GetComplianceInfos

func GetComplianceInfos() (ComplianceInfosHeadersResult, int)

type KeyInfo

type KeyInfo struct {
	Name      string         `json:"name"`
	Type      string         `json:"type"`
	Address   sdk.AccAddress `json:"address"`
	PublicKey string         `json:"pubkey"`
}

func CreateKey

func CreateKey(accountName string) (KeyInfo, int)

func CreateNewAccount

func CreateNewAccount(roles auth.AccountRoles, vendorID uint16) KeyInfo

func GetKeyInfo

func GetKeyInfo(accountName string) (KeyInfo, int)

type ModelHeadersResult

type ModelHeadersResult struct {
	Total string            `json:"total"`
	Items []model.ModelItem `json:"items"`
}

func GetModels

func GetModels() (ModelHeadersResult, int)

type PendingAccountInfo

type PendingAccountInfo struct {
	Address   sdk.AccAddress    `json:"address"`
	Roles     auth.AccountRoles `json:"roles"`
	Approvals []sdk.AccAddress  `json:"approvals"`
}

type ProposedAccountHeadersResult

type ProposedAccountHeadersResult struct {
	Total string               `json:"total"`
	Items []PendingAccountInfo `json:"items"`
}

func GetProposedAccounts

func GetProposedAccounts() (ProposedAccountHeadersResult, int)

type ProposedAccountToRevokeHeadersResult

type ProposedAccountToRevokeHeadersResult struct {
	Total string                          `json:"total"`
	Items []auth.PendingAccountRevocation `json:"items"`
}

func GetProposedAccountsToRevoke

func GetProposedAccountsToRevoke() (ProposedAccountToRevokeHeadersResult, int)

type ProposedCertificateRevocationsHeadersResult

type ProposedCertificateRevocationsHeadersResult struct {
	Total string                              `json:"total"`
	Items []pki.ProposedCertificateRevocation `json:"items"`
}

func GetAllProposedX509RootCertsToRevoke

func GetAllProposedX509RootCertsToRevoke() (ProposedCertificateRevocationsHeadersResult, int)

type ProposedCertificatesHeadersResult

type ProposedCertificatesHeadersResult struct {
	Total string                    `json:"total"`
	Items []pki.ProposedCertificate `json:"items"`
}

func GetAllProposedX509RootCerts

func GetAllProposedX509RootCerts() (ProposedCertificatesHeadersResult, int)

type ResponseWrapper

type ResponseWrapper struct {
	Height string          `json:"height"`
	Result json.RawMessage `json:"result"`
}

type TxnResponse

type TxnResponse struct {
	Height string `json:"height"`
	TxHash string `json:"txhash"`
	Code   int    `json:"code"`
}

func AddModel

func AddModel(model model.MsgAddModel, sender KeyInfo) (TxnResponse, int)

func AddModelVersion

func AddModelVersion(modelVersion model.MsgAddModelVersion, sender KeyInfo) (TxnResponse, int)

func AddX509Cert

func AddX509Cert(addX509Cert pki.MsgAddX509Cert, account string, passphrase string) (TxnResponse, int)

func ApproveAddAccount

func ApproveAddAccount(keyInfo KeyInfo, signer KeyInfo) (TxnResponse, int)

func ApproveAddX509RootCert

func ApproveAddX509RootCert(approveAddX509RootCert pki.MsgApproveAddX509RootCert,
	account string, passphrase string) (TxnResponse, int)

func ApproveRevokeAccount

func ApproveRevokeAccount(keyInfo KeyInfo, signer KeyInfo) (TxnResponse, int)

func ApproveRevokeX509RootCert

func ApproveRevokeX509RootCert(approveRevokeX509RootCert pki.MsgApproveRevokeX509RootCert,
	account string, passphrase string) (TxnResponse, int)

func BroadcastMessage

func BroadcastMessage(message interface{}) (TxnResponse, int)

func ProposeAddAccount

func ProposeAddAccount(keyInfo KeyInfo, signer KeyInfo, roles auth.AccountRoles, vendorID uint16) (TxnResponse, int)

func ProposeAddX509RootCert

func ProposeAddX509RootCert(proposeAddX509RootCert pki.MsgProposeAddX509RootCert,
	account string, passphrase string) (TxnResponse, int)

func ProposeRevokeAccount

func ProposeRevokeAccount(keyInfo KeyInfo, signer KeyInfo) (TxnResponse, int)

func ProposeRevokeX509RootCert

func ProposeRevokeX509RootCert(proposeRevokeX509RootCert pki.MsgProposeRevokeX509RootCert,
	account string, passphrase string) (TxnResponse, int)

func PublishCertifiedModel

func PublishCertifiedModel(certifyModel compliance.MsgCertifyModel, sender KeyInfo) (TxnResponse, int)

func PublishRevokedModel

func PublishRevokedModel(revokeModel compliance.MsgRevokeModel, sender KeyInfo) (TxnResponse, int)

func PublishTestingResult

func PublishTestingResult(testingResult compliancetest.MsgAddTestingResult, sender KeyInfo) (TxnResponse, int)

func RevokeX509Cert

func RevokeX509Cert(revokeX509Cert pki.MsgRevokeX509Cert, account string, passphrase string) (TxnResponse, int)

func SignAndBroadcastMessage

func SignAndBroadcastMessage(sender KeyInfo, message sdk.Msg) (TxnResponse, int)

func SignAndBroadcastTransaction

func SignAndBroadcastTransaction(sender KeyInfo, txn types.StdTx) (TxnResponse, int)

func UpdateModel

func UpdateModel(model model.MsgUpdateModel, sender KeyInfo) (TxnResponse, int)

func UpdateModelVersion

func UpdateModelVersion(modelVersion model.MsgUpdateModelVersion, sender KeyInfo) (TxnResponse, int)

type VendorItemHeadersResult

type VendorItemHeadersResult struct {
	Total string             `json:"total"`
	Items []model.VendorItem `json:"items"`
}

func GetVendors

func GetVendors() (VendorItemHeadersResult, int)

Jump to

Keyboard shortcuts

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