Examples of SbiUser


Examples of it.eng.spagobi.profiling.bean.SbiUser

  public SpagoBIUserProfile createUserProfile(String userId) {
    logger.debug("IN - userId: " + userId);
    SpagoBIUserProfile profile = null;
    try {
      SbiUser user = DAOFactory.getSbiUserDAO().loadSbiUserByUserId(userId);

      if (user == null) {
        logger.error("UserName [" + userId + "] not found!!");
          return null;
      }
 
      profile = new SpagoBIUserProfile();
      profile.setUniqueIdentifier(userId);
      profile.setUserId(userId);
      profile.setUserName(user.getFullName());
 
      // get user name
      String userName = userId;
      // get roles of the user
     
      ArrayList<SbiExtRoles> rolesSB = DAOFactory.getSbiUserDAO().loadSbiUserRolesById(user.getId());
      List roles = new ArrayList();
      Iterator iterRolesSB = rolesSB.iterator();
     
      IRoleDAO roleDAO = DAOFactory.getRoleDAO();
      while (iterRolesSB.hasNext()) {
        SbiExtRoles roleSB = (SbiExtRoles) iterRolesSB.next();

          roles.add(roleSB.getName());
      }
      HashMap attributes = new HashMap();
      ArrayList<SbiUserAttributes> attribs = DAOFactory.getSbiUserDAO().loadSbiUserAttributesById(user.getId());
      if(attribs != null){
        Iterator iterAttrs = attribs.iterator();
        while(iterAttrs.hasNext()){
            // Attribute to lookup
          SbiUserAttributes attribute = (SbiUserAttributes) iterAttrs.next();
View Full Code Here

Examples of it.eng.spagobi.profiling.bean.SbiUser

    // get user name
    String userName = userId;
    // get user from database
   
    try {
      SbiUser user = DAOFactory.getSbiUserDAO().loadSbiUserByUserId(userId);
      if(user == null){
        logger.error("UserName not found into database");
        return null;
      }
      String password = user.getPassword();
      String encrPass = Password.encriptPassword(psw);
      if (password == null || password.length() == 0) {
          logger.error("UserName/pws not defined into database");
          return null;
      }else if(password.equals(encrPass)){
View Full Code Here

Examples of it.eng.spagobi.profiling.bean.SbiUser

      String fullName = getAttributeAsString(FULL_NAME);
      String password = getAttributeAsString(PASSWORD);
      JSONArray rolesJSON = getAttributeAsJSONArray(ROLES);
      JSONArray attributesJSON = getAttributeAsJSONArray(ATTRIBUTES);
      if (userId != null) {
        SbiUser user = new SbiUser();
        user.setUserId(userId);
        user.setFullName(fullName);
        if(password != null && password.length() > 0){
          try {
            user.setPassword(Password.encriptPassword(password));
          } catch (Exception e) {
            logger.error("Impossible to encript Password", e);
            throw new SpagoBIServiceException(SERVICE_NAME,
                "Impossible to encript Password",e);
          }
        }
       
        if(id!=null){
          user.setId(id);
        }
        try {
          HashMap<Integer, String> attrList = null;
          if(attributesJSON != null){
            attrList = deserializeAttributesJSONArray(attributesJSON);
View Full Code Here

Examples of it.eng.spagobi.profiling.bean.SbiUser

      ISbiUserDAO userDAO= DAOFactory.getSbiUserDAO();

      while (it.hasNext()) {
          SourceBean user = (SourceBean) it.next();
         
          SbiUser sbiUser = new SbiUser();
          String userId = (String) user.getAttribute("userId");
          sbiUser.setUserId(userId);
          String password = (String) user.getAttribute("password");
        if (password!=null){
            try {
              sbiUser.setPassword(Password.encriptPassword(password));
          } catch (Exception e) {
            logger.error("Impossible to encript Password", e);
          }
        }
          String fullName = (String) user.getAttribute("fullName");
          if(fullName != null){
            sbiUser.setFullName(fullName);
          }

          try {
            //checks if user already exists
            Integer existingId = userDAO.loadByUserId(userId);
View Full Code Here

Examples of it.eng.spagobi.profiling.bean.SbiUser

      boolean isInternalSecurity = ("true".equalsIgnoreCase((String)request.getAttribute("isInternalSecurity")))?true:false;
      logger.debug("isInternalSecurity: " + isInternalSecurity);
      if (isInternalSecurity)  {      
        //gets the user bo
        ISbiUserDAO userDao = DAOFactory.getSbiUserDAO();
        SbiUser user = userDao.loadSbiUserByUserId(userId);

        //check user's role: if he's admin it doesn't apply checks on password
        String strAdminPatter =  SingletonConfig.getInstance().getConfigValue("SPAGOBI.SECURITY.ROLE-TYPE-PATTERNS.ADMIN-PATTERN");
        int sbiUserId=-1;
        if (user!=null)sbiUserId=user.getId();
        List lstRoles = userDao.loadSbiUserRolesById(sbiUserId);
        boolean isAdminUser = false;

        for (int i=0; i<lstRoles.size(); i++){
          SbiExtRoles tmpRole = (SbiExtRoles)lstRoles.get(i);
          Role role = DAOFactory.getRoleDAO().loadByID(tmpRole.getExtRoleId());
          if (role.getName().equals(strAdminPatter)){
            isAdminUser = true;
            logger.debug("User is administrator. Checks on the password are not applied !");
            break;
          }
        }

        if (!isAdminUser){
          //check validation of the password
          logger.debug("Validation password starting...");

          boolean goToChangePwd = checkPwd(user);
          if (goToChangePwd){
            response.setAttribute("user_id", user.getUserId());
            String url = servletRequest.getProtocol().substring(0,servletRequest.getProtocol().indexOf("/")) +
            "://"+servletRequest.getServerName()+":"+servletRequest.getLocalPort()+servletRequest.getContextPath();
            response.setAttribute("start_url", url);
            response.setAttribute(SpagoBIConstants.PUBLISHER_NAME, "ChangePwdPublisher");
            return;
          }

          logger.info("The pwd is active!");
          //update lastAccessDate on db with current date
          try{
            if (user!=null){
              user.setDtLastAccess(new Date());
              userDao.updateSbiUser(user, user.getId());
            }
          }catch(Exception e){
            logger.error("Error while update user's dtLastAccess: " + e);
          }
        }
View Full Code Here

Examples of it.eng.spagobi.profiling.bean.SbiUser

      throw new SerializationException("SbiUserJSONSerializer is unable to serialize object of type: " + o.getClass().getName());
    }
   
    try {

      SbiUser sbiUser = (SbiUser)o;
      result.put(ID, sbiUser.getId());
      result.put(USER_ID, sbiUser.getUserId());
      result.put(FULL_NAME, sbiUser.getFullName());
      result.put(PWD, sbiUser.getPassword());
     
      //roles
      Set<SbiExtUserRoles> userRoles = sbiUser.getSbiExtUserRoleses();
      Iterator itRoles = userRoles.iterator();
      JSONArray rolesJSON = new JSONArray();
      rolesJSON.put("roles");

      while(itRoles.hasNext()){
        JSONObject jsonRole = new JSONObject();
        SbiExtRoles extRole = (SbiExtRoles)itRoles.next();
        Integer roleId= extRole.getExtRoleId();

        jsonRole.put("name", extRole.getName());
        jsonRole.put("id", roleId);
        jsonRole.put("description", extRole.getDescr());
        rolesJSON.put(jsonRole);
     
      result.put("userRoles", rolesJSON);
     
      //attributes
      Set<SbiUserAttributes> userAttributes = sbiUser.getSbiUserAttributeses();
      Iterator itAttrs = userAttributes.iterator();
      JSONArray attrsJSON = new JSONArray();
      attrsJSON.put("attributes");

      while(itAttrs.hasNext()){
View Full Code Here

Examples of it.eng.spagobi.profiling.bean.SbiUser

     
      String q = "from SbiUser us where us.userId = :userId";
      Query query = aSession.createQuery(q);
      query.setString("userId", userId);
     
      SbiUser user = (SbiUser)query.uniqueResult();     
     
      if(user != null)
        return Integer.valueOf(user.getId());
    } catch (HibernateException he) {
      logger.error(he.getMessage(),he);
      if (tx != null)
        tx.rollback();
      throw new EMFUserError(EMFErrorSeverity.ERROR, 100);
View Full Code Here

Examples of it.eng.spagobi.profiling.bean.SbiUser

   * @throws EMFUserError the EMF user error
   *
   */
  public SbiUser loadSbiUserById(Integer id) throws EMFUserError {
    logger.debug("IN");
    SbiUser toReturn = null;
    Session aSession = null;
    Transaction tx = null;
    try {
      aSession = getSession();
      tx = aSession.beginTransaction();
      String q = "from SbiUser us where us.id = :id";
      Query query = aSession.createQuery(q);
      query.setInteger("id", id);
      toReturn = (SbiUser)query.uniqueResult();
      Hibernate.initialize(toReturn);
      Hibernate.initialize(toReturn.getSbiExtUserRoleses());
      Hibernate.initialize(toReturn.getSbiUserAttributeses());
      for(SbiUserAttributes current : toReturn.getSbiUserAttributeses() ){
        Hibernate.initialize(current.getSbiAttribute());
      }
     
      tx.commit();
    } catch (HibernateException he) {
View Full Code Here

Examples of it.eng.spagobi.profiling.bean.SbiUser

      //checks if user with same userId exists
      String q = "from SbiUser us where us.userId = :userId";
      Query query = aSession.createQuery(q);
      query.setString("userId", user.getUserId());
     
      SbiUser userExists = (SbiUser)query.uniqueResult();
      if(userExists == null){
        Integer id = (Integer)aSession.save(user);       
        tx.commit();
        return id;
      }else{
View Full Code Here

Examples of it.eng.spagobi.profiling.bean.SbiUser

      tx = aSession.beginTransaction();
      String q = "from SbiUser us where us.userId = :userId";
      Query query = aSession.createQuery(q);
      query.setString("userId", userId);
     
      SbiUser user = (SbiUser)query.uniqueResult();
      tx.commit();
      return user;
    } catch (HibernateException he) {
      logger.error(he.getMessage(), he);
      if (tx != null)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.