/******************************************************************************* * 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.struts.action; import java.math.BigInteger; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Set; import org.apache.commons.lang3.StringUtils; import at.gv.egiz.components.configuration.meta.api.ConfigurationStorageException; import at.gv.egiz.eaaf.core.impl.utils.KeyValueUtils; import at.gv.egiz.eaaf.core.impl.utils.Random; import at.gv.egovernment.moa.id.commons.config.ConfigurationMigrationUtils; 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.ChainingModeType; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.ChainingModes; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.ConnectionParameterClientAuthType; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.Contact; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.DefaultBKUs; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.ForeignIdentities; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.GeneralConfiguration; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.IdentityLinkSigners; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.LegacyAllowed; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.MOAIDConfiguration; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.MOASP; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OAuth; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.OnlineMandates; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.Organization; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.PVP2; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.Protocols; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.SAML1; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.SLRequestTemplates; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.SSO; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.STORK; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.SecurityLayer; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.StorkAttribute; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.TimeOuts; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.TransformsInfoType; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.VerifyAuthBlock; import at.gv.egovernment.moa.id.commons.db.dao.config.deprecated.VerifyIdentityLink; import at.gv.egovernment.moa.id.commons.validation.ValidationHelper; import at.gv.egovernment.moa.id.config.webgui.exception.ConfigurationException; import at.gv.egovernment.moa.id.configuration.Constants; import at.gv.egovernment.moa.id.configuration.config.ConfigurationProvider; import at.gv.egovernment.moa.id.configuration.data.GeneralMOAIDConfig; import at.gv.egovernment.moa.id.configuration.data.GeneralStorkConfig; import at.gv.egovernment.moa.id.configuration.exception.BasicActionException; import at.gv.egovernment.moa.id.configuration.helper.LanguageHelper; import at.gv.egovernment.moa.id.configuration.helper.StringHelper; import at.gv.egovernment.moa.id.configuration.validation.moaconfig.MOAConfigValidator; import at.gv.egovernment.moa.id.configuration.validation.moaconfig.StorkConfigValidator; import at.gv.egovernment.moa.util.MiscUtil; import lombok.extern.slf4j.Slf4j; @Slf4j public class EditGeneralConfigAction extends BasicAction { private static final long serialVersionUID = 1L; private GeneralMOAIDConfig moaconfig; private GeneralStorkConfig storkconfig; private String formID; public String loadConfig() { try { populateBasicInformations(); } catch (final BasicActionException e) { return Constants.STRUTS_ERROR; } if (authUser.isAdmin()) { final MOAIDConfiguration dbconfig = configuration.getDbRead().getMOAIDConfiguration(); moaconfig = new GeneralMOAIDConfig(); moaconfig.parse(dbconfig); if (moaconfig == null) { log.error("MOA configuration is null"); } if (moaconfig.isMoaidMode()) { storkconfig = new GeneralStorkConfig(); storkconfig.parse(dbconfig); if (storkconfig == null) { log.error("Stork configuration is null"); } } formID = Random.nextRandom(); session.setAttribute(Constants.SESSION_FORMID, formID); return Constants.STRUTS_SUCCESS; } else { addActionError(LanguageHelper.getErrorString("errors.notallowed", request)); return Constants.STRUTS_NOTALLOWED; } } public String saveConfig() { try { populateBasicInformations(); } catch (final BasicActionException e) { return Constants.STRUTS_ERROR; } final Object formidobj = session.getAttribute(Constants.SESSION_FORMID); if (formidobj != null && formidobj instanceof String) { final String formid = (String) formidobj; if (!formid.equals(formID)) { log.warn("FormIDs does not match. Some suspect Form is received from user " + authUser.getFamilyName() + authUser.getGivenName() + authUser.getUserID()); return Constants.STRUTS_ERROR; } } else { log.warn("FormIDs does not match. Some suspect Form is received from user " + authUser.getFamilyName() + authUser.getGivenName() + authUser.getUserID()); return Constants.STRUTS_ERROR; } session.setAttribute(Constants.SESSION_FORMID, null); boolean isMoaidMode = false; try { isMoaidMode = ConfigurationProvider.getInstance().isMOAIDMode(); } catch (final ConfigurationException e) { log.warn("Can NOT load configuration. Set 'moaidmode' to 'false'", e); } if (authUser.isAdmin()) { final MOAConfigValidator validator = new MOAConfigValidator(); final List errors = validator.validate(moaconfig, request, isMoaidMode); if (isMoaidMode) { errors.addAll(new StorkConfigValidator().validate(storkconfig, request)); } if (errors.size() > 0) { log.info("General MOA-ID configuration has some errors."); for (final String el : errors) { addActionError(el); } if (moaconfig.getSecLayerTransformation() != null) { session.setAttribute(Constants.SESSION_SLTRANSFORMATION, moaconfig.getSecLayerTransformation()); } formID = Random.nextRandom(); session.setAttribute(Constants.SESSION_FORMID, formID); return Constants.STRUTS_ERROR_VALIDATION; } else { if (moaconfig.getSecLayerTransformation() == null && session.getAttribute(Constants.SESSION_SLTRANSFORMATION) != null && session.getAttribute(Constants.SESSION_SLTRANSFORMATION) instanceof Map) { moaconfig.setSecLayerTransformation((Map) session.getAttribute( Constants.SESSION_SLTRANSFORMATION)); } } final String error = saveFormToDatabase(isMoaidMode); if (error != null) { log.warn("General MOA-ID config can not be stored in Database"); // set new formID formID = Random.nextRandom(); session.setAttribute(Constants.SESSION_FORMID, formID); addActionError(error); return Constants.STRUTS_ERROR_VALIDATION; } session.setAttribute(Constants.SESSION_SLTRANSFORMATION, null); } else { addActionError(LanguageHelper.getErrorString("errors.notallowed", request)); return Constants.STRUTS_NOTALLOWED; } addActionMessage(LanguageHelper.getGUIString("webpages.moaconfig.save.success", request)); return Constants.STRUTS_SUCCESS; } public String back() { try { populateBasicInformations(); } catch (final BasicActionException e) { return Constants.STRUTS_ERROR; } return Constants.STRUTS_SUCCESS; } private String saveFormToDatabase(boolean isMoaidMode) { log.debug("Saving form to database"); // log.error("Saving form to db"); // log.info("SV frm db"); // for (Object obj : Collections.list(request.getParameterNames())) { // log.error(" PARAM: " + obj.toString()); // } // for (Object obj : Collections.list(request.getSession().getAttributeNames())) { // log.error(" SES PARAM: " + obj.toString()); // } try { log.error(" ASSERTION " + moaconfig.getTimeoutAssertion()); } catch (final Exception ex) { ex.printStackTrace(); } MOAIDConfiguration dbconfig = configuration.getDbRead().getMOAIDConfiguration(); if (dbconfig == null) { dbconfig = new MOAIDConfiguration(); } AuthComponentGeneral dbauth = dbconfig.getAuthComponentGeneral(); if (dbauth == null) { dbauth = new AuthComponentGeneral(); dbconfig.setAuthComponentGeneral(dbauth); } GeneralConfiguration dbauthgeneral = dbauth.getGeneralConfiguration(); if (dbauthgeneral == null) { dbauthgeneral = new GeneralConfiguration(); dbauth.setGeneralConfiguration(dbauthgeneral); } // GeneralConfiguration oldauthgeneral = null; // if (oldauth != null) // oldauthgeneral = oldauth.getGeneralConfiguration(); // set Public URL Prefix final String pubURLPrefix = moaconfig.getPublicURLPrefix(); if (moaconfig.isVirtualPublicURLPrefixEnabled()) { dbauthgeneral.setPublicURLPreFix( KeyValueUtils.normalizeCSVValueString(pubURLPrefix)); } else { if (pubURLPrefix.contains(KeyValueUtils.CSV_DELIMITER)) { dbauthgeneral.setPublicURLPreFix( pubURLPrefix.trim().substring(0, pubURLPrefix.indexOf(KeyValueUtils.CSV_DELIMITER))); } else { dbauthgeneral.setPublicURLPreFix( StringUtils.chomp(pubURLPrefix.trim())); } } dbauthgeneral.setVirtualPublicURLPrefixEnabled( moaconfig.isVirtualPublicURLPrefixEnabled()); // if (MiscUtil.isNotEmpty(moaconfig.getAlternativeSourceID())) // dbauthgeneral.setAlternativeSourceID(moaconfig.getAlternativeSourceID()); // else { // if (oldauthgeneral != null) // dbauthgeneral.setAlternativeSourceID(oldauthgeneral.getAlternativeSourceID()); // } // if (MiscUtil.isNotEmpty(moaconfig.getCertStoreDirectory())) // dbauthgeneral.setCertStoreDirectory(moaconfig.getCertStoreDirectory()); TimeOuts dbtimeouts = dbauthgeneral.getTimeOuts(); if (dbtimeouts == null) { dbtimeouts = new TimeOuts(); dbauthgeneral.setTimeOuts(dbtimeouts); } if (MiscUtil.isEmpty(moaconfig.getTimeoutAssertion())) { dbtimeouts.setAssertion(BigInteger.valueOf(GeneralMOAIDConfig.DEFAULTTIMEOUTASSERTION)); } else { dbtimeouts.setAssertion(new BigInteger(moaconfig.getTimeoutAssertion())); } if (MiscUtil.isEmpty(moaconfig.getTimeoutMOASessionCreated())) { dbtimeouts.setMOASessionCreated(BigInteger.valueOf(GeneralMOAIDConfig.DEFAULTTIMEOUTMOASESSIONCREATED)); } else { dbtimeouts.setMOASessionCreated(new BigInteger(moaconfig.getTimeoutMOASessionCreated())); } if (MiscUtil.isEmpty(moaconfig.getTimeoutMOASessionUpdated())) { dbtimeouts.setMOASessionUpdated(BigInteger.valueOf(GeneralMOAIDConfig.DEFAULTTIMEOUTMOASESSIONUPDATED)); } else { dbtimeouts.setMOASessionUpdated(new BigInteger(moaconfig.getTimeoutMOASessionUpdated())); } dbauthgeneral.setTrustManagerRevocationChecking(moaconfig.isTrustmanagerrevocationcheck()); Protocols dbprotocols = dbauth.getProtocols(); if (dbprotocols == null) { dbprotocols = new Protocols(); dbauth.setProtocols(dbprotocols); } LegacyAllowed legprot = dbprotocols.getLegacyAllowed(); if (legprot == null) { legprot = new LegacyAllowed(); dbprotocols.setLegacyAllowed(legprot); } List el = legprot.getProtocolName(); if (el == null) { el = new ArrayList<>(); legprot.setProtocolName(el); } // Workaround for DB cleaning is only needed for one or the releases (insert in // 2.1.1) if (el.size() > 2) { el.clear(); } if (el.contains(Constants.MOA_CONFIG_PROTOCOL_PVP2)) { if (!moaconfig.isLegacy_pvp2()) { el.remove(Constants.MOA_CONFIG_PROTOCOL_PVP2); } } else { if (moaconfig.isLegacy_pvp2()) { el.add(Constants.MOA_CONFIG_PROTOCOL_PVP2); } } if (el.contains(Constants.MOA_CONFIG_PROTOCOL_SAML1)) { if (!moaconfig.isLegacy_saml1()) { el.remove(Constants.MOA_CONFIG_PROTOCOL_SAML1); } } else { if (moaconfig.isLegacy_saml1()) { el.add(Constants.MOA_CONFIG_PROTOCOL_SAML1); } } SAML1 saml1 = dbprotocols.getSAML1(); if (saml1 == null) { saml1 = new SAML1(); dbprotocols.setSAML1(saml1); } saml1.setIsActive(moaconfig.isProtocolActiveSAML1()); if (MiscUtil.isNotEmpty(moaconfig.getSaml1SourceID())) { saml1.setSourceID(moaconfig.getSaml1SourceID()); } else { if (MiscUtil.isNotEmpty(saml1.getSourceID())) { saml1.setSourceID(moaconfig.getSaml1SourceID()); } } OAuth oauth = dbprotocols.getOAuth(); if (oauth == null) { oauth = new OAuth(); dbprotocols.setOAuth(oauth); } PVP2 pvp2 = dbprotocols.getPVP2(); if (pvp2 == null) { pvp2 = new PVP2(); dbprotocols.setPVP2(pvp2); } if (isMoaidMode) { oauth.setIsActive(moaconfig.isProtocolActiveOAuth()); pvp2.setIsActive(moaconfig.isProtocolActivePVP21()); } if (MiscUtil.isNotEmpty(moaconfig.getPvp2IssuerName())) { pvp2.setIssuerName(moaconfig.getPvp2IssuerName()); // if (MiscUtil.isNotEmpty(moaconfig.getPvp2PublicUrlPrefix())) // pvp2.setPublicURLPrefix(moaconfig.getPvp2PublicUrlPrefix()); } Organization pvp2org = pvp2.getOrganization(); if (pvp2org == null) { pvp2org = new Organization(); pvp2.setOrganization(pvp2org); } if (MiscUtil.isNotEmpty(moaconfig.getPvp2OrgDisplayName())) { pvp2org.setDisplayName(StringHelper.getUTF8String( moaconfig.getPvp2OrgDisplayName())); } if (MiscUtil.isNotEmpty(moaconfig.getPvp2OrgName())) { pvp2org.setName(StringHelper.getUTF8String(moaconfig.getPvp2OrgName())); } if (MiscUtil.isNotEmpty(moaconfig.getPvp2OrgURL())) { pvp2org.setURL(moaconfig.getPvp2OrgURL()); } List pvp2cont = pvp2.getContact(); if (pvp2cont == null) { pvp2cont = new ArrayList<>(); pvp2.setContact(pvp2cont); } if (pvp2cont.size() == 0) { final Contact cont = new Contact(); pvp2cont.add(cont); } final Contact cont = pvp2cont.get(0); if (MiscUtil.isNotEmpty(moaconfig.getPvp2Contact().getCompany())) { cont.setCompany(StringHelper.getUTF8String( moaconfig.getPvp2Contact().getCompany())); } if (MiscUtil.isNotEmpty(moaconfig.getPvp2Contact().getGivenname())) { cont.setGivenName(StringHelper.getUTF8String( moaconfig.getPvp2Contact().getGivenname())); } if (cont.getMail() != null && cont.getMail().size() > 0) { cont.getMail().set(0, moaconfig.getPvp2Contact().getMail()); } else { cont.setMail(Arrays.asList(moaconfig.getPvp2Contact().getMail())); } if (cont.getPhone() != null && cont.getPhone().size() > 0) { cont.getPhone().set(0, moaconfig.getPvp2Contact().getPhone()); } else { cont.setPhone(Arrays.asList(moaconfig.getPvp2Contact().getPhone())); } cont.setSurName(StringHelper.getUTF8String(moaconfig.getPvp2Contact().getSurname())); if (MiscUtil.isNotEmpty(moaconfig.getPvp2Contact().getType())) { cont.setType(moaconfig.getPvp2Contact().getType()); } ChainingModes dbchainingmodes = dbconfig.getChainingModes(); if (dbchainingmodes == null) { dbchainingmodes = new ChainingModes(); dbconfig.setChainingModes(dbchainingmodes); } dbchainingmodes.setSystemDefaultMode( ChainingModeType.fromValue("pkix")); if (isMoaidMode) { SSO dbsso = dbauth.getSSO(); if (dbsso == null) { dbsso = new SSO(); dbauth.setSSO(dbsso); } if (MiscUtil.isNotEmpty(moaconfig.getSsoFriendlyName())) { dbsso.setFriendlyName(StringHelper.getUTF8String( moaconfig.getSsoFriendlyName())); } if (MiscUtil.isNotEmpty(moaconfig.getSsoSpecialText())) { dbsso.setSpecialText(StringHelper.getUTF8String( moaconfig.getSsoSpecialText())); // if (MiscUtil.isNotEmpty(moaconfig.getSsoPublicUrl())) // dbsso.setPublicURL(moaconfig.getSsoPublicUrl()); } if (MiscUtil.isNotEmpty(moaconfig.getSsoTarget())) { if (!ValidationHelper.isValidAdminTarget(moaconfig.getSsoTarget())) { String num = moaconfig.getSsoTarget().replaceAll(" ", ""); String pre = null; if (num.startsWith(Constants.IDENIFICATIONTYPE_FN)) { num = num.substring(Constants.IDENIFICATIONTYPE_FN.length()); num = at.gv.egovernment.moa.util.StringUtils.deleteLeadingZeros(num); pre = Constants.IDENIFICATIONTYPE_FN; } if (num.startsWith(Constants.IDENIFICATIONTYPE_ZVR)) { num = num.substring(Constants.IDENIFICATIONTYPE_ZVR.length()); pre = Constants.IDENIFICATIONTYPE_ZVR; } if (num.startsWith(Constants.IDENIFICATIONTYPE_ERSB)) { num = num.substring(Constants.IDENIFICATIONTYPE_ERSB.length()); pre = Constants.IDENIFICATIONTYPE_ERSB; } dbsso.setTarget(Constants.PREFIX_WPBK + pre + "+" + num); } else { dbsso.setTarget(moaconfig.getSsoTarget()); } } // if (MiscUtil.isNotEmpty(moaconfig.getSsoIdentificationNumber())) { // IdentificationNumber ssoid = dbsso.getIdentificationNumber(); // if (ssoid == null) { // ssoid = new IdentificationNumber(); // dbsso.setIdentificationNumber(ssoid); // } // ssoid.setValue(moaconfig.getSsoIdentificationNumber()); // } DefaultBKUs dbbkus = dbconfig.getDefaultBKUs(); if (dbbkus == null) { dbbkus = new DefaultBKUs(); dbconfig.setDefaultBKUs(dbbkus); } if (MiscUtil.isNotEmpty(moaconfig.getDefaultBKUHandy())) { dbbkus.setHandyBKU(moaconfig.getDefaultBKUHandy()); } else { dbbkus.setHandyBKU(new String()); } if (MiscUtil.isNotEmpty(moaconfig.getDefaultBKUOnline())) { dbbkus.setOnlineBKU(moaconfig.getDefaultBKUOnline()); } else { dbbkus.setOnlineBKU(new String()); } if (MiscUtil.isNotEmpty(moaconfig.getDefaultBKULocal())) { dbbkus.setLocalBKU(moaconfig.getDefaultBKULocal()); } else { dbbkus.setLocalBKU(new String()); } IdentityLinkSigners idlsigners = dbauth.getIdentityLinkSigners(); if (idlsigners == null) { idlsigners = new IdentityLinkSigners(); dbauth.setIdentityLinkSigners(idlsigners); } ForeignIdentities dbforeign = dbauth.getForeignIdentities(); if (dbforeign == null) { dbforeign = new ForeignIdentities(); dbauth.setForeignIdentities(dbforeign); } if (MiscUtil.isNotEmpty(moaconfig.getSzrgwURL())) { ConnectionParameterClientAuthType forcon = dbforeign.getConnectionParameter(); if (forcon == null) { forcon = new ConnectionParameterClientAuthType(); dbforeign.setConnectionParameter(forcon); } if (KeyValueUtils.isCSVValueString(moaconfig.getSzrgwURL())) { forcon.setURL(KeyValueUtils.normalizeCSVValueString(moaconfig.getSzrgwURL())); } else { if (moaconfig.getSzrgwURL().contains(KeyValueUtils.CSV_DELIMITER)) { forcon.setURL( moaconfig.getSzrgwURL().trim().substring(0, moaconfig.getSzrgwURL().indexOf(KeyValueUtils.CSV_DELIMITER))); } else { forcon.setURL( StringUtils.chomp(moaconfig.getSzrgwURL().trim())); } } } final ForeignIdentities foreign = dbauth.getForeignIdentities(); if (foreign != null) { STORK stork = foreign.getSTORK(); if (stork == null) { stork = new STORK(); foreign.setSTORK(stork); } try { log.error("QAAAA " + storkconfig.getDefaultQaa()); stork.setGeneral_eIDAS_LOA(storkconfig.getDefaultQaa()); if (storkconfig.getAttributes() != null) { final List dbStorkAttr = new ArrayList<>(); stork.setAttributes(dbStorkAttr); for (final StorkAttribute attr : storkconfig.getAttributes()) { if (attr != null && MiscUtil.isNotEmpty(attr.getName())) { dbStorkAttr.add(attr); } else { log.info("Remove null or empty STORK attribute"); } } } else { stork.setAttributes(new ArrayList()); } if (storkconfig.getCpepslist() != null) { final List dbStorkCPEPS = new ArrayList<>(); stork.setCPEPS(dbStorkCPEPS); for (final CPEPS cpeps : storkconfig.getCpepslist()) { if (cpeps != null && MiscUtil.isNotEmpty(cpeps.getURL()) && MiscUtil.isNotEmpty(cpeps.getCountryCode())) { if (cpeps.getCountryCode().equals("CC") && cpeps.getURL().equals("http://")) { log.info("Remove dummy STORK CPEPS entry."); } else { dbStorkCPEPS.add(cpeps); } } else { log.info("Remove null or emtpy STORK CPEPS configuration"); } } } else { stork.setCPEPS(new ArrayList()); } } catch (final Exception e) { e.printStackTrace(); } try { log.info("CPEPS LIST: " + storkconfig.getCpepslist().size()); log.trace("CPEPS 1:" + storkconfig.getCpepslist().get(0).getCountryCode() + storkconfig .getCpepslist().get(0).getURL()); } catch (final Exception ex) { log.info("CPEPS LIST is null"); } } // write MIS Mandate-Service URLs if (MiscUtil.isNotEmpty(moaconfig.getMandateURL())) { OnlineMandates dbmandate = dbauth.getOnlineMandates(); if (dbmandate == null) { dbmandate = new OnlineMandates(); dbauth.setOnlineMandates(dbmandate); } ConnectionParameterClientAuthType dbmandateconnection = dbmandate.getConnectionParameter(); if (dbmandateconnection == null) { dbmandateconnection = new ConnectionParameterClientAuthType(); dbmandate.setConnectionParameter(dbmandateconnection); } if (KeyValueUtils.isCSVValueString(moaconfig.getMandateURL())) { dbmandateconnection.setURL(KeyValueUtils.normalizeCSVValueString(moaconfig.getMandateURL())); } else { if (moaconfig.getMandateURL().contains(KeyValueUtils.CSV_DELIMITER)) { dbmandateconnection.setURL( moaconfig.getMandateURL().trim().substring(0, moaconfig.getMandateURL().indexOf(KeyValueUtils.CSV_DELIMITER))); } else { dbmandateconnection.setURL( StringUtils.chomp(moaconfig.getMandateURL().trim())); } } } // write ELGA Mandate-Service URLs if (MiscUtil.isNotEmpty(moaconfig.getElgaMandateServiceURL())) { if (KeyValueUtils.isCSVValueString(moaconfig.getElgaMandateServiceURL())) { dbconfig.setElgaMandateServiceURLs(KeyValueUtils.normalizeCSVValueString(moaconfig .getElgaMandateServiceURL())); } else { if (moaconfig.getElgaMandateServiceURL().contains(KeyValueUtils.CSV_DELIMITER)) { dbconfig.setElgaMandateServiceURLs( moaconfig.getElgaMandateServiceURL().trim().substring(0, moaconfig.getElgaMandateServiceURL().indexOf(KeyValueUtils.CSV_DELIMITER))); } else { dbconfig.setElgaMandateServiceURLs( StringUtils.chomp(moaconfig.getElgaMandateServiceURL().trim())); } } } else { dbconfig.setElgaMandateServiceURLs(null); } } // write E-ID System URLs if (MiscUtil.isNotEmpty(moaconfig.getEidSystemServiceURL())) { if (KeyValueUtils.isCSVValueString(moaconfig.getEidSystemServiceURL())) { dbconfig.setEidSystemServiceURLs(KeyValueUtils.normalizeCSVValueString(moaconfig .getEidSystemServiceURL())); } else { if (moaconfig.getEidSystemServiceURL().contains(KeyValueUtils.CSV_DELIMITER)) { dbconfig.setEidSystemServiceURLs( moaconfig.getEidSystemServiceURL().trim().substring(0, moaconfig.getEidSystemServiceURL().indexOf(KeyValueUtils.CSV_DELIMITER))); } else { dbconfig.setEidSystemServiceURLs( StringUtils.chomp(moaconfig.getEidSystemServiceURL().trim())); } } } else { dbconfig.setEidSystemServiceURLs(null); } if (isMoaidMode) { MOASP dbmoasp = dbauth.getMOASP(); if (dbmoasp == null) { dbmoasp = new MOASP(); dbauth.setMOASP(dbmoasp); } if (MiscUtil.isNotEmpty(moaconfig.getMoaspssURL())) { ConnectionParameterClientAuthType moaspcon = dbmoasp.getConnectionParameter(); if (moaspcon == null) { moaspcon = new ConnectionParameterClientAuthType(); dbmoasp.setConnectionParameter(moaspcon); } moaspcon.setURL(moaconfig.getMoaspssURL()); } VerifyIdentityLink moaidl = dbmoasp.getVerifyIdentityLink(); if (moaidl == null) { moaidl = new VerifyIdentityLink(); dbmoasp.setVerifyIdentityLink(moaidl); } moaidl.setTrustProfileID(moaconfig.getMoaspssIdlTrustProfile()); moaidl.setTestTrustProfileID(moaconfig.getMoaspssIdlTrustProfileTest()); VerifyAuthBlock moaauth = dbmoasp.getVerifyAuthBlock(); if (moaauth == null) { moaauth = new VerifyAuthBlock(); dbmoasp.setVerifyAuthBlock(moaauth); } moaauth.setTrustProfileID(moaconfig.getMoaspssAuthTrustProfile()); moaauth.setTestTrustProfileID(moaconfig.getMoaspssAuthTrustProfileTest()); if (moaauth.getVerifyTransformsInfoProfileID() != null && moaauth.getVerifyTransformsInfoProfileID().size() > 0) { moaauth.getVerifyTransformsInfoProfileID().set(0, moaconfig.getAuthTransformList().get(0)); } else { if (moaauth.getVerifyTransformsInfoProfileID() == null) { moaauth.setVerifyTransformsInfoProfileID(new ArrayList()); } moaauth.getVerifyTransformsInfoProfileID().add(moaconfig.getAuthTransformList().get(0)); } SecurityLayer seclayertrans = dbauth.getSecurityLayer(); if (seclayertrans == null) { seclayertrans = new SecurityLayer(); dbauth.setSecurityLayer(seclayertrans); } final List trans = new ArrayList<>(); final Map moatrans = moaconfig.getSecLayerTransformation(); if (moatrans != null) { final Set keys = moatrans.keySet(); for (final String key : keys) { final TransformsInfoType elem = new TransformsInfoType(); elem.setFilename(key); elem.setTransformation(moatrans.get(key)); trans.add(elem); } } if (trans.size() > 0) { seclayertrans.setTransformsInfo(trans); } SLRequestTemplates slrequesttempl = dbconfig.getSLRequestTemplates(); if (slrequesttempl == null) { slrequesttempl = new SLRequestTemplates(); dbconfig.setSLRequestTemplates(slrequesttempl); } if (MiscUtil.isNotEmpty(moaconfig.getSLRequestTemplateHandy())) { slrequesttempl.setHandyBKU(moaconfig.getSLRequestTemplateHandy()); } if (MiscUtil.isNotEmpty(moaconfig.getSLRequestTemplateLocal())) { slrequesttempl.setLocalBKU(moaconfig.getSLRequestTemplateLocal()); } if (MiscUtil.isNotEmpty(moaconfig.getSLRequestTemplateOnline())) { slrequesttempl.setOnlineBKU(moaconfig.getSLRequestTemplateOnline()); } } if (MiscUtil.isNotEmpty(moaconfig.getTrustedCACerts())) { dbconfig.setTrustedCACertificates(moaconfig.getTrustedCACerts()); } // save config try { log.debug("JaxB to Key/Value configuration transformation started ..."); final Map keyValueConfig = ConfigurationMigrationUtils.convertHyberJaxBMOAIDConfigToKeyValue(dbconfig); log.debug( "JaxB to Key/Value configuration transformation finished. Start Key/Value storage process ..."); configuration.getConfigModule().storeChanges(keyValueConfig, null, null); log.info("General MOA-ID Key/Value configuration successfull stored."); } catch (final ConfigurationStorageException e) { log.warn("MOAID Configuration can not be stored in Database", e); return LanguageHelper.getErrorString("error.db.oa.store", request); } finally { } return null; } /** * @return the moaconfig */ public GeneralMOAIDConfig getMoaconfig() { return moaconfig; } /** * @param moaconfig the moaconfig to set */ public void setMoaconfig(GeneralMOAIDConfig moaconfig) { this.moaconfig = moaconfig; } /** * Gets the storkconfig. * * @return the storkconfig */ public GeneralStorkConfig getStorkconfig() { return storkconfig; } /** * Sets the storkconfig. * * @param storkconfig the new storkconfig */ public void setStorkconfig(GeneralStorkConfig storkconfig) { this.storkconfig = storkconfig; } /** * @return the formID */ @Override public String getFormID() { return formID; } /** * @param formID the formID to set */ @Override public void setFormID(String formID) { this.formID = formID; } }