{"modulePath":"github.com/eric-erki/https-hyperledger.org","version":"v1.0.0-alpha","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package attr\n\n## Functions\n\n```go\nfunc GetValueFrom(attributeName string, cert []byte) ([]byte, error)\n```\nGetValueFrom returns the value of 'attributeName0' from a cert.\n\n## Types\n\n```go\ntype AttributesHandler interface {\n\n\t//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\n\t// Example:\n\t//    containsAttrs, error:= handler.VerifyAttributes(\u0026ac.Attribute{\"position\",  \"Software Engineer\"}, \u0026ac.Attribute{\"company\", \"ACompany\"})\n\tVerifyAttributes(attrs ...*accesscontrol.Attribute) (bool, error)\n\n\t//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.\n\t//Example:\n\t//    containsAttr, error := handler.VerifyAttribute(\"position\", \"Software Engineer\")\n\tVerifyAttribute(attributeName string, attributeValue []byte) (bool, error)\n\n\t//GetValue is used to read an specific attribute from the transaction certificate, *attributeName* is passed as input parameter to this function.\n\t// Example:\n\t//  attrValue,error:=handler.GetValue(\"position\")\n\tGetValue(attributeName string) ([]byte, error)\n}\n```\nAttributesHandler is an entity can be used to both verify and read attributes.\n\n\t\t\tThe 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\n\t\t\t if you need multiple access create a hanlder is better:\n\t\tMultiple accesses\n\t\t\tIf 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.\n\t   Example:\n\n\t\t\tAttributesHandler, err := ac.NewAttributesHandlerImpl(stub)\n\t\t\tif err != nil {\n\t\t\t\treturn false, err\n\t\t\t}\n\t\t\tAttributesHandler.VerifyAttribute(attributeName, attributeValue)\n\t\t\t... you can make other verifications and/or read attribute values by using the AttributesHandler\n\n```go\ntype AttributesHandlerImpl struct {\n\t// contains filtered or unexported fields\n}\n```\nAttributesHandlerImpl is an implementation of AttributesHandler interface.\n\n```go\nfunc NewAttributesHandlerImpl(holder chaincodeHolder) (*AttributesHandlerImpl, error)\n```\nNewAttributesHandlerImpl creates a new AttributesHandlerImpl from a pb.ChaincodeSecurityContext object.\n\n```go\nfunc (attributesHandler *AttributesHandlerImpl) GetValue(attributeName string) ([]byte, error)\n```\nGetValue is used to read an specific attribute from the transaction certificate, \\*attributeName\\* is passed as input parameter to this function.\n\n\t\tExample:\n\t \tattrValue,error:=handler.GetValue(\"position\")\n\n```go\nfunc (attributesHandler *AttributesHandlerImpl) VerifyAttribute(attributeName string, attributeValue []byte) (bool, error)\n```\nVerifyAttribute 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.\n\n\t\tExample:\n\t \tcontainsAttr, error := handler.VerifyAttribute(\"position\", \"Software Engineer\")\n\n```go\nfunc (attributesHandler *AttributesHandlerImpl) VerifyAttributes(attrs ...*accesscontrol.Attribute) (bool, error)\n```\nVerifyAttributes does the same as VerifyAttribute but it checks for a list of attributes and their respective values instead of a single attribute/value pair\n\n\t\tExample:\n\t \tcontainsAttrs, error:= handler.VerifyAttributes(\u0026ac.Attribute{\"position\",  \"Software Engineer\"}, \u0026ac.Attribute{\"company\", \"ACompany\"})\n\n","path":"github.com/eric-erki/https-hyperledger.org/accesscontrol/crypto/attr","name":"attr","synopsis":"","isRedistributable":true}
