Search in sources :

Example 1 with TransactionPrivilegeBitset

use of com.jd.blockchain.ledger.TransactionPrivilegeBitset in project jdchain-core by blockchain-jd-com.

the class RolePrivilegeDataset method addRolePrivilege.

/**
 * 加入新的角色权限; <br>
 *
 * 如果指定的角色已经存在,则引发 {@link LedgerException} 异常;
 *
 * @param roleName          角色名称;不能超过 {@link #MAX_ROLE_NAME_LENGTH} 个 Unicode
 *                          字符;
 * @param ledgerPermissions 给角色授予的账本权限列表;
 * @param txPermissions     给角色授予的交易权限列表;
 * @return
 */
public long addRolePrivilege(String roleName, LedgerPermission[] ledgerPermissions, TransactionPermission[] txPermissions) {
    LedgerPrivilegeBitset ledgerPrivilege = new LedgerPrivilegeBitset();
    for (LedgerPermission lp : ledgerPermissions) {
        ledgerPrivilege.enable(lp);
    }
    TransactionPrivilegeBitset txPrivilege = new TransactionPrivilegeBitset();
    for (TransactionPermission tp : txPermissions) {
        txPrivilege.enable(tp);
    }
    return addRolePrivilege(roleName, ledgerPrivilege, txPrivilege);
}
Also used : TransactionPermission(com.jd.blockchain.ledger.TransactionPermission) LedgerPermission(com.jd.blockchain.ledger.LedgerPermission) TransactionPrivilegeBitset(com.jd.blockchain.ledger.TransactionPrivilegeBitset) LedgerPrivilegeBitset(com.jd.blockchain.ledger.LedgerPrivilegeBitset)

Aggregations

LedgerPermission (com.jd.blockchain.ledger.LedgerPermission)1 LedgerPrivilegeBitset (com.jd.blockchain.ledger.LedgerPrivilegeBitset)1 TransactionPermission (com.jd.blockchain.ledger.TransactionPermission)1 TransactionPrivilegeBitset (com.jd.blockchain.ledger.TransactionPrivilegeBitset)1