use of com.jd.blockchain.ledger.AuthorizationException in project jdchain-core by blockchain-jd-com.
the class UserRoleDatasetEditor method addUserRoles.
/**
* 加入新的用户角色授权; <br>
*
* 如果该用户的授权已经存在,则引发 {@link LedgerException} 异常;
*
* @param userAddress
* @param rolesPolicy
* @param roles
*/
public void addUserRoles(Bytes userAddress, RolesPolicy rolesPolicy, String... roles) {
UserRoles roleAuth = new UserRoles(userAddress, -1, rolesPolicy);
roleAuth.addRoles(roles);
long nv = setUserRolesAuthorization(roleAuth);
if (nv < 0) {
throw new AuthorizationException("Roles authorization of User[" + userAddress + "] already exists!");
}
if (ledgerDataStructure.equals(LedgerDataStructure.KV)) {
Bytes index = USEERROLR_SEQUENCE_KEY_PREFIX.concat(Bytes.fromString(String.valueOf(dataset.getDataCount() + userrole_index_in_block)));
nv = dataset.setValue(index, userAddress.toBytes(), -1);
if (nv < 0) {
throw new AuthorizationException("Roles authorization seq of User[" + userAddress + "] already exists!");
}
userrole_index_in_block++;
}
}
use of com.jd.blockchain.ledger.AuthorizationException in project jdchain-core by blockchain-jd-com.
the class UserRoleDatasetEditor method addUserRoles.
/**
* 加入新的用户角色授权; <br>
*
* 如果该用户的授权已经存在,则引发 {@link LedgerException} 异常;
*
* @param userAddress
* @param rolesPolicy
* @param roles
*/
public void addUserRoles(Bytes userAddress, RolesPolicy rolesPolicy, Collection<String> roles) {
UserRoles roleAuth = new UserRoles(userAddress, -1, rolesPolicy);
roleAuth.addRoles(roles);
long nv = setUserRolesAuthorization(roleAuth);
if (nv < 0) {
throw new AuthorizationException("Roles authorization of User[" + userAddress + "] already exists!");
}
if (ledgerDataStructure.equals(LedgerDataStructure.KV)) {
Bytes index = USEERROLR_SEQUENCE_KEY_PREFIX.concat(Bytes.fromString(String.valueOf(dataset.getDataCount() + userrole_index_in_block)));
nv = dataset.setValue(index, userAddress.toBytes(), -1);
if (nv < 0) {
throw new AuthorizationException("Roles authorization seq of User[" + userAddress + "] already exists!");
}
userrole_index_in_block++;
}
}
Aggregations