Package com.yourpackagename.yourwebproject.model.entity

Examples of com.yourpackagename.yourwebproject.model.entity.User


        return validity;
    }


    @Override public User findByUsername(String username) throws NotFoundException {
        User user = userRepository.findByUsername(username);

        if(user != null) {
            return user;
        } else {
            throw new NotFoundException(key.unfMsg, key.unfCode);
View Full Code Here


                                @ModelAttribute(Key.loginUserForm) UserRO userRO) {
        try {
            // Authenticate the credentials
            if ((userRO.username != null && userRO.username.trim().length() > 0)
                    && (userRO.password != null && userRO.password.trim().length() > 0)) {
                final User user = userService.findByUsername(userRO.username);
                log.info("User Found: " + user.getUserName());

                if (user.getPassWord().equals(User.hashPassword(userRO.password))) {
                    log.info("Authenticated: " + user.getUserName());

                    // Update the login count and other info
                    userService.loginUser(user, request);

                    // Store the user in session
                    request.getSession(true).setAttribute(Key.userInSession, user);
                    model.addAttribute("ls", true);
                    return Key.redirect + Route.dashboard;
                } else {
                    log.info("User Authentication Failed: " + user.getUserName());
                    throw new AuthenticationFailedException(msg.aFailed, msg.aFailedCode);
                }
            } else {
                throw new AuthCredentialsMissingException(msg.aParamMissing, msg.aParamMissingCode);
            }
View Full Code Here

     */
    @RequestMapping(value = Route.registerUser, method = RequestMethod.POST, consumes = Key.formEncoded)
    public String registerUser(Locale locale, Model model,
                                   @ModelAttribute(Key.regUserForm) UserRO userRO) {
        try {
            User u = userRO.user(props);
            Validity validity = userService.validate(u);
            if (validity.isValid()) {
                userService.registerUser(u, request);
                mailSenderActor.sendUserEmailIdConfirmationMail(u);
                request.getSession(true).setAttribute(Key.userInSession, u);
View Full Code Here

        else if (ecs)
            addSuccess(msg.emailCnfSuccess, model);

        if (request.getSession(false) != null &&
                request.getSession(false).getAttribute(Key.userInSession) != null) {
            User u = (User) request.getSession(false).getAttribute(Key.userInSession);
            addUser(u, model);

            return View.dashboard;
        } else {
            return Key.redirect + Route.home;
View Full Code Here

    public String country;
    public String postalCode;


    public User user(Props props) {
        User user = new User();
        user.setUserName(username);
        user.setPassWord(password);
        user.setEmail(email);
        user.setMobile(mobile);

        if(role != null)
            user.setRole(role);
        else
            user.setRole(Role.USER);

        Address address = new Address();
        address.setStreetAddress(streetAddress);
        address.setCity(city);
        address.setState(state);
        address.setPostalCode(postalCode);
        if (country == null || country.trim().equalsIgnoreCase("")) {
            address.setCountry(props.fUserCountry);
        } else {
            address.setCountry(country);
        }

        user.setAddress(address);
        return user;
    }
View Full Code Here

    @RequestMapping(value = ApiRoute.uRegister, method = RequestMethod.POST)
    public @ResponseBody ModelAndView register(@RequestBody UserRO userRO,
                                               @RequestHeader("pass") String password) {
        Response response = serverResponse();
        try {
            User user = userRO.user(props);
            user.setPassWord(password);
            Validity vsUser = userService.validate(user);
            if (vsUser.isValid()) {
                userService.registerUser(user, request);
                response.setResult(user);
            } else {
View Full Code Here

                        String credString = new String(Base64.decodeBase64(creds[1].getBytes()));
                        String[] userPass = credString.split(":");

                        // Authenticate the credentials
                        if (userPass != null && userPass.length > 0) {
                            User user;
                            if (request.getSession(false) != null &&
                                    request.getSession(false).getAttribute(Key.userInSession) != null) {
                                user = (User) request.getSession(false).getAttribute(Key.userInSession);
                                authenticateUserFromSession(user, userPass, request);
                            }
View Full Code Here

    }


    private void authenticateUser(String[] userPass, HttpServletRequest request)
            throws NotFoundException, AuthenticationFailedException {
        final User user = userService.findByUsername(userPass[0]);
        log.info("User Found: " + user.getUserName());

        if (user.getPassWord().equals(User.hashPassword(userPass[1]))) {
            log.info("Authenticated: " + user.getUserName());

            // Store the attribute to be referenced later in the API code
            request.getSession(true).setAttribute(Key.userInSession, user);
        } else {
            log.info("User Authentication Failed: " + user.getUserName());
            throw new AuthenticationFailedException(msg.aFailed);
        }
    }
View Full Code Here

TOP

Related Classes of com.yourpackagename.yourwebproject.model.entity.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.