custodian

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: AGPL-3.0 Imports: 11 Imported by: 0

README

Interfaces and Structures

There is currently one interface (Asset, defined in custodian/asset_model.go) that represents items stored in the Custodian.

The Asset interface has three functions:

  • GetOID() string: returns the OID of the Asset
  • SetOID(OID string): modifies the OID of the Asset
  • String() string: returns a printable version of the Asset

The structures for the contract and the signature are defined in custodian/model_contract.go.

Documentation

To read the documentation you must install godoc. Open a terminal in the custodian/src/core/common folder or one of its subfolders, and run the following command:

godoc -http=localhost:6060

The documentation for the structures and interfaces is accessible at http://localhost:6060/pkg/gitlab.com/data-custodian/custodian-go/models/

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TimeIn

func TimeIn(t time.Time, zone string) time.Time

TimeIn returns the time t encoded for a specific zone (e.g., "UTC")

Types

type Asset

type Asset interface {
	GetOID() string
	SetOID(OID string)
	String() string
}

Asset is an interface used by the Custodian to store objects in the database

type Constraint

type Constraint struct {
	Function             string                 `json:"function"`
	Owner                string                 `json:"owner"`
	ConstraintAttributes map[string]interface{} `json:"constraint_attributes"`
}

type ContractBody

type ContractBody struct {
	OID      string                `json:"id,omitempty" bson:"id"`
	Tag      []Tag                 `json:"tag" bson:"tag"`
	Contract []ContractDescription `json:"contract" bson"contract"`
	Var      []Variable            `json:"var" bson:"var"`
	Subject  []Subject             `json:"subject" bson:"subject"`
	Verb     []Verb                `json:"verb" bson:"verb"`
	Object   []Object              `json:"object" bson:"object"`
	Scope    []Scope               `json:"scope" bson:"scope"`
	Validity Validity              `json:"validity" bson:"validity"`
}

ContractBody is the structure of the contracts used by the Custodian

func (ContractBody) GetOID

func (b ContractBody) GetOID() string

func (ContractBody) Hash

func (b ContractBody) Hash() []byte

func (*ContractBody) SetOID

func (b *ContractBody) SetOID(oid string)

func (ContractBody) String

func (b ContractBody) String() string

type ContractDescription

type ContractDescription struct {
	Language    string   `json:"lang" bson:"lang"`
	Title       string   `json:"title" bson:"title"`
	Description string   `json:"description" bson:"description"` // Human readable
	Check       string   `json:"check" bson:"check"`
	Action      []string `json:"action" bson:"action"`
}

func (ContractDescription) String

func (c ContractDescription) String() string

type ContractString

type ContractString struct {
	OID      string `json:"id" bson:"id" asn1:"printable"`
	Contract string `json:"contract" bson:"contract" asn1:"printable"`
}

ContractString is used to store a contract as a string in the database

func (ContractString) GetOID

func (c ContractString) GetOID() string

func (ContractString) Hash

func (c ContractString) Hash() []byte

func (*ContractString) SetOID

func (c *ContractString) SetOID(oid string)

func (ContractString) String

func (c ContractString) String() string

type Event

type Event struct {
	Unix      int64                  `json:"u"`
	Token     string                 `json:"token"`
	ID        string                 `json:"id"`
	Resource  string                 `json:"resource"`
	Action    string                 `json:"action"`
	Attribute map[string]interface{} `json:"attribute"`
}

type Identity

type Identity struct {
	ID         string           `json:"id"`
	PublicKey  *ecdsa.PublicKey `json:"publicKey"`
	PrivateKey *ecdsa.PrivateKey
}

func (Identity) GetKID

func (id Identity) GetKID() string
type Link struct {
	ID           string `json:"id" bson:"id" asn1:"printable"` // FIXME: OID?
	DigestMethod string `json:"digestMethod" bson:"digestMethod" asn1:"printable"`
	Digest       string `json:"digest" bson:"digest" asn1:"printable"`
}

Link is used to make a reference to a contract or signature.

The digest attribute contains a base4 hash of the contract/signature the link points to.

type Object

type Object struct {
	ID        string                 `json:"id" bson:"id"`
	Owner     string                 `json:"owner" bson:"owner"`
	Attribute map[string]interface{} `json:"attribute" bson:"attribute"`
}

func (Object) String

func (o Object) String() string

type Scope

type Scope struct {
	Subject []string `json:"subject" bson:"subject"`
	Verb    []string `json:"verb" bson:"verb"`
	Object  []string `json:"object" bson:"object"`
}

func (Scope) String

func (s Scope) String() string

type Seal

type Seal struct {
	Signee          string    `json:"signee" bson:"signee" asn1:"printable"`
	Timestamp       time.Time `json:"timestamp" bson:"timestamp" asn1:"generalized"`
	Source          string    `json:"source" bson:"source" asn1:"source"`
	SignatureMethod string    `json:"signatureMethod" bson:"signatureMethod" asn1:"printable"`
	Signature       string    `json:"signature" bson:"signature" asn1:"printable,optional"`
}

Seal is the structure used to store the users digital signatures and their information

func (Seal) String

func (s Seal) String() string

type Signature

type Signature struct {
	OID    string          `json:"id" bson:"id" asn1:"printable"`
	Header SignatureHeader `json:"header" bson:"header"`
	Seal   []Seal          `json:"seal" bson:"seal"`
}

Signature is the structure of the contract signature used by the Custodian.

When a contract requires multiple signatures, the latter are chained using reference links in their header.

func (Signature) ComputeOID

func (s Signature) ComputeOID(timestamp time.Time, signee string) string

func (*Signature) FormatTimestamps

func (s *Signature) FormatTimestamps()

FormatTimestamps converts the seals timestamps to UTC

func (Signature) GetOID

func (s Signature) GetOID() string

func (Signature) Hash

func (s Signature) Hash() ([]byte, error)

Hash returns a hash of the signature

func (Signature) PartialString

func (s Signature) PartialString(index int) string

func (Signature) PreSignatureHash

func (s Signature) PreSignatureHash() ([]byte, error)

PreSignatureHash returns the hash of the signature before we added the last seal's signature attribute

func (*Signature) SetOID

func (s *Signature) SetOID(oid string)

func (Signature) String

func (s Signature) String() string

func (Signature) ToASN1

func (s Signature) ToASN1() ([]byte, error)

type SignatureHeader

type SignatureHeader struct {
	Body Link `json:"body" bson:"body" asn1:"omitempty"`
	Prev Link `json:"prev" bson:"prev" asn1:"omitempty,optional"`
}

SignatureHeader represents the header of the signatures

The header contains a link to the contract body it makes reference to, as well as a link to the previous signature in the chain. If the signature is the first of the chain, the Prev field is empty.

func (SignatureHeader) String

func (h SignatureHeader) String() string

type Subject

type Subject struct {
	ID        string                 `json:"id" bson:"id"`
	Attribute map[string]interface{} `json:"attribute" bson:"attribute"`
}

func (Subject) String

func (s Subject) String() string

type Tag

type Tag struct {
	Name  string `json:"name" bson:"name"`
	Value string `json:"value" bson:"value"`
}

func (Tag) String

func (t Tag) String() string

type TokenClaims

type TokenClaims struct {
	UserID      string       `json:"userid"`
	ClientID    string       `json:"clientid"`
	SignatureID string       `json:"signatureid"`
	Actor       string       `json:"actor"`
	Scope       []string     `json:"scope"`
	Constraints []Constraint `json:"constraints"`
	jwt.StandardClaims
}

type Validity

type Validity struct {
	NotBefore time.Time `json:"notBefore" bson:"notBefore"` // Contract valid from
	NotAfter  time.Time `json:"notAfter" bson:"notAfter"`   // Contract valid until
	Sign      []string  `json:"sign" bson:"sign"`
}

func (Validity) String

func (v Validity) String() string

type Variable

type Variable struct {
	ID     string `json:"id" bson:"id"`
	Value  string `json:"value" bson:"value"`
	Type   string `json:"type" bson:"type"`
	Regexp string `json:"regexp" bson:"regexp"`
}

func (Variable) String

func (v Variable) String() string

type Verb

type Verb struct {
	ID        string                 `json:"id" bson:"id"`
	Function  string                 `json:"function" bson:"function"`
	Attribute map[string]interface{} `json:"attribute" bson:"attribute"`
}

func (Verb) String

func (v Verb) String() string

Jump to

Keyboard shortcuts

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