Package org.zanata.model

Examples of org.zanata.model.HAccount


        @Override
        public void afterOpenIdAuth(OpenIdAuthenticationResult result) {
            if (result.isAuthenticated()) {
                AccountDAO accountDAO =
                        ServiceLocator.instance().getInstance(AccountDAO.class);
                HAccount account =
                        accountDAO.getByCredentialsId(result
                                .getAuthenticatedId());
                if (account == null) {
                    account = new HAccount(); // In case an account is not found
                }
                Contexts.getSessionContext().set("obsoleteAccount", account); // Outject
                                                                              // the
                                                                              // account
            }
View Full Code Here


        }
        log.info("Logout: Removing user {} from all workspaces, session: {}",
                username, httpSessionId);
        String personName = "<unknown>";
        String personEmail = "<unknown>";
        HAccount account = getAccountDAO().getByUsername(username);
        if (account != null) {
            HPerson person = account.getPerson();
            if (person != null) {
                personName = person.getName();
                personEmail = person.getEmail();
            }
        }
View Full Code Here

        }

        transfer(project, hProject);

        if (identity != null && hProject.getMaintainers().isEmpty()) {
            HAccount hAccount =
                    accountDAO.getByUsername(identity.getCredentials()
                            .getUsername());
            if (hAccount != null && hAccount.getPerson() != null) {
                hProject.getMaintainers().add(hAccount.getPerson());
            }
        }

        projectDAO.makePersistent(hProject);
        projectDAO.flush();
View Full Code Here

        }

    }

    public HAccount create(String username, String password, boolean enabled) {
        HAccount account = new HAccount();
        account.setUsername(username);
        // TODO add a @PasswordSalt field to HAccount
        // otherwise, Seam uses the @UserPrincipal field as salt
        String saltPhrase = username;
        @SuppressWarnings("deprecation")
        String passwordHash =
                PasswordHash.instance().generateSaltedHash(password,
                        saltPhrase, PasswordHash.ALGORITHM_MD5);
        account.setPasswordHash(passwordHash);
        account.setEnabled(enabled);
        makePersistent(account);
        return account;
    }
View Full Code Here

        return (projectStatus.equals(EntityStatus.ACTIVE) && iterStatus
                .equals(EntityStatus.ACTIVE));
    }

    protected Person retrievePerson() {
        HAccount authenticatedAccount =
                (HAccount) Contexts.getSessionContext().get(
                        JpaIdentityStore.AUTHENTICATED_USER);
        return new Person(new PersonId(authenticatedAccount.getUsername()),
                authenticatedAccount.getPerson().getName(),
                gravatarServiceImpl.getUserImageUrl(16, authenticatedAccount
                        .getPerson().getEmail()));
    }
View Full Code Here

        scheduler.shutdown();
    }

    public <V> ListenableFuture<V> startTask(
            final @Nonnull AsyncTask<Future<V>> task) {
        HAccount taskOwner = ServiceLocator.instance()
                .getInstance(ZanataJpaIdentityStore.AUTHENTICATED_USER,
                        HAccount.class);
        ZanataIdentity ownerIdentity = ZanataIdentity.instance();

        // Extract security context from current thread
        final String taskOwnerUsername =
                taskOwner != null ? taskOwner.getUsername() : null;
        final Principal runAsPpal = ownerIdentity.getPrincipal();
        final Subject runAsSubject = ownerIdentity.getSubject();

        // final result
        final AsyncTaskResult<V> taskFuture = new AsyncTaskResult<V>();
View Full Code Here

                    ServiceLocator.instance().getInstance(
                            ZanataJpaIdentityStore.class);
            AuthenticationEvents authEvts =
                    ServiceLocator.instance().getInstance(
                            AuthenticationEvents.class);
            HAccount authenticatedAccount = accountDAO.getByUsername(username);
            idStore.setAuthenticateUser(authenticatedAccount);
        }
    }
View Full Code Here

                .addConstructorParameterMaker(HLocale.class, 0,
                        FixedValueMaker.fix(localeId)).build();
    }

    public void makeSampleUsers() {
        HAccount adminAccount =
                makeAccount("admin", "Eyox7xbNQ09MkIfRyH+rjg==",
                        "b6d7044e9ee3b2447c28fb7c50d86d98", 1L);
        assignAccountRole(1L, "admin");

        admin = makePerson(1L, "Administrator", "admin");
        assignAccountToPerson(adminAccount, admin);

        HAccount translatorAccount =
                makeAccount("translator", "Fr5JHlcaEqKLSHjnBm4gXg==",
                        "d83882201764f7d339e97c4b087f0806", 2L);
        assignAccountRole(2L, "user");
        HPerson translator = makePerson(2L, "translator", "translator");
        assignAccountToPerson(translatorAccount, translator);

        HAccount glossaristAccount =
                makeAccount("glossarist", "fRIeiPDPlSMtHbBNoqDjNQ==",
                        "b1e3daa18e41c0ce79829e87ce66b201", 3L);
        assignAccountRole(3L, "glossarist");
        HPerson glossarist = makePerson(3L, "glossarist", "glossarist");
        assignAccountToPerson(glossaristAccount, glossarist);

        HAccount gAdminAccount =
                makeAccount("glossaryadmin", "/W0YpteXk+WtymQ7H84kPQ==",
                        "5a6a34d28d39ff90ea47402311f339d4", 4L);
        assignAccountRole(4L, "glossary-admin");
        HPerson glossaryAdmin =
                makePerson(4L, "glossary-admin", "glossary-admin");
View Full Code Here

                    "This email address is already taken");
        }
    }

    protected void validateUsername(String username) {
        HAccount account = accountDAO.getByUsername(username);

        if (account != null && !account.equals(authenticatedAccount)) {
            valid = false;
            FacesMessages.instance().addToControl("username",
                    "This username is already taken");
        }
    }
View Full Code Here

    }

    @BeforeMethod
    public void setUp() throws Exception {
        AccountDAO accountDAO = new AccountDAO(getSession());
        HAccount authenticatedAccount = getEm().find(HAccount.class, 1L);
        // @formatter:off
        handler = SeamAutowire.instance()
            .reset()
            .use(JpaIdentityStore.AUTHENTICATED_USER, authenticatedAccount)
            .use("accountDAO", accountDAO)
View Full Code Here

TOP

Related Classes of org.zanata.model.HAccount

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.