/*
* Copyright 2003 Federal Chancellery Austria
* MOA-SPSS has been developed in a cooperation between BRZ, the Federal
* Chancellery Austria - ICT staff unit, and Graz University of Technology.
*
* Licensed under the EUPL, Version 1.1 or - as soon they will be approved by
* the European Commission - subsequent versions of the EUPL (the "Licence");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
* http://www.osor.eu/eupl/
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*
* This product combines work with different licenses. See the "NOTICE" text
* file for details on the various modules and licenses.
* The "NOTICE" text file is part of the distribution. Any derivative works
* that you distribute must include a readable copy of the "NOTICE" text file.
*/
package at.gv.egovernment.moa.spss.server.iaik.config;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import iaik.logging.LoggerConfig;
import iaik.pki.PKIConfiguration;
import iaik.server.ConfigurationData;
import at.gv.egovernment.moa.spss.server.config.HardwareCryptoModule;
import at.gv.egovernment.moa.spss.server.config.HardwareKeyModule;
import at.gv.egovernment.moa.spss.server.config.ConfigurationProvider;
import at.gv.egovernment.moa.spss.server.config.SoftwareKeyModule;
/**
* An implementation of the ConfigurationData
interface using
* MOA configuration data.
*
* @see iaik.server.ConfigurationData
* @author Patrick Peck
* @version $Id$
*/
public class ConfigurationDataImpl implements ConfigurationData {
/** PKI configuration data. */
private PKIConfiguration pkiConfiguration;
/** Crypto modules configuration data. */
private List cryptoModuleConfigurations;
/** Key modules configuration data. */
private List keyModuleConfigurations;
/** Logging configuration data. */
private LoggerConfig loggerConfig;
/**
* Create a new ConfigurationDataImpl
.
*
* @param config The underlying MOA configuration data.
*/
public ConfigurationDataImpl(ConfigurationProvider config) {
this.pkiConfiguration = new PKIConfigurationImpl(config);
this.cryptoModuleConfigurations = buildCryptoModuleConfigurations(config);
this.keyModuleConfigurations = buildKeyModuleConfigurations(config);
this.loggerConfig = new LoggerConfigImpl();
}
/**
* Build the list of CryptoModuleConfiguration
s.
*
* @param config The underlying MOA configuration data.
* @return The list of CryptoModuleConfiguration
s configured in
* the MOA configuration.
*/
private List buildCryptoModuleConfigurations(ConfigurationProvider config) {
List modules = new ArrayList();
Iterator iter = config.getHardwareCryptoModules().iterator();
while (iter.hasNext()) {
HardwareCryptoModule module = (HardwareCryptoModule) iter.next();
modules.add(new HardwareCryptoModuleConfigurationImpl(module));
}
return modules;
}
/**
* Build the list of KeyModuleConfiguration
s.
*
* @param config The underlying MOA configuration data.
* @return The list of KeyModuleConfiguration
s configured in the
* MOA configuration.
*/
private List buildKeyModuleConfigurations(ConfigurationProvider config) {
List keys = new ArrayList();
Iterator iter;
// add the hardware keys
iter = config.getHardwareKeyModules().iterator();
while (iter.hasNext()) {
HardwareKeyModule key = (HardwareKeyModule) iter.next();
keys.add(new HardwareKeyModuleConfigurationImpl(key));
}
// add the software keys
iter = config.getSoftwareKeyModules().iterator();
while (iter.hasNext()) {
SoftwareKeyModule key = (SoftwareKeyModule) iter.next();
keys.add(new SoftwareKeyModuleConfigurationImpl(key));
}
return keys;
}
/**
* @see iaik.server.ConfigurationData#getPKIConfiguration()
*/
public PKIConfiguration getPKIConfiguration() {
return pkiConfiguration;
}
/**
* @see iaik.server.ConfigurationData#getCryptoModuleConfigurations()
*/
public List getCryptoModuleConfigurations() {
return cryptoModuleConfigurations;
}
/**
* @see iaik.server.ConfigurationData#getKeyModuleConfigurations()
*/
public List getKeyModuleConfigurations() {
return keyModuleConfigurations;
}
/**
* @see iaik.server.ConfigurationData#getLoggerConfig()
*/
public LoggerConfig getLoggerConfig() {
return loggerConfig;
}
}