driver

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CommServiceID = reflect.TypeOf((*CommService)(nil))
)

Functions

This section is empty.

Types

type AuditRegistry

type AuditRegistry interface {
	// RegisterAuditInfo binds the passed audit info to the passed identity
	RegisterAuditInfo(identity view.Identity, info []byte) error

	// GetAuditInfo returns the audit info associated to the passed identity, nil if not found
	GetAuditInfo(identity view.Identity) ([]byte, error)
}

AuditRegistry models a repository of identities' audit information

func GetAuditRegistry

func GetAuditRegistry(sp ServiceProvider) AuditRegistry

type CommService added in v0.3.0

type CommService interface {
	Addresses(id view.Identity) ([]string, error)
}

func GetCommService added in v0.3.0

func GetCommService(ctx ServiceProvider) CommService

GetCommService returns an instance of the communication service. It panics, if no instance is found.

type ConfigService

type ConfigService interface {
	// GetString returns the value associated with the key as a string
	GetString(key string) string
	// GetInt returns the value associated with the key as an integer
	GetInt(key string) int
	// GetDuration returns the value associated with the key as a duration
	GetDuration(key string) time.Duration
	// GetBool returns the value associated with the key asa boolean
	GetBool(key string) bool
	// GetStringSlice returns the value associated with the key as a slice of strings
	GetStringSlice(key string) []string
	// IsSet checks to see if the key has been set in any of the data locations
	IsSet(key string) bool
	// UnmarshalKey takes a single key and unmarshals it into a Struct
	UnmarshalKey(key string, rawVal interface{}) error
	// ConfigFileUsed returns the file used to populate the config registry
	ConfigFileUsed() string
	// GetPath allows configuration strings that specify a (config-file) relative path
	GetPath(key string) string
	// TranslatePath translates the passed path relative to the config path
	TranslatePath(path string) string
}

ConfigService models a configuration registry

func GetConfigService

func GetConfigService(sp ServiceProvider) ConfigService

GetConfigService returns an instance of the config service. It panics, if no instance is found.

type DecodeHookFuncType

type DecodeHookFuncType func(reflect.Type, reflect.Type, interface{}) (interface{}, error)

type EndpointService

type EndpointService interface {
	// Endpoint returns the known endpoints bound to the passed identity
	Endpoint(party view.Identity) (map[PortName]string, error)

	// Resolve returns the identity the passed identity is bound to.
	// It returns also: the endpoints and the pkiID
	Resolve(party view.Identity) (view.Identity, map[PortName]string, []byte, error)

	// GetIdentity returns an identity bound to either the passed label or public-key identifier.
	GetIdentity(label string, pkiID []byte) (view.Identity, error)

	// Bind binds b to identity a
	Bind(b view.Identity, a view.Identity) error

	// IsBoundTo returns true if b was bound to a
	IsBoundTo(a view.Identity, b view.Identity) bool

	// AddResolver adds a resolver for tha passed parameters. The passed id can be retrieved by using the passed name in a call to GetIdentity method.
	// The addresses can retrieved by passing the identity in a call to Resolve.
	// If a resolver is already bound to the passed name, then the passed identity is linked to the already existing identity. The already existing
	// identity is returned
	AddResolver(name string, domain string, addresses map[string]string, aliases []string, id []byte) (view.Identity, error)

	// AddPKIResolver add a new PKI resolver
	AddPKIResolver(pkiResolver PKIResolver) error
}

EndpointService models the endpoint service

func GetEndpointService

func GetEndpointService(ctx ServiceProvider) EndpointService

GetEndpointService returns an instance of the endpoint service. It panics, if no instance is found.

type Factory

type Factory interface {
	// NewView returns an instance of the View interface build using the passed argument.
	NewView(in []byte) (view.View, error)
}

Factory is used to create instances of the View interface

type Identity

type Identity interface {
	// Serialize returns the byte representation of this identity
	Serialize() ([]byte, error)

	// Verify verifies the signature over the passed message.
	Verify(message []byte, signature []byte) error
}

type IdentityProvider

type IdentityProvider interface {
	// DefaultIdentity returns the default identity known by this provider
	DefaultIdentity() view.Identity
	// Identity returns the identity bound to the passed label
	Identity(label string) view.Identity
	// Admins returns the identities of the administrators
	Admins() []view.Identity
	// Clients returns the identities of the clients of this node
	Clients() []view.Identity
}

IdentityProvider models the identity provider

func GetIdentityProvider

func GetIdentityProvider(sp ServiceProvider) IdentityProvider

GetIdentityProvider returns an instance of the IdentityProvider interface. It panics, if no instance is found.

type PKIResolver

type PKIResolver interface {
	// GetPKIidOfCert returns the id of the public key contained in the passed identity
	GetPKIidOfCert(peerIdentity view.Identity) []byte
}

PKIResolver extracts public key ids from identities

type PortName

type PortName string

PortName is the type variable for the socket ports

const (
	// ListenPort is the port at which the FSC node might listen for some service
	ListenPort PortName = "Listen"
	// ViewPort is the port on which the View Service Server respond
	ViewPort PortName = "View"
	// P2PPort is the port on which the P2P Communication Layer respond
	P2PPort PortName = "P2P"
)

type Registry

type Registry interface {
	// GetIdentifier returns the identifier of the passed view
	GetIdentifier(f view.View) string

	// RegisterFactory binds an id to a View Factory
	RegisterFactory(id string, factory Factory) error

	// RegisterResponder binds a responder to an initiator.
	// The responder is the view that will be called when the initiator (initiatedBy) contacts the FSC node where
	// this RegisterResponder is invoked.
	// The argument initiatedBy can be a view or a view identifier.
	// If a view is passed, its identifier is computed and used to register the responder.
	RegisterResponder(responder view.View, initiatedBy interface{}) error

	// RegisterResponderWithIdentity binds the pair <responder, id> to an initiator.
	// The responder is the view that will be called when the initiator (initiatedBy) contacts the FSC node where
	// this RegisterResponderWithIdentity is invoked.
	// The argument initiatedBy can be a view or a view identifier.
	// If a view is passed, its identifier is computed and used to register the responder.
	RegisterResponderWithIdentity(responder view.View, id view.Identity, initiatedBy interface{}) error

	// GetResponder returns the responder for the passed initiator.
	GetResponder(initiatedBy interface{}) (view.View, error)
}

Registry keeps track of the available view and view factories

func GetRegistry

func GetRegistry(sp ServiceProvider) Registry

type ServiceProvider

type ServiceProvider interface {
	// GetService returns an instance of the given type
	GetService(v interface{}) (interface{}, error)
}

ServiceProvider is used to return instances of a given type

type Session

type Session interface {
	view.Session
}

Session encapsulates a communication channel to an endpoint

type SigRegistry

type SigRegistry interface {
	// RegisterSigner binds the passed identity to the passed signer and verifier
	RegisterSigner(identity view.Identity, signer Signer, verifier Verifier) error

	// RegisterVerifier binds the passed identity to the passed verifier
	RegisterVerifier(identity view.Identity, verifier Verifier) error
}

func GetSigRegistry

func GetSigRegistry(sp ServiceProvider) SigRegistry

type SigService

type SigService interface {
	// GetSigner returns the signer bound to the passed identity
	GetSigner(identity view.Identity) (Signer, error)

	// GetVerifier returns the verifier bound to the passed identity
	GetVerifier(identity view.Identity) (Verifier, error)

	// GetSigningIdentity returns the signer identity bound to the passed identity
	GetSigningIdentity(identity view.Identity) (SigningIdentity, error)

	// IsMe returns true if a signer was ever registered for the passed identity
	IsMe(identity view.Identity) bool
}

SigService models a repository of sign and verify keys.

func GetSigService

func GetSigService(sp ServiceProvider) SigService

type Signer

type Signer interface {
	// Sign signs message bytes and returns the signature or an error on failure.
	Sign(message []byte) ([]byte, error)
}

Signer is an interface which wraps the Sign method.

type SigningIdentity

type SigningIdentity interface {
	Identity

	// Sign signs message bytes and returns the signature or an error on failure.
	Sign(message []byte) ([]byte, error)

	GetPublicVersion() Identity
}

type Verifier

type Verifier interface {
	// Verify verifies the signature over the passed message.
	Verify(message, sigma []byte) error
}

Verifier is an interface which wraps the Verify method.

type ViewManager

type ViewManager interface {
	// NewView returns a new instance of the view identified by the passed id and on input
	NewView(id string, in []byte) (view.View, error)
	// Context returns the context associated to the passed id, an error if not context is found.
	Context(contextID string) (view.Context, error)
	// InitiateView invokes the passed view and returns the result produced by that view
	InitiateView(view view.View) (interface{}, error)
	// InitiateContext initiates a new context for the passed view
	InitiateContext(view view.View) (view.Context, error)
	// InitiateContextWithIdentityAndID initiates a new context
	InitiateContextWithIdentityAndID(view view.View, id view.Identity, contextID string) (view.Context, error)
}

ViewManager manages the lifecycle of views and contexts

func GetViewManager

func GetViewManager(sp ServiceProvider) ViewManager

GetViewManager returns an instance of the view manager. It panics, if no instance is found.

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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