attr

package
v0.0.0-...-667e438 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetValueFrom

func GetValueFrom(attributeName string, cert []byte) ([]byte, error)

GetValueFrom returns the value of 'attributeName0' from a cert.

Types

type Attribute

type Attribute struct {
	Name  string
	Value []byte
}

Attribute defines a name, value pair to be verified.

type AttributesHandler

type AttributesHandler interface {

	//VerifyAttributes does the same as VerifyAttribute but it checks for a list of attributes and their respective values instead of a single attribute/value pair
	// Example:
	//    containsAttrs, error:= handler.VerifyAttributes(&ac.Attribute{"position",  "Software Engineer"}, &ac.Attribute{"company", "ACompany"})
	VerifyAttributes(attrs ...*Attribute) (bool, error)

	//VerifyAttribute is used to verify if the transaction certificate has an attribute with name *attributeName* and value *attributeValue* which are the input parameters received by this function.
	//Example:
	//    containsAttr, error := handler.VerifyAttribute("position", "Software Engineer")
	VerifyAttribute(attributeName string, attributeValue []byte) (bool, error)

	//GetValue is used to read an specific attribute from the transaction certificate, *attributeName* is passed as input parameter to this function.
	// Example:
	//  attrValue,error:=handler.GetValue("position")
	GetValue(attributeName string) ([]byte, error)
}

AttributesHandler is an entity can be used to both verify and read attributes.

		The functions declared can be used to access the attributes stored in the transaction certificates from the application layer. Can be used directly from the ChaincodeStub API but
		 if you need multiple access create a hanlder is better:
	Multiple accesses
		If multiple calls to the functions above are required, a best practice is to create an AttributesHandler instead of calling the functions multiple times, this practice will avoid creating a new AttributesHandler for each of these calls thus eliminating an unnecessary overhead.
   Example:

		AttributesHandler, err := ac.NewAttributesHandlerImpl(stub)
		if err != nil {
			return false, err
		}
		AttributesHandler.VerifyAttribute(attributeName, attributeValue)
		... you can make other verifications and/or read attribute values by using the AttributesHandler

type AttributesHandlerImpl

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

AttributesHandlerImpl is an implementation of AttributesHandler interface.

func NewAttributesHandlerImpl

func NewAttributesHandlerImpl(holder chaincodeHolder) (*AttributesHandlerImpl, error)

NewAttributesHandlerImpl creates a new AttributesHandlerImpl from a pb.ChaincodeSecurityContext object.

func (*AttributesHandlerImpl) GetValue

func (attributesHandler *AttributesHandlerImpl) GetValue(attributeName string) ([]byte, error)

GetValue is used to read an specific attribute from the transaction certificate, *attributeName* is passed as input parameter to this function.

	Example:
 	attrValue,error:=handler.GetValue("position")

func (*AttributesHandlerImpl) VerifyAttribute

func (attributesHandler *AttributesHandlerImpl) VerifyAttribute(attributeName string, attributeValue []byte) (bool, error)

VerifyAttribute is used to verify if the transaction certificate has an attribute with name *attributeName* and value *attributeValue* which are the input parameters received by this function.

	Example:
 	containsAttr, error := handler.VerifyAttribute("position", "Software Engineer")

func (*AttributesHandlerImpl) VerifyAttributes

func (attributesHandler *AttributesHandlerImpl) VerifyAttributes(attrs ...*Attribute) (bool, error)

VerifyAttributes does the same as VerifyAttribute but it checks for a list of attributes and their respective values instead of a single attribute/value pair

	Example:
 	containsAttrs, error:= handler.VerifyAttributes(&ac.Attribute{"position",  "Software Engineer"}, &ac.Attribute{"company", "ACompany"})

Jump to

Keyboard shortcuts

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