CRecordUserDbGetRightList
Fetch the list of oll known permissions from the user database.
This message belongs to the session manager API.
{ "id": "5950828d-2bac-40cb-aab7-84bfcd978f45", "name": "USER_DB_GET_RIGHT_LIST", "description": "Get a list of all rights.", "slots": [ { "key": "SessionToken", "name": "SESSION_TOKEN", "direction": "REQUEST", "mandatory": "true", "type": "UUID", "description": "The session token." }, { "key": "rights", "name": "RIGHTS", "direction": "ANSWER", "mandatory": "false", "type": "STRING_ARRAY", "description": "The list of all known permissions." } ] }
Example of use of the class CRecordUserDbGetRightList (after generating)
You need the microservice ID of the session manager:
public static final IId SESSION_MICROSERVICE_ID = CIdFactory.fromObject("ccf168c1-f18b-4229-85f9-24461a19ee6a");
The own SessionToken is needed to verify the authorization for the change.
You need the permission NY_GetListOfRights
.
private void getRightList(@NotNull final UUID aToken) throws CException { final CEnvelope env = CEnvelope.forMicroService(SESSION_MICROSERVICE_ID); final CRecord record = CRecordUserDbGetRightList.create(); CRecordUserDbGetRightList.setSessionToken(record, aToken); sendRequest(env, record); }
To catch the response of the request, we need a message handler. We add it in the constructor of the message handler registry.
// constructor: addMessageHandler(CRecordUserDbGetRightList.ID, this::asyncGetRightList);
private boolean asyncGetRightList(@NotNull final CEnvelope aEnvelope, @NotNull final CRecord aRecord) { if (aEnvelope.isAnswer()) { final int resultCode = aEnvelope.getResultCode(); if (resultCode == CResultCode.SUCCESS) { final String[] rights = CRecordUserDbGetRightList.getRights(aRecord, null); // ... } return true; } return false; }