Beispiel #1
0
 public void checkRoles(ComponentSystemEvent event) {
   if (getUserAuth() == null
       && JSFUtils.getUserName() != null
       && !JSFUtils.getUserName().isEmpty()) {
     userAuth = userRepository.findByUsername(JSFUtils.getUserName());
     setUserAuth(userAuth);
     logOperationsController.save("LOGIN", JSFUtils.getUserName(), "LOGIN");
   }
   String acl = "" + event.getComponent().getAttributes().get("roles");
   for (String a : acl.split(",")) {
     if ("ANY".equalsIgnoreCase(a)) {
       if (JSFUtils.getUserName() != null && JSFUtils.getUserName().length() > 0) {
         return;
       }
     }
     if (isInRole(a.trim())) {
       return;
     }
   }
   try {
     logger.info(acl + " - non consentito!");
     FacesContext context = FacesContext.getCurrentInstance();
     ConfigurableNavigationHandler handler =
         (ConfigurableNavigationHandler) context.getApplication().getNavigationHandler();
     handler.performNavigation("administration");
   } catch (Exception e) {
     e.printStackTrace();
     // Se siamo qui il redirect è fallito.
     // A questo punto, piuttosto che lasciare andare l'utente dove
     // non deve.. runtime exception!
     throw new RuntimeException("Accesso non consentito");
   }
 }
  public void onRowDblselect(SelectEvent event) {
    FacesContext context = FacesContext.getCurrentInstance();
    ConfigurableNavigationHandler handler =
        (ConfigurableNavigationHandler) context.getApplication().getNavigationHandler();
    Flash flash = context.getExternalContext().getFlash();
    flash.put("selectedCar", (StockProductoTiendaOrigen) event.getObject());

    handler.performNavigation("carDetail");
  }
Beispiel #3
0
  public void checkLogin(ComponentSystemEvent event) {

    System.out.println("checando o login");

    if (!loggedIn) {
      FacesContext context = FacesContext.getCurrentInstance();

      ConfigurableNavigationHandler handler =
          (ConfigurableNavigationHandler) context.getApplication().getNavigationHandler();

      handler.performNavigation("login");
    }
  }
Beispiel #4
0
 public void modif() {
   FacesContext fc = FacesContext.getCurrentInstance();
   ConfigurableNavigationHandler nav =
       (ConfigurableNavigationHandler) fc.getApplication().getNavigationHandler();
   nav.performNavigation("modif_four");
 }