|
| 1 | +package appmsp |
| 2 | + |
| 3 | +/* |
| 4 | +Copyright IBM Corp. 2016 All Rights Reserved. |
| 5 | +
|
| 6 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +you may not use this file except in compliance with the License. |
| 8 | +You may obtain a copy of the License at |
| 9 | +
|
| 10 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +
|
| 12 | +Unless required by applicable law or agreed to in writing, software |
| 13 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +See the License for the specific language governing permissions and |
| 16 | +limitations under the License. |
| 17 | +*/ |
| 18 | + |
| 19 | +import "github.com/hyperledger/fabric/msp" |
| 20 | +import mspconfig "github.com/hyperledger/fabric/protos/msp" |
| 21 | + |
| 22 | +// Membership service provider APIs for Hyperledger Fabric: |
| 23 | +// |
| 24 | +// By "membership service provider" we refer to an abstract component of the |
| 25 | +// system that would provide (anonymous) credentials to clients, and peers for |
| 26 | +// them to participate in Hyperledger/fabric network. Clients use these |
| 27 | +// credentials to authenticate their transactions, and peers use these credentials |
| 28 | +// to authenticate transaction processing results (endorsements). While |
| 29 | +// strongly connected to the transaction processing components of the systems, |
| 30 | +// this interface aims to have membership services components defined, in such |
| 31 | +// a way such that alternate implementations of this can be smoothly plugged in |
| 32 | +// without modifying the core of transaction processing components of the system. |
| 33 | +// |
| 34 | +// This file includes Membership service provider interface that covers the |
| 35 | +// needs of an application. This is based on an extension of peerMSP and peerManager |
| 36 | +// covering the needs of an application/client. |
| 37 | +// |
| 38 | + |
| 39 | +// ApplicationMSPManager is an interface defining a manager of one or more membership |
| 40 | +// service providers (MSPs). This essentially acts as a mediator to MSP calls and routes |
| 41 | +// MSP related calls to the appropriate MSP. |
| 42 | +type ApplicationMSPManager interface { |
| 43 | + |
| 44 | + // Extends PeerMSPManager |
| 45 | + msp.MSPManager |
| 46 | + |
| 47 | + // GetMember returns the member object corresponding to the provided identifier |
| 48 | + GetMember(identifier MemberIdentifier) (Member, error) |
| 49 | + |
| 50 | + // DeleteMember deletes a specific member object corresponding to the provided |
| 51 | + // identifiers |
| 52 | + DeleteMember(identifier MemberIdentifier) error |
| 53 | + |
| 54 | + // ImportMember imports a member. |
| 55 | + // @param req The import request |
| 56 | + ImportMember(req *MemberImportRequest) (Member, error) |
| 57 | +} |
| 58 | + |
| 59 | +// ApplicationMSP is the membership service provider interface for application use |
| 60 | +type ApplicationMSP interface { |
| 61 | + |
| 62 | + // Extends MSP |
| 63 | + msp.MSP |
| 64 | + |
| 65 | + // GetMember returns an already enrolled member, |
| 66 | + // or nil if an enrolled member with this name was not found. |
| 67 | + // @param name The enrollment name |
| 68 | + GetMember(identifier MemberIdentifier) (Member, error) |
| 69 | + |
| 70 | + // DeleteMember deletes a specific member object corresponding to the provided identifier |
| 71 | + DeleteMember(identifier MemberIdentifier) (bool, error) |
| 72 | + |
| 73 | + // ImportMember imports a member. |
| 74 | + // @param req The import request |
| 75 | + ImportMember(req *MemberImportRequest) (Member, error) |
| 76 | +} |
| 77 | + |
| 78 | +type MemberImportRequest struct { |
| 79 | + // MSPIdentifier to enroll with |
| 80 | + MSPIdentifier string |
| 81 | + |
| 82 | + // MemberSigningIdentity includes the long term enrollment identity |
| 83 | + // of a member |
| 84 | + MemberSigningIdentity *mspconfig.SigningIdentityInfo |
| 85 | +} |
| 86 | + |
| 87 | +// Member represents an enrolled entity within an identity provider |
| 88 | +type Member interface { |
| 89 | + |
| 90 | + // GetIdentifier returns the member identifier; this naturally includes the |
| 91 | + // identifier of the provider this member is a member of. |
| 92 | + GetIdentifier() MemberIdentifier |
| 93 | + |
| 94 | + // GetOrganizationUnits returns the organization this member belongs to. In certain |
| 95 | + // implementations this could be implemented by certain attributes that |
| 96 | + // are publicly associated to that member, or that member's identity. |
| 97 | + // E.g., Groups here could refer to the authorities that have signed a |
| 98 | + // member's enrollment certificate or registered tse user. |
| 99 | + GetOrganizationUnits() string |
| 100 | + |
| 101 | + // GetFabricRole returns the role in the fabric of this member. E.g., if the |
| 102 | + // member is a peer, or a client. |
| 103 | + // Note: Do we have to have distinction here you think? |
| 104 | + GetFabricRole() FabricRole |
| 105 | + |
| 106 | + // GetEnrollmentIdentity returns the enrollment identity of this member. |
| 107 | + // The assumption here is that there is only one enrollment identity per |
| 108 | + // member. |
| 109 | + GetEndrollmentIdentity() msp.SigningIdentity |
| 110 | + |
| 111 | + // GetIdentities returns other identities for use by this member, that comply |
| 112 | + // with the specifications passed as arguments. |
| 113 | + // @param specs The specifications of the identities that are to be retrieved. |
| 114 | + GetIdentities(count int, specs *IdentitySpec) ([]msp.SigningIdentity, error) |
| 115 | + |
| 116 | + // GetAttributes returns all attributes associated with this member |
| 117 | + GetAttributes() []string |
| 118 | + |
| 119 | + // DeleteIdentities deletes all identities complying with the specifications passed as parameter |
| 120 | + // in this function. This function aims to serve clean up operations, i.e., |
| 121 | + // removing expired identities, or revoked ones(?). |
| 122 | + // @param specs The identity specs of the identities to be deleted. |
| 123 | + DeleteIdentities(specs *IdentitySpec) error |
| 124 | + |
| 125 | + // RevokeIdentities revokes all identities that comply with the specifications passed as parameter |
| 126 | + // in this function. |
| 127 | + // @param specs The identity specs of the identities to be deleted. |
| 128 | + RevokeIdentities(specs *IdentitySpec) error |
| 129 | +} |
| 130 | + |
| 131 | +// IdentitySpec is the interface describing the specifications of the |
| 132 | +// identity one wants to recover |
| 133 | +type IdentitySpec interface { |
| 134 | + // Identity of the identity |
| 135 | + GetName() string |
| 136 | + |
| 137 | + // Type indicates whether it is a signing or an Identity |
| 138 | + GetType() |
| 139 | + |
| 140 | + // IsAnonymous returns a boolean indicating if the identity is anonymous |
| 141 | + IsAnonymous() bool |
| 142 | + |
| 143 | + // A list of attributes this identity includes |
| 144 | + GetAttributeList() []msp.Attribute |
| 145 | + |
| 146 | + // Identifier of the identity to recover |
| 147 | + GetIdentifier() string |
| 148 | +} |
| 149 | + |
| 150 | +// MemberIdentifier uniquely identifies a member naturally |
| 151 | +// inheriting the namespace of the associated identity provider. |
| 152 | +type MemberIdentifier struct { |
| 153 | + // The identifier of the associated identity provider |
| 154 | + MSPIdentifier string |
| 155 | + // Returns the identifier for a member within a provider |
| 156 | + MemberIdentifier string |
| 157 | +} |
0 commit comments