use of org.springframework.security.core.token.DefaultToken in project spring-security by spring-projects.
the class DefaultTokenTests method testEquality.
@Test
public void testEquality() {
String key = "key";
long created = new Date().getTime();
String extendedInformation = "extended";
DefaultToken t1 = new DefaultToken(key, created, extendedInformation);
DefaultToken t2 = new DefaultToken(key, created, extendedInformation);
assertThat(t2).isEqualTo(t1);
}
use of org.springframework.security.core.token.DefaultToken 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.DefaultToken in project spring-security by spring-projects.
the class DefaultTokenTests method testRejectsNullExtendedInformation.
@Test(expected = IllegalArgumentException.class)
public void testRejectsNullExtendedInformation() {
String key = "key";
long created = new Date().getTime();
new DefaultToken(key, created, null);
}
use of org.springframework.security.core.token.DefaultToken in project spring-security by spring-projects.
the class DefaultTokenTests method testEqualityWithDifferentExtendedInformation3.
@Test
public void testEqualityWithDifferentExtendedInformation3() {
String key = "key";
long created = new Date().getTime();
DefaultToken t1 = new DefaultToken(key, created, "length1");
DefaultToken t2 = new DefaultToken(key, created, "longerLength2");
assertThat(t1).isNotEqualTo(t2);
}
use of org.springframework.security.core.token.DefaultToken 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());
}
Aggregations