|
| 1 | +/* |
| 2 | +Copyright IBM Corp. 2016 All Rights Reserved. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package api |
| 18 | + |
| 19 | +import "time" |
| 20 | + |
| 21 | +// SecurityAdvisor defines an external auxiliary object |
| 22 | +// that provides security and identity related capabilities |
| 23 | +type SecurityAdvisor interface { |
| 24 | + // IsInMyOrg returns whether the given peer's certificate represents |
| 25 | + // a peer in the invoker's organization |
| 26 | + IsInMyOrg(PeerCert) bool |
| 27 | + |
| 28 | + // Verify verifies a JoinChannelMessage, returns nil on success, |
| 29 | + // and an error on failure |
| 30 | + Verify(JoinChannelMessage) error |
| 31 | +} |
| 32 | + |
| 33 | +// ChannelNotifier is implemented by the gossip component and is used for the peer |
| 34 | +// layer to notify the gossip component of a JoinChannel event |
| 35 | +type ChannelNotifier interface { |
| 36 | + JoinChannel(joinMsg JoinChannelMessage, chainID ChainID) |
| 37 | +} |
| 38 | + |
| 39 | +// JoinChannelMessage is the message that asserts a creation or mutation |
| 40 | +// of a channel's membership list, and is the message that is gossipped |
| 41 | +// among the peers |
| 42 | +type JoinChannelMessage interface { |
| 43 | + |
| 44 | + // GetTimestamp returns the timestamp of the message's creation |
| 45 | + GetTimestamp() time.Time |
| 46 | + |
| 47 | + // PeerList returns all the peers that are in the channel |
| 48 | + PeerList() []RemotePeer |
| 49 | +} |
| 50 | + |
| 51 | +// ChainID defines the identity representation of a chain |
| 52 | +type ChainID []byte |
| 53 | + |
| 54 | +// RemotePeer is a peer's certificate and endpoint (host:port) |
| 55 | +type RemotePeer struct { |
| 56 | + cert PeerCert |
| 57 | + host string |
| 58 | + port int |
| 59 | +} |
| 60 | + |
| 61 | +// PeerCert defines the cryptographic identity of a peer |
| 62 | +type PeerCert []byte |
0 commit comments