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

The following examples show how to use org.springframework.security.web.authentication.rememberme.PersistentRememberMeToken. 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 File: MongoPersistentTokenRepositoryImpl.java    From JiwhizBlogWeb with Apache License 2.0 5 votes vote down vote up
@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 #2
Source File: PersistentTokenRepositoryImpl.java    From springboot-vue.js-bbs with Apache License 2.0 5 votes vote down vote up
@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 #3
Source File: PersistentTokenRepositoryImpl.java    From springboot-vue.js-bbs with Apache License 2.0 5 votes vote down vote up
@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 #4
Source File: PersistentTokenService.java    From zhcet-web with 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 #5
Source File: PersistentTokenService.java    From zhcet-web with 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 #6
Source File: PersistentTokenService.java    From zhcet-web with 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 #7
Source File: RememberMeRepository.java    From java-master with 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 #8
Source File: PersistentLogins.java    From zxl with 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 #9
Source File: JpaReMemberMeRepository.java    From lolibox with 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 #10
Source File: JpaReMemberMeRepository.java    From lolibox with 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 #11
Source File: IpAwarePersistentTokenRepository.java    From maven-framework-project with MIT License 5 votes vote down vote up
/**
 * 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 #12
Source File: IpAwarePersistentTokenRepository.java    From maven-framework-project with MIT License 5 votes vote down vote up
/**
 * 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 #13
Source File: RememberMeRepository.java    From java-master with 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 #14
Source File: JdbcTokenRepository.java    From zxl with 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 #15
Source File: PersistentLogin.java    From Spring-Security-Third-Edition with 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 #16
Source File: PersistentLogin.java    From Spring-Security-Third-Edition with 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 File: JdbcTokenRepository.java    From zxl with Apache License 2.0 4 votes vote down vote up
@Override
public void createNewToken(PersistentRememberMeToken token) {
	PersistentLogins persistentLogins = new PersistentLogins(token);
	commonBaseService.save(persistentLogins);
}
 
Example #18
Source File: PersistentLogin.java    From Spring-Security-Third-Edition with 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 File: PersistentTokenService.java    From zhcet-web with Apache License 2.0 4 votes vote down vote up
@Override
public void createNewToken(PersistentRememberMeToken token) {
    persistentLoginRepository.save(getLoginFromToken(token));
}
 
Example #20
Source File: PersistentLogin.java    From Spring-Security-Third-Edition with 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 File: PersistentLogin.java    From Spring-Security-Third-Edition with 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 File: PersistentLogin.java    From Spring-Security-Third-Edition with 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 File: PersistentLogin.java    From Spring-Security-Third-Edition with 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 File: PersistentLogin.java    From Spring-Security-Third-Edition with 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 File: PersistentLogin.java    From Spring-Security-Third-Edition with 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 File: PersistentLogin.java    From Spring-Security-Third-Edition with 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 File: PersistentLogin.java    From Spring-Security-Third-Edition with 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 File: PersistentLogin.java    From Spring-Security-Third-Edition with 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 File: PersistentLogin.java    From Spring-Security-Third-Edition with 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 File: PersistentLogin.java    From Spring-Security-Third-Edition with 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();
}