Java 类org.springframework.security.web.authentication.rememberme.PersistentRememberMeToken 实例源码

项目:kayura-uasp    文件:PersistentRememberMeServices.java   
protected void onLoginSuccess(HttpServletRequest request, HttpServletResponse response,
        Authentication successfulAuthentication) {

    LoginUser user = (LoginUser) successfulAuthentication.getPrincipal();

    logger.debug("Creating new persistent login for user " + user.getUsername());

    PersistentRememberMeToken persistentToken = new PersistentRememberMeToken(user.getUserId(),
            generateSeriesData(), generateTokenData(), new Date());
    try {
        tokenRepository.createNewToken(persistentToken);
        addCookie(persistentToken, request, response);
    } catch (Exception e) {
        logger.error("Failed to save persistent token ", e);
    }
}
项目:GisGMP    文件:MemberRepositoryImpl.java   
@Override
public PersistentRememberMeToken getTokenForSeries(String seriesId) {
    try {
        return getJdbcTemplate().queryForObject(sqlSelect, new RowMapper<PersistentRememberMeToken>() {
            public PersistentRememberMeToken mapRow(ResultSet rs, int rowNum) throws SQLException {
                //String username, String series, String tokenValue, Date date
                return new PersistentRememberMeToken(rs.getString(3),
                        rs.getString(1),
                        rs.getString(2),
                        rs.getTimestamp(4));
            }
        }, seriesId);
    } catch (EmptyResultDataAccessException zeroResults) {
        if (logger.isInfoEnabled()) {
            logger.info("Querying token for series '" + seriesId + "' returned no results.", zeroResults);
        }
    } catch (IncorrectResultSizeDataAccessException moreThanOne) {
        logger.error("Querying token for series '" + seriesId + "' returned more than one value. Series" +
                " should be unique");
    } catch (DataAccessException e) {
        logger.error("Failed to load token for series " + seriesId, e);
    }

    return null;
}
项目:FeedbackCollectionAndMgmtSystem    文件:HibernateTokenRepositoryImpl.java   
@Override
public void createNewToken(PersistentRememberMeToken token) {
    logger.info("Creating Token for user : {}", token.getUsername());
    UserSessions userSession = new UserSessions();
    userSession.setUserEmail(token.getUsername());
    userSession.setSeries(token.getSeries());
    userSession.setSessionToken(token.getTokenValue());
    userSession.setLastLogin(token.getDate());
    persist(userSession);

}
项目:FeedbackCollectionAndMgmtSystem    文件:HibernateTokenRepositoryImpl.java   
@Override
public PersistentRememberMeToken getTokenForSeries(String seriesId) {
    logger.info("Fetch Token if any for seriesId : {}", seriesId);
    try {
        Criteria crit = createEntityCriteria();
        crit.add(Restrictions.eq("series", seriesId));
        UserSessions userSession = (UserSessions) crit.uniqueResult();

        return new PersistentRememberMeToken(userSession.getUserEmail(), userSession.getSeries(),
                userSession.getSessionToken(), userSession.getLastLogin());
    } catch (Exception e) {
        logger.info("Token not found...");
        return null;
    }
}
项目:springuni-particles    文件:DelegatingPersistentTokenRepository.java   
@Override
public PersistentRememberMeToken getTokenForSeries(String seriesId) {
  Long sessionId = Long.valueOf(seriesId);
  return sessionService
      .findSession(sessionId)
      .map(this::toPersistentRememberMeToken)
      .orElse(null);
}
项目:springuni-particles    文件:DelegatingPersistentTokenRepository.java   
private PersistentRememberMeToken toPersistentRememberMeToken(Session session) {
  String username = String.valueOf(session.getUserId());
  String series = String.valueOf(session.getId());
  LocalDateTime lastUsedAt =
      Optional.ofNullable(session.getLastUsedAt()).orElseGet(session::getIssuedAt);
  return new PersistentRememberMeToken(
      username, series, session.getToken(), toDate(lastUsedAt));
}
项目:Webstore    文件:HibernateTokenRepositoryImpl.java   
@Override
public void createNewToken(PersistentRememberMeToken token) {
    logger.info("Creating Token for user : {}", token.getUsername());
    PersistentLogin persistentLogin = new PersistentLogin();
    persistentLogin.setUsername(token.getUsername());
    persistentLogin.setSeries(token.getSeries());
    persistentLogin.setToken(token.getTokenValue());
    persistentLogin.setLast_used(token.getDate());
    persist(persistentLogin);

}
项目:Webstore    文件:HibernateTokenRepositoryImpl.java   
@Override
public PersistentRememberMeToken getTokenForSeries(String seriesId) {
    logger.info("Fetch Token if any for seriesId : {}", seriesId);
    try {
        Criteria crit = createEntityCriteria();
        crit.add(Restrictions.eq("series", seriesId));
        PersistentLogin persistentLogin = (PersistentLogin) crit.uniqueResult();

        return new PersistentRememberMeToken(persistentLogin.getUsername(), persistentLogin.getSeries(),
                persistentLogin.getToken(), persistentLogin.getLast_used());
    } catch (Exception e) {
        logger.info("Token not found...");
        return null;
    }
}
项目:springsecuredthymeleafapp    文件:MongoPersistentTokenRepositoryImpl.java   
/** {@inheritDoc} */
@Override
public PersistentRememberMeToken getTokenForSeries(String seriesId) {
    RememberMeToken token = this.rememberMeTokenRepository.findBySeries(seriesId);
    if (null == token) {
        return null;
    }
    return new PersistentRememberMeToken(token.getUsername(), token.getSeries(), token.getTokenValue(),
            token.getDate());
}
项目:springsecuredthymeleafapp    文件:RememberMeToken.java   
/**
 * <p>Constructor for RememberMeToken.</p>
 *
 * @param token a {@link org.springframework.security.web.authentication.rememberme.PersistentRememberMeToken} object.
 */
public RememberMeToken(PersistentRememberMeToken token) {
    this.series = token.getSeries();
    this.username = token.getUsername();
    this.tokenValue = token.getTokenValue();
    this.date = token.getDate();
}
项目:castlemock    文件:SessionTokenRepository.java   
/**
 * The method provides the functionality to store a new token in the token repository
 * @param token The token that will be stored in the token repository
 */
@Override
public synchronized void createNewToken(PersistentRememberMeToken token) {
    PersistentRememberMeToken current = this.seriesTokens.get(token.getSeries());
    if(current != null) {
        throw new DataIntegrityViolationException("Series Id \'" + token.getSeries() + "\' already exists!");
    } else {
        this.seriesTokens.put(token.getSeries(), token);
        saveTokens();
    }
}
项目:castlemock    文件:SessionTokenRepository.java   
/**
 * Updates a specific token with a new values to a specific token
 * @param series The token that will be updated
 * @param tokenValue The new token value
 * @param lastUsed Date for when it was last used
 */
@Override
public synchronized void updateToken(String series, String tokenValue, Date lastUsed) {
    PersistentRememberMeToken token = this.getTokenForSeries(series);
    PersistentRememberMeToken newToken = new PersistentRememberMeToken(token.getUsername(), series, tokenValue, new Date());
    this.seriesTokens.put(series, newToken);
    saveTokens();
}
项目:castlemock    文件:SessionTokenRepository.java   
/**
 * Remove a user token from the repository
 * @param username The token that matches this user name will be removed
 */
@Override
public synchronized void removeUserTokens(String username) {
    Iterator series = this.seriesTokens.keySet().iterator();

    while(series.hasNext()) {
        String seriesId = (String)series.next();
        PersistentRememberMeToken token = this.seriesTokens.get(seriesId);
        if(username.equals(token.getUsername())) {
            series.remove();
        }
    }
    saveTokens();
}
项目:castlemock    文件:SessionTokenRepository.java   
/**
 * Get all tokens in a token list
 * @return A list of tokens
 */
private SessionTokenList getTokens(){
    final SessionTokenList tokens = new SessionTokenList();
    for(PersistentRememberMeToken persistentRememberMeToken : seriesTokens.values()){
        final SessionToken token = new SessionToken(persistentRememberMeToken);
        tokens.add(token);
    }
    return tokens;
}
项目:java-spring-jspx-hibernate-template    文件:PersistentLoginService.java   
@Override
public void createNewToken(PersistentRememberMeToken token) {
    PersistentLoginEntity userPersistentToken = new PersistentLoginEntity();
    userPersistentToken.setSeries(token.getSeries());
    userPersistentToken.setUsername(token.getUsername());
    userPersistentToken.setToken(token.getTokenValue());
    userPersistentToken.setLastUsed(token.getDate());
    persistentLoginRepository.save(userPersistentToken);
}
项目:java-spring-jspx-hibernate-template    文件:PersistentLoginService.java   
@Override
public PersistentRememberMeToken getTokenForSeries(String seriesId) {
    PersistentLoginEntity userPersistentToken = persistentLoginRepository.findBySeries(seriesId);
    if (userPersistentToken == null) {
        return null;
    }
    return new PersistentRememberMeToken(
            userPersistentToken.getUsername(),
            userPersistentToken.getSeries(),
            userPersistentToken.getToken(),
            userPersistentToken.getLastUsed());
}
项目:submerge    文件:PersistentTokenRepositoryServiceImpl.java   
@Override
public void createNewToken(PersistentRememberMeToken token) {

    PersistentLogin persistentLogin = new PersistentLogin();
    UserBO user = this.userService.findByName(token.getUsername());
    persistentLogin.setSeries(token.getSeries());
    persistentLogin.setToken(token.getTokenValue());
    persistentLogin.setUser(UserConverter.convert(user));
    persistentLogin.setLastUsed(token.getDate());

    this.sessionFactory.getCurrentSession().save(persistentLogin);
}
项目:kayura-uasp    文件:RememberMeTokenRepositoryImpl.java   
@Override
public void createNewToken(PersistentRememberMeToken token) {

    AutoLogin vo = new AutoLogin();
    vo.setToken(token.getTokenValue());
    vo.setSeriesId(token.getSeries());
    vo.setLastUsed(token.getDate());
    vo.setUserId(token.getUsername());

    userService.createLoginToken(vo);
}
项目:web-harvester    文件:HarvesterSecurityServiceImpl.java   
@Override
public void createNewToken(PersistentRememberMeToken prmt) {
    TokenEntity tokenEntity = new TokenEntity();
    tokenEntity.setDate(prmt.getDate());
    tokenEntity.setSeries(prmt.getSeries());
    tokenEntity.setTokenValue(prmt.getTokenValue());
    tokenEntity.setUsername(prmt.getUsername());
    tokenRepository.save(tokenEntity);
}
项目:web-harvester    文件:HarvesterSecurityServiceImpl.java   
@Override
public PersistentRememberMeToken getTokenForSeries(String series) {
    TokenEntity tokenEntity = tokenRepository.findBySeries(series);

    if (tokenEntity != null) {
        return new PersistentRememberMeToken(tokenEntity.getUsername(), tokenEntity.getSeries(), 
                tokenEntity.getTokenValue(), tokenEntity.getDate());
    }

    return null;
}
项目:summerb    文件:PersistentTokenRepositoryDefaultImpl.java   
@Override
public void createNewToken(PersistentRememberMeToken token) {
    try {
        authTokenService.createAuthToken(token.getUsername(), CurrentRequestUtils.get().getRemoteAddr(),
                token.getSeries(), token.getTokenValue());
    } catch (Throwable e) {
        throw new RuntimeException("Failed to create auth token", e);
    }
}
项目:summerb    文件:PersistentTokenRepositoryDefaultImpl.java   
@Override
public PersistentRememberMeToken getTokenForSeries(String seriesId) {
    try {
        AuthToken authToken = authTokenService.getAuthTokenByUuid(seriesId);
        User user = userService.getUserByUuid(authToken.getUserUuid());

        return new PersistentRememberMeToken(user.getEmail(), authToken.getUuid(), authToken.getTokenValue(),
                new Date(authToken.getLastVerifiedAt()));
    } catch (Throwable e) {
        log.info("Persistent auth token wasn't found for seriesId " + seriesId);
        return null;
    }
}
项目:zxl    文件:JdbcTokenRepository.java   
@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());
}
项目:zxl    文件:PersistentLogins.java   
public PersistentLogins(PersistentRememberMeToken token) {
    super();
    this.series = token.getSeries();
    this.username = token.getUsername();
    this.tokenValue = token.getTokenValue();
    this.lastUsedDate = token.getDate();
}
项目:lolibox    文件:JpaReMemberMeRepository.java   
@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);
}
项目:lolibox    文件:JpaReMemberMeRepository.java   
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());
}
项目:maven-framework-project    文件:IpAwarePersistentTokenRepository.java   
/**
 * 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);
}
项目:maven-framework-project    文件:IpAwarePersistentTokenRepository.java   
/**
 * 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);
}
项目:JiwhizBlogWeb    文件:MongoPersistentTokenRepositoryImpl.java   
@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());
}
项目:fat-lining    文件:CustomPersistentTokenRepository.java   
@Override
@Transactional
public void createNewToken(PersistentRememberMeToken token) {
    repo.save(RememberMeToken.of(token.getSeries(), token.getUsername(), token.getTokenValue(), token.getDate()));
}
项目:fat-lining    文件:CustomPersistentTokenRepository.java   
@Override
public PersistentRememberMeToken getTokenForSeries(String seriesId) {
    return repo.findBySeries(seriesId).map(RememberMeToken::toPersistentRememberMeToken).orElse(null);
}
项目:fat-lining    文件:RememberMeToken.java   
public PersistentRememberMeToken toPersistentRememberMeToken() {
    return new PersistentRememberMeToken(username, series, tokenValue, date);
}
项目:springuni-particles    文件:DelegatingPersistentTokenRepository.java   
@Override
public void createNewToken(PersistentRememberMeToken token) {
  Long sessionId = Long.valueOf(token.getSeries());
  Long userId = Long.valueOf(token.getUsername());
  sessionService.createSession(sessionId, userId, token.getTokenValue());
}
项目:Spring-Security-Third-Edition    文件:PersistentLogin.java   
public PersistentLogin(PersistentRememberMeToken token){
    this.series = token.getSeries();
    this.username = token.getUsername();
    this.token = token.getTokenValue();
    this.lastUsed = token.getDate();
}
项目:Spring-Security-Third-Edition    文件:PersistentLogin.java   
public PersistentLogin(PersistentRememberMeToken token){
    this.series = token.getSeries();
    this.username = token.getUsername();
    this.token = token.getTokenValue();
    this.lastUsed = token.getDate();
}
项目:Spring-Security-Third-Edition    文件:PersistentLogin.java   
public PersistentLogin(PersistentRememberMeToken token){
    this.series = token.getSeries();
    this.username = token.getUsername();
    this.token = token.getTokenValue();
    this.lastUsed = token.getDate();
}
项目:Spring-Security-Third-Edition    文件:PersistentLogin.java   
public PersistentLogin(PersistentRememberMeToken token){
    this.series = token.getSeries();
    this.username = token.getUsername();
    this.token = token.getTokenValue();
    this.lastUsed = token.getDate();
}
项目:Spring-Security-Third-Edition    文件:PersistentLogin.java   
public PersistentLogin(PersistentRememberMeToken token){
    this.series = token.getSeries();
    this.username = token.getUsername();
    this.token = token.getTokenValue();
    this.lastUsed = token.getDate();
}
项目:Spring-Security-Third-Edition    文件:PersistentLogin.java   
public PersistentLogin(PersistentRememberMeToken token){
    this.series = token.getSeries();
    this.username = token.getUsername();
    this.token = token.getTokenValue();
    this.lastUsed = token.getDate();
}
项目:Spring-Security-Third-Edition    文件:PersistentLogin.java   
public PersistentLogin(PersistentRememberMeToken token){
    this.series = token.getSeries();
    this.username = token.getUsername();
    this.token = token.getTokenValue();
    this.lastUsed = token.getDate();
}