Package org.exoplatform.services.organization

Examples of org.exoplatform.services.organization.User


        if (isEnable()) {
            RequestLifeCycle.begin(PortalContainer.getInstance());
            checkJcrFlag();
            try {
                if (!isSetup()) {
                    User root = getRootUser();
                    root.setPassword(rootPassword());
                    orgService.getUserHandler().saveUser(root, true);
                }
            } catch (Exception e) {
                throw new RuntimeException(e);
            } finally {
View Full Code Here


            }
        }
    }

    public User getRootUser() throws Exception {
        User root = orgService.getUserHandler().findUserByName("root", UserStatus.ANY);
        // In the case the root user is not present
        // This case can happens if organization-configuration.xml is not well configured
        if (root == null) {
            root = orgService.getUserHandler().createUserInstance("root");
            root.setFirstName("Root");
            root.setLastName("Root");
            root.setEmail("root@localhost");
            root.setDisplayName("root");
            orgService.getUserHandler().createUser(root, true);
            // Get memberships
            MembershipType manager = orgService.getMembershipTypeHandler().findMembershipType("manager");
            MembershipType member = orgService.getMembershipTypeHandler().findMembershipType("member");
            // Get groups
View Full Code Here

            OrganizationService orgSrc = uiForm.getApplicationComponent(OrganizationService.class);
            String userName = uiForm.getUIStringInput(Username).getValue();
            String email = uiForm.getUIStringInput(Email).getValue();
            uiForm.reset();

            User user = null;

            String tokenId = null;

            // User provided his username
            if (userName != null) {
                user = orgSrc.getUserHandler().findUserByName(userName);
                if (user == null) {
                    requestContext.getUIApplication().addMessage(
                            new ApplicationMessage("UIForgetPassword.msg.user-not-exist", null));
                    return;
                }
            }

            // User provided his email address
            if (user == null && email != null) {
                Query query = new Query();
                // Querying on email won't work. PLIDM-12
                // Note that querying on email is inefficient as it loops over all users...
                query.setEmail(email);
                PageList<User> users = orgSrc.getUserHandler().findUsers(query);
                if (users.getAll().size() > 0) {
                    user = users.getAll().get(0);
                } else {
                    requestContext.getUIApplication().addMessage(
                            new ApplicationMessage("UIForgetPassword.msg.email-not-exist", null));
                    return;
                }
            }

            email = user.getEmail();

            // Create token
            RemindPasswordTokenService tokenService = uiForm.getApplicationComponent(RemindPasswordTokenService.class);
            Credentials credentials = new Credentials(user.getUserName(), "");
            tokenId = tokenService.createToken(credentials);

            String portalName = URLEncoder.encode(Util.getUIPortal().getName(), "UTF-8");

            ResourceBundle res = requestContext.getApplicationResourceBundle();
            String headerMail = "headermail";
            String footerMail = "footer";
            try {
                headerMail = res.getString(uiForm.getId() + ".mail.header") + "\n\n"
                        + res.getString(uiForm.getId() + ".mail.user") + user.getUserName() + "\n"
                        + res.getString(uiForm.getId() + ".mail.link");
                footerMail = "\n\n\n" + res.getString(uiForm.getId() + ".mail.footer");
            } catch (MissingResourceException e) {
                log.error(e.getMessage(), e);
            }
View Full Code Here

            // Modified by nguyenanhkien2a@gmail.com
            // We should check account for existing
            String username = Util.getPortalRequestContext().getRemoteUser();
            OrganizationService service = uiPortal.getApplicationComponent(OrganizationService.class);
            User useraccount = service.getUserHandler().findUserByName(username);

            if (useraccount != null) {
                UIAccountSetting uiAccountForm = uiMaskWS.createUIComponent(UIAccountSetting.class, null, null);
                uiMaskWS.setUIComponent(uiAccountForm);
                uiMaskWS.setShow(true);
View Full Code Here

    public UIAccountProfiles() throws Exception {
        super();
        String username = Util.getPortalRequestContext().getRemoteUser();
        OrganizationService service = this.getApplicationComponent(OrganizationService.class);
        User useraccount = service.getUserHandler().findUserByName(username);

        UIFormStringInput userName = new UIFormStringInput("userName", "userName", username);
        userName.setReadOnly(true);
        addUIFormInput(userName.addValidator(MandatoryValidator.class).addValidator(StringLengthValidator.class, 3, 30)
                .addValidator(ResourceValidator.class)
                .addValidator(ExpressionValidator.class, Utils.USER_NAME_VALIDATOR_REGEX, "ResourceValidator.msg.Invalid-char"));
        addUIFormInput(new UIFormStringInput("firstName", "firstName", useraccount.getFirstName())
                .addValidator(StringLengthValidator.class, 1, 45).addValidator(MandatoryValidator.class)
                .addValidator(PersonalNameValidator.class));
        addUIFormInput(new UIFormStringInput("lastName", "lastName", useraccount.getLastName())
                .addValidator(StringLengthValidator.class, 1, 45).addValidator(MandatoryValidator.class)
                .addValidator(PersonalNameValidator.class));
        addUIFormInput(new UIFormStringInput("displayName", "displayName", useraccount.getDisplayName()).addValidator(
                StringLengthValidator.class, 0, 90).addValidator(UserConfigurableValidator.class, "displayname",
                UserConfigurableValidator.KEY_PREFIX + "displayname", false));
        addUIFormInput(new UIFormStringInput("email", "email", useraccount.getEmail()).addValidator(MandatoryValidator.class)
                .addValidator(EmailAddressValidator.class));
    }
View Full Code Here

    public static class ResetActionListener extends EventListener<UIAccountProfiles> {
        public void execute(Event<UIAccountProfiles> event) throws Exception {
            UIAccountProfiles uiForm = event.getSource();
            String userName = uiForm.getUIStringInput("userName").getValue();
            OrganizationService service = uiForm.getApplicationComponent(OrganizationService.class);
            User user = service.getUserHandler().findUserByName(userName);
            uiForm.getUIStringInput("firstName").setValue(user.getFirstName());
            uiForm.getUIStringInput("lastName").setValue(user.getLastName());
            uiForm.getUIStringInput("displayName").setValue(user.getDisplayName());
            uiForm.getUIStringInput("email").setValue(user.getEmail());
            event.getRequestContext().addUIComponentToUpdateByAjax(uiForm);
        }
View Full Code Here

            WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
            UIApplication uiApp = context.getUIApplication();

            ConversationState state = ConversationState.getCurrent();
            String userName = ((User) state.getAttribute(CacheUserProfileFilter.USER_PROFILE)).getUserName();
            User user = service.getUserHandler().findUserByName(userName);
            if (user != null) {
                String oldEmail = user.getEmail();
                String newEmail = uiForm.getUIStringInput("email").getValue();

                // Check if mail address is already used
                Query query = new Query();
                query.setEmail(newEmail);
                if (service.getUserHandler().findUsers(query).getAll().size() > 0 && !oldEmail.equals(newEmail)) {
                    // Be sure it keep old value
                    user.setEmail(oldEmail);
                    Object[] args = { userName };
                    uiApp.addMessage(new ApplicationMessage("UIAccountInputSet.msg.email-exist", args));
                    return;
                }
                user.setFirstName(uiForm.getUIStringInput("firstName").getValue());
                user.setLastName(uiForm.getUIStringInput("lastName").getValue());
                user.setDisplayName(uiForm.getUIStringInput("displayName").getValue());
                user.setEmail(newEmail);
                uiApp.addMessage(new ApplicationMessage("UIAccountProfiles.msg.update.success", null));
                try {
                    service.getUserHandler().saveUser(user, true);
                } catch (Exception e) {
                    uiApp.addMessage(new ApplicationMessage("UIAccountProfiles.msg.update.fail", null, ApplicationMessage.ERROR));
View Full Code Here

            UIAccountChangePass uiForm = event.getSource();
            OrganizationService service = uiForm.getApplicationComponent(OrganizationService.class);
            WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
            UIApplication uiApp = context.getUIApplication();
            String username = Util.getPortalRequestContext().getRemoteUser();
            User user = service.getUserHandler().findUserByName(username);
            String currentPass = uiForm.getUIStringInput("currentpass").getValue();
            String newPass = uiForm.getUIStringInput("newpass").getValue();
            String confirmnewPass = uiForm.getUIStringInput("confirmnewpass").getValue();

            Authenticator authenticator = uiForm.getApplicationComponent(Authenticator.class);
            boolean authenticated;
            try {
                UsernameCredential usernameCred = new UsernameCredential(username);
                PasswordCredential passwordCred = new PasswordCredential(currentPass);
                authenticator.validateUser(new Credential[] { usernameCred, passwordCred });
                authenticated = true;
            } catch (Exception ex) {
                authenticated = false;
            }

            if (!authenticated) {
                uiApp.addMessage(new ApplicationMessage("UIAccountChangePass.msg.currentpassword-is-not-match", null, 1));
                uiForm.reset();
                event.getRequestContext().addUIComponentToUpdateByAjax(uiForm);
                return;
            }

            if (!newPass.equals(confirmnewPass)) {
                uiApp.addMessage(new ApplicationMessage("UIAccountChangePass.msg.password-is-not-match", null, 1));
                uiForm.reset();
                event.getRequestContext().addUIComponentToUpdateByAjax(uiForm);
                return;
            }
            try {
                user.setPassword(newPass);
                service.getUserHandler().saveUser(user, true);
                uiApp.addMessage(new ApplicationMessage("UIAccountChangePass.msg.change.pass.success", null));
                UIAccountSetting ui = uiForm.getParent();
                ui.getChild(UIAccountProfiles.class).setRendered(true);
                ui.getChild(UIAccountChangePass.class).setRendered(false);
View Full Code Here

                return;
            }

            OrganizationService orgSrc = uiPortal.getApplicationComponent(OrganizationService.class);
            // get user
            User user = orgSrc.getUserHandler().findUserByName(token.getPayload().getUsername());
            if (user == null) {
                requestContext.getUIApplication().addMessage(new ApplicationMessage("UIForgetPassword.msg.user-delete", null));
                return;
            }
View Full Code Here

      }
      catch (Exception e)
      {
      }

      User user = uHandler.createUserInstance("not-existed-user");
      try
      {
         mHandler.linkMembership(user, gHandler.findGroupById("/" + groupName1), mtHandler
                  .findMembershipType(membershipType), true);
         fail("Exception  should be thrown");
View Full Code Here

TOP

Related Classes of org.exoplatform.services.organization.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.