aboutsummaryrefslogtreecommitdiff
path: root/id
diff options
context:
space:
mode:
authorThomas Lenz <tlenz@iaik.tugraz.at>2014-07-07 14:27:08 +0200
committerThomas Lenz <tlenz@iaik.tugraz.at>2014-07-07 14:27:08 +0200
commit85d5d9885979ca298f3d83699a07f7c5c234bec7 (patch)
treed273ccd77d098bde8f698fec0e78c0470e21e05c /id
parentb6b155c4d55a31a13d189f50831fb7fa8c504b90 (diff)
parentf595cb0d46358e44fad838dd01a449e40c52e18b (diff)
downloadmoa-id-spss-85d5d9885979ca298f3d83699a07f7c5c234bec7.tar.gz
moa-id-spss-85d5d9885979ca298f3d83699a07f7c5c234bec7.tar.bz2
moa-id-spss-85d5d9885979ca298f3d83699a07f7c5c234bec7.zip
Merge remote-tracking branch 'remotes/origin/persistance-fixes' into moa-2.1-Snapshot
Diffstat (limited to 'id')
-rw-r--r--id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/GeneralStorkConfig.java20
-rw-r--r--id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/struts/action/EditGeneralConfigAction.java81
-rw-r--r--id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/moaconfig/StorkConfigValidator.java15
-rw-r--r--id/ConfigWebTool/src/main/resources/applicationResources_de.properties1
-rw-r--r--id/ConfigWebTool/src/main/resources/applicationResources_en.properties1
-rw-r--r--id/ConfigWebTool/src/main/webapp/js/common.js3
-rw-r--r--id/ConfigWebTool/src/main/webapp/jsp/editMOAConfig.jsp3
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java4
-rw-r--r--id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBUtils.java2
-rw-r--r--id/server/moa-id-commons/src/main/resources/config/bindings.xjb20
-rw-r--r--id/server/moa-id-commons/src/main/resources/config/moaid_config_2.0.xsd2
11 files changed, 82 insertions, 70 deletions
diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/GeneralStorkConfig.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/GeneralStorkConfig.java
index 9e5ba684c..b1e268fef 100644
--- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/GeneralStorkConfig.java
+++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/data/GeneralStorkConfig.java
@@ -25,12 +25,14 @@ package at.gv.egovernment.moa.id.configuration.data;
import java.util.ArrayList;
import java.util.List;
+import at.gv.egovernment.moa.id.commons.db.ConfigurationDBRead;
import at.gv.egovernment.moa.id.commons.db.dao.config.AuthComponentGeneral;
import at.gv.egovernment.moa.id.commons.db.dao.config.CPEPS;
import at.gv.egovernment.moa.id.commons.db.dao.config.ForeignIdentities;
import at.gv.egovernment.moa.id.commons.db.dao.config.MOAIDConfiguration;
import at.gv.egovernment.moa.id.commons.db.dao.config.STORK;
import at.gv.egovernment.moa.id.commons.db.dao.config.StorkAttribute;
+
import org.apache.log4j.Logger;
public class GeneralStorkConfig {
@@ -88,6 +90,24 @@ public class GeneralStorkConfig {
}
public List<CPEPS> getCpepslist() {
+ if (null == cpepslist)
+ return null;
+
+ MOAIDConfiguration dbconfig = ConfigurationDBRead.getMOAIDConfiguration();
+
+ List<CPEPS> cpepss = dbconfig.getAuthComponentGeneral().getForeignIdentities().getSTORK().getCPEPS();
+
+ // 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;
}
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 0a308a354..0f1673c3a 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
@@ -237,20 +237,8 @@ public class EditGeneralConfigAction extends BasicAction {
} catch (Exception ex) {
ex.printStackTrace();
}
-
- MOAIDConfiguration oldconfig = ConfigurationDBRead.getMOAIDConfiguration();
- AuthComponentGeneral oldauth = null;
- if (oldconfig != null) {
- oldauth = oldconfig.getAuthComponentGeneral();
- }
-
-// MOAIDConfiguration dbconfig = ConfigurationDBRead.getMOAIDConfiguration();
-// if (dbconfig == null) {
-// dbconfig = new MOAIDConfiguration();
-// isnewconfig = true;
-// }
- MOAIDConfiguration dbconfig = new MOAIDConfiguration();
+ MOAIDConfiguration dbconfig = ConfigurationDBRead.getMOAIDConfiguration();
AuthComponentGeneral dbauth = dbconfig.getAuthComponentGeneral();
if (dbauth == null) {
@@ -486,23 +474,6 @@ public class EditGeneralConfigAction extends BasicAction {
dbchainingmodes.setSystemDefaultMode(
ChainingModeType.fromValue(moaconfig.getDefaultchainigmode()));
- if (oldconfig != null) {
- ChainingModes oldchainigmodes = oldconfig.getChainingModes();
- if (oldchainigmodes != null) {
- List<TrustAnchor> oldtrustanchor = oldchainigmodes.getTrustAnchor();
- if (oldtrustanchor != null) {
- List<TrustAnchor> trustanchor = new ArrayList<TrustAnchor>();
- for (TrustAnchor oldel : oldtrustanchor) {
- TrustAnchor TAel = new TrustAnchor();
- TAel.setX509IssuerName(oldel.getX509IssuerName());
- TAel.setX509SerialNumber(oldel.getX509SerialNumber());
- TAel.setMode(oldel.getMode());
- trustanchor.add(TAel);
- }
- dbchainingmodes.setTrustAnchor(trustanchor);
- }
- }
- }
IdentityLinkSigners idlsigners = dbauth.getIdentityLinkSigners();
if (idlsigners == null) {
@@ -525,43 +496,39 @@ public class EditGeneralConfigAction extends BasicAction {
forcon.setURL(moaconfig.getSzrgwURL());
}
- //TODO: Set STORK Config!!!
- if (oldauth != null) {
- ForeignIdentities oldforeign = oldauth.getForeignIdentities();
- if (oldforeign != null) {
- STORK oldstork = oldforeign.getSTORK();
- if (oldstork == null)
- oldstork = new STORK();
+ ForeignIdentities foreign = dbauth.getForeignIdentities();
+ if (foreign != null) {
+ STORK stork = foreign.getSTORK();
+ if (stork == null)
+ stork = new STORK();
try {
log.error("QAAAA " + storkconfig.getDefaultQaa());
- oldstork.setQualityAuthenticationAssuranceLevel(storkconfig.getDefaultQaa());
+ stork.setQualityAuthenticationAssuranceLevel(storkconfig.getDefaultQaa());
if (storkconfig.getAttributes() != null)
- oldstork.setAttributes(storkconfig.getAttributes());
+ stork.setAttributes(storkconfig.getAttributes());
else
- oldstork.setAttributes((List<StorkAttribute>) (new ArrayList<StorkAttribute>()));
+ stork.setAttributes((List<StorkAttribute>) (new ArrayList<StorkAttribute>()));
if (storkconfig.getCpepslist() != null)
- oldstork.setCPEPS(storkconfig.getCpepslist());
-
+
+ stork.setCPEPS(storkconfig.getCpepslist());
else
- oldstork.setCPEPS((List<CPEPS>) (new ArrayList<CPEPS>()));
+ stork.setCPEPS((List<CPEPS>) (new ArrayList<CPEPS>()));
- dbforeign.setSTORK(oldstork);
} catch (Exception e) {
e.printStackTrace();
}
try{
- log.error("CPEPS LIST: " + storkconfig.getCpepslist().size() );
- log.error("CPEPS 1:" + storkconfig.getCpepslist().get(0).getCountryCode() +storkconfig.getCpepslist().get(0).getURL());
+ log.info("CPEPS LIST: " + storkconfig.getCpepslist().size() );
+ log.trace("CPEPS 1:" + storkconfig.getCpepslist().get(0).getCountryCode() +storkconfig.getCpepslist().get(0).getURL());
} catch (Exception ex) {
- ex.printStackTrace();
+ log.info("CPEPS LIST is null");
}
}
- }
if (MiscUtil.isNotEmpty(moaconfig.getMandateURL())) {
OnlineMandates dbmandate = dbauth.getOnlineMandates();
@@ -604,7 +571,7 @@ public class EditGeneralConfigAction extends BasicAction {
}
moaauth.setTrustProfileID(moaconfig.getMoaspssAuthTrustProfile());
- moaauth.setVerifyTransformsInfoProfileID(moaconfig.getAuthTransformList());
+ moaauth.getVerifyTransformsInfoProfileID().set(0, moaconfig.getAuthTransformList().get(0));
SecurityLayer seclayertrans = dbauth.getSecurityLayer();
if (seclayertrans == null) {
@@ -621,19 +588,6 @@ public class EditGeneralConfigAction extends BasicAction {
elem.setTransformation(moatrans.get(key));
trans.add(elem);
}
- } else {
- if (oldauth != null) {
- SecurityLayer oldsectrans = oldauth.getSecurityLayer();
- if (oldsectrans != null) {
- List<TransformsInfoType> oldtranslist = oldsectrans.getTransformsInfo();
- for (TransformsInfoType oldel : oldtranslist) {
- TransformsInfoType elem = new TransformsInfoType();
- elem.setFilename(oldel.getFilename());
- elem.setTransformation(oldel.getTransformation());
- trans.add(elem);
- }
- }
- }
}
if (trans.size() > 0)
seclayertrans.setTransformsInfo(trans);
@@ -660,9 +614,6 @@ public class EditGeneralConfigAction extends BasicAction {
ConfigurationDBUtils.save(dbconfig);
- if (oldconfig != null)
- ConfigurationDBUtils.delete(oldconfig);
-
} catch (MOADatabaseException e) {
log.warn("MOAID Configuration can not be stored in Database", e);
return LanguageHelper.getErrorString("error.db.oa.store", request);
diff --git a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/moaconfig/StorkConfigValidator.java b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/moaconfig/StorkConfigValidator.java
index 8bc916e5a..f7d61653d 100644
--- a/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/moaconfig/StorkConfigValidator.java
+++ b/id/ConfigWebTool/src/main/java/at/gv/egovernment/moa/id/configuration/validation/moaconfig/StorkConfigValidator.java
@@ -28,6 +28,10 @@ public class StorkConfigValidator {
if (form.getCpepslist() != null) {
for(CPEPS current : form.getCpepslist()) {
+ // if an existing record got deleted
+ if(null == current)
+ continue;
+
// check country code
String check = current.getCountryCode();
if (MiscUtil.isNotEmpty(check)) {
@@ -46,7 +50,7 @@ public class StorkConfigValidator {
errors.add(LanguageHelper.getErrorString("validation.stork.cpeps.empty",
new Object[] {check}, request ));
}
-
+
// check url
check = current.getURL();
if (MiscUtil.isNotEmpty(check)) {
@@ -60,6 +64,15 @@ public class StorkConfigValidator {
new Object[] {check}, request ));
}
}
+
+ // ensure uniqueness of country code
+ for (CPEPS one : form.getCpepslist())
+ for (CPEPS another : form.getCpepslist())
+ if (null != one && null != another)
+ if (!one.equals(another) && one.getCountryCode().equals(another.getCountryCode())) {
+ errors.add(LanguageHelper.getErrorString("validation.stork.cpeps.duplicate", request));
+ break;
+ }
}
// check qaa
diff --git a/id/ConfigWebTool/src/main/resources/applicationResources_de.properties b/id/ConfigWebTool/src/main/resources/applicationResources_de.properties
index e4e7a0b63..2c71d86a5 100644
--- a/id/ConfigWebTool/src/main/resources/applicationResources_de.properties
+++ b/id/ConfigWebTool/src/main/resources/applicationResources_de.properties
@@ -453,6 +453,7 @@ validation.general.testcredentials.oid.valid=Die Testdaten OID {0} ist ung\u00FC
validation.stork.cpeps.cc=CPEPS L\u00E4ndercode folgt nicht ISO 3166-2
validation.stork.cpeps.empty=CPEPS Konfiguration ist unvollst\u00E4ndig
validation.stork.cpeps.url=CPEPS URL ist ung\u00FCltig
+validation.stork.cpeps.duplicate=L\u00E4ndercodes sind nicht eindeutig
validation.stork.requestedattributes=STORK Attribute sind fehlerhaft. Bsp.: attr1, attr2
validation.stork.qaa.outofrange=G\u00FCltige QAA Werte sind 1, 2, 3, und 4
validation.stork.attributes.empty=Es muss mindestens ein Attribut definiert sein
diff --git a/id/ConfigWebTool/src/main/resources/applicationResources_en.properties b/id/ConfigWebTool/src/main/resources/applicationResources_en.properties
index dcf36103b..a494ef089 100644
--- a/id/ConfigWebTool/src/main/resources/applicationResources_en.properties
+++ b/id/ConfigWebTool/src/main/resources/applicationResources_en.properties
@@ -450,6 +450,7 @@ validation.general.testcredentials.oid.valid=The OID {0} for test credentials is
validation.stork.cpeps.cc=CPEPS country code is not based on 3166-2
validation.stork.cpeps.empty=CPEPS configuration is incomplete
validation.stork.cpeps.url=CPEPS URL is invalid
+validation.stork.cpeps.duplicate=Country codes are not unique
validation.stork.requestedattributes=STORK attributes are incorrect. Example: attr1, attr2
validation.stork.qaa.outofrange=Valid QAA values are 1, 2, 3, and 4
validation.stork.attributes.empty=Only one attribute can be provided
diff --git a/id/ConfigWebTool/src/main/webapp/js/common.js b/id/ConfigWebTool/src/main/webapp/js/common.js
index 32e79bb66..f7ef2c415 100644
--- a/id/ConfigWebTool/src/main/webapp/js/common.js
+++ b/id/ConfigWebTool/src/main/webapp/js/common.js
@@ -230,6 +230,9 @@ function newPeps() {
var lastindex = 1;
}
var nextindex = lastindex + 1;
+
+ clone.innerHTML = clone.innerHTML.replace(/[A-Z]{2}</, '<');
+ clone.innerHTML = clone.innerHTML.replace(/<input.*type="hidden".*>/, '<div id="wwgrp_loadGeneralConfig_storkconfig_cpepslist_0__countryCode" class="wwgrp"> <div id="wwctrl_loadGeneralConfig_storkconfig_cpepslist_0__countryCode" class="wwctrl"> <input id="loadGeneralConfig_storkconfig_cpepslist_0__countryCode" class="textfield_short" type="text" value="IT" name="storkconfig.cpepslist[0].countryCode"> </div> </div>');
clone.innerHTML = clone.innerHTML.replace(/name="storkconfig.cpepslist\[\d/g, 'name="storkconfig.cpepslist[' + nextindex);
clone.innerHTML = clone.innerHTML.replace(/(.*" value=").*?(".*)/g, '$1$2');
target.parentNode.appendChild(clone);
diff --git a/id/ConfigWebTool/src/main/webapp/jsp/editMOAConfig.jsp b/id/ConfigWebTool/src/main/webapp/jsp/editMOAConfig.jsp
index 6f266f865..21ba246c1 100644
--- a/id/ConfigWebTool/src/main/webapp/jsp/editMOAConfig.jsp
+++ b/id/ConfigWebTool/src/main/webapp/jsp/editMOAConfig.jsp
@@ -251,7 +251,8 @@
<table id="stork_pepslist">
<tr><th>Country Shortcode</th><th>PEPS URL</th>
<s:iterator value="storkconfig.cpepslist" status="stat">
- <tr><td><s:textfield name="storkconfig.cpepslist[%{#stat.index}].countryCode" value="%{countryCode}" cssClass="textfield_short"/></td>
+ <tr><td><s:hidden name="storkconfig.cpepslist[%{#stat.index}].hjid" property="%{hjid}"/>
+ <s:property value="%{countryCode}" /></td>
<td><s:textfield name="storkconfig.cpepslist[%{#stat.index}].URL" value="%{URL}" cssClass="textfield_long"/></td>
<td><input type="button" value="<%=LanguageHelper.getGUIString("webpages.moaconfig.stork.removepeps", request) %>" onclick='this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode);'/></td></tr>
</s:iterator>
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java
index 88220cded..e890e2145 100644
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBRead.java
@@ -147,8 +147,8 @@ public class ConfigurationDBRead {
Logger.trace("Found entries: " + result.size());
if (result.size() == 0) {
- Logger.trace("No entries found.");
- return null;
+ Logger.trace("No entries found. Create fresh instance.");
+ return new MOAIDConfiguration();
}
return (MOAIDConfiguration) result.get(0);
diff --git a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBUtils.java b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBUtils.java
index 6bd987f96..cdb19340d 100644
--- a/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBUtils.java
+++ b/id/server/moa-id-commons/src/main/java/at/gv/egovernment/moa/id/commons/db/ConfigurationDBUtils.java
@@ -154,7 +154,7 @@ public final class ConfigurationDBUtils {
synchronized (session) {
tx.begin();
- session.persist(dbo);
+ session.merge(dbo);
tx.commit();
//session.clear();
diff --git a/id/server/moa-id-commons/src/main/resources/config/bindings.xjb b/id/server/moa-id-commons/src/main/resources/config/bindings.xjb
index cf04319c8..21714849b 100644
--- a/id/server/moa-id-commons/src/main/resources/config/bindings.xjb
+++ b/id/server/moa-id-commons/src/main/resources/config/bindings.xjb
@@ -2,6 +2,8 @@
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
+ xmlns:hj="http://hyperjaxb3.jvnet.org/ejb/schemas/customizations"
+ xmlns:orm="http://java.sun.com/xml/ns/persistence/orm"
jaxb:extensionBindingPrefixes="hj">
<jaxb:bindings schemaLocation="moaid_config_2.0.xsd" node="/xsd:schema">
@@ -12,4 +14,22 @@
adapter="com.sun.tools.xjc.runtime.ZeroOneBooleanAdapter"/>
</jaxb:globalBindings>
</jaxb:bindings>
+
+ <jaxb:bindings schemaLocation="moaid_config_2.0.xsd" node="/xsd:schema/xsd:element[@name='C-PEPS']//xsd:element[@ref='OA_STORK']">
+ <hj:many-to-many name="OA_STORK">
+ <orm:join-table name="OA_CPEPS">
+ <orm:join-column name="aid" referenced-column-name="hjid" />
+ <orm:inverse-join-column name="bid" referenced-column-name="hjid" />
+ </orm:join-table>
+ </hj:many-to-many>
+ </jaxb:bindings>
+
+ <jaxb:bindings schemaLocation="moaid_config_2.0.xsd" node="/xsd:schema/xsd:element[@name='OA_STORK']//xsd:element[@ref='C-PEPS']">
+ <hj:many-to-many name="CPEPS" mappedBy="OA_STORK">
+ <hj:cascade>
+ <hj:cascade-persist/>
+ </hj:cascade>
+ </hj:many-to-many>
+ </jaxb:bindings>
+
</jaxb:bindings> \ No newline at end of file
diff --git a/id/server/moa-id-commons/src/main/resources/config/moaid_config_2.0.xsd b/id/server/moa-id-commons/src/main/resources/config/moaid_config_2.0.xsd
index 8bc532236..f99304dcc 100644
--- a/id/server/moa-id-commons/src/main/resources/config/moaid_config_2.0.xsd
+++ b/id/server/moa-id-commons/src/main/resources/config/moaid_config_2.0.xsd
@@ -803,6 +803,7 @@
<xsd:annotation>
<xsd:documentation>Name zum Key eines KeyStores, der den privaten
Schlüssel zum Erstellen einer Signatur darstellt
+
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
@@ -822,6 +823,7 @@
<xsd:complexType>
<xsd:sequence>
<xsd:element name="AttributeValue" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
+ <xsd:element ref="OA_STORK" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
<xsd:attribute name="countryCode" type="CountryCodeType" use="required"/>
<xsd:attribute name="URL" type="xsd:anyURI" use="required"/>