aboutsummaryrefslogtreecommitdiff
path: root/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditGeneralConfigAction.java
diff options
context:
space:
mode:
Diffstat (limited to 'id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditGeneralConfigAction.java')
-rw-r--r--id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditGeneralConfigAction.java1548
1 files changed, 781 insertions, 767 deletions
diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditGeneralConfigAction.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditGeneralConfigAction.java
index 8e057db0f..0992d7f1a 100644
--- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditGeneralConfigAction.java
+++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditGeneralConfigAction.java
@@ -30,7 +30,6 @@ import java.util.Map;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
-import org.apache.log4j.Logger;
import at.gv.egiz.components.configuration.meta.api.ConfigurationStorageException;
import at.gv.egiz.eaaf.core.impl.utils.KeyValueUtils;
@@ -76,164 +75,160 @@ 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 Logger log = Logger.getLogger(EditGeneralConfigAction.class);
- private static final long serialVersionUID = 1L;
-
- private GeneralMOAIDConfig moaconfig;
- private GeneralStorkConfig storkconfig;
-
- private String formID;
-
- public String loadConfig() {
- try {
- populateBasicInformations();
-
-
- } catch (BasicActionException e) {
- return Constants.STRUTS_ERROR;
-
- }
-
- if (authUser.isAdmin()) {
-
-
- 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");
- }
- }
+ 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<String> 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<String, byte[]>) 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;
+ }
-
-
- 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 (BasicActionException e) {
- return Constants.STRUTS_ERROR;
-
- }
-
- Object formidobj = session.getAttribute(Constants.SESSION_FORMID);
- if (formidobj != null && formidobj instanceof String) {
- 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 (ConfigurationException e) {
- log.warn("Can NOT load configuration. Set 'moaidmode' to 'false'", e);
- }
-
- if (authUser.isAdmin()) {
-
- MOAConfigValidator validator = new MOAConfigValidator();
-
- List<String> 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 (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<String, byte[]>)
- session.getAttribute(Constants.SESSION_SLTRANSFORMATION));
-
- }
- }
-
- 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 (BasicActionException e) {
- return Constants.STRUTS_ERROR;
-
- }
-
- return Constants.STRUTS_SUCCESS;
- }
-
- private String saveFormToDatabase(boolean isMoaidMode) {
-
- log.debug("Saving form to database");
+ private String saveFormToDatabase(boolean isMoaidMode) {
+
+ log.debug("Saving form to database");
// log.error("Saving form to db");
// log.info("SV frm db");
@@ -244,630 +239,649 @@ public class EditGeneralConfigAction extends BasicAction {
// log.error(" SES PARAM: " + obj.toString());
// }
- try {
- log.error(" ASSERTION " + moaconfig.getTimeoutAssertion());
- } catch (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);
- }
-
+ 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
- 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());
-
-
+
+ // 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<String> el = legprot.getProtocolName();
- if (el == null) {
- el = new ArrayList<String>();
- 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());
+
+ 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<String> 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<Contact> pvp2cont = pvp2.getContact();
- if (pvp2cont == null) {
- pvp2cont = new ArrayList<Contact>();
- pvp2.setContact(pvp2cont);
- }
-
- if (pvp2cont.size() == 0) {
- Contact cont = new Contact();
- pvp2cont.add(cont);
- }
-
- 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()));
-
- }
-
- }
-
- 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) {
- List<StorkAttribute> dbStorkAttr = new ArrayList<StorkAttribute>();
- stork.setAttributes(dbStorkAttr);
-
-
- for (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((List<StorkAttribute>) (new ArrayList<StorkAttribute>()));
-
- if (storkconfig.getCpepslist() != null) {
- List<CPEPS> dbStorkCPEPS = new ArrayList<CPEPS>();
- stork.setCPEPS(dbStorkCPEPS);
-
- for (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((List<CPEPS>) (new ArrayList<CPEPS>()));
-
- } catch (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 (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<String>());
-
- }
- moaauth.getVerifyTransformsInfoProfileID().add(moaconfig.getAuthTransformList().get(0));
- }
-
- SecurityLayer seclayertrans = dbauth.getSecurityLayer();
- if (seclayertrans == null) {
- seclayertrans = new SecurityLayer();
- dbauth.setSecurityLayer(seclayertrans);
- }
- List<TransformsInfoType> trans = new ArrayList<TransformsInfoType>();
- Map<String, byte[]> moatrans = moaconfig.getSecLayerTransformation();
- if (moatrans != null) {
- Set<String> keys = moatrans.keySet();
- for (String key : keys) {
- 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 ...");
- Map<String, String> 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 (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
- */
- public String getFormID() {
- return formID;
- }
-
- /**
- * @param formID the formID to set
- */
- public void setFormID(String formID) {
- this.formID = formID;
- }
-
-
-
+ }
+
+ 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<Contact> 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<StorkAttribute> 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<StorkAttribute>());
+ }
+
+ if (storkconfig.getCpepslist() != null) {
+ final List<CPEPS> 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<CPEPS>());
+ }
+
+ } 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<String>());
+
+ }
+ moaauth.getVerifyTransformsInfoProfileID().add(moaconfig.getAuthTransformList().get(0));
+ }
+
+ SecurityLayer seclayertrans = dbauth.getSecurityLayer();
+ if (seclayertrans == null) {
+ seclayertrans = new SecurityLayer();
+ dbauth.setSecurityLayer(seclayertrans);
+ }
+ final List<TransformsInfoType> trans = new ArrayList<>();
+ final Map<String, byte[]> moatrans = moaconfig.getSecLayerTransformation();
+ if (moatrans != null) {
+ final Set<String> 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<String, String> 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;
+ }
}