pkg

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: 32 Imported by: 9

Documentation

Overview

* Nuts registry * Copyright (C) 2020. Nuts community * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. *

* Nuts registry * Copyright (C) 2020. Nuts community * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. *

* Nuts registry * Copyright (C) 2020. Nuts community * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. *

Index

Constants

View Source
const ConfAddress = "address"

ConfAddress is the config name for the http server/client address

View Source
const ConfClientTimeout = "clientTimeout"

ConfClientTimeout is the time-out for the client in seconds (e.g. when using the CLI).

View Source
const ConfDataDir = "datadir"

ConfDataDir is the config name for specifiying the data location of the requiredFiles

View Source
const ConfMode = "mode"

ConfMode is the config name for the engine mode, server or client

View Source
const ConfOrganisationCertificateValidity = "organisationCertificateValidity"

ConfOrganisationCertificateValidity is the config name for the number of days organisation certificates are valid

View Source
const ConfSyncAddress = "syncAddress"

ConfSyncAddress is the config name for the remote address used to fetch updated registry files

View Source
const ConfSyncInterval = "syncInterval"

ConfSyncInterval is the config name for the interval in minutes to look for new registry files online

View Source
const ConfSyncMode = "syncMode"

ConfSyncMode is the config name for the used SyncMode

View Source
const ConfVendorCACertificateValidity = "vendorCACertificateValidity"

ConfVendorCACertificateValidity is the config name for the number of days vendor CA certificates are valid

View Source
const ModuleName = "Registry"

ModuleName == Registry

Variables

View Source
var ErrCertificateIssue = errors.New("unable to issue certificate")

ErrCertificateIssue indicates a certificate couldn't be issued

View Source
var ErrJWKConstruction = errors.New("unable to construct JWK")

ErrJWKConstruction indicates that a JWK couldn't be constructed

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

ErrOrganizationNotFound is returned when the specified organization was not found

View Source
var ErrVendorNotFound = errors.New("vendor not found")

ErrVendorNotFound is returned when a vendor is not found based on its ID

View Source
var ReloadRegistryIdleTimeout time.Duration

ReloadRegistryIdleTimeout defines the cooling down period after receiving a file watcher notification, before the registry is reloaded (from disk).

Functions

This section is empty.

Types

type Registry

type Registry struct {
	Config      RegistryConfig
	Db          db.Db
	EventSystem events.EventSystem

	OnChange func(registry *Registry)
	// contains filtered or unexported fields
}

Registry holds the config and Db reference

func NewRegistryInstance added in v0.15.0

func NewRegistryInstance(config RegistryConfig, cryptoClient crypto.Client, networkClient pkg.NetworkClient) *Registry

func NewTestRegistryInstance added in v0.15.0

func NewTestRegistryInstance(testDirectory string) *Registry

func RegistryInstance

func RegistryInstance() *Registry

RegistryInstance returns the singleton Registry

func (*Registry) Configure

func (r *Registry) Configure() error

Configure initializes the db, but only when in server mode

func (*Registry) Diagnostics added in v0.15.0

func (r *Registry) Diagnostics() []core.DiagnosticResult

func (*Registry) EndpointsByOrganizationAndType

func (r *Registry) EndpointsByOrganizationAndType(organizationIdentifier core.PartyID, endpointType *string) ([]db.Endpoint, error)

EndpointsByOrganization is a wrapper for sam func on DB

func (*Registry) Load

func (r *Registry) Load() error

Load signals the Db to (re)load sources. On success the OnChange func is called

func (*Registry) OrganizationById

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

OrganizationById is a wrapper for sam func on DB

func (*Registry) RefreshOrganizationCertificate added in v0.14.0

func (r *Registry) RefreshOrganizationCertificate(organizationID core.PartyID) (events.Event, error)

func (*Registry) RegisterEndpoint

func (r *Registry) RegisterEndpoint(organizationID core.PartyID, id string, url string, endpointType string, status string, properties map[string]string) (events.Event, error)

RegisterEndpoint registers an endpoint for an organization

func (*Registry) RegisterVendor

func (r *Registry) RegisterVendor(certificate *x509.Certificate) (events.Event, error)

RegisterVendor registers a vendor

func (*Registry) ReverseLookup

func (r *Registry) ReverseLookup(name string) (*db.Organization, error)

func (*Registry) SearchOrganizations

func (r *Registry) SearchOrganizations(query string) ([]db.Organization, error)

SearchOrganizations is a wrapper for sam func on DB

func (*Registry) Shutdown

func (r *Registry) Shutdown() error

Shutdown cleans up any leftover go routines

func (*Registry) Start

func (r *Registry) Start() error

Start initiates the routines for auto-updating the data

func (*Registry) VendorById added in v0.15.1

func (r *Registry) VendorById(id core.PartyID) (*db.Vendor, error)

func (*Registry) VendorCAs added in v0.15.0

func (r *Registry) VendorCAs() [][]*x509.Certificate

func (*Registry) VendorClaim

func (r *Registry) VendorClaim(orgID core.PartyID, orgName string, orgKeys []interface{}) (events.Event, error)

VendorClaim registers an organization under a vendor. The specified vendor has to exist and have a valid CA certificate as to issue the organisation certificate. If specified orgKeys are interpreted as the organization's keys in JWK format. If not specified, a new key pair is generated.

func (*Registry) Verify added in v0.14.0

func (r *Registry) Verify(fix bool) ([]events.Event, bool, error)

type RegistryClient

type RegistryClient interface {
	// EndpointsByOrganization returns all registered endpoints for an organization
	EndpointsByOrganizationAndType(organizationIdentifier core.PartyID, endpointType *string) ([]db.Endpoint, error)

	// SearchOrganizations searches the registry for any Organization matching the given query
	SearchOrganizations(query string) ([]db.Organization, error)

	// OrganizationById returns an Organization given the Id or an error if it doesn't exist
	OrganizationById(id core.PartyID) (*db.Organization, error)

	// ReverseLookup finds an exact match on name or returns an error if not found
	ReverseLookup(name string) (*db.Organization, error)

	// RegisterEndpoint registers an endpoint for an organization
	RegisterEndpoint(organizationID core.PartyID, id string, url string, endpointType string, status string, properties map[string]string) (events.Event, error)

	// VendorClaim registers an organization under a vendor. orgKeys are the organization's keys in JWK format
	VendorClaim(orgID core.PartyID, orgName string, orgKeys []interface{}) (events.Event, error)

	// RegisterVendor registers a vendor with the given id, name for the specified domain. If the vendor with this ID
	// already exists, it functions as an update.
	RegisterVendor(certificate *x509.Certificate) (events.Event, error)

	// RefreshOrganizationCertificate issues a new certificate for the organization. The organization must be registered under the current vendor.
	// If successful it returns the resulting event.
	RefreshOrganizationCertificate(organizationID core.PartyID) (events.Event, error)

	// Verify verifies the data in the registry owned by this node.
	// If fix=true, data will be fixed/upgraded when necessary (e.g. issue certificates). Events resulting from fixing the data are returned.
	// If the returned bool=true there's data to be fixed and Verify should be run with fix=true.
	Verify(fix bool) ([]events.Event, bool, error)

	// VendorCAs returns all registered vendors as list of chains, PEM encoded. The first entry in a chain will be the leaf and the last one the root.
	VendorCAs() [][]*x509.Certificate

	// VendorById finds a vendor by its ID. When not found it returns an ErrVendorNotFound error and a nil result.
	VendorById(vID core.PartyID) (*db.Vendor, error)
}

RegistryClient is the interface to be implemented by any remote or local client

type RegistryConfig

type RegistryConfig struct {
	Mode                            string
	SyncMode                        string
	SyncAddress                     string
	SyncInterval                    int
	Datadir                         string
	Address                         string
	VendorCACertificateValidity     int
	OrganisationCertificateValidity int
	ClientTimeout                   int
}

RegistryConfig holds the config

func DefaultRegistryConfig added in v0.14.1

func DefaultRegistryConfig() RegistryConfig

func TestRegistryConfig added in v0.15.0

func TestRegistryConfig(testDirectory string) RegistryConfig

Directories

Path Synopsis
* Nuts registry * Copyright (C) 2020.
* Nuts registry * Copyright (C) 2020.
* Nuts registry * Copyright (C) 2020.
* Nuts registry * Copyright (C) 2020.
domain
* Nuts registry * Copyright (C) 2020.
* Nuts registry * Copyright (C) 2020.
* Nuts registry * Copyright (C) 2020.
* Nuts registry * Copyright (C) 2020.
nextgen
* Nuts registry * Copyright (C) 2020.
* Nuts registry * Copyright (C) 2020.

Jump to

Keyboard shortcuts

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