Package bg.smoc.model

Examples of bg.smoc.model.UserAccount


        userAccountSerializer.delete(login);
        mediator.removeUser(login);
    }

    public void registerUserForContest(String userLogin, String contestId) {
        UserAccount account = getUserAccount(userLogin);
        account.getContestIds().add(contestId);
        update(account);
        mediator.registerUserForContest(contestId, userLogin);
    }
View Full Code Here


    private static final long serialVersionUID = 4929305359709832060L;

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        UserAccount userAccount = new UserAccount();
        Person person = new Person();
        if (isFormFilledCorrectly(request, userAccount, person)) {
            userAccount.setPasswordHash(ServletUtil.encryptPassword(userAccount.getPassword()));
            userAccount.setPassword(null);

            person.getLogins().add(userAccount.getLogin());

            SessionUtil util = SessionUtil.getInstance();
            util.getUserAccountManager().createUser(userAccount);
            util.getPersonManager().addPerson(person);

            response.sendRedirect("/");
        } else {
            request.setAttribute("username", userAccount.getLogin());
            request.setAttribute("password", userAccount.getPassword());
            request.setAttribute("names", person.getNames());
            request.setAttribute("town", person.getTown());
            request.setAttribute("email", person.getEmail());

            request.getRequestDispatcher("registerUser.jsp").forward(request, response);
View Full Code Here

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        SessionUtil sessionUtil = SessionUtil.getInstance();
        String userLogin = sessionUtil.getLoginManager().getActiveUserLogin(request);
        UserAccount userAccount = sessionUtil.getUserAccountManager().getUserAccount(userLogin);
        Vector<Contest> allContests = sessionUtil.getContestManager().getContests();

        Vector<Contest> availableForLogin = new Vector<Contest>();
        Vector<Contest> availableForRegistering = new Vector<Contest>();
        for (Contest contest : allContests) {
            if (userAccount.getContestIds().contains(contest.getId())) {
                availableForLogin.add(contest);
            } else {
                if (contest.isOpenContest())
                    availableForRegistering.add(contest);
            }
View Full Code Here

    public void createNewUser(String userLogin, String contestId) {
        if (getUserById(userLogin) != null)
            return;

        UserAccount user = new UserAccount();
        user.setLogin(userLogin);
        user.setPassword(generateRandomPassword());
        user.setPasswordHash(ServletUtil.encryptPassword(user.getPassword()));
        user.getContestIds().add(contestId);
        userAccounts.add(user);
        storeUsers();
    }
View Full Code Here

        }
        return null;
    }

    public void update(UserAccount userAccount) {
        UserAccount prevUser = getUserById(userAccount.getLogin());
        if (prevUser == null) {
            System.out.println("Count not update user " + userAccount.getLogin());
            return;
        }
        prevUser.populateFrom(userAccount);
        storeUsers();
    }
View Full Code Here

        personManager = sessionUtil.getPersonManager();
        personManager.setMediator(this);
    }

    public boolean verifyUserPassword(String login, String passwordHash) {
        UserAccount account = userAccountManager.getUserAccount(login);
        return (account != null && passwordHash.equals(account.getPasswordHash()));
    }
View Full Code Here

    String personId = request.getParameter("personId");
    String login = request.getParameter("login");

    SessionUtil sessionUtil = SessionUtil.getInstance();
    Person person = sessionUtil.getPersonManager().getPerson(personId);
    UserAccount userAccount = sessionUtil.getUserAccountManager().getUserAccount(login);
    if (userAccount != null) {
      if (person.getLogins() == null)
        person.setLogins(new Vector<String>());
      person.getLogins().add(login);
      sessionUtil.getPersonManager().update(person);
View Full Code Here

        personManager = sessionUtil.getPersonManager();
        personManager.setMediator(this);
    }

    public boolean verifyUserPassword(String login, String passwordHash) {
        UserAccount account = userAccountManager.getUserAccount(login);
        return (account != null && passwordHash.equals(account.getPasswordHash()));
    }
View Full Code Here

    private static final long serialVersionUID = 4929305359709832060L;

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        UserAccount userAccount = new UserAccount();
        Person person = new Person();
        if (isFormFilledCorrectly(request, userAccount, person)) {
            userAccount.setPasswordHash(ServletUtil.encryptPassword(userAccount.getPassword()));
            userAccount.setPassword(null);

            person.getLogins().add(userAccount.getLogin());

            SessionUtil util = SessionUtil.getInstance();
            util.getUserAccountManager().createUser(userAccount);
            util.getPersonManager().addPerson(person);

            response.sendRedirect("/");
        } else {
            request.setAttribute("username", userAccount.getLogin());
            request.setAttribute("password", userAccount.getPassword());
            request.setAttribute("names", person.getNames());
            request.setAttribute("town", person.getTown());
            request.setAttribute("email", person.getEmail());

            request.getRequestDispatcher("registerUser.jsp").forward(request, response);
View Full Code Here

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        String userLogin = request.getParameter("login");
        UserAccount userAccount = SessionUtil.getInstance().getUserAccountManager()
                .getUserAccount(userLogin);
        ContestManager contestManager = SessionUtil.getInstance().getContestManager();
        if (userAccount != null) {
            if (request.getParameter("password") != null && request.getParameter("password") != "") {
                userAccount.setPassword(request.getParameter("password"));
                userAccount.setPasswordHash(ServletUtil.encryptPassword(userAccount.getPassword()));
            }
            if (request.getParameter("contest") != null) {
                userAccount.getContestIds().add(request.getParameter("contest"));
                contestManager.registerUserForContest(request.getParameter("contest"), userLogin);
            }
            else if (request.getParameterValues("contests") != null) {
                userAccount.getContestIds().clear();
                for (String contest : request.getParameterValues("contests")) {
                    userAccount.getContestIds().add(contest);
                    contestManager.registerUserForContest(contest, userLogin);
                }
            } else {
                userAccount.setContestIds(null);
            }
            SessionUtil.getInstance().getUserAccountManager().update(userAccount);
        }

        response.sendRedirect("accounts");
View Full Code Here

TOP

Related Classes of bg.smoc.model.UserAccount

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.