@Test public void testIsUserInRole() throws Exception { expect(externalContext.isUserInRole(eq("admin"))).andReturn(false); expect(externalContext.isUserInRole(eq("user"))).andReturn(true); expect(externalContext.isUserInRole(eq("manager"))).andReturn(false); expect(externalContext.isUserInRole(eq("guest"))).andReturn(false); expect(externalContext.isUserInRole(eq("supervisor"))).andReturn(true); expect(externalContext.isUserInRole(eq("auditor"))).andReturn(false); environment.replay(); assertTrue(RichFunction.isUserInRole("admin, user, root")); Set<String> set = new LinkedHashSet<String>(); set.add("manager"); set.add("guest"); set.add("supervisor"); assertTrue(RichFunction.isUserInRole(set)); assertFalse(RichFunction.isUserInRole("auditor")); assertFalse(RichFunction.isUserInRole(null)); }
@Function public static boolean isUserInRole(Object rolesObject) { Set<String> rolesSet = Sets.asSet(rolesObject); if (rolesSet != null) { FacesContext facesContext = FacesContext.getCurrentInstance(); ExternalContext externalContext = facesContext.getExternalContext(); for (String role : rolesSet) { if (externalContext.isUserInRole(role)) { return true; } } } return false; }
RichFunction { @Function public static boolean isUserInRole(Object rolesObject) { Set<String> rolesSet = Sets.asSet(rolesObject); if (rolesSet != null) { FacesContext facesContext = FacesContext.getCurrentInstance(); ExternalContext externalContext = facesContext.getExternalContext(); for (String role : rolesSet) { if (externalContext.isUserInRole(role)) { return true; } } } return false; } }
RichFunction { @Function public static boolean isUserInRole(Object rolesObject) { Set<String> rolesSet = Sets.asSet(rolesObject); if (rolesSet != null) { FacesContext facesContext = FacesContext.getCurrentInstance(); ExternalContext externalContext = facesContext.getExternalContext(); for (String role : rolesSet) { if (externalContext.isUserInRole(role)) { return true; } } } return false; } private  RichFunction(); }
RichFunction { @Function public static boolean isUserInRole(Object rolesObject) { Set<String> rolesSet = Sets.asSet(rolesObject); if (rolesSet != null) { FacesContext facesContext = FacesContext.getCurrentInstance(); ExternalContext externalContext = facesContext.getExternalContext(); for (String role : rolesSet) { if (externalContext.isUserInRole(role)) { return true; } } } return false; } private  RichFunction(); static UIComponent findComponent(FacesContext context, String id); @Function static String clientId(String id); @Function static String component(String id); @Function static String element(String id); @Function static String jQuerySelector(String id); static String jQuerySelector(FacesContext facesContext, UIComponent component); @Function static String jQuery(String id); @Function static UIComponent findComponent(String id); @Function static boolean isUserInRole(Object rolesObject); @Function static String toScript(Object o); }
RichFunction { @Function public static boolean isUserInRole(Object rolesObject) { Set<String> rolesSet = Sets.asSet(rolesObject); if (rolesSet != null) { FacesContext facesContext = FacesContext.getCurrentInstance(); ExternalContext externalContext = facesContext.getExternalContext(); for (String role : rolesSet) { if (externalContext.isUserInRole(role)) { return true; } } } return false; } private  RichFunction(); static UIComponent findComponent(FacesContext context, String id); @Function static String clientId(String id); @Function static String component(String id); @Function static String element(String id); @Function static String jQuerySelector(String id); static String jQuerySelector(FacesContext facesContext, UIComponent component); @Function static String jQuery(String id); @Function static UIComponent findComponent(String id); @Function static boolean isUserInRole(Object rolesObject); @Function static String toScript(Object o);  }