Skip to content

Commit 256dc12

Browse files
committed
[FAB-12155] IssuerValidator Impl
This change-set does the following: 1. Implementes the IssuerValidator interface in the following way: The Validate method checks if the passed credential correspond to that of a valid member of a Fabric channel the validator is bound to. The Fabric channel is representetd by an MSP manager that collects all the MSPs registered in that channel. 2. It modify the manager.Manager to use the implementation introduced in point 1. 3. Refactor the interfaces to avoid circual package dependecy and local interfaces proliferation Change-Id: I0b48b17f3e6246f34be3a1c28842352649fed917 Signed-off-by: Angelo De Caro <adc@zurich.ibm.com> Signed-off-by: Mathias Bjoerkqvist <mbj@zurich.ibm.com>
1 parent 3b0e817 commit 256dc12

23 files changed

+1283
-321
lines changed

token/identity/identity.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package identity
8+
9+
import (
10+
"github.com/hyperledger/fabric/msp"
11+
)
12+
13+
// IssuingValidator is used to establish if the creator can issue tokens of the passed type.
14+
type IssuingValidator interface {
15+
// Validate returns no error if the passed creator can issue tokens of the passed type,, an error otherwise.
16+
Validate(creator PublicInfo, tokenType string) error
17+
}
18+
19+
// PublicInfo is used to identify token owners.
20+
type PublicInfo interface {
21+
Public() []byte
22+
}
23+
24+
// DeserializerManager returns instances of Deserializer
25+
type DeserializerManager interface {
26+
// Deserializer returns an instance of transaction.Deserializer for the passed channel
27+
// if the channel exists
28+
Deserializer(channel string) (Deserializer, error)
29+
}
30+
31+
// Deserializer
32+
type Deserializer interface {
33+
// Deserialize deserializes an identity.
34+
// Deserialization will fail if the identity is associated to
35+
// an msp that is different from this one that is performing
36+
// the deserialization.
37+
DeserializeIdentity(serializedIdentity []byte) (msp.Identity, error)
38+
}

token/identity/identity_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
Copyright IBM Corp. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package identity_test
8+
9+
import "github.com/hyperledger/fabric/msp"
10+
11+
//go:generate counterfeiter -o mock/issuing_validator.go -fake-name IssuingValidator . IssuingValidator
12+
//go:generate counterfeiter -o mock/public_info.go -fake-name PublicInfo . PublicInfo
13+
//go:generate counterfeiter -o mock/deserializer_manager.go -fake-name DeserializerManager . DeserializerManager
14+
//go:generate counterfeiter -o mock/deserializer.go -fake-name Deserializer . Deserializer
15+
//go:generate counterfeiter -o mock/identity.go -fake-name Identity ./../../msp/ Identity
16+
17+
type Identity interface {
18+
msp.Identity
19+
}

token/identity/mock/deserializer.go

Lines changed: 109 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

token/identity/mock/deserializer_manager.go

Lines changed: 103 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)