use of org.springframework.security.core.token.Token in project spring-security by spring-projects.
the class KeyBasedPersistenceTokenServiceTests method testOperationWithSimpleExtendedInformation.
@Test
public void testOperationWithSimpleExtendedInformation() {
KeyBasedPersistenceTokenService service = getService();
Token token = service.allocateToken("Hello world");
Token result = service.verifyToken(token.getKey());
assertThat(result).isEqualTo(token);
}
use of org.springframework.security.core.token.Token in project spring-security by spring-projects.
the class KeyBasedPersistenceTokenServiceTests method testOperationWithComplexExtendedInformation.
@Test
public void testOperationWithComplexExtendedInformation() {
KeyBasedPersistenceTokenService service = getService();
Token token = service.allocateToken("Hello:world:::");
Token result = service.verifyToken(token.getKey());
assertThat(result).isEqualTo(token);
}
use of org.springframework.security.core.token.Token in project spring-security by spring-projects.
the class KeyBasedPersistenceTokenServiceTests method testOperationWithTamperedKey.
@Test(expected = IllegalArgumentException.class)
public void testOperationWithTamperedKey() {
KeyBasedPersistenceTokenService service = getService();
Token goodToken = service.allocateToken("");
String fake = goodToken.getKey().toUpperCase();
Token token = new DefaultToken(fake, new Date().getTime(), "");
service.verifyToken(token.getKey());
}
use of org.springframework.security.core.token.Token in project spring-security by spring-projects.
the class KeyBasedPersistenceTokenServiceTests method testOperationWithMissingKey.
@Test(expected = IllegalArgumentException.class)
public void testOperationWithMissingKey() {
KeyBasedPersistenceTokenService service = getService();
Token token = new DefaultToken("", new Date().getTime(), "");
service.verifyToken(token.getKey());
}
use of org.springframework.security.core.token.Token in project spring-security by spring-projects.
the class KeyBasedPersistenceTokenServiceTests method testOperationWithNoExtendedInformation.
@Test
public void testOperationWithNoExtendedInformation() {
KeyBasedPersistenceTokenService service = getService();
Token token = service.allocateToken("");
Token result = service.verifyToken(token.getKey());
assertThat(result).isEqualTo(token);
}
Aggregations