...

Package server

import "github.com/hyperledger/fabric/token/server"
Overview
Index
Subdirectories

Overview ▾

Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0

Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0

Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0

Index ▾

func UnmarshalCommand(raw []byte) (*token.Command, error)
type ACLProvider
type ACLResources
type CapabilityChecker
type Issuer
type Manager
    func (manager *Manager) GetIssuer(channel string, privateCredential, publicCredential []byte) (Issuer, error)
    func (manager *Manager) GetTransactor(channel string, privateCredential, publicCredential []byte) (Transactor, error)
type Marshaler
type PeerLedgerManager
    func (*PeerLedgerManager) GetLedgerReader(channel string) (ledger.LedgerReader, error)
type PolicyBasedAccessControl
    func (ac *PolicyBasedAccessControl) Check(sc *token.SignedCommand, c *token.Command) error
type PolicyChecker
type Prover
    func NewProver(policyChecker PolicyChecker, signingIdentity SignerIdentity) (*Prover, error)
    func (s *Prover) ListUnspentTokens(ctxt context.Context, header *token.Header, listRequest *token.ListRequest) (*token.CommandResponse_UnspentTokens, error)
    func (s *Prover) MarshalErrorResponse(command []byte, e error) (*token.SignedCommandResponse, error)
    func (s *Prover) ProcessCommand(ctx context.Context, sc *token.SignedCommand) (*token.SignedCommandResponse, error)
    func (s *Prover) RequestApprove(ctx context.Context, header *token.Header, request *token.ApproveRequest) (*token.CommandResponse_TokenTransaction, error)
    func (s *Prover) RequestExpectation(ctx context.Context, header *token.Header, request *token.ExpectationRequest) (*token.CommandResponse_TokenTransaction, error)
    func (s *Prover) RequestImport(ctx context.Context, header *token.Header, requestImport *token.ImportRequest) (*token.CommandResponse_TokenTransaction, error)
    func (s *Prover) RequestRedeem(ctx context.Context, header *token.Header, request *token.RedeemRequest) (*token.CommandResponse_TokenTransaction, error)
    func (s *Prover) RequestTransfer(ctx context.Context, header *token.Header, request *token.TransferRequest) (*token.CommandResponse_TokenTransaction, error)
    func (s *Prover) RequestTransferFrom(ctx context.Context, header *token.Header, request *token.TransferRequest) (*token.CommandResponse_TokenTransaction, error)
    func (s *Prover) ValidateHeader(header *token.Header) error
type ResponseMarshaler
    func NewResponseMarshaler(signerID SignerIdentity) (*ResponseMarshaler, error)
    func (s *ResponseMarshaler) MarshalCommandResponse(command []byte, responsePayload interface{}) (*token.SignedCommandResponse, error)
type Signer
type SignerIdentity
type TMSManager
type TimeFunc
type TokenCapabilityChecker
    func (c *TokenCapabilityChecker) FabToken(channelId string) (bool, error)
type Transactor

Package files

accesscontrol.go capability_checker.go ledgermanager.go manager.go marshal.go msp.go prover.go tms.go

func UnmarshalCommand

func UnmarshalCommand(raw []byte) (*token.Command, error)

UnmarshalCommand unmarshal token.Command messages

type ACLProvider

type ACLProvider interface {
    // CheckACL checks access control for the resource for the given channel.
    // idinfo is an object such as []*common.SignedData from which
    // an id can be extracted for testing against a policy
    CheckACL(resName string, channelID string, idinfo interface{}) error
}

type ACLResources

type ACLResources struct {
    IssueTokens    string
    TransferTokens string
    ListTokens     string
}

type CapabilityChecker

CapabilityChecker is used to check whether or not a channel supports token functions.

type CapabilityChecker interface {
    FabToken(channelId string) (bool, error)
}

type Issuer

An Issuer creates token import requests.

type Issuer interface {
    // Issue creates an import request transaction.
    RequestImport(tokensToIssue []*token.TokenToIssue) (*token.TokenTransaction, error)

    // RequestExpectation allows indirect import based on the expectation.
    // It creates a token transaction with the outputs as specified in the expectation.
    RequestExpectation(request *token.ExpectationRequest) (*token.TokenTransaction, error)
}

type Manager

Manager implements token/server/TMSManager interface TODO: it will be updated after lscc-baased tms configuration is available

type Manager struct {
    LedgerManager ledger.LedgerManager
}

func (*Manager) GetIssuer

func (manager *Manager) GetIssuer(channel string, privateCredential, publicCredential []byte) (Issuer, error)

For now it returns a plain issuer. After lscc-based tms configuration is available, it will be updated to return an issuer configured for the specific channel

func (*Manager) GetTransactor

func (manager *Manager) GetTransactor(channel string, privateCredential, publicCredential []byte) (Transactor, error)

GetTransactor returns a Transactor bound to the passed channel and whose credential is the tuple (privateCredential, publicCredential).

type Marshaler

A Marshaler is responsible for marshaling and signging command responses.

type Marshaler interface {
    MarshalCommandResponse(command []byte, responsePayload interface{}) (*token.SignedCommandResponse, error)
}

type PeerLedgerManager

PeerLedgerManager implements the LedgerManager interface by using the peer infrastructure

type PeerLedgerManager struct {
}

func (*PeerLedgerManager) GetLedgerReader

func (*PeerLedgerManager) GetLedgerReader(channel string) (ledger.LedgerReader, error)

type PolicyBasedAccessControl

PolicyBasedAccessControl implements token command access control functions.

type PolicyBasedAccessControl struct {
    ACLProvider  ACLProvider
    ACLResources *ACLResources
}

func (*PolicyBasedAccessControl) Check

func (ac *PolicyBasedAccessControl) Check(sc *token.SignedCommand, c *token.Command) error

type PolicyChecker

A PolicyChecker is responsible for performing policy based access control checks related to token commands.

type PolicyChecker interface {
    Check(sc *token.SignedCommand, c *token.Command) error
}

type Prover

A Provider is responslble for processing token commands.

type Prover struct {
    CapabilityChecker CapabilityChecker
    Marshaler         Marshaler
    PolicyChecker     PolicyChecker
    TMSManager        TMSManager
}

func NewProver

func NewProver(policyChecker PolicyChecker, signingIdentity SignerIdentity) (*Prover, error)

NewProver creates a Prover

func (*Prover) ListUnspentTokens

func (s *Prover) ListUnspentTokens(ctxt context.Context, header *token.Header, listRequest *token.ListRequest) (*token.CommandResponse_UnspentTokens, error)

func (*Prover) MarshalErrorResponse

func (s *Prover) MarshalErrorResponse(command []byte, e error) (*token.SignedCommandResponse, error)

func (*Prover) ProcessCommand

func (s *Prover) ProcessCommand(ctx context.Context, sc *token.SignedCommand) (*token.SignedCommandResponse, error)

func (*Prover) RequestApprove

func (s *Prover) RequestApprove(ctx context.Context, header *token.Header, request *token.ApproveRequest) (*token.CommandResponse_TokenTransaction, error)

func (*Prover) RequestExpectation

func (s *Prover) RequestExpectation(ctx context.Context, header *token.Header, request *token.ExpectationRequest) (*token.CommandResponse_TokenTransaction, error)

RequestExpectation gets an issuer or transactor and creates a token transaction response for import, transfer or redemption.

func (*Prover) RequestImport

func (s *Prover) RequestImport(ctx context.Context, header *token.Header, requestImport *token.ImportRequest) (*token.CommandResponse_TokenTransaction, error)

func (*Prover) RequestRedeem

func (s *Prover) RequestRedeem(ctx context.Context, header *token.Header, request *token.RedeemRequest) (*token.CommandResponse_TokenTransaction, error)

func (*Prover) RequestTransfer

func (s *Prover) RequestTransfer(ctx context.Context, header *token.Header, request *token.TransferRequest) (*token.CommandResponse_TokenTransaction, error)

func (*Prover) RequestTransferFrom

func (s *Prover) RequestTransferFrom(ctx context.Context, header *token.Header, request *token.TransferRequest) (*token.CommandResponse_TokenTransaction, error)

func (*Prover) ValidateHeader

func (s *Prover) ValidateHeader(header *token.Header) error

type ResponseMarshaler

ResponseMarshaler produces token.SignedCommandResponse

type ResponseMarshaler struct {
    Signer  Signer
    Creator []byte
    Time    TimeFunc
}

func NewResponseMarshaler

func NewResponseMarshaler(signerID SignerIdentity) (*ResponseMarshaler, error)

func (*ResponseMarshaler) MarshalCommandResponse

func (s *ResponseMarshaler) MarshalCommandResponse(command []byte, responsePayload interface{}) (*token.SignedCommandResponse, error)

type Signer

type Signer interface {
    // Sign signs the given payload and returns a signature
    Sign([]byte) ([]byte, error)
}

type SignerIdentity

SignerIdentity signs messages and serializes its public identity to bytes

type SignerIdentity interface {
    Signer

    // Serialize returns a byte representation of this identity which is used to verify
    // messages signed by this SignerIdentity
    Serialize() ([]byte, error)
}

type TMSManager

type TMSManager interface {
    // GetIssuer returns an Issuer bound to the passed channel and whose credential
    // is the tuple (privateCredential, publicCredential).
    GetIssuer(channel string, privateCredential, publicCredential []byte) (Issuer, error)

    // GetTransactor returns a Transactor bound to the passed channel and whose credential
    // is the tuple (privateCredential, publicCredential).
    GetTransactor(channel string, privateCredential, publicCredential []byte) (Transactor, error)
}

type TimeFunc

type TimeFunc func() time.Time

type TokenCapabilityChecker

TokenCapabilityChecker implements CapabilityChecker interface

type TokenCapabilityChecker struct {
    PeerOps peer.Operations
}

func (*TokenCapabilityChecker) FabToken

func (c *TokenCapabilityChecker) FabToken(channelId string) (bool, error)

type Transactor

Transactor allows to operate on issued tokens

type Transactor interface {
    // RequestTransfer Create data associated to the transfer of a token assuming
    // an application-level identity. The inTokens bytes are the identifiers
    // of the outputs, the details of which need to be looked up from the ledger.
    RequestTransfer(request *token.TransferRequest) (*token.TokenTransaction, error)

    // RequestRedeem allows the redemption of the tokens in the input tokenIds
    // It queries the ledger to read detail for each token id.
    // It creates a token transaction with an output for redeemed tokens and
    // possibly another output to transfer the remaining tokens, if any, to the creator
    RequestRedeem(request *token.RedeemRequest) (*token.TokenTransaction, error)

    // ListTokens returns a slice of unspent tokens owned by this transactor
    ListTokens() (*token.UnspentTokens, error)

    // RequestApprove creates a token transaction that includes the data necessary
    // for approve
    RequestApprove(request *token.ApproveRequest) (*token.TokenTransaction, error)

    // RequestTransferFrom creates a token transaction that includes the data necessary
    // for transferring the tokens of a third party that previsouly delegated the transfer
    // via an approve request
    RequestTransferFrom(request *token.TransferRequest) (*token.TokenTransaction, error)

    // RequestExpectation allows indirect transfer based on the expectation.
    // It creates a token transaction with the outputs as specified in the expectation.
    RequestExpectation(request *token.ExpectationRequest) (*token.TokenTransaction, error)

    // Done releases any resources held by this transactor
    Done()
}

Subdirectories

Name Synopsis
..
mock Code generated by counterfeiter.