/******************************************************************************* * 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 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; import lombok.extern.slf4j.Slf4j; @Slf4j public class GeneralStorkConfig { private List cpepslist; private List attributes; private String qaa; private MOAIDConfiguration dbconfig = null; /** * */ public GeneralStorkConfig() { try { dbconfig = ConfigurationProvider.getInstance().getDbRead().getMOAIDConfiguration(); } catch (final 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) { final AuthComponentGeneral auth = config.getAuthComponentGeneral(); if (auth != null) { final ForeignIdentities foreign = auth.getForeignIdentities(); if (foreign != null) { final STORK stork = foreign.getSTORK(); if (stork != null) { // deep clone all the things // to foreclose lazyloading session timeouts if (stork.getCPEPS() != null) { for (final CPEPS current : stork.getCPEPS()) { cpepslist.add(current); } } final List tmp = stork.getAttributes(); if (null != tmp) { for (final StorkAttribute current : tmp) { attributes.add(current); } } try { qaa = stork.getGeneral_eIDAS_LOA(); } catch (final NullPointerException e) { qaa = MOAIDConstants.eIDAS_LOA_HIGH; } } } } } if (cpepslist.isEmpty()) { final 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 { final List cpepss = dbconfig.getAuthComponentGeneral().getForeignIdentities().getSTORK() .getCPEPS(); if (cpepss != null) { // make CountryCode "readonly" for (final CPEPS newone : cpepslist) { for (final CPEPS current : cpepss) { if (null != newone) { if (current.getHjid().equals(newone.getHjid())) { newone.setCountryCode(current.getCountryCode()); break; } } } } } return cpepslist; } catch (final 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; } }