use of org.forgerock.openam.cts.api.tokens.Token in project OpenAM by OpenRock.
the class TokenMonitoringResultHandlerTest method shouldInvokeStoreOnProcessResults.
@Test
public void shouldInvokeStoreOnProcessResults() {
Token mockToken = mock(Token.class);
handler.processResults(mockToken);
verify(mockStore).addTokenOperation(eq(mockToken), eq(operation), eq(true));
}
use of org.forgerock.openam.cts.api.tokens.Token in project OpenAM by OpenRock.
the class LdapTokenAttributeConversion method tokenFromEntry.
/**
* Convert an Entry into a Token.
*
* The implication of function is that the Entry contains all the attributes of the
* Token. If any required attributes are missing, this operation will fail.
*
* @param entry A non null Entry.
*
* @return A non null Token initialised with the contents of the Entry.
*
* @see #mapFromEntry(org.forgerock.opendj.ldap.Entry)
*/
public Token tokenFromEntry(Entry entry) {
Map<CoreTokenField, Object> map = mapFromEntry(entry);
String tokenId = (String) map.get(CoreTokenField.TOKEN_ID);
TokenType type = (TokenType) map.get(CoreTokenField.TOKEN_TYPE);
Token token = new Token(tokenId, type);
for (Map.Entry<CoreTokenField, Object> e : map.entrySet()) {
CoreTokenField key = e.getKey();
Object value = e.getValue();
if (Token.isFieldReadOnly(key)) {
continue;
}
token.setAttribute(key, value);
}
return token;
}
use of org.forgerock.openam.cts.api.tokens.Token in project OpenAM by OpenRock.
the class CoreTokenAdapter method query.
/**
* Queries the persistence layer using the given TokenFilter to constrain the values.
*
* @param tokenFilter A non null TokenFilter.
* @return A non null, possibly empty collection of Tokens that match the Filter.
*
* @throws CoreTokenException If there was a problem processing the error or if there
* was a problem waiting for the response from the processor.
*/
public Collection<Token> query(final TokenFilter tokenFilter) throws CoreTokenException {
debug("Query: queued with Filter: {0}", tokenFilter);
ResultHandler<Collection<Token>, CoreTokenException> handler = handlerFactory.getQueryHandler();
dispatcher.query(tokenFilter, handler);
try {
Collection<Token> tokens = handler.getResults();
for (Token token : tokens) {
reverseBlobStrategy(token);
}
debug("Query: returned {0} Tokens with Filter: {1}", tokens.size(), tokenFilter);
return tokens;
} catch (CoreTokenException e) {
throw new QueryFailedException(tokenFilter, e);
}
}
use of org.forgerock.openam.cts.api.tokens.Token in project OpenAM by OpenRock.
the class SAML2CTSPersistentStore method saveSAML2Token.
/**
* {@inheritDoc}
*/
@Override
public void saveSAML2Token(String primaryKey, String secondaryKey, Object samlObj, long expirationTime) throws SAML2TokenRepositoryException {
// Save the SAML2 Token.
try {
// Perform the Save of the Token to the Token Repository.
SAMLToken samlToken = new SAMLToken(primaryKey, secondaryKey, expirationTime, samlObj);
Token token = tokenAdapter.toToken(samlToken);
persistentStore.createAsync(token);
} catch (CoreTokenException e) {
debug.error("SAML2CTSPersistentStore.saveSAML2Token(): failed to save SAML2 " + "token using primary key:" + primaryKey, e);
throw new SAML2TokenRepositoryException(e.getMessage(), e);
}
}
use of org.forgerock.openam.cts.api.tokens.Token in project OpenAM by OpenRock.
the class CTSOperationsTest method shouldReadTokenFromCTS.
@Test
public void shouldReadTokenFromCTS() throws CoreTokenException, SessionException {
// Given
Token mockToken = mock(Token.class);
given(mockCTS.read(anyString())).willReturn(mockToken);
InternalSession mockInternalSession = mock(InternalSession.class);
given(mockAdapter.fromToken(eq(mockToken))).willReturn(mockInternalSession);
SessionInfo mockSessionInfo = mock(SessionInfo.class);
given(mockInfoFactory.getSessionInfo(eq(mockInternalSession), any(SessionID.class))).willReturn(mockSessionInfo);
// When
SessionInfo result = ctsOperations.refresh(mockSession, false);
// Then
assertThat(result).isEqualTo(mockSessionInfo);
}
Aggregations