code: public void checkRoleForResource(CmsDbContext dbc, CmsRole role, CmsResource resource)
      throws CmsRoleViolationException {
  
          if (!hasRoleForResource(dbc, dbc.currentUser(), role, resource)) {
              throw role.createRoleViolationExceptionForResource(dbc.getRequestContext(), resource);
          }
      }
docs: Checks if the user of the current database context has permissions to impersonate the given role
  for the given resource.<p>
  
  @param dbc the current OpenCms users database context
  @param role the role to check
  @param resource the resource to check the role for
  
  @throws CmsRoleViolationException if the user does not have the required role permissions
  
  @see org.opencms.security.CmsRoleManager#checkRole(CmsObject, CmsRole)