a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Copyright (c) 2008 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: SAML2ConfigService.java,v 1.6 2009/06/12 22:21:40 mallas Exp $
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterimport com.sun.identity.plugin.configuration.ConfigurationActionEvent;
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterimport com.sun.identity.plugin.configuration.ConfigurationException;
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterimport com.sun.identity.plugin.configuration.ConfigurationInstance;
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterimport com.sun.identity.plugin.configuration.ConfigurationListener;
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterimport com.sun.identity.plugin.configuration.ConfigurationManager;
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterimport com.sun.identity.shared.configuration.SystemPropertiesManager;
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * This class provides methods to retrieve SAML2 configuration
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * from the data store.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Fosterpublic class SAML2ConfigService implements ConfigurationListener {
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster static final String CONFIG_NAME = "SAML2_CONFIG";
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster static final String SERVICE_NAME = "sunFAMSAML2Configuration";
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster static Debug debug = Debug.getInstance("libSAML2");
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster static final String SAML2_FAILOVER_ATTR = "failOverEnabled";
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster static final String SAML2_BUFFER_LENGTH = "bufferLength";
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster ci = ConfigurationManager.getConfigurationInstance(CONFIG_NAME);
4a48635cccc646ac479830fd4df0ee8e10c5bd8djeff.schenk SAML2ConfigService saml2ConfigService = new SAML2ConfigService();
4a48635cccc646ac479830fd4df0ee8e10c5bd8djeff.schenk if ( (saml2ConfigService != null) && (ci != null) )
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Default Constructor.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * This method will be invoked when a component's
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * configuration data has been changed. The parameters componentName,
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * realm and configName denotes the component name,
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * organization and configuration instance name that are changed
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * respectively.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param e Configuration action event, like ADDED, DELETED, MODIFIED etc.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster public void configChanged(ConfigurationActionEvent e) {
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster debug.message("SAML2ConfigService: configChanged");
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * This method reads values from service schema.
9e8eccb356ecf7096672d8baea66a42ac708b56dDirk Hogan debug.warning("ConfigurationInstance is null, so default values for " +
9e8eccb356ecf7096672d8baea66a42ac708b56dDirk Hogan "failover (false) and buffer length (2048) will be set.");
9e8eccb356ecf7096672d8baea66a42ac708b56dDirk Hogan debug.error("Exception caught obtaining updated configuration. " + SAML2_FAILOVER_ATTR + " and " +
9e8eccb356ecf7096672d8baea66a42ac708b56dDirk Hogan SAML2_BUFFER_LENGTH + " will not be updated. Exception: " + ce, ce);
9e8eccb356ecf7096672d8baea66a42ac708b56dDirk Hogan debug.message("The updated configuration: " + attrMap);
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster Set values = (Set)attrMap.get(SAML2_FAILOVER_ATTR);
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster if ((values != null) && (values.size() == 1)) {
9e8eccb356ecf7096672d8baea66a42ac708b56dDirk Hogan debug.warning("Value for " + SAML2_FAILOVER_ATTR + " null or size!=1. Defaulting to false.");
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster values = (Set)attrMap.get(SAML2_BUFFER_LENGTH);
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster if ((values != null) && (values.size() == 1)) {
9e8eccb356ecf7096672d8baea66a42ac708b56dDirk Hogan debug.warning("Value for " + SAML2_BUFFER_LENGTH + " null or size!=1. Defaulting to 2048.");
9e8eccb356ecf7096672d8baea66a42ac708b56dDirk Hogan debug.warning("Attribute map returned from ConfigurationInstance for the SAML2 config is null! " +
9e8eccb356ecf7096672d8baea66a42ac708b56dDirk Hogan "Default values for failover (false) and buffer length (2048) will be set.");
9e8eccb356ecf7096672d8baea66a42ac708b56dDirk Hogan debug.message("Attributes in SAML2ConfigService updated to: "
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * Retrieves current value of an AttributeSchema in the SAML2Config
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * ServiceSchema.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @param attributeName the name of the attributeSchema.
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * @return the value of the attribute schema. It could return null if
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * input attibuteName is null, or the attributeName can not be
a688bcbb4bcff5398fdd29b86f83450257dc0df4Allan Foster * found in the service schema.