Authing DocsDocuments
Concept
workflow
Guides
Development Integration
Application integration
Concept
workflow
Guides
Development Integration
Application integration
Old Version
Development Integration
  • Single Sign-On (SSO)
  • Login component

  • JavaScript/Node.js

  • Java / Kotlin

    • User Authentication Module

    • Management Module

      • Management user
      • Management application
      • Management role
      • Management resources and permissions
      • Management groups
      • Management organization
      • Management User Custom Fields
      • Management registration white list
      • Management user pool configuration
      • Management log statistics
  • Python

  • C#

  • PHP

  • Go

  • Ruby
  • Android

  • iOS

  • Flutter

  • React Native
  • WeChat Mini Program
  • WeChat webpage authorization
  • Framework Integration
  • Error code
  1. Development Integration
  2. /
  3. Java / Kotlin
  4. /
  5. Management Module
  6. /
  7. Management role

¶ RolesManagementClient

Update Time: 2025-02-18 09:00:47
Edit

This client is used to manage Authing roles. It can create, query, update and delete roles, add/delete users to/from roles, add/delete role's policy and perform other operations.

¶ Create a role

  • RolesManagementClient().create(code)
  • RolesManagementClient().create(code, description)
  • RolesManagementClient().create(code, description, parent)
  • RolesManagementClient().create(code, description, parent, namespace)

Create a role

¶ Parameters

  • code <String> Unique id of the role.
  • description <String> Description of the role.
  • parent <String> Parent role code.
  • namespace <String> Code of the privilege group. For more details, please refer to: Use privilege groups to manage privileged resources.

¶ Example

Role role = managementClient.roles().create(new CreateRoleParam("code")).execute();

¶ Delete a role

RolesManagementClient().delete(code)

Delete a role

¶ Parameter

  • code <String> Unique id of the role

¶ Example

CommonMessage message = managementClient.roles().delete("code").execute();

¶ Bulk delete roles

  • RolesManagementClient().deleteMany(codeList)
  • RolesManagementClient().deleteMany(param)

Bulk delete roles.

¶ Parameter

  • codeList <List<String>> Role code list.
  • param <DeleteRolesParam> Roles delete param object.
  • param.codeList <List<String>> Unique id of the roles list.
  • param.namespace <String>> Code of the privilege group. For more details, please refer to: Use privilege groups to manage privileged resources.

¶ Example

ArrayList<String> list = new ArrayList<String>();
list.add("code");
CommonMessage result = managementClient.roles().deleteMany(list).execute();

¶ Update a role

  • RolesManagementClient().update(code, input)
  • RolesManagementClient().update(code, description)
  • RolesManagementClient().update(code, description, newCode)

Update a role

¶ Parameters

  • code <String> Unique id of the role
  • input <UpdateRoleParam>
  • input.description <String> Description
  • input.newCode <String> New unique id
  • description <String> Description
  • newCode <String> New unique id

¶ Example

Role role = rolesManagementClient.roles().update(new UpdateRoleParam("code").withDescription("desc")).execute();

¶ Get role details

RolesManagementClient().findByCode(param)

Get role details

¶ Parameter

  • param <RoleParam> Role detail param object.
  • param.code <String> Unique id of the role.
  • param.namespace <String> Code of the privilege group. For more details, please refer to: Use privilege groups to manage privileged resources.

¶ Example

Role role = managementClient.roles().findByCode(new RoleParam(randomRole.getCode())).execute());

¶ Get roles list

  • RolesManagementClient().list()
  • RolesManagementClient().list(page)
  • RolesManagementClient().list(page, limit, sortBy)
  • RolesManagementClient().list(page, limit, sortBy, namespace)

Get roles list

¶ Parameters

  • page <Integer> Page number. Default value: 1.
  • limit <Integer> Roles per page, default value: 10.
  • sortBy <SortByEnum> Sorting rules.
  • namespace <String> Code of the privilege group. For more details, please refer to: Use privilege groups to manage privileged resources.

¶ Example

PaginatedRoles roles = managementClient.roles().list().execute();

¶ Get role's users list

  • RolesManagementClient().listUsers(code)
  • RolesManagementClient().listUsers(code, param)

Get role's users list

¶ Parameter

  • code <String> Unique id of the role.
  • param <RoleWithUsersParam> Role's user list query param.
  • param.code <String> Unique id of the role.
  • param.namespace <String> Code of the privilege group. For more details, please refer to: Use privilege groups to manage privileged resources.
  • param.page <Integer> Page number. Default value: 1.
  • param.limit <Integer> Roles per page, default value: 10.

¶ Example

PaginatedUsers users = managementClient.roles().listUsers("code").execute();

¶ Add users

  • RolesManagementClient().addUsers(code, userIds)
  • RolesManagementClient().addUsers(param)

Add users

¶ Parameters

  • code <String> Unique id of the role.
  • userIds <List<String>> Unique id list of the users.
  • param <AssignRoleParam> Assign role param.
  • param.namespace <String> Code of the privilege group. For more details, please refer to: Use privilege groups to manage privileged resources.
  • param.roleCode <String> Unique id of the role.
  • param.roleCodes <List<String>> Unique id list of the role.
  • param.userIds <List<String>> Unique id list of the user.
  • param.groupCodes <List<String>> Unique id list of the group.
  • param.nodeCodes <List<String>> Unique id list of the group node.

¶ Example

ArrayList<String> userIds = new ArrayList<>();
userIds.add("userId");
CommonMessage message = managementClient.roles().addUsers("code", userIds).execute();

¶ Remove a user

  • RolesManagementClient().removeUsers(code, userIds)
  • RolesManagementClient().removeUsers(param)

Remove a user

¶ Parameters

  • code <String> Unique id of the role.
  • userIds <List<String>> Unique id list of the users.
  • param <RevokeRoleParam> Revoke role param.
  • param.namespace <String> Code of the privilege group. For more details, please refer to: Use privilege groups to manage privileged resources.
  • param.roleCode <String> Unique id of the role.
  • param.roleCodes <List<String>> Unique id list of the role.
  • param.userIds <List<String>> Unique id list of the user.
  • param.groupCodes <List<String>> Unique id list of the group.
  • param.nodeCodes <List<String>> Unique id list of the group node.

¶ Example

ArrayList<String> userIds = new ArrayList<>();
userIds.add("userId");
CommonMessage message = managementClient.roles().removeUsers("code", userIds).execute();

¶ Get the role policy list

  • RolesManagementClient().listPolicies(code)
  • RolesManagementClient().listPolicies(code, page, limit)
  • RolesManagementClient().listPolicies(code, page, limit, namespace)

Get the role policy list

¶ Parameters

  • code <String> Unique id of the role.
  • page <Integer> Page number. Default value: 1.
  • limit <Integer> Roles per page, default value: 10.
  • namespage <String> Code of the privilege group. For more details, please refer to: Use privilege groups to manage privileged resources.

¶ Example

PaginatedPolicyAssignments result = managementClient.roles().listPolicies("code").execute();

¶ Add policies

RolesManagementClient().addPolicies(code, policies)

Add policies for roles.

¶ Parameters

  • code <String> Unique id of the role.
  • policies <List<String>> Unique id list of the policies.

¶ Example

ArrayList<String> policies = new ArrayList<>();
policies.add("policy id");
CommonMessage message = managementClient.roles().addPolicies("code", policies).execute();

¶ Remove policies

RolesManagementClient().removePolicies(code, policies)

Remove policies for roles

¶ Parameters

  • code <String> Unique id of the role.
  • policies <List<String>> Unique id list of the policies.

¶ Example

ArrayList<String> policies = new ArrayList<>();
policies.add("policy id");
CommonMessage message = managementClient.roles().removePolicies("code", policies).execute();

¶ Get UdfValue

RolesManagementClient().getUdfValue(code)

Get UdfValue

¶ Parameters

  • code <String> Unique id of the role.

¶ Example


Map<String, Object> data = managementClient.roles().getUdfValue("code").execute();

¶ Get UdfValue Batch

RolesManagementClient().getUdfValueBatch(codeList)

Get UdfValue Batch

¶ Parameters

  • codeList <String> Unique id list of the role.

¶ Example


Map<String, Map<String, Object>> data = managementClient.roles().getUdfValueBatch(Arrays.asList("code1","code2")).execute();

¶ Set UdfValue

  • RolesManagementClient().setUdfValue(code, data)
  • RolesManagementClient().setUdfValue(code, key, value)

Set UdfValue

¶ Parameters

  • code <String> Unique id of the role.
  • data <Map<String, String>> User custom defined data map.
  • key <String> key.
  • value <String> value.

¶ Example

Map<String, String> data = new HashMap<>();
data.put("key1", "value1");
data.put("key2", "value2");
List<UserDefinedData> data = managementClient.roles().setUdfValue("code", data).execute();

¶ Set UdfValue Batch

RolesManagementClient().setUdfValueBatch(params)

Set UdfValue Batch

¶ Parameters

  • params <List<RoleSetUdfValueBatchParams>>
  • params.roleCode <String> Unique id of the role.
  • params.data <Map<String, String>> User custom defined data map.

¶ Example

Map<String, String> data = new HashMap<>();
data.put("key1", "value1");
data.put("key2", "value2");
List<RoleSetUdfValueBatchParams> params = Arrays.asList(new RoleSetUdfValueBatchParams("code", data));
List<UserDefinedData> data = managementClient.roles().setUdfValueBatch(params).execute();

¶ Remove UdfValue

RolesManagementClient().removeUdfValue(code, key)

Remove UdfValue

¶ Parameters

  • code <String> Unique id of the role.
  • key <String> key.

¶ Example


List<UserDefinedData> data = managementClient.roles().removeUdfValue("code", "key").execute();
Prev: Management application Next: Management resources and permissions
  • Create a role
  • Delete a role
  • Bulk delete roles
  • Update a role
  • Get role details
  • Get roles list
  • Get role's users list
  • Add users
  • Remove a user
  • Get the role policy list
  • Add policies
  • Remove policies
  • Get UdfValue
  • Get UdfValue Batch
  • Set UdfValue
  • Set UdfValue Batch
  • Remove UdfValue

User identity management

Integrated third-party login
Mobile phone number flash check (opens new window)
Universal login form component
Custom authentication process

Enterprise internal management

Single Sign On
Multi-factor Authentication
Authority Management

Developers

Development Document
Framework Integration
Blog (opens new window)
GitHub (opens new window)
Community User Center (opens new window)

Company

400 888 2106
sales@authing.cn
16 / F, Block B, NORTH STAR CENTURY CENTER, Beijing(Total)
room 406, 4th floor, zone B, building 1, No. 200, Tianfu Fifth Street, Chengdu(branch)

Beijing ICP No.19051205-1

© Beijing Steamory Technology Co.