* @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;