Package org.zanata.model

Examples of org.zanata.model.HAccount


    @Override
    public Response put(Account account) {
        log.debug("HTTP PUT {} : \n{}", request.getRequestURL(), account);

        // RestUtils.validateEntity(account);
        HAccount hAccount = accountDAO.getByUsername(username);
        ResponseBuilder response;
        String operation;

        if (hAccount == null) {
            // creating
            operation = "insert";
            response = Response.created(uri.getAbsolutePath());

            hAccount = new HAccount();
            HPerson person = new HPerson();
            person.setAccount(hAccount);
            hAccount.setPerson(person);
        } else {
            // updating
            operation = "update";
            response = Response.ok();
        }
View Full Code Here


                adminExists = false;
            }

            for (String adminUsername : applicationConfiguration
                    .getAdminUsers()) {
                HAccount adminAccount = accountDAO.getByUsername(adminUsername);
                HAccountRole adminRole = accountRoleDAO.findByName("admin");
                if (adminAccount != null
                        && !adminAccount.getRoles().contains(adminRole)) {
                    log.info("Making user " + adminAccount.getUsername()
                            + " a system admin.");
                    adminAccount.getRoles().add(adminRole);
                    accountDAO.makePersistent(adminAccount);
                    accountDAO.flush();
                    adminExists = true;
                }
            }
View Full Code Here

    }

    @Override
    public void invoke(final HttpRequest request, final HttpResponse response) {

        HAccount authenticatedUser = getAuthenticatedUser();
        String apiKey = HeaderHelper.getApiKey(request);

        try {
            // we are not validating api key but will rate limit any api key
            if (authenticatedUser == null && Strings.isNullOrEmpty(apiKey)) {
                response.sendError(
                        Response.Status.UNAUTHORIZED.getStatusCode(),
                        API_KEY_ABSENCE_WARNING);
                return;
            }

            Runnable taskToRun = new Runnable() {

                @Override
                public void run() {
                    RestLimitingSynchronousDispatcher.super.invoke(request,
                            response);
                }
            };

            if (authenticatedUser == null) {
                processor.processApiKey(apiKey, response, taskToRun);
            } else if (!Strings.isNullOrEmpty(authenticatedUser.getApiKey())) {
                processor.processApiKey(authenticatedUser.getApiKey(),
                        response, taskToRun);
            } else {
                processor.processUsername(authenticatedUser.getUsername(),
                        response, taskToRun);
            }

        } catch (UnhandledException e) {
            Throwable cause = e.getCause();
View Full Code Here

            String checkResult = checkExpiryDate(entry.getCreationDate());

            if (StringUtils.isEmpty(checkResult)) {
                HPerson person = entry.getPerson();
                HAccount account = person.getAccount();
                if (!account.getUsername().equals(
                        identity.getCredentials().getUsername())) {
                    throw new LoginException();
                }

                person.setEmail(entry.getEmail());
                account.setEnabled(true);
                personDAO.makePersistent(person);
                personDAO.flush();
                emailChangeService.removeEntry(entry);
                FacesMessages.instance().add(
                        "You have successfully changed your email account.");
View Full Code Here

    public boolean isPasswordSet() {
        return authenticatedAccount.getPasswordHash() != null;
    }

    public List<HCredentials> getUserCredentials() {
        HAccount account = accountDAO.findById(authenticatedAccount.getId());
        return Lists.newArrayList(account.getCredentials());
    }
View Full Code Here

        else
            return "Unknown";
    }

    public void remove(HCredentials toRemove) {
        HAccount account =
                accountDAO.findById(authenticatedAccount.getId(), false);
        account.getCredentials().remove(toRemove);
        //userCredentials = new ArrayList<HCredentials>(account.getCredentials()); // Reload
        // the
        // credentials
        accountDAO.makePersistent(account);
        accountDAO.flush();
View Full Code Here

                    new CredentialsCreationCallback(newCreds));
        }
    }

    public boolean isApiKeyGenerated() {
        HAccount account =
                accountDAO.findById(authenticatedAccount.getId());

        return account.getApiKey() != null;
    }
View Full Code Here

        return account.getApiKey() != null;
    }

    public String getAccountApiKey() {
        HAccount account =
                accountDAO.findById(authenticatedAccount.getId());
        return account.getApiKey();
    }
View Full Code Here

        }
        return serverName.replace(".", "_");
    }

    public void regenerateApiKey() {
        HAccount account =
                accountDAO.findById(authenticatedAccount.getId());

        accountDAO.createApiKey(account);
        accountDAO.makePersistent(account);
        log.info("Reset API key for {}", account.getUsername());
    }
View Full Code Here

    private AccountDAO accountDAO;

    @Override
    public SaveOptionsResult execute(SaveOptionsAction action,
            ExecutionContext context) throws ActionException {
        HAccount account =
                accountDAO.findById(authenticatedAccount.getId(), true);

        for (Entry<UserOptions, String> entry : action.getConfigurationMap()
                .entrySet()) {
            this.setOrCreateOptionValue(account, entry.getKey(),
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.