Package org.bigk.invoices.model

Examples of org.bigk.invoices.model.User


      throws ServiceException {
    if (logger.isDebugEnabled()) {
      logger.debug("processLogin(String login=" + login + ", String password=xxx) - start");
    }
   
    User user = null;
    try {
      user = usersDAO.getUser4Login(login);
    } catch (DBAccessException ex) {
      logger.error("processLogin(String, String)", ex);
      throw new ServiceException(ex);
    }
   
    if (user == null) {
      throw new ServiceException("No user found for username",
          "services.LoginServiceImpl.processLogin.no_user",
          new Object[] {login}
      );
    }
   
    String passSHA1 = null;
    try {
      passSHA1 = DigestUtils.digestSHA1(password);
    } catch (NoSuchAlgorithmException e) {
      logger.error("processLogin(String, String)", e);
      throw new ServiceException("NoSuchAlgorithmException", e,
          "services.LoginServiceImpl.processLogin.algoritm_problem",
          new Object[] {e.getMessage()}
      );     
    }
   

    if (logger.isDebugEnabled()) {
      logger.debug("processLogin(String, String) - passSHA1=" + passSHA1);
      logger.debug("processLogin(String, String) - user.getPassword()=" + user.getPassword());
    }
   
    if (!passSHA1.equalsIgnoreCase(user.getPassword())) {
      throw new ServiceException("Wrong password",
          "services.LoginServiceImpl.processLogin.wrong_password",
          null
      );
    }
View Full Code Here


  @Override
  public User getUser(Long id) throws DBAccessException {
    logger.debug("getUser(id=[{}]) - start", id);
   
    User user = em.find(User.class, id);
   
    logger.debug("getUser() - end - return value=[{}]", user);
    return user;
  }
View Full Code Here

    logger.debug("getUserByLogin(login=[{}]) - start", login);
   
    TypedQuery<User> query = em.createQuery(USER_BY_LOGIN_QUERY, User.class);
    query.setParameter("login", login);

        User user = null;
        try {
          user = query.getSingleResult();
        } catch (NoResultException ex) {
          logger.info("NoResultException caught, means that no user found for login [{}]", login);
        }
View Full Code Here

  public void nullUserByIdReturnedForNotExistingId() throws Exception {
   
    // given - configured by spring
   
    // when
    User user = dao.getUser(0L);
   
    // then
    assertNull(user);
  }
View Full Code Here

  public void userByIdReturnedForExistingId() throws Exception {
   
    // given - configured by spring
   
    // when
    User user = dao.getUser(1L);
   
    // then
    assertNotNull(user);
  }
View Full Code Here

  public void nullUserByLoginReturnedForNotExistingLogin() throws Exception {
   
    // given - configured by spring
   
    // when
    User user = dao.getUserByLogin("no-login");
   
    // then
    assertNull(user);
  }
View Full Code Here

  public void userByLoginReturnedForExistingLogin() throws Exception {
   
    // given - configured by spring
   
    // when
    User user = dao.getUserByLogin("admin");
   
    // then
    assertNotNull(user);
  }
View Full Code Here

      logger.debug("execute() - start");
    }

    String result = null;
   
    User user = null;
    try {
      user = loginService.processLogin(username, password);
      result = SUCCESS;
     
    } catch (ServiceException ex) {
View Full Code Here

  public User getUser(Long id) throws DBAccessException {
    if (logger.isDebugEnabled()) {
      logger.debug("getUser(Long id=" + id + ") - start");
    }

    User user = null;
    Session session = null;
    try {
      session = HibernateUtils.getCurrentSession();
      user = (User) session.get(User.class, id);
    } catch (HibernateException ex) {
View Full Code Here

  public User getUser4Login(String login) throws DBAccessException {
    if (logger.isDebugEnabled()) {
      logger.debug("getUser4Login(String login=" + login + ") - start");
    }
   
    User user = null;
    Session session = null;

        try {
      session = HibernateUtils.getCurrentSession();
View Full Code Here

TOP

Related Classes of org.bigk.invoices.model.User

Copyright © 2018 www.massapicom. 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.