@@ -0,0 +1,1447 @@
+package com.github.dkanellis.fikey.storage;%0A%0Aimport com.google.common.cache.CacheBuilder;%0Aimport com.google.common.cache.CacheLoader;%0Aimport com.google.common.cache.LoadingCache;%0Aimport com.yubico.u2f.data.DeviceRegistration;%0A%0Aimport java.util.*;%0A%0A/**%0A * @author Dimitris%0A */%0Apublic class DataStorage%3CT, K, V%3E %7B%0A%0A    private LoadingCache%3CT, Map%3CK, V%3E%3E users;%0A    private Map%3CK, V%3E requests;%0A%0A    public DataStorage() %7B%0A        this.requests = new HashMap%3C%3E();%0A        this.users = CacheBuilder.newBuilder().build(new CacheLoader%3CT, Map%3CK, V%3E%3E() %7B%0A            @Override%0A            public Map%3CK, V%3E load(T key) throws Exception %7B%0A                return new HashMap%3C%3E();%0A            %7D%0A        %7D);%0A    %7D%0A%0A    public void addRequest(K key, V value) %7B%0A        requests.put(key, value);%0A    %7D%0A%0A    public V removeRequest(K key) %7B%0A        return requests.remove(key);%0A    %7D%0A%0A    public void addDeviceToUser(T username, K key, V value) %7B%0A        users.getUnchecked(username).put(key, value);%0A    %7D%0A%0A    public Iterable%3CDeviceRegistration%3E getDevicesFromUser(T username) %7B%0A        List%3CDeviceRegistration%3E registrations = new ArrayList%3C%3E();%0A        for (V serialized : getSerializedDevices(username)) %7B%0A            registrations.add(DeviceRegistration.fromJson((String) serialized));%0A        %7D%0A        return registrations;%0A    %7D%0A%0A    private Collection%3CV%3E getSerializedDevices(T username) %7B%0A        return users.getUnchecked(username).values();%0A    %7D%0A%0A%0A%7D%0A

Add user and device storage