Package com.philip.journal.core.bean

Examples of com.philip.journal.core.bean.User


            final PrintWriter printWriter = response.getWriter();
            String errorMsg = null;
            try {
                getServiceProxy().setSessionId(request.getSession().getId());
                final User user = getServiceProxy().authenticateUser(username, password);
                request.getSession().setAttribute(SessionConstant.USER, user);
                printWriter.write("{success: true, redirect: '" + request.getContextPath() + "/home" + "'}");
                getLogger().debug("LOGIN SUCCESS");
                return;
            } catch (final Exception e) { // catch All
View Full Code Here


    private final Logger logger = Logger.getLogger(getClass()); // NOPMD by r39

    @Override
    public User authenticateUser(final Map<String, Object> session, final String username, final String pPassword)
    {
        final User user = getDaoFacade().getUserDAO().readByUsername(username);
        if (user == null) {
            throw new UserNotFoundException(username);
        } else {
            final String password = pPassword == null ? "" : pPassword;
            if (PasswordUtil.getInstance().checkPassword(user, password) || password.equals(user.getPassword())) {
                session.put(Constant.CURRENT_USER, user);
                return user;
            } else {
                logger.debug(PasswordUtil.getInstance().encrypt(user, password));
                logger.debug(user.getPassword());
                throw new IncorrectPasswordException();
            }
        }
    }
View Full Code Here

    @Override
    public void changePassword(final Map<String, Object> session, final String oldPassword, final String pNewPassword)
    {
        final String newPassword = pNewPassword == null ? "" : pNewPassword;
        User user = (User) session.get(Constant.CURRENT_USER);
        user = getDaoFacade().getUserDAO().readByUsername(user.getUsername());
        if (PasswordUtil.getInstance().checkPassword(user, oldPassword) || oldPassword.equals(user.getPassword())) {
            final Date now = new Date();
            user.setUpdateDate(now);
            user.setUpdateTime(now);
            user.setUpdater(user);
            user.setPassword(PasswordUtil.getInstance().encrypt(user, newPassword));
            // user.setChecksum(PasswordUtil.encrypt(user, user.getPassword() + user.getClass()));
            getDaoFacade().getUserDAO().save(user);
        } else {
            throw new IncorrectPasswordException();
        }
View Full Code Here

    @Override
    public User readByUsername(final String username)
    {
        final Map<String, Object> param = new HashMap<String, Object>();
        param.put("username", username);
        User user = null;
        try {
            user = readObject(param);
        } catch (final Exception e) {
            throw new JournalException(e.getMessage(), e);
        }
View Full Code Here

     * @return the current updater set on the Entity.
     */
    private String getActorId(final StatelessSession session, final AbstractPreDatabaseOperationEvent event)
    {
        final EntityMode entityMode = event.getPersister().guessEntityMode(event.getEntity());
        User actor = ((User) event.getPersister().getPropertyValue(event.getEntity(), "updater", entityMode));
        if (actor == null) {//can happen due to bad data.  I do not set the creator and updater before so...
            actor = ((User) event.getPersister().getPropertyValue(event.getEntity(), "creator", entityMode));
        }
        return actor.getUsername();
    }
View Full Code Here

TOP

Related Classes of com.philip.journal.core.bean.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.