/*
 * Copyright (c) 2013, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
 *
 * WSO2 Inc. licenses this file to you under the Apache License,
 * Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

package org.wso2.carbon.identity.oidc.session.cache;

import org.wso2.carbon.identity.application.common.cache.BaseCache;

/**
 * This is the class used to cache request session.
 */
public class OIDCSessionDataCache extends BaseCache<OIDCSessionDataCacheKey, OIDCSessionDataCacheEntry> {

    private static final String SESSION_DATA_CACHE_NAME = "OIDCSessionDataCache";

    private static volatile OIDCSessionDataCache instance;

    private OIDCSessionDataCache() {

        super(SESSION_DATA_CACHE_NAME);
    }

    public static OIDCSessionDataCache getInstance() {

        if (instance == null) {
            synchronized (OIDCSessionDataCache.class) {
                if (instance == null) {
                    instance = new OIDCSessionDataCache();
                }
            }
        }
        return instance;
    }
}

@@ -718,16 +718,109 @@
 cache;%0A%0A
+import org.wso2.carbon.identity.application.authentication.framework.store.SessionDataStore;%0A
 import o
@@ -1590,11 +1590,1316 @@
 e;%0A    %7D
+%0A%0A    /**%0A     * Add OIDCSessionDataCache to cache.%0A     *%0A     * @param key   OIDCSessionDataCacheKey.%0A     * @param entry OIDCSessionDataCacheEntry.%0A     */%0A    public void addToCache(OIDCSessionDataCacheKey key, OIDCSessionDataCacheEntry entry) %7B%0A%0A        super.addToCache(key, entry);%0A        SessionDataStore.getInstance().storeSessionData(key.getSessionDataId(), SESSION_DATA_CACHE_NAME, entry);%0A    %7D%0A%0A    /**%0A     * Get OIDCSessionDataCacheEntry from OIDCSessionDataCache.%0A     *%0A     * @param key OIDCSessionDataCacheKey.%0A     * @return OIDCSessionDataCacheEntry.%0A     */%0A    public OIDCSessionDataCacheEntry getValueFromCache(OIDCSessionDataCacheKey key) %7B%0A%0A        OIDCSessionDataCacheEntry cacheEntry = super.getValueFromCache(key);%0A        if (cacheEntry == null) %7B%0A            cacheEntry = (OIDCSessionDataCacheEntry) SessionDataStore.getInstance().%0A                    getSessionData(key.getSessionDataId(), SESSION_DATA_CACHE_NAME);%0A        %7D%0A        return cacheEntry;%0A    %7D%0A%0A    /**%0A     * Clear OIDCSessionDataCache.%0A     *%0A     * @param key OIDCSessionDataCacheKey.%0A     */%0A    public void clearCacheEntry(OIDCSessionDataCacheKey key) %7B%0A%0A        super.clearCacheEntry(key);%0A        SessionDataStore.getInstance().clearSessionData(key.getSessionDataId(), SESSION_DATA_CACHE_NAME);%0A    %7D
 %0A%7D%0A

Make OIDCSessionDataCache a persistence cache