aboutsummaryrefslogtreecommitdiff
path: root/connector/src
diff options
context:
space:
mode:
authorThomas Lenz <thomas.lenz@egiz.gv.at>2020-02-21 16:35:26 +0100
committerThomas Lenz <thomas.lenz@egiz.gv.at>2020-02-21 16:35:26 +0100
commitd9970493ecf3d3da3f800bcc0336717ae51fe2bf (patch)
treefd153df2c82b40fdde054a83b3a93e6be524010b /connector/src
parent37c144539cda49199609a91bd295a2beb66496e6 (diff)
downloadNational_eIDAS_Gateway-d9970493ecf3d3da3f800bcc0336717ae51fe2bf.tar.gz
National_eIDAS_Gateway-d9970493ecf3d3da3f800bcc0336717ae51fe2bf.tar.bz2
National_eIDAS_Gateway-d9970493ecf3d3da3f800bcc0336717ae51fe2bf.zip
fix a few CodeStyle validation errors
Diffstat (limited to 'connector/src')
-rw-r--r--connector/src/main/java/at/asitplus/eidas/specific/connector/config/PvpEndPointConfiguration.java70
-rw-r--r--connector/src/main/java/at/asitplus/eidas/specific/connector/provider/PvpMetadataProvider.java3
-rw-r--r--connector/src/test/resources/config/junit_config_1.properties7
3 files changed, 75 insertions, 5 deletions
diff --git a/connector/src/main/java/at/asitplus/eidas/specific/connector/config/PvpEndPointConfiguration.java b/connector/src/main/java/at/asitplus/eidas/specific/connector/config/PvpEndPointConfiguration.java
index 82be730c..d7d88017 100644
--- a/connector/src/main/java/at/asitplus/eidas/specific/connector/config/PvpEndPointConfiguration.java
+++ b/connector/src/main/java/at/asitplus/eidas/specific/connector/config/PvpEndPointConfiguration.java
@@ -23,10 +23,19 @@
package at.asitplus.eidas.specific.connector.config;
+import java.util.Arrays;
import java.util.List;
+import org.apache.commons.lang3.StringUtils;
import org.opensaml.saml.saml2.metadata.ContactPerson;
+import org.opensaml.saml.saml2.metadata.ContactPersonTypeEnumeration;
+import org.opensaml.saml.saml2.metadata.EmailAddress;
+import org.opensaml.saml.saml2.metadata.GivenName;
import org.opensaml.saml.saml2.metadata.Organization;
+import org.opensaml.saml.saml2.metadata.OrganizationDisplayName;
+import org.opensaml.saml.saml2.metadata.OrganizationName;
+import org.opensaml.saml.saml2.metadata.OrganizationURL;
+import org.opensaml.saml.saml2.metadata.SurName;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -34,13 +43,17 @@ import org.springframework.stereotype.Service;
import at.asitplus.eidas.specific.connector.MsEidasNodeConstants;
import at.gv.egiz.eaaf.core.api.idp.IConfiguration;
+import at.gv.egiz.eaaf.core.exceptions.EaafConfigurationException;
import at.gv.egiz.eaaf.core.exceptions.EaafException;
import at.gv.egiz.eaaf.modules.pvp2.api.IPvp2BasicConfiguration;
+import at.gv.egiz.eaaf.modules.pvp2.impl.utils.Saml2Utils;
@Service("PVPEndPointConfiguration")
public class PvpEndPointConfiguration implements IPvp2BasicConfiguration {
private static final Logger log = LoggerFactory.getLogger(PvpEndPointConfiguration.class);
+ private static final String DEFAULT_XML_LANG = "en";
+
@Autowired(required = true)
IConfiguration basicConfiguration;
@@ -71,14 +84,52 @@ public class PvpEndPointConfiguration implements IPvp2BasicConfiguration {
@Override
public List<ContactPerson> getIdpContacts() throws EaafException {
- // Return contact person, if it shall be included in metadata
- return null;
+ final ContactPerson contactPerson = Saml2Utils.createSamlObject(ContactPerson.class);
+ final GivenName givenName = Saml2Utils.createSamlObject(GivenName.class);
+ final SurName surname = Saml2Utils.createSamlObject(SurName.class);
+ final EmailAddress emailAddress = Saml2Utils.createSamlObject(EmailAddress.class);
+
+ givenName.setName(getAndVerifyFromConfiguration(
+ MsEidasNodeConstants.CONFIG_PROPS_METADATA_CONTACT_GIVENNAME));
+ surname.setName(getAndVerifyFromConfiguration(
+ MsEidasNodeConstants.CONFIG_PROPS_METADATA_CONTACT_SURNAME));
+ emailAddress.setAddress(getAndVerifyFromConfiguration(
+ MsEidasNodeConstants.CONFIG_PROPS_METADATA_CONTACT_EMAIL));
+
+ contactPerson.setType(ContactPersonTypeEnumeration.TECHNICAL);
+ contactPerson.setGivenName(givenName);
+ contactPerson.setSurName(surname);
+ contactPerson.getEmailAddresses().add(emailAddress);
+
+ return Arrays.asList(contactPerson);
+
}
@Override
public Organization getIdpOrganisation() throws EaafException {
- // Return organization, if it shall be included in metadata
- return null;
+ final Organization organisation = Saml2Utils.createSamlObject(Organization.class);
+ final OrganizationName orgName = Saml2Utils.createSamlObject(OrganizationName.class);
+ final OrganizationDisplayName orgDisplayName = Saml2Utils.createSamlObject(OrganizationDisplayName.class);
+ final OrganizationURL orgUrl = Saml2Utils.createSamlObject(OrganizationURL.class);
+
+ orgName.setXMLLang(DEFAULT_XML_LANG);
+ orgName.setValue(getAndVerifyFromConfiguration(
+ MsEidasNodeConstants.CONFIG_PROPS_METADATA_ORGANISATION_NAME));
+
+ orgDisplayName.setXMLLang(DEFAULT_XML_LANG);
+ orgDisplayName.setValue(getAndVerifyFromConfiguration(
+ MsEidasNodeConstants.CONFIG_PROPS_METADATA_ORGANISATION_FRIENDLYNAME));
+
+ orgUrl.setXMLLang(DEFAULT_XML_LANG);
+ orgUrl.setValue(getAndVerifyFromConfiguration(
+ MsEidasNodeConstants.CONFIG_PROPS_METADATA_ORGANISATION_URL));
+
+
+ organisation.getOrganizationNames().add(orgName);
+ organisation.getDisplayNames().add(orgDisplayName);
+ organisation.getURLs().add(orgUrl);
+
+ return organisation;
}
@Override
@@ -93,4 +144,15 @@ public class PvpEndPointConfiguration implements IPvp2BasicConfiguration {
return url;
}
}
+
+ private String getAndVerifyFromConfiguration(String configKey) throws EaafConfigurationException {
+ final String value = basicConfiguration.getBasicConfiguration(configKey);
+ if (StringUtils.isEmpty(value)) {
+ throw new EaafConfigurationException("config.08",
+ new Object[] {configKey});
+
+ }
+
+ return value;
+ }
}
diff --git a/connector/src/main/java/at/asitplus/eidas/specific/connector/provider/PvpMetadataProvider.java b/connector/src/main/java/at/asitplus/eidas/specific/connector/provider/PvpMetadataProvider.java
index 7738b0be..43f1740f 100644
--- a/connector/src/main/java/at/asitplus/eidas/specific/connector/provider/PvpMetadataProvider.java
+++ b/connector/src/main/java/at/asitplus/eidas/specific/connector/provider/PvpMetadataProvider.java
@@ -31,6 +31,7 @@ import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.text.MessageFormat;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
@@ -168,7 +169,7 @@ public class PvpMetadataProvider extends AbstractChainingMetadataProvider {
@Override
protected List<String> getAllMetadataUrlsFromConfiguration() throws EaafConfigurationException {
- return null;
+ return Collections.emptyList();
}
@Override
diff --git a/connector/src/test/resources/config/junit_config_1.properties b/connector/src/test/resources/config/junit_config_1.properties
index 982d3e24..8bff74a9 100644
--- a/connector/src/test/resources/config/junit_config_1.properties
+++ b/connector/src/test/resources/config/junit_config_1.properties
@@ -88,6 +88,13 @@ eidas.ms.pvp2.key.signing.alias=
eidas.ms.pvp2.key.signing.password=
eidas.ms.pvp2.metadata.validity=24
+eidas.ms.pvp2.metadata.organisation.name=JUnit
+eidas.ms.pvp2.metadata.organisation.friendyname=For testing with jUnit
+eidas.ms.pvp2.metadata.organisation.url=http://junit.test
+eidas.ms.pvp2.metadata.contact.givenname=Max
+eidas.ms.pvp2.metadata.contact.surname=Mustermann
+eidas.ms.pvp2.metadata.contact.email=max@junit.test
+
## Service Provider configuration
eidas.ms.sp.0.uniqueID=
eidas.ms.sp.0.pvp2.metadata.truststore=keys/junit.jks