SessionRepositoryFactory.java revision 89503929c8983c48e2049c77284b52e79ad37c32
3853N/A/*
3853N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3853N/A *
3853N/A * Copyright (c) 2012 ForgeRock US Inc. All Rights Reserved
3853N/A *
3853N/A * The contents of this file are subject to the terms of the Common Development and
3853N/A * Distribution License (the License). You may not use this file except in compliance with the
3853N/A * License.
3853N/A *
3853N/A * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
3853N/A * specific language governing permission and limitations under the License.
3853N/A *
3853N/A * When distributing Covered Software, include this CDDL Header Notice in each file and include
3853N/A * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
3853N/A * Header, with the fields enclosed by brackets [] replaced by your own identifying
3853N/A * information:
3853N/A *
3853N/A * "Portions copyright [year] [name of copyright owner]".
3853N/A *
3853N/A */
3853N/Apackage com.iplanet.dpro.session.service;
3853N/A
3853N/Aimport com.iplanet.am.util.SystemProperties;
3853N/Aimport com.sun.identity.coretoken.interfaces.AMSessionRepository;
5014N/Aimport com.sun.identity.sm.ldap.CTSPersistentStore;
3853N/Aimport com.sun.identity.sm.mq.JMQSessionRepository;
3853N/A
3853N/A/**
3853N/A * <code>SessionRepositoryFactory</code> provides a default
3853N/A * factory for obtaining our Core Token services BackEnd Repository.
3853N/A */
3853N/A
3853N/Aclass SessionRepositoryFactory {
3853N/A
3853N/A /**
3853N/A * Global Definitions.
3853N/A */
3853N/A private static final String DEFAULT_CTS_REPOSITORY_CLASS_NAME =
3853N/A CTSPersistentStore.class.getName();
3853N/A
3853N/A private static final String CTS_REPOSITORY_CLASS_NAME = SystemProperties.get(
3853N/A AMSessionRepository.CTS_REPOSITORY_CLASS_PROPERTY, DEFAULT_CTS_REPOSITORY_CLASS_NAME);
3853N/A
3853N/A /**
3853N/A * Singleton instance of AM Session Repository or CTS.
3853N/A */
3853N/A private static AMSessionRepository sessionRepository = null;
3853N/A
3853N/A /**
3853N/A * Private, do not allow instantiation.
3853N/A */
3853N/A private SessionRepositoryFactory() {
3853N/A }
3853N/A
3853N/A /**
3853N/A * Common Get Instance method to obtain access to
3853N/A * Service Methods.
3853N/A *
3853N/A * @return AMSessionRepository Singleton Instance.
5130N/A * @throws Exception
5130N/A */
5130N/A protected static AMSessionRepository getInstance()
5130N/A throws Exception {
3853N/A if (sessionRepository == null) {
3853N/A if (CTS_REPOSITORY_CLASS_NAME.equals(CTSPersistentStore.class.getName())) {
3853N/A sessionRepository = CTSPersistentStore.getInstance();
3853N/A } else if (CTS_REPOSITORY_CLASS_NAME.equals(JMQSessionRepository.class.getName())) {
3853N/A sessionRepository = JMQSessionRepository.getInstance();
3853N/A } else {
3853N/A throw new IllegalAccessException("Unable to instantiate the CTS Persistent Store as Implementation Class:["+
3853N/A CTS_REPOSITORY_CLASS_NAME+"], is unknown to OpenAM!");
3853N/A }
3853N/A }
3853N/A return sessionRepository;
3853N/A }
3853N/A
3853N/A}
3853N/A