identity

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2019 License: MIT Imports: 12 Imported by: 12

Documentation

Overview

Package access contains structs for storing chaincode access control information

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrPemEncodedExpected pem format error
	ErrPemEncodedExpected = errors.New("expecting a PEM-encoded X509 certificate; PEM block not found")
)

Functions

func Certificate

func Certificate(c []byte) (cert *x509.Certificate, err error)

Certificate decode and parse .pem []byte x509 certificate structure

func GetDN

func GetDN(name *pkix.Name) string

GetDN (distinguished name) associated with a pkix.Name. NOTE: This code is almost a direct copy of the String() function in https://go-review.googlesource.com/c/go/+/67270/1/src/crypto/x509/pkix/pkix.go#26 which returns a DN as defined by RFC 2253.

func ID

func ID(subject, issuer string) string

ID returns identifier from .509 certificate and base64 encode

func IDByCert

func IDByCert(cert *x509.Certificate) string

IDByCert returns id by certificate subject and issuer

func IDRaw

func IDRaw(subject, issuer string) string

IDRaw generates string identifier from .509 certificate

Types

type CertIdentity

type CertIdentity struct {
	MspID string
	Cert  *x509.Certificate
}

CertIdentity structs holds data of an tx creator

func FromFile

func FromFile(mspID string, filename string, getContent GetContent) (ci *CertIdentity, err error)

FromFile creates certIdentity from file determined by filename

func FromSerialized

func FromSerialized(s msp.SerializedIdentity) (ci *CertIdentity, err error)

FromSerialized converts msp.SerializedIdentity struct to Identity interface{}

func FromStub

func FromStub(stub shim.ChaincodeStubInterface) (ci *CertIdentity, err error)

FromStub creates Identity interface from tx creator mspID and certificate (stub.GetCreator)

func New

func New(mspID string, certPEM []byte) (ci *CertIdentity, err error)

New creates CertIdentity struct from an mspID and certificate

func (CertIdentity) GetID

func (ci CertIdentity) GetID() string

GetID get id based in certificate subject and issuer

func (CertIdentity) GetIssuer

func (ci CertIdentity) GetIssuer() string

GetIssuer returns invoker's certificate issuer

func (CertIdentity) GetMSPID

func (ci CertIdentity) GetMSPID() string

GetMSPID returns invoker's membership service provider id

func (CertIdentity) GetPEM

func (ci CertIdentity) GetPEM() []byte

GetPEM certificate encoded to PEM

func (CertIdentity) GetPublicKey

func (ci CertIdentity) GetPublicKey() interface{}

func (CertIdentity) GetSubject

func (ci CertIdentity) GetSubject() string

GetSubject returns invoker's certificate subject

func (CertIdentity) Is

func (ci CertIdentity) Is(id Identity) bool

Is checks invoker is equal an identity

func (CertIdentity) ToBytes

func (ci CertIdentity) ToBytes() ([]byte, error)

ToBytes converts to serializedIdentity and then to json

func (CertIdentity) ToSerialized

func (ci CertIdentity) ToSerialized() *msp.SerializedIdentity

ToSerialized converts CertIdentity to *msp.SerializedIdentity

type Entry

type Entry struct {
	MSPId   string
	Subject string
	Issuer  string
	PEM     []byte
	Cert    *x509.Certificate `json:"-"` // temporary cert
}

Entry structure for storing identity information string representation certificate Subject and Issuer can be used for reach query searching

func CreateEntry

func CreateEntry(i Identity) (g *Entry, err error)

CreateEntry creates IdentityEntry structure from an identity interface

func EntryFromSerialized

func EntryFromSerialized(s msp.SerializedIdentity) (g *Entry, err error)

EntryFromSerialized creates Entry from SerializedEntry

func EntryFromStub

func EntryFromStub(stub shim.ChaincodeStubInterface) (g *Entry, err error)

func (Entry) GetID

func (e Entry) GetID() string

GetID identifier by certificate subject and issuer

func (Entry) GetIdentityEntry

func (e Entry) GetIdentityEntry() Entry

func (Entry) GetIssuer

func (e Entry) GetIssuer() string

GetIssuer certificate issuer

func (Entry) GetMSPID

func (e Entry) GetMSPID() string

GetMSPID membership service provider identifier

func (Entry) GetPEM

func (e Entry) GetPEM() []byte

GetPK certificate issuer

func (Entry) GetPublicKey

func (e Entry) GetPublicKey() interface{}

func (Entry) GetSubject

func (e Entry) GetSubject() string

GetSubject certificate subject

func (Entry) Is

func (e Entry) Is(id Identity) bool

Is checks IdentityEntry is equal to an other Identity

type GetContent

type GetContent func(string) ([]byte, error)

type Id

type Id struct {
	MSP  string
	Cert string
}

Id structure defines short id representation

type Identity

type Identity interface {
	// GetID Identifier, based on Subject and Issuer
	GetID() string

	// GetMSPID msp identifier
	GetMSPID() string

	//  GetSubject string representation of X.509 cert subject
	GetSubject() string
	//  GetIssuer string representation of X.509 cert issuer
	GetIssuer() string

	// GetPublicKey *rsa.PublicKey or *dsa.PublicKey or *ecdsa.PublicKey:
	GetPublicKey() interface{}
	GetPEM() []byte
	Is(i Identity) bool
}

Identity interface for invoker (tx creator) and grants, stored in chain code state

type IdentityEntry

type IdentityEntry interface {
	GetIdentityEntry() Entry
}

IdentityEntry interface

Jump to

Keyboard shortcuts

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