package at.gv.egovernment.moa.id.config; import java.math.BigInteger; import java.security.Principal; import java.security.cert.X509Certificate; import java.util.Map; import at.gv.egovernment.moa.id.data.IssuerAndSerial; /** * Base class for AuthConfigurationProvider and ProxyConfigurationProvider, * providing functions common to both of them. * * @author Paul Ivancsics * @version $Id$ */ public class ConfigurationProvider { /** * Constructor */ public ConfigurationProvider() { super(); } /** * The name of the system property which contains the file name of the * configuration file. */ public static final String CONFIG_PROPERTY_NAME = "moa.id.configuration"; /** * The name of the generic configuration property giving the certstore directory path. */ public static final String DIRECTORY_CERTSTORE_PARAMETER_PROPERTY = "DirectoryCertStoreParameters.RootDir"; /** * A Map which contains generic configuration information. Maps a * configuration name (a String) to a configuration value (also a * String). */ protected Map genericConfiguration; /** The default chaining mode. */ protected String defaultChainingMode; /** * A Map which contains the IssuerAndSerial to * chaining mode (a String) mapping. */ protected Map chainingModes; /** * the URL for the trusted CA Certificates */ protected String trustedCACertificates; /** * Returns the mapping of generic configuration properties. * * @return The mapping of generic configuration properties (a name to value * mapping) from the configuration. */ public Map getGenericConfiguration() { return genericConfiguration; } /** * Returns the value of a parameter from the generic configuration section. * * @return the parameter value; null if no such parameter */ public String getGenericConfigurationParameter(String parameter) { if (! genericConfiguration.containsKey(parameter)) return null; return (String)genericConfiguration.get(parameter); } /** * Return the chaining mode for a given trust anchor. * * @param trustAnchor The trust anchor for which the chaining mode should be * returned. * @return The chaining mode for the given trust anchor. If the trust anchor * has not been configured separately, the system default will be returned. */ public String getChainingMode(X509Certificate trustAnchor) { Principal issuer = trustAnchor.getIssuerDN(); BigInteger serial = trustAnchor.getSerialNumber(); IssuerAndSerial issuerAndSerial = new IssuerAndSerial(issuer, serial); String mode = (String) chainingModes.get(issuerAndSerial); return mode != null ? mode : defaultChainingMode; } /** * Returns the trustedCACertificates. * @return String */ public String getTrustedCACertificates() { return trustedCACertificates; } }