use of org.forgerock.openam.cts.exceptions.CoreTokenException in project OpenAM by OpenRock.
the class DeleteOnQueryResultHandlerTest method shouldInvokeDeleteForEachHitEvenIfThereWasAnException.
@Test
public void shouldInvokeDeleteForEachHitEvenIfThereWasAnException() throws Exception {
Collection<PartialToken> hits = getHits(5);
handler.processResults(hits);
willThrow(new CoreTokenException("")).willNothing().given(mockTaskDispatcher).delete(anyString(), any(ResultHandler.class));
for (PartialToken hit : hits) {
verify(mockTaskDispatcher).delete(eq(hit.<String>getValue(CoreTokenField.TOKEN_ID)), any(ResultHandler.class));
}
}
use of org.forgerock.openam.cts.exceptions.CoreTokenException in project OpenAM by OpenRock.
the class CTSTokenPersistenceImpl method listTokens.
@Override
public List<STSIssuedTokenState> listTokens(QueryFilter<CoreTokenField> queryFilter) throws CTSTokenPersistenceException {
Collection<PartialToken> partialTokens;
try {
partialTokens = ctsPersistentStore.attributeQuery(buildTokenFilter(queryFilter));
} catch (CoreTokenException e) {
throw new CTSTokenPersistenceException(ResourceException.INTERNAL_ERROR, e.getMessage(), e);
}
List<STSIssuedTokenState> issuedTokens = new ArrayList<>(partialTokens.size());
for (PartialToken partialToken : partialTokens) {
issuedTokens.add(marshalIssuedTokenState(partialToken));
}
return issuedTokens;
}
use of org.forgerock.openam.cts.exceptions.CoreTokenException in project OpenAM by OpenRock.
the class UmaTokenStore method deleteRPT.
public void deleteRPT(String id) throws NotFoundException, ServerException {
try {
// check token is RPT
readRPT(id);
cts.delete(id);
} catch (CoreTokenException e) {
throw new ServerException("Could not delete token: " + id);
}
}
use of org.forgerock.openam.cts.exceptions.CoreTokenException in project OpenAM by OpenRock.
the class UmaTokenStore method readToken.
public UmaToken readToken(String ticketId, JavaBeanAdapter<? extends UmaToken> adapter) throws NotFoundException {
try {
Token token = cts.read(ticketId);
if (token == null) {
throw new NotFoundException("No valid ticket exists with ticketId");
}
UmaToken ticket = adapter.fromToken(token);
if (!realm.equals(ticket.getRealm())) {
throw new NotFoundException("No valid ticket exists with ticketId in the realm, " + realm);
}
return ticket;
} catch (CoreTokenException e) {
throw new NotFoundException("No valid ticket exists with ticketId");
}
}
use of org.forgerock.openam.cts.exceptions.CoreTokenException in project OpenAM by OpenRock.
the class UmaTokenStore method createRPT.
RequestingPartyToken createRPT(PermissionTicket permissionTicket) throws ServerException, NotFoundException {
UmaProviderSettings settings = settingsFactory.get(realm);
Permission permission = new Permission(permissionTicket.getResourceSetId(), permissionTicket.getScopes());
RequestingPartyToken rpt = new RequestingPartyToken(null, permissionTicket.getResourceServerClientId(), asSet(permission), System.currentTimeMillis() + (settings.getRPTLifetime() * 1000), permissionTicket.getId(), permissionTicket.getClientClientId());
rpt.setRealm(realm);
try {
cts.create(rptAdapter.toToken(rpt));
} catch (CoreTokenException e) {
throw new ServerException(e);
}
return rpt;
}
Aggregations