Package org.apache.shale.usecases.logic

Examples of org.apache.shale.usecases.logic.LogonLogic


        } catch (NumberFormatException e) {
            return UNAUTHENTICATED;
        }

        // Locate the corresponding valid user (if any) and return it
        LogonLogic logic = (LogonLogic) getBean(LOGIC_BEAN);
        User user = logic.findUser(id);
        if (user == null) {
            return UNAUTHENTICATED;
        }

        // Register the newly authenticated user and return that outcome
View Full Code Here


     * <p>Authenticate the entered username and password.</p>
     */
    public String logon() {

        // Attempt a successful authentication
        LogonLogic logic = (LogonLogic) getBean(LOGIC_BEAN);
        User user = logic.authenticate(username, password);
        if (user != null) {
            if (user.isConfirmed()) {
                // Confirmed user, log him/her on
                register(user);
                if (isRememberMe()) {
View Full Code Here

                okPassword = false;
            }
        }

        // Validate duplicate username if creating
        LogonLogic logic = (LogonLogic) getBean(LOGIC_BEAN);
        if (state.isCreating() && (logic.findUser(state.getUsername()) != null)) {
            error(messages.getMessage("profile.duplicate"));
            okUsername = false;
        }

        // Return appropriate outcome on validation failures
        if (!okUsername) {
            return USERNAME;
        } else if (!okPassword) {
            return PASSWORD;
        }

        // Create or acquire our User instance
        User user = null;
        if (state.isCreating()) {
            user = logic.createUser();
        } else {
            user = (User) getBean(getUserKey());
        }

        // Update to reflect changes during this dialog
        user.setCategories(state.getCategories());
        if (state.isCreating()) {
            user.setConfirmed(!isConfirmation());
        }
        user.setEmailAddress(state.getEmailAddress());
        user.setFullName(state.getFullName());
        if ((state.getPassword() != null) && (state.getPassword().length() > 0)) {
            user.setPassword(state.getPassword());
        }
        user.setUsername(state.getUsername());

        // Persist the changes made during this dialog
        if (state.isCreating()) {
            logic.insertUser(user);
        } else {
            logic.updateUser(user);
        }

        // Log in a new user if already confirmed
        // Otherwise, send the confirmation email
        if (state.isCreating()) {
View Full Code Here

TOP

Related Classes of org.apache.shale.usecases.logic.LogonLogic

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.