use of org.forgerock.openam.cts.api.tokens.TokenIdFactory 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.api.tokens.TokenIdFactory 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.api.tokens.TokenIdFactory 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);
}
use of org.forgerock.openam.cts.api.tokens.TokenIdFactory in project OpenAM by OpenRock.
the class SAMLAdapterTest method setup.
@BeforeMethod
public void setup() {
serialisation = mock(JSONSerialisation.class);
tokenIdFactory = mock(TokenIdFactory.class);
blobUtils = mock(TokenBlobUtils.class);
encoding = new KeyConversion();
adapter = new SAMLAdapter(tokenIdFactory, serialisation, blobUtils);
}
Aggregations