use of com.jd.blockchain.ledger.RolePrivileges in project jdchain-core by blockchain-jd-com.
the class RolePrivilegeDataset method enablePermissions.
/**
* 授权角色指定的权限; <br>
* 如果角色不存在,则返回 -1;
*
* @param roleName
* @param ledgerPermissions
* @param txPermissions
* @return
*/
public long enablePermissions(String roleName, LedgerPermission[] ledgerPermissions, TransactionPermission[] txPermissions) {
RolePrivileges roleAuth = getRolePrivilege(roleName);
if (roleAuth == null) {
return -1;
}
roleAuth.getLedgerPrivilege().enable(ledgerPermissions);
roleAuth.getTransactionPrivilege().enable(txPermissions);
return setRolePrivilege(roleAuth);
}
use of com.jd.blockchain.ledger.RolePrivileges in project jdchain-core by blockchain-jd-com.
the class RolePrivilegeDataset method disablePermissions.
/**
* 禁止角色指定的权限; <br>
* 如果角色不存在,则返回 -1;
*
* @param roleName 角色;
* @param permissions 权限列表;
* @return
*/
public long disablePermissions(String roleName, LedgerPermission... permissions) {
RolePrivileges roleAuth = getRolePrivilege(roleName);
if (roleAuth == null) {
return -1;
}
roleAuth.getLedgerPrivilege().disable(permissions);
return setRolePrivilege(roleAuth);
}
use of com.jd.blockchain.ledger.RolePrivileges in project jdchain-core by blockchain-jd-com.
the class RolePrivilegeDataset method enablePermissions.
/**
* 授权角色指定的权限; <br>
* 如果角色不存在,则返回 -1;
*
* @param roleName 角色;
* @param permissions 权限列表;
* @return
*/
public long enablePermissions(String roleName, TransactionPermission... permissions) {
RolePrivileges roleAuth = getRolePrivilege(roleName);
if (roleAuth == null) {
return -1;
}
roleAuth.getTransactionPrivilege().enable(permissions);
return setRolePrivilege(roleAuth);
}
use of com.jd.blockchain.ledger.RolePrivileges in project jdchain-core by blockchain-jd-com.
the class RolePrivilegeDataset method disablePermissions.
/**
* 禁用角色指定的权限; <br>
* 如果角色不存在,则返回 -1;
*
* @param roleName
* @param ledgerPermissions
* @param txPermissions
* @return
*/
public long disablePermissions(String roleName, LedgerPermission[] ledgerPermissions, TransactionPermission[] txPermissions) {
RolePrivileges roleAuth = getRolePrivilege(roleName);
if (roleAuth == null) {
return -1;
}
roleAuth.getLedgerPrivilege().disable(ledgerPermissions);
roleAuth.getTransactionPrivilege().disable(txPermissions);
return setRolePrivilege(roleAuth);
}
use of com.jd.blockchain.ledger.RolePrivileges in project jdchain-core by blockchain-jd-com.
the class RolePrivilegeDataset method getRolePrivilege.
/**
* 查询角色权限;
*
* <br>
* 如果不存在,则返回 null;
*
* @param address
* @return
*/
@Override
public RolePrivileges getRolePrivilege(String roleName) {
// 只返回最新版本;
Bytes key = encodeKey(roleName);
DataEntry<Bytes, byte[]> kv = dataset.getDataEntry(key);
if (kv == null) {
return null;
}
PrivilegeSet privilege = BinaryProtocol.decode(kv.getValue());
return new RolePrivileges(roleName, kv.getVersion(), privilege);
}
Aggregations