@Test public void shouldDoNothingIfLatestAccessTimeNotFound() throws UnsupportedEncodingException { Token mockToken = mock(Token.class); given(mockToken.getBlob()).willReturn("badger".getBytes(TokenBlobUtils.ENCODING)); adapter.filterLatestAccessTime(mockToken); verify(mockToken, times(0)).setBlob(any(byte[].class)); }
public String filterLatestAccessTime(Token token) { String contents = blobUtils.getBlobAsString(token); Matcher matcher = LATEST_ACCESSED_TIME.matcher(contents); if (!matcher.find()) { return null; } String latestAccessTime = matcher.group(1); contents = contents.substring(0, matcher.start()) + contents.substring(matcher.end(), contents.length()); blobUtils.setBlobFromString(token, contents); return latestAccessTime; }
SessionAdapter implements TokenAdapter<InternalSession> { public String filterLatestAccessTime(Token token) { String contents = blobUtils.getBlobAsString(token); Matcher matcher = LATEST_ACCESSED_TIME.matcher(contents); if (!matcher.find()) { return null; } String latestAccessTime = matcher.group(1); contents = contents.substring(0, matcher.start()) + contents.substring(matcher.end(), contents.length()); blobUtils.setBlobFromString(token, contents); return latestAccessTime; } }
SessionAdapter implements TokenAdapter<InternalSession> { public String filterLatestAccessTime(Token token) { String contents = blobUtils.getBlobAsString(token); Matcher matcher = LATEST_ACCESSED_TIME.matcher(contents); if (!matcher.find()) { return null; } String latestAccessTime = matcher.group(1); contents = contents.substring(0, matcher.start()) + contents.substring(matcher.end(), contents.length()); blobUtils.setBlobFromString(token, contents); return latestAccessTime; } @Inject  SessionAdapter(TokenIdFactory tokenIdFactory, CoreTokenConfig config,
                          JSONSerialisation serialisation, LDAPDataConversion dataConversion,
                          TokenBlobUtils blobUtils); }
SessionAdapter implements TokenAdapter<InternalSession> { public String filterLatestAccessTime(Token token) { String contents = blobUtils.getBlobAsString(token); Matcher matcher = LATEST_ACCESSED_TIME.matcher(contents); if (!matcher.find()) { return null; } String latestAccessTime = matcher.group(1); contents = contents.substring(0, matcher.start()) + contents.substring(matcher.end(), contents.length()); blobUtils.setBlobFromString(token, contents); return latestAccessTime; } @Inject  SessionAdapter(TokenIdFactory tokenIdFactory, CoreTokenConfig config,
                          JSONSerialisation serialisation, LDAPDataConversion dataConversion,
                          TokenBlobUtils blobUtils); Token toToken(InternalSession session); InternalSession fromToken(Token token); int findIndexOfValidField(String blob); String filterLatestAccessTime(Token token); }
SessionAdapter implements TokenAdapter<InternalSession> { public String filterLatestAccessTime(Token token) { String contents = blobUtils.getBlobAsString(token); Matcher matcher = LATEST_ACCESSED_TIME.matcher(contents); if (!matcher.find()) { return null; } String latestAccessTime = matcher.group(1); contents = contents.substring(0, matcher.start()) + contents.substring(matcher.end(), contents.length()); blobUtils.setBlobFromString(token, contents); return latestAccessTime; } @Inject  SessionAdapter(TokenIdFactory tokenIdFactory, CoreTokenConfig config,
                          JSONSerialisation serialisation, LDAPDataConversion dataConversion,
                          TokenBlobUtils blobUtils); Token toToken(InternalSession session); InternalSession fromToken(Token token); int findIndexOfValidField(String blob); String filterLatestAccessTime(Token token);  }