forked from hyperledger/fabric
/
policies.go
38 lines (30 loc) · 851 Bytes
/
policies.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package commonext
import (
"fmt"
"github.com/golang/protobuf/proto"
"github.com/hyperledger/fabric-protos-go/common"
)
type Policy struct{ *common.Policy }
func (p *Policy) Underlying() proto.Message {
return p.Policy
}
func (p *Policy) VariablyOpaqueFields() []string {
return []string{"value"}
}
func (p *Policy) VariablyOpaqueFieldProto(name string) (proto.Message, error) {
if name != p.VariablyOpaqueFields()[0] {
return nil, fmt.Errorf("not a marshaled field: %s", name)
}
switch p.Type {
case int32(common.Policy_SIGNATURE):
return &common.SignaturePolicyEnvelope{}, nil
case int32(common.Policy_IMPLICIT_META):
return &common.ImplicitMetaPolicy{}, nil
default:
return nil, fmt.Errorf("unable to decode policy type: %v", p.Type)
}
}