use of org.forgerock.openam.cts.utils.blob.TokenBlobUtils in project OpenAM by OpenRock.
the class SAMLAdapterTest method shouldSerialiseAndDeserialiseToken.
@Test
public void shouldSerialiseAndDeserialiseToken() {
// Given
// Need real delegates for this test.
serialisation = new JSONSerialisation(new ObjectMapper());
adapter = new SAMLAdapter(new TokenIdFactory(encoding), new JSONSerialisation(new ObjectMapper()), new TokenBlobUtils());
String tokenId = encoding.encodeKey("badger");
Token token = new Token(tokenId, TokenType.SAML2);
// SAML tokens only store time to seconds resolution
Calendar now = Calendar.getInstance();
now.set(Calendar.MILLISECOND, 0);
token.setExpiryTimestamp(now);
// SAML implementation detail around stored object
String blob = "woodland forrest";
token.setBlob(serialisation.serialise(blob).getBytes());
token.setAttribute(SAMLTokenField.OBJECT_CLASS.getField(), String.class.getName());
// SAML detail for secondary key
String secondaryKey = encoding.encodeKey("weasel");
token.setAttribute(SAMLTokenField.SECONDARY_KEY.getField(), secondaryKey);
// When
Token result = adapter.toToken(adapter.fromToken(token));
// Then
TokenTestUtils.assertTokenEquals(result, token);
}
use of org.forgerock.openam.cts.utils.blob.TokenBlobUtils in project OpenAM by OpenRock.
the class SessionAdapterTest method shouldFilterLatestAccessTime.
@Test
public void shouldFilterLatestAccessTime() throws CoreTokenException {
// Given
Token token = new Token("badger", TokenType.SESSION);
String latestAccessTime = "\"latestAccessTime\":1376308558,";
String someJSONLikeText = "{\"clientDomain\":null,\"creationTime\":1376307674,\"isISStored\":true," + latestAccessTime + "\"maxCachingTime\":3}";
token.setBlob(someJSONLikeText.getBytes());
TokenBlobUtils utils = new TokenBlobUtils();
// When
adapter.filterLatestAccessTime(token);
// Then
String contents = utils.getBlobAsString(token);
// Present in the original json text.
assertTrue(someJSONLikeText.contains(latestAccessTime));
// Removed in the treated json text.
assertFalse(contents.contains(latestAccessTime));
}
use of org.forgerock.openam.cts.utils.blob.TokenBlobUtils in project OpenAM by OpenRock.
the class OAuthAdapterTest method generateOAuthAdapter.
/**
* @return Makes a standard OAuthAdapter with real dependencies.
*/
private OAuthAdapter generateOAuthAdapter() {
JSONSerialisation serialisation = new JSONSerialisation(new ObjectMapper());
KeyConversion keyConversion = new KeyConversion();
OAuthValues oAuthValues = new OAuthValues();
TokenBlobUtils blobUtils = new TokenBlobUtils();
return new OAuthAdapter(new TokenIdFactory(keyConversion), serialisation, oAuthValues, blobUtils);
}
use of org.forgerock.openam.cts.utils.blob.TokenBlobUtils in project OpenAM by OpenRock.
the class AttributeCompressionStrategyTest method setup.
@BeforeMethod
public void setup() {
blobUtils = new TokenBlobUtils();
compression = new AttributeCompressionStrategy(blobUtils);
}
use of org.forgerock.openam.cts.utils.blob.TokenBlobUtils in project OpenAM by OpenRock.
the class SessionAdapterTest method setup.
@BeforeMethod
public void setup() {
tokenIdFactory = mock(TokenIdFactory.class);
coreTokenConfig = mock(CoreTokenConfig.class);
jsonSerialisation = mock(JSONSerialisation.class);
blobUtils = new TokenBlobUtils();
adapter = new SessionAdapter(tokenIdFactory, coreTokenConfig, jsonSerialisation, blobUtils);
}
Aggregations