class OpenAMTokenStore implements OpenIdConnectTokenStore {

    @Override
    public DeviceCode readDeviceCode(String clientId, String code, OAuth2Request request) throws ServerException,
            NotFoundException, InvalidGrantException {
        DeviceCode deviceCode = request.getToken(DeviceCode.class);
        if (deviceCode == null) {
            try {
                JsonValue token = tokenStore.read(code);

                if (token == null) {
                    return null;
                }

                deviceCode = new DeviceCode(token);
            } catch (CoreTokenException e) {
                logger.error("Unable to read device code corresponding to id: " + code, e);
                throw new ServerException("Could not read token in CTS: " + e.getMessage());
            }
        }
        if (!clientId.equals(deviceCode.getClientId())) {
            throw new InvalidGrantException();
        }
        validateTokenRealm(deviceCode.getRealm(), request);
        request.setToken(DeviceCode.class, deviceCode);
        return deviceCode;
    }

    @Inject public  OpenAMTokenStore(OAuthTokenStore tokenStore, OAuth2ProviderSettingsFactory providerSettingsFactory,
            OAuth2UrisFactory<RealmInfo> oauth2UrisFactory,
            OpenIdConnectClientRegistrationStore clientRegistrationStore, RealmNormaliser realmNormaliser,
            SSOTokenManager ssoTokenManager, CookieExtractor cookieExtractor, OAuth2AuditLogger auditLogger,
            @Named(OAuth2Constants.DEBUG_LOG_NAME) Debug logger, SecureRandom secureRandom,
            ClientAuthenticationFailureFactory failureFactory);

}