/******************************************************************************* * Copyright 2014 Federal Chancellery Austria * MOA-ID 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. ******************************************************************************/ /* * Copyright 2003 Federal Chancellery Austria * MOA-ID 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.id.commons.utils.ssl; import java.io.File; import java.util.Collections; import java.util.Set; import at.gv.egovernment.moa.logging.Logger; import iaik.pki.store.certstore.CertStoreConfiguration; import iaik.pki.store.certstore.CertStoreParameters; import iaik.pki.store.certstore.CertStoreTypes; import iaik.pki.store.certstore.directory.DirectoryCertStoreParameters; /** * Implementation of interface needed to initialize an IAIK JSSE TrustManager * * @author Paul Ivancsics * @version $Id$ */ public class CertStoreConfigurationImpl extends ObservableImpl implements CertStoreConfiguration, DirectoryCertStoreParameters { /** * identifies the rootDirectory */ private String rootDirectory; /** * Array for storing all CertStoreParameters */ private CertStoreParameters[] parameters; /** * Create a new CertStoreConfigurationImpl. * * @param conf The MOA configuration from which the configuration data is * @throws ConfigurationException an any config-error * being read. */ public CertStoreConfigurationImpl(String certStoreRootDirParam) throws SSLConfigurationException { if (certStoreRootDirParam == null) throw new SSLConfigurationException( "config.08", new Object[]{"CertStoreDirectory"}); //rootDirectory = FileUtils.makeAbsoluteURL(certStoreRootDirParam, conf.getRootConfigFileDir()); rootDirectory = certStoreRootDirParam; Logger.error("Using file: " + rootDirectory); if (rootDirectory.startsWith("file:")) rootDirectory = rootDirectory.substring(5); Logger.error("Using file2: " + rootDirectory); File f = new File(rootDirectory); //Logger.error("Using file: " + certStoreRootDirParam + " param: " + conf.getRootConfigFileDir()); if (!f.exists()) { Logger.error("File does not exists: " + f.getAbsolutePath()); throw new SSLConfigurationException( "config.05", new Object[]{"CertStoreDirectory"}); } if (!f.isDirectory()) { Logger.error("File is not a directory: " + f.getAbsolutePath()); throw new SSLConfigurationException( "config.05", new Object[]{"CertStoreDirectory"}); } parameters = new CertStoreParameters[]{this}; } /** * @see iaik.pki.store.certstore.CertStoreConfiguration#getParameters() */ public CertStoreParameters[] getParameters() { return parameters; } /** * @see iaik.pki.store.certstore.directory.DirectoryCertStoreParameters#getRootDirectory() */ public String getRootDirectory() { return rootDirectory; } /** * @see iaik.pki.store.certstore.directory.DirectoryCertStoreParameters#createNew() */ public boolean createNew() { return true; } /** * @see iaik.pki.store.certstore.CertStoreParameters#getId() */ public String getId() { return "MOA ID Directory CertStore"; } /** * @see iaik.pki.store.certstore.CertStoreParameters#isReadOnly() */ public boolean isReadOnly() { return false; } /** * @return CertStoreTypes.DIRECTORY * @see iaik.pki.store.certstore.CertStoreParameters#getType() */ public String getType() { return CertStoreTypes.DIRECTORY; } /* (non-Javadoc) * @see iaik.pki.store.certstore.directory.DirectoryCertStoreParameters#getVirtualStores() */ @Override public Set getVirtualStores() { //TODO: only for Testing and not complete !!!Ask Harald !!!! return Collections.EMPTY_SET; } }