use of org.springframework.security.core.token.KeyBasedPersistenceTokenService in project spring-security by spring-projects.
the class KeyBasedPersistenceTokenServiceTests method getService.
private KeyBasedPersistenceTokenService getService() {
SecureRandomFactoryBean fb = new SecureRandomFactoryBean();
KeyBasedPersistenceTokenService service = new KeyBasedPersistenceTokenService();
service.setServerSecret("MY:SECRET$$$#");
service.setServerInteger(Integer.valueOf(454545));
try {
SecureRandom rnd = (SecureRandom) fb.getObject();
service.setSecureRandom(rnd);
service.afterPropertiesSet();
} catch (Exception e) {
throw new RuntimeException(e);
}
return service;
}
use of org.springframework.security.core.token.KeyBasedPersistenceTokenService in project spring-security by spring-projects.
the class KeyBasedPersistenceTokenServiceTests method testOperationWithEmptyRandomNumber.
@Test
public void testOperationWithEmptyRandomNumber() {
KeyBasedPersistenceTokenService service = getService();
service.setPseudoRandomNumberBytes(0);
Token token = service.allocateToken("Hello:world:::");
Token result = service.verifyToken(token.getKey());
assertThat(result).isEqualTo(token);
}
Aggregations