identity

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	SerializedIdentityType = "si"
)

Variables

This section is empty.

Functions

func MarshallRawOwner

func MarshallRawOwner(o *RawOwner) (view.Identity, error)

Types

type DeserializeVerifierProvider

type DeserializeVerifierProvider interface {
	DeserializeVerifier(id view.Identity) (driver.Verifier, error)
}

type Deserializer

type Deserializer interface {
	// DeserializeSigner deserializes a signer from its bytes representation
	DeserializeSigner(raw []byte) (driver.Signer, error)
}

Deserializer is an interface for deserializing identities

type EnrollmentIDUnmarshaler

type EnrollmentIDUnmarshaler interface {
	// GetEnrollmentID returns the enrollment ID from the audit info
	GetEnrollmentID(auditInfo []byte) (string, error)
}

EnrollmentIDUnmarshaler decodes an enrollment ID form an audit info

type Info

type Info struct {
	driver.IdentityInfo
	Provider *Provider
}

Info wraps a driver.IdentityInfo to further register the audit info, and binds the new identity to the default FSC node identity

func (*Info) EnrollmentID

func (i *Info) EnrollmentID() string

func (*Info) Get

func (i *Info) Get() (view.Identity, []byte, error)

func (*Info) ID

func (i *Info) ID() string

type KVS

type KVS interface {
	Exists(id string) bool
	Put(id string, state interface{}) error
	Get(id string, state interface{}) error
}

type Provider

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

Provider implements the driver.IdentityProvider interface

func NewProvider

func NewProvider(sp view2.ServiceProvider, enrollmentIDUnmarshaler EnrollmentIDUnmarshaler, wallets Wallets) *Provider

NewProvider creates a new identity provider

func (*Provider) AddDeserializer

func (p *Provider) AddDeserializer(d Deserializer)

func (*Provider) Bind

func (p *Provider) Bind(id view.Identity, to view.Identity) error

func (*Provider) GetAuditInfo

func (p *Provider) GetAuditInfo(identity view.Identity) ([]byte, error)

func (*Provider) GetEnrollmentID

func (p *Provider) GetEnrollmentID(auditInfo []byte) (string, error)

func (*Provider) GetIdentityInfo

func (p *Provider) GetIdentityInfo(role driver.IdentityRole, id string) (driver.IdentityInfo, error)

func (*Provider) GetSigner

func (p *Provider) GetSigner(identity view.Identity) (driver.Signer, error)

func (*Provider) IsMe

func (p *Provider) IsMe(identity view.Identity) bool

func (*Provider) LookupIdentifier

func (p *Provider) LookupIdentifier(role driver.IdentityRole, v interface{}) (view.Identity, string, error)

func (*Provider) RegisterAuditInfo

func (p *Provider) RegisterAuditInfo(id view.Identity, auditInfo []byte) error

func (*Provider) RegisterIssuerWallet

func (p *Provider) RegisterIssuerWallet(id string, path string) error

func (*Provider) RegisterOwnerWallet

func (p *Provider) RegisterOwnerWallet(id string, path string) error

func (*Provider) RegisterRecipientIdentity

func (p *Provider) RegisterRecipientIdentity(id view.Identity) error

func (*Provider) RegisterSigner

func (p *Provider) RegisterSigner(identity view.Identity, signer driver.Signer, verifier driver.Verifier) error

type RawOwner

type RawOwner struct {
	// Type encodes the type of the owner (currently it can only be a SerializedIdentity)
	Type string `protobuf:"bytes,1,opt,name=type,json=type,proto3" json:"type,omitempty"`
	// Identity encodes the identity
	Identity []byte `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"`
}

RawOwner encodes an owner of an identity

func UnmarshallRawOwner

func UnmarshallRawOwner(id view.Identity) (*RawOwner, error)

type RawOwnerIdentityDeserializer

type RawOwnerIdentityDeserializer struct {
	DeserializeVerifierProvider
}

RawOwnerIdentityDeserializer takes as MSP identity and returns an ECDSA verifier

func (*RawOwnerIdentityDeserializer) DeserializeSigner

func (deserializer *RawOwnerIdentityDeserializer) DeserializeSigner(raw []byte) (driver.Signer, error)

func (*RawOwnerIdentityDeserializer) DeserializeVerifier

func (deserializer *RawOwnerIdentityDeserializer) DeserializeVerifier(id view.Identity) (driver.Verifier, error)

func (*RawOwnerIdentityDeserializer) Info

func (deserializer *RawOwnerIdentityDeserializer) Info(raw []byte, auditInfo []byte) (string, error)

type Wallet

type Wallet interface {
	// MapToID returns the identity for the given argument
	MapToID(v interface{}) (view.Identity, string, error)
	// GetIdentityInfo returns the identity information for the given identity identifier
	GetIdentityInfo(id string) driver.IdentityInfo
	// RegisterIdentity registers the given identity
	RegisterIdentity(id string, path string) error
}

Wallet helps to find identity identifiers and retrieve the corresponding identities

type WalletEntry

type WalletEntry struct {
	Prefix string
	Wallet driver.Wallet
}

type Wallets

type Wallets map[driver.IdentityRole]Wallet

Wallets is a map of Wallet, one for each identity role

func NewWallets

func NewWallets() Wallets

NewWallets returns a new Wallets maps

func (Wallets) Put

func (m Wallets) Put(usage driver.IdentityRole, wallet Wallet)

Put associates a wallet to a given identity role

type WalletsRegistry

type WalletsRegistry struct {
	ID               token.TMSID
	IdentityProvider driver.IdentityProvider
	IdentityRole     driver.IdentityRole
	KVS              KVS

	sync.RWMutex
	Wallets map[string]*WalletEntry
}

func NewWalletsRegistry

func NewWalletsRegistry(id token.TMSID, identityProvider driver.IdentityProvider, identityRole driver.IdentityRole, KVS KVS) *WalletsRegistry

NewWalletsRegistry returns a new wallets registry for the passed parameters

func (*WalletsRegistry) ContainsIdentity

func (r *WalletsRegistry) ContainsIdentity(identity view.Identity, wID string) bool

ContainsIdentity returns true if the passed identity belongs to the passed wallet, false otherwise

func (*WalletsRegistry) GetWallet

func (r *WalletsRegistry) GetWallet(identity view.Identity) (string, error)

GetWallet returns the wallet identifier bound to the passed identity

func (*WalletsRegistry) Lookup

func (r *WalletsRegistry) Lookup(id interface{}) (driver.Wallet, driver.IdentityInfo, string, error)

Lookup searches the wallet corresponding to the passed id. If a wallet is found, Lookup returns the wallet and its identifier. If no wallet is found, Lookup returns the identity info and a potential wallet identifier for the passed id. The identity info can be nil meaning that nothing has been found bound to the passed identifier

func (*WalletsRegistry) RegisterIdentity

func (r *WalletsRegistry) RegisterIdentity(identity view.Identity, wID string) error

RegisterIdentity binds the passed identity to the passed wallet identifier

func (*WalletsRegistry) RegisterWallet

func (r *WalletsRegistry) RegisterWallet(id string, w driver.Wallet)

RegisterWallet binds the passed wallet to the passed id

Directories

Path Synopsis
msp

Jump to

Keyboard shortcuts

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