Custom SPI: Resource - Associated Permission

I am extending RolePolicyProvider but I cant get the connection from a resource to an associated permission.
The permission object attained as:
ResourcePermission permission = evaluation.getPermission();
Resource resource = permission.getResource();

is another one than the associated one. There is an URL: http://localhost:8080/admin/realms/Realm-Test/clients/957e9af8-09b6-4a35-a4ab-f7e15c46af21/authz/resource-server/resource/fe8b4cd5-601c-46af-9f2q-1534ade8cab2/permissions

I need exactly this call but in the code. Cant get hold of the proper permission object in the code.
resource.getAssociatedPermissions() doesnt exist.
Any advice will be appreciated.