code: public boolean hasRoleForResource(CmsObject cms, String userName, CmsRole role, String resourceName) {
  
          CmsResource resource;
          try {
              resource = cms.readResource(resourceName, CmsResourceFilter.ALL);
          } catch (CmsException e) {
              // ignore
              return false;
          }
          CmsUser user;
          try {
              user = cms.readUser(userName);
          } catch (CmsException e) {
              // ignore
              return false;
          }
          return m_securityManager.hasRoleForResource(cms.getRequestContext(), user, role, resource);
      }
docs: Checks if the given context user has the given role for the given resource.<p>
  
  @param cms the opencms context
  @param userName the name of the user to check the role for
  @param role the role to check
  @param resourceName the name of the resource to check
  
  @return <code>true</code> if the given context user has the given role for the given resource