Package com.googlecode.memwords.domain

Examples of com.googlecode.memwords.domain.UserInformation


            Account account = new Account(userId);
            account.setMasterPassword(persistentPassword);
            account.setEncryptedSecretKey(encryptedSecretKey);
            em.persist(account);
            tx.commit();
            return new UserInformation(account.getUserId(),
                                       secretKey,
                                       new Preferences(account.getPreferredLocale(),
                                                       account.getPreferredTimeZone(),
                                                       account.isPasswordsUnmasked(),
                                                       account.getPasswordGenerationPreferences()));
View Full Code Here


        byte[] iv = cryptoEngine.buildInitializationVector(wrappingKey.getEncoded());
        byte[] encryptionKeyAsBytes = cryptoEngine.decrypt(account.getEncryptedSecretKey(),
                                                           wrappingKey,
                                                           iv);
        SecretKey secretKey = cryptoEngine.bytesToSecretKey(encryptionKeyAsBytes);
        return new UserInformation(account.getUserId(),
                                   secretKey,
                                   new Preferences(account.getPreferredLocale(),
                                                   account.getPreferredTimeZone(),
                                                   account.isPasswordsUnmasked(),
                                                   account.getPasswordGenerationPreferences()));
View Full Code Here

    /**
     * Changes the preferred locale
     * @return a redirect resolution to the preferences page, with a success message
     */
    public Resolution change() {
        UserInformation userInformation = getContext().getUserInformation();
        Preferences preferences = userInformation.getPreferences();
        Preferences newPreferences = preferences.withLocale(this.locale);
        accountService.changePreferences(userInformation.getUserId(), newPreferences);
        getContext().setUserInformation(
            userInformation.withPreferences(newPreferences));
        getContext().getMessages().add(new ScopedLocalizableMessage(ChangePreferredLocaleActionBean.class,
                                                                    "preferredLocaleChanged"));
        return new RedirectResolution(PreferencesActionBean.class);
    }
View Full Code Here

     */
    protected void loadUserInformation() {
        if (getUserInformation() != null) {
            return;
        }
        UserInformation infoWithoutSecretKey = (UserInformation) getRequest().getSession()
            .getAttribute(USER_INFORMATION_SESSION_ATTRIBUTE);
        if (infoWithoutSecretKey != null) {
            Cookie secretKeyCookie = null;
            Cookie[] allCookies = getRequest().getCookies();
            for (Cookie c : allCookies) {
                if (SECRET_KEY_COOKIE_NAME.equals(c.getName())) {
                    secretKeyCookie = c;
                    break;
                }
            }
            if (secretKeyCookie != null) {
                // important : no end of line, else the cookie contains control
                // characters,
                // and it doesn't work
                Base64 base64 = new Base64(-1);
                byte[] encryptedSecretKey = base64.decode(secretKeyCookie.getValue());

                byte[] cookieEncryptionKeyAsBytes =
                    (byte[]) getRequest().getSession().getAttribute(COOKIE_ENCRYPTION_KEY_SESSION_ATTRIBUTE);
                SecretKey cookieEncryptionKey = cryptoEngine.bytesToSecretKey(cookieEncryptionKeyAsBytes);
                byte[] secretKeyAsBytes =
                    cryptoEngine.decrypt(encryptedSecretKey,
                                         cookieEncryptionKey,
                                         cryptoEngine.buildInitializationVector(cookieEncryptionKeyAsBytes));
                SecretKey secretKey = cryptoEngine.bytesToSecretKey(secretKeyAsBytes);
                UserInformation userInformation = infoWithoutSecretKey.withSecretKey(secretKey);
                setUserInformation(userInformation);
            }
        }
    }
View Full Code Here

     * Gets the time zone to use for this request. If set in the user preferences, returns this one.
     * Else, returns GMT.
     * @return the time zone to use for this request
     */
    public TimeZone getTimeZone() {
        UserInformation userInformation = getUserInformation();
        if (userInformation != null) {
            return userInformation.getPreferences().getTimeZone();
        }
        else {
            return TimeZone.getTimeZone(MwConstants.GMT);
        }
    }
View Full Code Here

     * @return a resolution to the source page if the login failed, with an error message;
     * a redirect resolution to the request URL if any and if the login succeeded; or a
     * redirect resolution to the cards page if the login succeeded and if no URL was requested.
     */
    public Resolution login() throws IOException {
        UserInformation userInformation =
            accountService.login(userId, masterPassword);
        if (userInformation == null) {
            getContext().getValidationErrors().addGlobalError(
                    new LocalizableError("loginFailed"));
            return getContext().getSourcePageResolution();
        }
        getContext().login(userInformation);

        HistoricLogin historicLogin =
            loginHistoryService.getLatestHistoricLogin(userInformation.getUserId());
        if (historicLogin != null) {
            TimeZone timeZone = getContext().getTimeZone();
            DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.FULL, getContext().getLocale());
            dateFormat.setTimeZone(timeZone);
            DateFormat timeFormat = DateFormat.getTimeInstance(DateFormat.MEDIUM, getContext().getLocale());
View Full Code Here

    /**
     * Creates the account
     * @return a redirect resolution to the cards page
     */
    public Resolution createAccount() {
        UserInformation userInformation =
            accountService.createAccount(userId, masterPassword);
        getContext().login(userInformation);
        return new RedirectResolution(CardsActionBean.class);
    }
View Full Code Here

    /**
     * Loads the cards to display
     */
    protected void loadCards() {
        UserInformation userInformation = getContext().getUserInformation();
        this.cards = cardService.getCards(userInformation.getUserId(),
                                          userInformation.getEncryptionKey());
    }
View Full Code Here

    /**
     * Performs the change
     */
    private void doChange() {
        UserInformation userInformation = getContext().getUserInformation();
        Preferences preferences = userInformation.getPreferences();

        PasswordGenerationPreferences newGenerationPreferences =
            new PasswordGenerationPreferences(this.length,
                                              this.lowerCaseLettersIncluded,
                                              this.upperCaseLettersIncluded,
                                              this.digitsIncluded,
                                              this.specialCharactersIncluded);
        Preferences newPreferences =
            preferences.withPasswordGenerationPreferences(newGenerationPreferences);
        accountService.changePreferences(userInformation.getUserId(),
                                         newPreferences);
        getContext().setUserInformation(
            userInformation.withPreferences(newPreferences));
        getContext().getMessages().add(
            new ScopedLocalizableMessage(ChangePasswordGenerationPreferencesActionBean.class,
                                         "passwordGenerationPreferencesChanged"));
    }
View Full Code Here

    /**
     * Performs the change
     */
    private void doChange() {
        UserInformation userInformation = getContext().getUserInformation();
        Preferences preferences = userInformation.getPreferences();
        Preferences newPreferences = preferences.withPasswordsUnmasked(this.unmasked);
        accountService.changePreferences(userInformation.getUserId(),
                                         newPreferences);
        getContext().setUserInformation(
            userInformation.withPreferences(newPreferences));
        getContext().getMessages().add(
            new ScopedLocalizableMessage(ChangePasswordPreferencesActionBean.class,
                                         "passwordPreferencesChanged"));
    }
View Full Code Here

TOP

Related Classes of com.googlecode.memwords.domain.UserInformation

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.