Skip to content

Commit

Permalink
CA Management: add generateCRL function. blockchain-desktop#202
Browse files Browse the repository at this point in the history
Signed-off-by: Yi DENG <[email protected]>
  • Loading branch information
dengyi9 committed Mar 28, 2019
1 parent 84ec940 commit 480005d
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 2 deletions.
1 change: 1 addition & 0 deletions fabric/v1.1/fabcar/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hfc-key-store
8 changes: 8 additions & 0 deletions fabric/v1.1/fabcar/desktopConfigCAAdmin.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
peerGrpcUrl: grpc://localhost:7051
peerEventUrl: grpc://localhost:7053
ordererUrl: grpc://localhost:7050
mspId: Org1MSP
# 私钥和证书,每次需手动执行node enrollAdmin.js生成,并手动hfc-key-store/admin复制出证书创建新文件,并修改私钥对应的文件
certificate: hfc-key-store/admin.crt
privateKey: hfc-key-store/474b19c5aff786e6db33b89b94c8daa6b3336183e843c1e58630450c53f5bd96-priv
caServerUrl: http://localhost:7054
3 changes: 3 additions & 0 deletions src/common/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ Common.REVOKE_USERNAME = 'User ID';
Common.REVOKE_OPTIONAL = 'Optional';
Common.REVOKE_CONFIRM = 'Revoke';

Common.GENERATE_CRL = 'GENERATE CERTIFICATE REVOKE LIST--CRL';
Common.GENERATE_CRL_OPTIONAL = 'Optional';
Common.GENERATE_CRL_CONFIRM = 'Get';

Common.WARN = {
chaincodeName: 'chaincode name can not be null!',
Expand Down
3 changes: 3 additions & 0 deletions src/common/common_cn.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ Common.REVOKE_USERNAME = '用户ID';
Common.REVOKE_OPTIONAL = '其他参数';
Common.REVOKE_CONFIRM = '吊销';

Common.GENERATE_CRL = '证书吊销列表(CRL)获取';
Common.GENERATE_CRL_OPTIONAL = '其他参数';
Common.GENERATE_CRL_CONFIRM = '获取';

Common.WARN = {
chaincodeName: '链码名称不能为空!',
Expand Down
48 changes: 46 additions & 2 deletions src/components/content/CAUpdateContent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,18 @@ export default class CAUpdateContent extends React.Component {
revokeUserName: '',
revokeOptional: '',
revokeResult: '',

generateCrlOptional: '',
generateCrlResult: '',
};

this.onChangeReenrollOptional = this.onChangeReenrollOptional.bind(this);
this.onChangeRevokeUserName = this.onChangeRevokeUserName.bind(this);
this.onChangeRevokeOptional = this.onChangeRevokeOptional.bind(this);
this.onChangeRevokeOptional = this.onChangeRevokeOptional.bind(this);
this.handleReenroll = this.handleReenroll.bind(this);
this.handleRevoke = this.handleRevoke.bind(this);
this.handleGenerateCrl = this.handleGenerateCrl.bind(this);
}

onChangeReenrollOptional(event) {
Expand All @@ -38,6 +43,9 @@ export default class CAUpdateContent extends React.Component {
onChangeRevokeOptional(event) {
this.setState({ revokeOptional: event.target.value });
}
onChangeGenerateCrlOptional(event) {
this.setState({ generateCrlOptional: event.target.value });
}

handleReenroll() {
let req = null;
Expand Down Expand Up @@ -80,14 +88,37 @@ export default class CAUpdateContent extends React.Component {
})
.then((result) => {
logger.debug('revoke successfully, result: ', result);
self.setState({ revokeResult: result.toString() });
self.setState({ revokeResult: 'success' });
})
.catch((err) => {
self.setState({ revokeResult: 'Revocation fails.' });
logger.debug(err);
});
}

handleGenerateCrl() {
let req = null;
if (this.state.enrollOptional) {
req = JSON.parse(this.state.enrollOptional);
}

const self = this;

getFabricClientSingleton()
.then((client) => {
logger.debug('start to generateCRL, request: ', req);
return client.generateCRL(req);
})
.then((result) => {
logger.debug('crlResult: ', result);
self.setState({ generateCrlResult: result.toString() });
})
.catch((err) => {
self.setState({ generateCrlResult: 'Fail.' });
logger.debug(err);
});
}

render() {
const outerDivStyle = {
padding: '24px',
Expand Down Expand Up @@ -192,7 +223,20 @@ export default class CAUpdateContent extends React.Component {
/>
</div>

{/*TODO: 实现generateCRL */}
<div>{this.state.Common.GENERATE_CRL}</div>
<div style={DivStyle}>
<span style={spanStyle}>{this.state.Common.GENERATE_CRL_OPTIONAL}</span>
<Input placeholder="Optional json parameters" style={configInputStyle} value={this.state.generateCrlOptional} onChange={this.onChangeGenerateCrlOptional} />
</div>
<div style={DivStyle}>
<Button style={ButtonStyle} type="primary" onClick={this.handleGenerateCrl}>{this.state.Common.GENERATE_CRL_CONFIRM}</Button>
<TextArea
placeholder="GenerateCRL Result"
value={this.state.generateCrlResult}
autosize={{ minRows: 2, maxRows: 2 }}
readOnly
/>
</div>
</div>

);
Expand Down
3 changes: 3 additions & 0 deletions src/util/fabric.js
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,9 @@ class FabricClient {
* @returns {Promise<any>}
*/
generateCRL(req) {
if (!req) {
req = {};
}
return this.fabricCAClient.generateCRL(req, this.user);
}

Expand Down

0 comments on commit 480005d

Please sign in to comment.