Java Code Examples for org.springframework.security.web.authentication.rememberme.PersistentRememberMeToken

The following examples show how to use org.springframework.security.web.authentication.rememberme.PersistentRememberMeToken. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: java-master   Source File: RememberMeRepository.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void createNewToken(PersistentRememberMeToken token) {
    SysRememberMe sysRememberMe = new SysRememberMe();
    sysRememberMe.setSeries(token.getSeries());
    sysRememberMe.setUsername(token.getUsername());
    sysRememberMe.setToken(token.getTokenValue());
    sysRememberMe.setLastUsed(token.getDate());
    sysRememberMeMapper.insert(sysRememberMe);
}
 
Example 2
Source Project: java-master   Source File: RememberMeRepository.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public PersistentRememberMeToken getTokenForSeries(String seriesId) {
    SysRememberMe sysRememberMe = sysRememberMeMapper.selectByPrimaryKey(seriesId);
    if (sysRememberMe == null) {
        return null;
    }
    PersistentRememberMeToken meToken = new PersistentRememberMeToken(
            sysRememberMe.getUsername(),
            sysRememberMe.getSeries(),
            sysRememberMe.getToken(),
            sysRememberMe.getLastUsed()
    );
    return meToken;
}
 
Example 3
Source Project: zhcet-web   Source File: PersistentTokenService.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@Transactional
public PersistentRememberMeToken getTokenForSeries(String seriesId) {
    return persistentLoginRepository.findById(seriesId)
            .map(PersistentTokenService::getTokenFromLogin)
            .orElse(null);
}
 
Example 4
Source Project: zhcet-web   Source File: PersistentTokenService.java    License: Apache License 2.0 5 votes vote down vote up
private static PersistentLogin getLoginFromToken(PersistentRememberMeToken token) {
    return new PersistentLogin(
            token.getSeries(),
            token.getUsername(),
            token.getTokenValue(),
            token.getDate()
    );
}
 
Example 5
Source Project: zhcet-web   Source File: PersistentTokenService.java    License: Apache License 2.0 5 votes vote down vote up
private static PersistentRememberMeToken getTokenFromLogin(PersistentLogin persistentLogin) {
    return new PersistentRememberMeToken(
            persistentLogin.getUsername(),
            persistentLogin.getSeries(),
            persistentLogin.getToken(),
            persistentLogin.getLastUsed()
    );
}
 
Example 6
@Override
public void createNewToken(PersistentRememberMeToken token) {
    User user = userRepository.findByUsername(token.getUsername());
    PersistentLogins persistentLogins = new PersistentLogins(user, token.getSeries(), token.getTokenValue(),
            dateToLocalDate(token.getDate()));
    persistentLoginsRepository.save(persistentLogins);
}
 
Example 7
@Override
public PersistentRememberMeToken getTokenForSeries(String series) {
    PersistentLogins persistentLogins = persistentLoginsRepository.findOne(series);
    try {
        return new PersistentRememberMeToken(persistentLogins.getUser().getUsername(), series,
                persistentLogins.getToken(), localDateToDate(persistentLogins.getLastUsed()));
    } catch (NullPointerException e) {
        return null;
    }
}
 
Example 8
Source Project: zxl   Source File: JdbcTokenRepository.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public PersistentRememberMeToken getTokenForSeries(String seriesId) {
	PersistentLogins persistentLogins = new PersistentLogins();
	persistentLogins.setSeries(seriesId);
	PersistentLogins persistentLoginsInDB = commonBaseService.getUnique(PersistentLogins.class, persistentLogins);
	if (persistentLoginsInDB == null)
		return null;
	return new PersistentRememberMeToken(persistentLoginsInDB.getUsername(), persistentLoginsInDB.getSeries(), persistentLoginsInDB.getTokenValue(), persistentLoginsInDB.getLastUsedDate());
}
 
Example 9
Source Project: zxl   Source File: PersistentLogins.java    License: Apache License 2.0 5 votes vote down vote up
public PersistentLogins(PersistentRememberMeToken token) {
	super();
	this.series = token.getSeries();
	this.username = token.getUsername();
	this.tokenValue = token.getTokenValue();
	this.lastUsedDate = token.getDate();
}
 
Example 10
Source Project: lolibox   Source File: JpaReMemberMeRepository.java    License: Apache License 2.0 5 votes vote down vote up
@Modifying
@Transactional
default void createNewToken(PersistentRememberMeToken token) {
    PersistentLogins logins = new PersistentLogins();
    logins.setLastUsed(token.getDate());
    logins.setSeries(token.getSeries());
    logins.setToken(token.getTokenValue());
    logins.setUsername(token.getUsername());
    this.save(logins);
}
 
Example 11
Source Project: lolibox   Source File: JpaReMemberMeRepository.java    License: Apache License 2.0 5 votes vote down vote up
default PersistentRememberMeToken getTokenForSeries(String seriesId) {
    List<PersistentLogins> logins = this.findBySeries(seriesId);
    if (logins.isEmpty()) {
        return null;
    }
    PersistentLogins login = logins.get(0);
    return new PersistentRememberMeToken(login.getUsername(), login.getSeries(), login.getToken(), login.getLastUsed());
}
 
Example 12
/**
 * Stores the new {@link PersistentRememberMeToken} but first changes the series to be series + currentIpAddress and
 * then delegates to the injected {@link PersistentTokenRepository} to do all the work.
 */
@Override
public void createNewToken(PersistentRememberMeToken token) {
    String ipSeries = ipSeries(token.getSeries());
    PersistentRememberMeToken ipToken = tokenWithSeries(token, ipSeries);
    this.delegateRepository.createNewToken(ipToken);
}
 
Example 13
/**
 * Gets the {@link PersistentRememberMeToken} for the given seriesId + currentIpAddress. By always adding the IP
 * address to the identifier we guarantee that the token can only be retrieved if the IP of the original token
 * matches the current user's token. It then delegates to the injected {@link PersistentTokenRepository} to do all
 * the work.
 */
@Override
public PersistentRememberMeToken getTokenForSeries(String seriesId) {
    String ipSeries = ipSeries(seriesId);
    PersistentRememberMeToken ipToken = delegateRepository.getTokenForSeries(ipSeries);
    return tokenWithSeries(ipToken, seriesId);
}
 
Example 14
@Override
public PersistentRememberMeToken getTokenForSeries(String seriesId) {
    RememberMeToken token = this.rememberMeTokenRepository.findBySeries(seriesId);
    if (token == null){
        return null;
    }
    return new PersistentRememberMeToken(token.getUsername(), token.getSeries(), token.getTokenValue(), token.getDate());
}
 
Example 15
Source Project: zhcet-web   Source File: PersistentTokenService.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void createNewToken(PersistentRememberMeToken token) {
    persistentLoginRepository.save(getLoginFromToken(token));
}
 
Example 16
Source Project: Spring-Security-Third-Edition   Source File: PersistentLogin.java    License: MIT License 4 votes vote down vote up
public PersistentLogin(PersistentRememberMeToken token){
    this.series = token.getSeries();
    this.username = token.getUsername();
    this.token = token.getTokenValue();
    this.lastUsed = token.getDate();
}
 
Example 17
Source Project: Spring-Security-Third-Edition   Source File: PersistentLogin.java    License: MIT License 4 votes vote down vote up
public PersistentLogin(PersistentRememberMeToken token){
    this.series = token.getSeries();
    this.username = token.getUsername();
    this.token = token.getTokenValue();
    this.lastUsed = token.getDate();
}
 
Example 18
Source Project: Spring-Security-Third-Edition   Source File: PersistentLogin.java    License: MIT License 4 votes vote down vote up
public PersistentLogin(PersistentRememberMeToken token){
    this.series = token.getSeries();
    this.username = token.getUsername();
    this.token = token.getTokenValue();
    this.lastUsed = token.getDate();
}
 
Example 19
Source Project: Spring-Security-Third-Edition   Source File: PersistentLogin.java    License: MIT License 4 votes vote down vote up
public PersistentLogin(PersistentRememberMeToken token){
    this.series = token.getSeries();
    this.username = token.getUsername();
    this.token = token.getTokenValue();
    this.lastUsed = token.getDate();
}
 
Example 20
Source Project: Spring-Security-Third-Edition   Source File: PersistentLogin.java    License: MIT License 4 votes vote down vote up
public PersistentLogin(PersistentRememberMeToken token){
    this.series = token.getSeries();
    this.username = token.getUsername();
    this.token = token.getTokenValue();
    this.lastUsed = token.getDate();
}
 
Example 21
Source Project: Spring-Security-Third-Edition   Source File: PersistentLogin.java    License: MIT License 4 votes vote down vote up
public PersistentLogin(PersistentRememberMeToken token){
    this.series = token.getSeries();
    this.username = token.getUsername();
    this.token = token.getTokenValue();
    this.lastUsed = token.getDate();
}
 
Example 22
Source Project: Spring-Security-Third-Edition   Source File: PersistentLogin.java    License: MIT License 4 votes vote down vote up
public PersistentLogin(PersistentRememberMeToken token){
    this.series = token.getSeries();
    this.username = token.getUsername();
    this.token = token.getTokenValue();
    this.lastUsed = token.getDate();
}
 
Example 23
Source Project: Spring-Security-Third-Edition   Source File: PersistentLogin.java    License: MIT License 4 votes vote down vote up
public PersistentLogin(PersistentRememberMeToken token){
    this.series = token.getSeries();
    this.username = token.getUsername();
    this.token = token.getTokenValue();
    this.lastUsed = token.getDate();
}
 
Example 24
Source Project: Spring-Security-Third-Edition   Source File: PersistentLogin.java    License: MIT License 4 votes vote down vote up
public PersistentLogin(PersistentRememberMeToken token){
    this.series = token.getSeries();
    this.username = token.getUsername();
    this.token = token.getTokenValue();
    this.lastUsed = token.getDate();
}
 
Example 25
Source Project: Spring-Security-Third-Edition   Source File: PersistentLogin.java    License: MIT License 4 votes vote down vote up
public PersistentLogin(PersistentRememberMeToken token){
    this.series = token.getSeries();
    this.username = token.getUsername();
    this.token = token.getTokenValue();
    this.lastUsed = token.getDate();
}
 
Example 26
Source Project: Spring-Security-Third-Edition   Source File: PersistentLogin.java    License: MIT License 4 votes vote down vote up
public PersistentLogin(PersistentRememberMeToken token){
    this.series = token.getSeries();
    this.username = token.getUsername();
    this.token = token.getTokenValue();
    this.lastUsed = token.getDate();
}
 
Example 27
Source Project: Spring-Security-Third-Edition   Source File: PersistentLogin.java    License: MIT License 4 votes vote down vote up
public PersistentLogin(PersistentRememberMeToken token){
    this.series = token.getSeries();
    this.username = token.getUsername();
    this.token = token.getTokenValue();
    this.lastUsed = token.getDate();
}
 
Example 28
Source Project: Spring-Security-Third-Edition   Source File: PersistentLogin.java    License: MIT License 4 votes vote down vote up
public PersistentLogin(PersistentRememberMeToken token){
    this.series = token.getSeries();
    this.username = token.getUsername();
    this.token = token.getTokenValue();
    this.lastUsed = token.getDate();
}
 
Example 29
Source Project: Spring-Security-Third-Edition   Source File: PersistentLogin.java    License: MIT License 4 votes vote down vote up
public PersistentLogin(PersistentRememberMeToken token){
    this.series = token.getSeries();
    this.username = token.getUsername();
    this.token = token.getTokenValue();
    this.lastUsed = token.getDate();
}
 
Example 30
Source Project: Spring-Security-Third-Edition   Source File: PersistentLogin.java    License: MIT License 4 votes vote down vote up
public PersistentLogin(PersistentRememberMeToken token){
    this.series = token.getSeries();
    this.username = token.getUsername();
    this.token = token.getTokenValue();
    this.lastUsed = token.getDate();
}