Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Commit 18e615e

Browse files
author
Aleksandar Likic
committed
[FAB-8683] Split IdentityManager and CAClient
CA Client interface is separated from IdentityManager. Change-Id: Iafcccac078171b343bb0305de6aba929559ca7e9 Signed-off-by: Aleksandar Likic <aleksandar.likic@securekey.com>
1 parent 7695ec2 commit 18e615e

File tree

13 files changed

+281
-201
lines changed

13 files changed

+281
-201
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ dockerenv-latest-up: clean
327327
.PHONY: mock-gen
328328
mock-gen:
329329
mockgen -build_flags '$(GO_LDFLAGS_ARG)' github.com/hyperledger/fabric-sdk-go/pkg/context/api/core Config,Providers,IdentityManager | sed "s/github.com\/hyperledger\/fabric-sdk-go\/vendor\///g" | goimports > pkg/context/api/core/mocks/mockcoreapi.gen.go
330+
mockgen -build_flags '$(GO_LDFLAGS_ARG)' github.com/hyperledger/fabric-sdk-go/pkg/context/api/msp Client | sed "s/github.com\/hyperledger\/fabric-sdk-go\/vendor\///g" | goimports > pkg/context/api/msp/mocks/mockmspapi.gen.go
330331
mockgen -build_flags '$(GO_LDFLAGS_ARG)' github.com/hyperledger/fabric-sdk-go/pkg/context/api/fab ProposalProcessor,Providers | sed "s/github.com\/hyperledger\/fabric-sdk-go\/vendor\///g" | goimports > pkg/context/api/fab/mocks/mockfabapi.gen.go
331332
mockgen -build_flags '$(GO_LDFLAGS_ARG)' github.com/hyperledger/fabric-sdk-go/pkg/common/context Providers,Client | sed "s/github.com\/hyperledger\/fabric-sdk-go\/vendor\///g" | goimports > pkg/common/context/mocks/mockcontext.gen.go
332333
mockgen -build_flags '$(GO_LDFLAGS_ARG)' github.com/hyperledger/fabric-sdk-go/pkg/fabsdk/api CoreProviderFactory,ServiceProviderFactory | sed "s/github.com\/hyperledger\/fabric-sdk-go\/vendor\///g" | goimports > pkg/fabsdk/mocks/mockfabsdkapi.gen.go

pkg/context/api/core/identitymgr.go

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -27,76 +27,4 @@ type SigningIdentity struct {
2727
type IdentityManager interface {
2828
GetSigningIdentity(name string) (*SigningIdentity, error)
2929
GetUser(name string) (User, error)
30-
Enroll(enrollmentID string, enrollmentSecret string) error
31-
Reenroll(user User) error
32-
Register(request *RegistrationRequest) (string, error)
33-
Revoke(request *RevocationRequest) (*RevocationResponse, error)
34-
CAName() string
35-
}
36-
37-
// AttributeRequest is a request for an attribute.
38-
type AttributeRequest struct {
39-
Name string
40-
Optional bool
41-
}
42-
43-
// RegistrationRequest defines the attributes required to register a user with the CA
44-
type RegistrationRequest struct {
45-
// Name is the unique name of the identity
46-
Name string
47-
// Type of identity being registered (e.g. "peer, app, user")
48-
Type string
49-
// MaxEnrollments is the number of times the secret can be reused to enroll.
50-
// if omitted, this defaults to max_enrollments configured on the server
51-
MaxEnrollments int
52-
// The identity's affiliation e.g. org1.department1
53-
Affiliation string
54-
// Optional attributes associated with this identity
55-
Attributes []Attribute
56-
// CAName is the name of the CA to connect to
57-
CAName string
58-
// Secret is an optional password. If not specified,
59-
// a random secret is generated. In both cases, the secret
60-
// is returned from registration.
61-
Secret string
62-
}
63-
64-
// Attribute defines additional attributes that may be passed along during registration
65-
type Attribute struct {
66-
Name string
67-
Key string
68-
Value string
69-
}
70-
71-
// RevocationRequest defines the attributes required to revoke credentials with the CA
72-
type RevocationRequest struct {
73-
// Name of the identity whose certificates should be revoked
74-
// If this field is omitted, then Serial and AKI must be specified.
75-
Name string
76-
// Serial number of the certificate to be revoked
77-
// If this is omitted, then Name must be specified
78-
Serial string
79-
// AKI (Authority Key Identifier) of the certificate to be revoked
80-
AKI string
81-
// Reason is the reason for revocation. See https://godoc.org/golang.org/x/crypto/ocsp
82-
// for valid values. The default value is 0 (ocsp.Unspecified).
83-
Reason string
84-
// CAName is the name of the CA to connect to
85-
CAName string
86-
}
87-
88-
// RevocationResponse represents response from the server for a revocation request
89-
type RevocationResponse struct {
90-
// RevokedCerts is an array of certificates that were revoked
91-
RevokedCerts []RevokedCert
92-
// CRL is PEM-encoded certificate revocation list (CRL) that contains all unexpired revoked certificates
93-
CRL []byte
94-
}
95-
96-
// RevokedCert represents a revoked certificate
97-
type RevokedCert struct {
98-
// Serial number of the revoked certificate
99-
Serial string
100-
// AKI of the revoked certificate
101-
AKI string
10230
}

pkg/context/api/core/mocks/mockcoreapi.gen.go

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

pkg/context/api/msp/client.go

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
Copyright SecureKey Technologies Inc. All Rights Reserved.
3+
4+
SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
package msp
8+
9+
import (
10+
"github.com/hyperledger/fabric-sdk-go/pkg/context/api/core"
11+
)
12+
13+
// Client provides management of identities in a Fabric network
14+
type Client interface {
15+
CAName() string
16+
Enroll(enrollmentID string, enrollmentSecret string) error
17+
Reenroll(user core.User) error
18+
Register(request *RegistrationRequest) (string, error)
19+
Revoke(request *RevocationRequest) (*RevocationResponse, error)
20+
}
21+
22+
// AttributeRequest is a request for an attribute.
23+
type AttributeRequest struct {
24+
Name string
25+
Optional bool
26+
}
27+
28+
// RegistrationRequest defines the attributes required to register a user with the CA
29+
type RegistrationRequest struct {
30+
// Name is the unique name of the identity
31+
Name string
32+
// Type of identity being registered (e.g. "peer, app, user")
33+
Type string
34+
// MaxEnrollments is the number of times the secret can be reused to enroll.
35+
// if omitted, this defaults to max_enrollments configured on the server
36+
MaxEnrollments int
37+
// The identity's affiliation e.g. org1.department1
38+
Affiliation string
39+
// Optional attributes associated with this identity
40+
Attributes []Attribute
41+
// CAName is the name of the CA to connect to
42+
CAName string
43+
// Secret is an optional password. If not specified,
44+
// a random secret is generated. In both cases, the secret
45+
// is returned from registration.
46+
Secret string
47+
}
48+
49+
// Attribute defines additional attributes that may be passed along during registration
50+
type Attribute struct {
51+
Name string
52+
Key string
53+
Value string
54+
}
55+
56+
// RevocationRequest defines the attributes required to revoke credentials with the CA
57+
type RevocationRequest struct {
58+
// Name of the identity whose certificates should be revoked
59+
// If this field is omitted, then Serial and AKI must be specified.
60+
Name string
61+
// Serial number of the certificate to be revoked
62+
// If this is omitted, then Name must be specified
63+
Serial string
64+
// AKI (Authority Key Identifier) of the certificate to be revoked
65+
AKI string
66+
// Reason is the reason for revocation. See https://godoc.org/golang.org/x/crypto/ocsp
67+
// for valid values. The default value is 0 (ocsp.Unspecified).
68+
Reason string
69+
// CAName is the name of the CA to connect to
70+
CAName string
71+
}
72+
73+
// RevocationResponse represents response from the server for a revocation request
74+
type RevocationResponse struct {
75+
// RevokedCerts is an array of certificates that were revoked
76+
RevokedCerts []RevokedCert
77+
// CRL is PEM-encoded certificate revocation list (CRL) that contains all unexpired revoked certificates
78+
CRL []byte
79+
}
80+
81+
// RevokedCert represents a revoked certificate
82+
type RevokedCert struct {
83+
// Serial number of the revoked certificate
84+
Serial string
85+
// AKI of the revoked certificate
86+
AKI string
87+
}

pkg/context/api/msp/mocks/mockmspapi.gen.go

Lines changed: 98 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)