use of com.jd.blockchain.ledger.RolesConfigureOperation.RolePrivilegeEntry in project jdchain-core by blockchain-jd-com.
the class RolesConfigureOperationHandle method doProcess.
@Override
protected void doProcess(RolesConfigureOperation operation, LedgerTransactionContext transactionContext, TransactionRequestExtension request, LedgerQuery ledger, OperationHandleContext handleContext, EventManager manager) {
// 权限校验;
SecurityPolicy securityPolicy = SecurityContext.getContextUsersPolicy();
securityPolicy.checkEndpointPermission(LedgerPermission.CONFIGURE_ROLES, MultiIDsPolicy.AT_LEAST_ONE);
// 操作账本;
RolePrivilegeEntry[] rpcfgs = operation.getRoles();
RolePrivilegeSettings rpSettings = transactionContext.getDataset().getAdminDataset().getAdminSettings().getRolePrivileges();
if (rpcfgs != null) {
for (RolePrivilegeEntry rpcfg : rpcfgs) {
RolePrivileges rp = rpSettings.getRolePrivilege(rpcfg.getRoleName());
if (rp == null) {
((RolePrivilegeDataset) rpSettings).addRolePrivilege(rpcfg.getRoleName(), rpcfg.getEnableLedgerPermissions(), rpcfg.getEnableTransactionPermissions());
} else {
rp.enable(rpcfg.getEnableLedgerPermissions());
rp.enable(rpcfg.getEnableTransactionPermissions());
rp.disable(rpcfg.getDisableLedgerPermissions());
rp.disable(rpcfg.getDisableTransactionPermissions());
((RolePrivilegeDataset) rpSettings).updateRolePrivilege(rp);
}
}
}
}
Aggregations