Package org.springframework.security.web.authentication.rememberme

Examples of org.springframework.security.web.authentication.rememberme.PersistentRememberMeToken


     * @param presentedToken presented token from cookie
     * @return {@code true} if token not exists in database or presented token equals to persistent token,
     *         {@code false} if token exists in database and it doesn't equals to presented token
     */
    public boolean equalWithPersistentToken(String presentedSeries, String presentedToken) {
        PersistentRememberMeToken token = persistentTokenRepository.getTokenForSeries(presentedSeries);
        if (token != null) {
            String persistentToken = token.getTokenValue();
            if (!ObjectUtils.equals(presentedToken, persistentToken)) {
                String logErrorMessage = composeErrorMessageForNotEqualTokens(
                        token.getUsername(), presentedToken, presentedSeries, persistentToken);
                LOGGER.error(logErrorMessage);
                return false;
            }
        }
        return true;
View Full Code Here


                "We didn't find anything in database for given series, so this method must return true");
    }
   
    @Test
    public void equalWithTheDifferentPersistentTokenShouldReturnFalse() {
        PersistentRememberMeToken notEqualPersistentRememberMeToken =
                new PersistentRememberMeToken("username", PRESENTED_SERIES, BROKED_TOKEN, null);
        when(persistentTokenRepository.getTokenForSeries(PRESENTED_SERIES))
            .thenReturn(notEqualPersistentRememberMeToken);

        boolean isEqual =
                rememberMeCheckService.equalWithPersistentToken(PRESENTED_SERIES, PRESENTED_TOKEN);
View Full Code Here

                "We found persistent token and it isn't equal to presented, so this method must return false");
    }
   
    @Test
    public void equalWithTheSamePersistenTokenShouldReturnTrue() {
        PersistentRememberMeToken notEqualPersistentRememberMeToken =
                new PersistentRememberMeToken("username", PRESENTED_SERIES, PRESENTED_TOKEN, null);
        when(persistentTokenRepository.getTokenForSeries(PRESENTED_SERIES))
            .thenReturn(notEqualPersistentRememberMeToken);

        boolean isEqual =
                rememberMeCheckService.equalWithPersistentToken(PRESENTED_SERIES, PRESENTED_TOKEN);
View Full Code Here

            persistentLogin = (PersistentLogin) query.getSingleResult();
        } catch (NoResultException e) {
            return null;
        }

        return new PersistentRememberMeToken(
            persistentLogin.getUsername(),
            persistentLogin.getSeries(),
            persistentLogin.getToken(),
            persistentLogin.getLastUsed());
    }
View Full Code Here

        RememberMeToken rememberMeToken = rememberMeTookenRepository.findBySeries(series);
        if (rememberMeToken == null) {
            log.debug("No remember me token for series '{}' was found.", series);
            return null;
        }
        return new PersistentRememberMeToken(rememberMeToken.getUsername(), rememberMeToken.getSeries(), rememberMeToken.getToken(), rememberMeToken.getLastUsed().toDate());
    }
View Full Code Here

TOP

Related Classes of org.springframework.security.web.authentication.rememberme.PersistentRememberMeToken

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.