use of org.company.oauth2.CustomOAuth2AccessToken in project spring-security-oauth by spring-projects.
the class CustomSerializationStrategyTests method loadCustomSerializationStrategy.
@Test
public void loadCustomSerializationStrategy() {
spy(SpringFactoriesLoader.class);
when(SpringFactoriesLoader.loadFactories(SerializationStrategy.class, SerializationUtils.class.getClassLoader())).thenReturn(Arrays.<SerializationStrategy>asList(new CustomSerializationStrategy()));
deserialize(new DefaultOAuth2AccessToken("access-token-" + UUID.randomUUID()));
deserialize(new OAuth2Authentication(new OAuth2Request(Collections.<String, String>emptyMap(), "clientId", Collections.<GrantedAuthority>emptyList(), false, Collections.<String>emptySet(), new HashSet<String>(Arrays.asList("resourceId-1", "resourceId-2")), "redirectUri", Collections.<String>emptySet(), Collections.<String, Serializable>emptyMap()), new UsernamePasswordAuthenticationToken("test", "N/A")));
deserialize(new DefaultExpiringOAuth2RefreshToken("access-token-" + UUID.randomUUID(), new Date()));
deserialize("xyz");
deserialize(new HashMap<String, String>());
deserialize(new CustomOAuth2AccessToken("xyz"));
deserialize(new CustomOAuth2Authentication(RequestTokenFactory.createOAuth2Request("id", false), new CustomAuthentication("test", false)));
}
use of org.company.oauth2.CustomOAuth2AccessToken in project spring-security-oauth by spring-projects.
the class SerializationUtilsTests method deserializeNotAllowedCustomClasses.
@Test(expected = IllegalArgumentException.class)
public void deserializeNotAllowedCustomClasses() {
OAuth2AccessToken accessToken = new CustomOAuth2AccessToken("FOO");
WhitelistedSerializationStrategy newStrategy = new WhitelistedSerializationStrategy();
SerializationStrategy oldStrategy = SerializationUtils.getSerializationStrategy();
try {
SerializationUtils.setSerializationStrategy(newStrategy);
byte[] bytes = SerializationUtils.serialize(accessToken);
OAuth2AccessToken clone = SerializationUtils.deserialize(bytes);
assertNotNull(clone);
assertEquals(accessToken, clone);
} finally {
SerializationUtils.setSerializationStrategy(oldStrategy);
}
}
use of org.company.oauth2.CustomOAuth2AccessToken in project spring-security-oauth by spring-projects.
the class SerializationUtilsTests method deserializeCustomClasses.
@Test
public void deserializeCustomClasses() {
OAuth2AccessToken accessToken = new CustomOAuth2AccessToken("FOO");
byte[] bytes = SerializationUtils.serialize(accessToken);
OAuth2AccessToken clone = SerializationUtils.deserialize(bytes);
assertNotNull(clone);
assertEquals(accessToken, clone);
}
Aggregations