/******************************************************************************* * 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. *******************************************************************************/ package at.gv.egovernment.moa.id.configuration.data; import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; import at.gv.egovernment.moa.id.commons.MOAIDConstants; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.AuthComponentGeneral; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.CPEPS; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.ForeignIdentities; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.MOAIDConfiguration; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.STORK; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.StorkAttribute; import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationException; import at.gv.egovernment.moa.id.configuration.config.ConfigurationProvider; public class GeneralStorkConfig { private List cpepslist; private List attributes; private String qaa; private static final Logger log = Logger.getLogger(GeneralStorkConfig.class); private MOAIDConfiguration dbconfig = null; /** * */ public GeneralStorkConfig() { try { dbconfig = ConfigurationProvider.getInstance().getDbRead().getMOAIDConfiguration(); } catch (ConfigurationException e) { log.error("MOA-ID-Configuration initialization FAILED.", e); } } public void parse(MOAIDConfiguration config) { log.info("Initializing general Stork config"); cpepslist = new ArrayList(); attributes = new ArrayList(); if (config != null) { AuthComponentGeneral auth = config.getAuthComponentGeneral(); if (auth != null) { ForeignIdentities foreign = auth.getForeignIdentities(); if (foreign != null) { STORK stork = foreign.getSTORK(); if (stork != null) { // deep clone all the things // to foreclose lazyloading session timeouts if (stork.getCPEPS() != null) { for(CPEPS current : stork.getCPEPS()) { cpepslist.add(current); } } List tmp = stork.getAttributes(); if(null != tmp) { for(StorkAttribute current : tmp) attributes.add(current); } try { qaa = stork.getGeneral_eIDAS_LOA(); } catch(NullPointerException e) { qaa = MOAIDConstants.eIDAS_LOA_HIGH; } } } } } if (cpepslist.isEmpty()) { CPEPS defaultCPEPS = new CPEPS(); defaultCPEPS.setCountryCode("CC"); defaultCPEPS.setURL("http://"); defaultCPEPS.setSupportsXMLSignature(true); cpepslist.add(defaultCPEPS ); } if(attributes.isEmpty()) attributes.add(new StorkAttribute()); } public List getAllowedLoALevels() { return MOAIDConstants.ALLOWED_eIDAS_LOA; } public List getRawCPEPSList() { return cpepslist; } public List getCpepslist() { if (null == cpepslist) return null; //MOAIDConfiguration dbconfig = ConfigurationDBRead.getMOAIDConfiguration(); try { List cpepss = dbconfig.getAuthComponentGeneral().getForeignIdentities().getSTORK().getCPEPS(); if (cpepss != null) { // make CountryCode "readonly" for (CPEPS newone : cpepslist) { for (CPEPS current : cpepss) { if (null != newone) if (current.getHjid().equals(newone.getHjid())) { newone.setCountryCode(current.getCountryCode()); break; } } } } return cpepslist; } catch (NullPointerException e) { return null; } } public void setCpepslist(List list) { cpepslist = list; } public List getAttributes() { return attributes; } public void setAttributes(List attributes) { this.attributes = attributes; } public String getDefaultQaa() { return qaa; } public void setDefaultQaa(String qaa) { this.qaa = qaa; } }