2 Replies Latest reply on Jun 13, 2014 1:39 AM by Tomas Remes

    Any idea about, please!

    Jimmy Añazco Newbie

      My application runs fine locally but on an intranet with multiple users have these problems. Help with some ideas community


      Here is the code which indicates the error and attach the file to see the output.


      package edu.unl.sbe.security;
      import java.io.Serializable;
      import javax.annotation.PostConstruct;
      import javax.ejb.TransactionAttribute;
      import javax.enterprise.context.RequestScoped;
      import javax.enterprise.inject.Produces;
      import javax.inject.Inject;
      import javax.inject.Named;
      import javax.persistence.EntityManager;
      import javax.persistence.NoResultException;
      import edu.unl.sbe.cdi.LoggedIn;
      import edu.unl.sbe.cdi.Web;
      import edu.unl.sbe.model.profile.Profile;
      import edu.unl.sbe.profile.ProfileService;
      import edu.unl.sbe.security.authorization.SecurityRules;
      import org.jboss.seam.security.Identity;
      
      
      /**
       * @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
       * @adapter <a href="mailto:jimmy.anazco@gmail.com">Jimmy Alexander Añazco</a>
      *
      */
      @Named("account")
      @RequestScoped
      public class Account implements Serializable
      {
         private static final long serialVersionUID = 8474539305281711165L;
      
      
         @Inject
         @Web
         private EntityManager em;
      
      
         @Inject
         private Identity identity;
      
      
         @Inject
         private ProfileService ps;
      
      
         @PostConstruct
         public void init()
         {
            ps.setEntityManager(em);
         }
      
      
         Profile loggedIn = new Profile();
      
      
         @Produces
         @LoggedIn
         @RequestScoped
         @Named("userProfile")
         public Profile getLoggedIn()
         {
            if (identity.isLoggedIn() && !loggedIn.isPersistent())
            {
               try {
                  loggedIn = ps.getProfileByIdentityKey(identity.getUser().getKey());
               }
               catch (NoResultException e) {
                  throw e;
               }
            }
            else if (!identity.isLoggedIn())
            {}
            return loggedIn;
         }
      
      
         @TransactionAttribute
         public void saveAjax()
         {
            Profile current = getLoggedIn();
            ps.save(current);
         }
      
      
         @TransactionAttribute
         public void displayBootcampAjax()
         {
            Profile current = getLoggedIn();
            current.setShowBootcamp(true);
            ps.save(current);
         }
      
         @TransactionAttribute
         public void dismissBootcampAjax()
         {
            Profile current = getLoggedIn();
            current.setShowBootcamp(false);
            ps.save(current);
         }
      
      
         public void setEntityManager(final EntityManager em)
         {
            this.em = em;
            ps.setEntityManager(em);
         }
      
         public String accesoSistema(Identity role){
             SecurityRules security=new SecurityRules();
             if(security.isAdmin(identity)){
             return "Admin";
             }
             else if(security.isBecas(identity)){
             return "Becas";
             }
             else if(security.isPsicopedagogico(identity)){
             return "Psicopedagogico";
             }
             else if (security.isDirector(identity)){
              return "Director";
             }
             return "Estudiante";
         }
      
      
          public boolean accesoSistemaSBE(final String grupoIden) {
              SecurityRules s = new SecurityRules();
              if (SecurityRules.ADMIN.equals(grupoIden)) {
                  return s.isAdmin(identity);
              } else if (SecurityRules.BECAS.equals(grupoIden)) {
                  return s.isBecas(identity);
              } else if (SecurityRules.PSICOPEDAGOGICO.equals(grupoIden)) {
                  return s.isPsicopedagogico(identity);
              } else if (SecurityRules.DIRECTOR.equals(grupoIden)) {
                  return s.isDirector(identity);
              }
              return false;
          }
      
             public String loadPages() {
              if (identity.isLoggedIn()) {
                  return null;
              }
              return "/pages/login.xhtml";
          }
          //Metodo Agregado para cambio de contraseña
          public Long getLoggedId() {
              Long id = new Long(0);
              if (identity.isLoggedIn()) {
                  try {
                      loggedIn = ps.getProfileByIdentityKey(identity.getUser().getKey());
                      if (loggedIn != null) {
                          id = loggedIn.getId();
                          return id;
                      }
                  } catch (NoResultException e) {
                      throw e;
                  }
              } else if (!identity.isLoggedIn()) {
              }
              return id;
          }
      }