code: private void addSecurityRoleChecksToModel(PortletRequest req, Map<String, Object> model) {
          PortletPreferences prefs = req.getPreferences();
          String[] securityRoles = prefs.getValues(PREF_SECURITY_ROLE_NAMES, new String[] {});
          for (int i = 0; i < securityRoles.length; i++) {
              model.put(
                      "is" + securityRoles[i].replace(" ", "_"), req.isUserInRole(securityRoles[i]));
          }
      }
docs: Run through the list of configured security roles and add an "is"+Rolename to the model. The
  security roles must also be defined with a <code>&lt;security-role-ref&gt;</code> element in
  the portlet.xml.
  
  @param req Portlet request
  @param model Model object to add security indicators to