a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * The contents of this file are subject to the terms
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * of the Common Development and Distribution License
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * (the License). You may not use this file except in
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * compliance with the License.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * You can obtain a copy of the License at
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * See the License for the specific language governing
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * permission and limitations under the License.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * When distributing Covered Code, include this CDDL
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Header Notice in each file and include the License file
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * If applicable, add the following below the CDDL Header,
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * with the fields enclosed by brackets [] replaced by
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * your own identifying information:
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * $Id: SAML2MetaCache.java,v 1.4 2008/07/08 01:08:43 exu Exp $
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Portions Copyrighted [2010] [ForgeRock AS]
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterimport com.sun.identity.saml2.jaxb.entityconfig.EntityConfigElement;
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterimport com.sun.identity.saml2.jaxb.metadata.EntityDescriptorElement;
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterimport com.sun.identity.saml2.jaxb.metadataattr.EntityAttributesType;
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterimport com.sun.identity.saml2.jaxb.metadataattr.EntityAttributesElement;
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterimport com.sun.identity.saml2.jaxb.metadataattr.ObjectFactory;
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * The <code>SAML2MetaCache</code> provides metadata cache.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster private static Debug debug = SAML2MetaUtils.debug;
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster private static Hashtable descriptorCache = new Hashtable();
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster private static Hashtable configCache = new Hashtable();
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Returns the standard metadata entity descriptor under the realm from
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param realm The realm under which the entity resides.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param entityId ID of the entity to be retrieved.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @return <code>EntityDescriptorElement</code> for the entity or null
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * if not found.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster static EntityDescriptorElement getEntityDescriptor(
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster String cacheKey = buildCacheKey(realm, entityId);
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster (EntityDescriptorElement)descriptorCache.get(cacheKey);
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster debug.message("SAML2MetaCache.getEntityDescriptor: cacheKey = " +
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster cacheKey + ", found = " + (descriptor != null));
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Adds the standard metadata entity descriptor under the realm to cache.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param realm The realm under which the entity resides.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param entityId ID of the entity to be retrieved.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param descriptor <code>EntityDescriptorElement</code> for the entity.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster static void putEntityDescriptor(String realm, String entityId,
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster String cacheKey = buildCacheKey(realm, entityId);
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster debug.message("SAML2MetaCache.putEntityDescriptor: cacheKey = " +
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster "SAML2MetaCache.putEntityDescriptor: delete cacheEey = " +
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Returns extended entity configuration under the realm from cache.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param realm The realm under which the entity resides.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param entityId ID of the entity to be retrieved.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @return <code>EntityConfigElement</code> object for the entity or null
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * if not found.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster String cacheKey = buildCacheKey(realm, entityId);
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster (EntityConfigElement)configCache.get(cacheKey);
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster debug.message("SAML2MetaCache.getEntityConfig: cacheKey = " +
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Adds extended entity configuration under the realm to cache.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param realm The realm under which the entity resides.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param entityId ID of the entity to be retrieved.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param config <code>EntityConfigElement</code> object for the entity.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster static void putEntityConfig(String realm, String entityId,
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster String cacheKey = buildCacheKey(realm, entityId);
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster debug.message("SAML2MetaCache.putEntityConfig: cacheKey = " +
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster "SAML2MetaCache.putEntityConfig: delete cacheKey = " +
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Clears cache completely.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster debug.message("SAML2MetaCache.clear() called");
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Build cache key for descriptorCache and configCache based on realm and
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * entity ID.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param realm The realm under which the entity resides.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param entityID The entity ID or the name of circle of trust.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @return The cache key.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster private static String buildCacheKey(String realm, String entityId) {