db

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2021 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const StatusActive = "active"

StatusActive represents the "active" status

Variables

View Source
var ErrOrganizationNotFound = errors.New("organization not found")

ErrOrganizationNotFound is returned when an organization is not found

Functions

This section is empty.

Types

type Db

type Db interface {
	RegisterEventHandlers(fn events.EventRegistrar)
	FindEndpointsByOrganizationAndType(organizationID core.PartyID, endpointType *string) ([]Endpoint, error)
	SearchOrganizations(query string) []Organization
	OrganizationById(id core.PartyID) (*Organization, error)
	VendorByID(id core.PartyID) *Vendor
	OrganizationsByVendorID(id core.PartyID) []*Organization
	ReverseLookup(name string) (*Organization, error)
}

type Endpoint

type Endpoint struct {
	URL          string            `json:"URL"`
	Organization core.PartyID      `json:"organization"`
	EndpointType string            `json:"endpointType"`
	Identifier   types.EndpointID  `json:"identifier"`
	Status       string            `json:"status"`
	Properties   map[string]string `json:"properties,omitempty"`
}

Endpoint defines component schema for Endpoint.

type MemoryDb

type MemoryDb struct {
	// contains filtered or unexported fields
}

func New

func New() *MemoryDb

func (*MemoryDb) FindEndpointsByOrganizationAndType

func (db *MemoryDb) FindEndpointsByOrganizationAndType(organizationIdentifier core.PartyID, endpointType *string) ([]Endpoint, error)

func (*MemoryDb) OrganizationById

func (db *MemoryDb) OrganizationById(id core.PartyID) (*Organization, error)

func (*MemoryDb) OrganizationsByVendorID

func (db *MemoryDb) OrganizationsByVendorID(id core.PartyID) []*Organization

func (*MemoryDb) RegisterEventHandlers

func (db *MemoryDb) RegisterEventHandlers(fn events.EventRegistrar)

RegisterEventHandlers registers event handlers on this database

func (*MemoryDb) ReverseLookup

func (db *MemoryDb) ReverseLookup(name string) (*Organization, error)

func (*MemoryDb) SearchOrganizations

func (db *MemoryDb) SearchOrganizations(query string) []Organization

func (*MemoryDb) VendorByID

func (db *MemoryDb) VendorByID(id core.PartyID) *Vendor

VendorByID looks up the vendor by the given ID.

type Organization

type Organization struct {
	Identifier core.PartyID `json:"identifier"`
	Vendor     core.PartyID `json:"vendor"`
	Name       string       `json:"name"`
	// Deprecated: use Keys or helper functions to retrieve the current key in use by the organization
	PublicKey *string       `json:"publicKey,omitempty"`
	Keys      []interface{} `json:"keys,omitempty"`
	Endpoints []Endpoint
}

Organization defines component schema for Organization.

func (Organization) CurrentPublicKey

func (o Organization) CurrentPublicKey() (jwk.Key, error)

CurrentPublicKey returns the public key associated with the organization certificate which has the longest validity. For backwards compatibility:

  1. If the organization has no certificates, it will return the first JWK.
  2. If the organization has no JWKs, it will return the (deprecated) PublicKey.

If none of the above conditions are matched, an error is returned.

func (Organization) GetActiveCertificates

func (o Organization) GetActiveCertificates() []*x509.Certificate

func (Organization) HasKey added in v0.13.5

func (o Organization) HasKey(key jwk.Key, validAtMoment time.Time) (bool, error)

HasKey checks whether the given key is owned by the organization

func (Organization) KeysAsSet

func (o Organization) KeysAsSet() (*jwk.Set, error)

KeysAsSet transforms the raw map in Keys to a jwk.Set. If no keys are present, it'll return an empty set

type Vendor

type Vendor struct {
	Identifier core.PartyID  `json:"identifier"`
	Name       string        `json:"name"`
	Domain     string        `json:"domain,omitempty"`
	Keys       []interface{} `json:"keys,omitempty"`
}

Vendor defines component schema for Vendor.

func (Vendor) GetActiveCertificates

func (v Vendor) GetActiveCertificates() []*x509.Certificate

GetActiveCertificates looks up the vendor's certificates and returns them sorted, longest valid certificate first. Expired certificates aren't returned.

Jump to

Keyboard shortcuts

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