Package com.stormpath.sdk.account

Examples of com.stormpath.sdk.account.Account


                // An account can also be retrieved from the DataStore,
                // like the way we do it to get an Application or Directory object,
                // if the account's Rest URL is known to the application.

                User sessionUser = (User) session.getAttribute("sessionUser");
                Account account = sessionUser.getAccount();
                account.setGivenName(user.getFirstName());
                account.setSurname(user.getLastName());
                account.setEmail(user.getEmail());
                account.setUsername(user.getFirstName().toLowerCase() + user.getLastName().toLowerCase());

                String existingGroupUrl = null;
                if (account.getGroupMemberships().iterator().hasNext()) {
                    GroupMembership groupMembership = account.getGroupMemberships().iterator().next();
                    existingGroupUrl = groupMembership.getGroup().getHref();
                    if (!existingGroupUrl.equals(user.getGroupUrl())) {
                        groupMembership.delete();
                        existingGroupUrl = null;
                    }
                }

                if (user.getGroupUrl() != null && !user.getGroupUrl().isEmpty() && existingGroupUrl == null) {
                    account.addGroup(stormpath.getDataStore().getResource(user.getGroupUrl(), Group.class));
                }

                account.save();

                user.setAccount(account);
                user.setUserName(sessionUser.getUserName());
                user.setTootList(sessionUser.getTootList());
View Full Code Here


            return "redirect:/password/forgot";
        }

        try {
            //New password was specified - verify the reset token and apply the new password:
            Account account = stormpath.getApplication().verifyPasswordResetToken(sptoken);

            //token is valid, set the password and sync to Stormpath:
            account.setPassword(user.getPassword());
            account.save();

            //remove any stale value:
            session.removeAttribute("stormpathAccount");

        } catch (ResourceException re) {
View Full Code Here

                // instantiating the proper AuthenticationRequest (UsernamePasswordRequest in this case),
                // providing the account's credentials.
                AuthenticationRequest request = new UsernamePasswordRequest(customer.getUserName(), customer.getPassword());
                AuthenticationResult authcResult = stormpath.getApplication().authenticateAccount(request);

                Account account = authcResult.getAccount();

                User user = new User(account);

                // If the customer queried from the database does not exist
                // we create it in the application's internal database,
View Full Code Here

            String userName = user.getFirstName().toLowerCase() + user.getLastName().toLowerCase();

            // For account creation, we should get an instance of Account from the DataStore,
            // set the account properties and create it in the proper directory.
            Account account = stormpath.getDataStore().instantiate(Account.class);
            account.setEmail(user.getEmail());
            account.setGivenName(user.getFirstName());
            account.setSurname(user.getLastName());
            account.setPassword(user.getPassword());
            account.setUsername(userName);

            // Saving the account to the Directory where the Tooter application belongs.
            Directory directory = stormpath.getDirectory();
            directory.createAccount(account);

            if (user.getGroupUrl() != null && !user.getGroupUrl().isEmpty()) {
                account.addGroup(stormpath.getDataStore().getResource(user.getGroupUrl(), Group.class));
            }

            user.setUserName(userName);
            customerDao.saveCustomer(user);
View Full Code Here

TOP

Related Classes of com.stormpath.sdk.account.Account

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.