@Test (expectedExceptions = IllegalArgumentException.class) public void shouldNotDeserialiseATokenWhichDoesntContainAMap() { JSONSerialisation serialisation = new JSONSerialisation(); OAuthAdapter adapter = generateOAuthAdapter(); Token token = new Token("", TokenType.OAUTH); token.setBlob(serialisation.serialise("badger").getBytes()); adapter.fromToken(token); }
public JsonValue fromToken(Token token) { if (token == null){ return null; } String data = blobUtils.getBlobAsString(token); JsonValue r; try { r = new JsonValue(serialisation.deserialise(data, Map.class)); Set<String> keys = r.keys(); for (String key : keys){ List<String> x = r.get(key).asList(String.class); Set<String> set = new HashSet<String>(x); r.remove(key); r.add(key, set); } } catch (RuntimeException e) { throw new IllegalArgumentException( "The CTS usage of the JsonValue depends on the value being of " + "type Map."); } return r; }
OAuthAdapter implements TokenAdapter<JsonValue> { public JsonValue fromToken(Token token) { if (token == null){ return null; } String data = blobUtils.getBlobAsString(token); JsonValue r; try { r = new JsonValue(serialisation.deserialise(data, Map.class)); Set<String> keys = r.keys(); for (String key : keys){ List<String> x = r.get(key).asList(String.class); Set<String> set = new HashSet<String>(x); r.remove(key); r.add(key, set); } } catch (RuntimeException e) { throw new IllegalArgumentException( "The CTS usage of the JsonValue depends on the value being of " + "type Map."); } return r; } }
OAuthAdapter implements TokenAdapter<JsonValue> { public JsonValue fromToken(Token token) { if (token == null){ return null; } String data = blobUtils.getBlobAsString(token); JsonValue r; try { r = new JsonValue(serialisation.deserialise(data, Map.class)); Set<String> keys = r.keys(); for (String key : keys){ List<String> x = r.get(key).asList(String.class); Set<String> set = new HashSet<String>(x); r.remove(key); r.add(key, set); } } catch (RuntimeException e) { throw new IllegalArgumentException( "The CTS usage of the JsonValue depends on the value being of " + "type Map."); } return r; } @Inject  OAuthAdapter(TokenIdFactory tokenIdFactory, JSONSerialisation serialisation,
                        OAuthValues oAuthValues, TokenBlobUtils blobUtils); }
OAuthAdapter implements TokenAdapter<JsonValue> { public JsonValue fromToken(Token token) { if (token == null){ return null; } String data = blobUtils.getBlobAsString(token); JsonValue r; try { r = new JsonValue(serialisation.deserialise(data, Map.class)); Set<String> keys = r.keys(); for (String key : keys){ List<String> x = r.get(key).asList(String.class); Set<String> set = new HashSet<String>(x); r.remove(key); r.add(key, set); } } catch (RuntimeException e) { throw new IllegalArgumentException( "The CTS usage of the JsonValue depends on the value being of " + "type Map."); } return r; } @Inject  OAuthAdapter(TokenIdFactory tokenIdFactory, JSONSerialisation serialisation,
                        OAuthValues oAuthValues, TokenBlobUtils blobUtils); Token toToken(JsonValue request); JsonValue fromToken(Token token); }
OAuthAdapter implements TokenAdapter<JsonValue> { public JsonValue fromToken(Token token) { if (token == null){ return null; } String data = blobUtils.getBlobAsString(token); JsonValue r; try { r = new JsonValue(serialisation.deserialise(data, Map.class)); Set<String> keys = r.keys(); for (String key : keys){ List<String> x = r.get(key).asList(String.class); Set<String> set = new HashSet<String>(x); r.remove(key); r.add(key, set); } } catch (RuntimeException e) { throw new IllegalArgumentException( "The CTS usage of the JsonValue depends on the value being of " + "type Map."); } return r; } @Inject  OAuthAdapter(TokenIdFactory tokenIdFactory, JSONSerialisation serialisation,
                        OAuthValues oAuthValues, TokenBlobUtils blobUtils); Token toToken(JsonValue request); JsonValue fromToken(Token token); static final String VALUE; }