aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/config
diff options
context:
space:
mode:
authorThomas Lenz <tlenz@iaik.tugraz.at>2015-06-19 13:34:42 +0200
committerThomas Lenz <tlenz@iaik.tugraz.at>2015-06-19 13:34:42 +0200
commite0c190004d654a2fa4f91f33133f6d55444e3798 (patch)
treef550ebfb176cf923a7749894e4b45c18159cc648 /id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/config
parent0ac1586549bf1bb391c48a4151a5f32a0863a5f4 (diff)
downloadmoa-id-spss-e0c190004d654a2fa4f91f33133f6d55444e3798.tar.gz
moa-id-spss-e0c190004d654a2fa4f91f33133f6d55444e3798.tar.bz2
moa-id-spss-e0c190004d654a2fa4f91f33133f6d55444e3798.zip
refactoring for properties based configuration
Diffstat (limited to 'id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/config')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/config/PVPConfiguration.java245
1 files changed, 100 insertions, 145 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/config/PVPConfiguration.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/config/PVPConfiguration.java
index d6f6308fd..5c473f32d 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/config/PVPConfiguration.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/config/PVPConfiguration.java
@@ -24,7 +24,6 @@ package at.gv.egovernment.moa.id.protocols.pvp2x.config;
import iaik.x509.X509Certificate;
-import java.io.File;
import java.net.URL;
import java.security.cert.CertificateException;
import java.util.ArrayList;
@@ -46,7 +45,7 @@ import org.opensaml.saml2.metadata.OrganizationURL;
import org.opensaml.saml2.metadata.SurName;
import org.opensaml.saml2.metadata.TelephoneNumber;
-import at.gv.egovernment.moa.id.commons.db.dao.config.Contact;
+import at.gv.egovernment.moa.id.commons.config.MOAIDConfigurationConstants;
import at.gv.egovernment.moa.id.commons.db.dao.config.OAPVP2;
import at.gv.egovernment.moa.id.config.ConfigurationException;
import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProviderFactory;
@@ -92,31 +91,19 @@ public class PVPConfiguration {
public static final String IDP_KEYALIASENCRYTPION = "sp.ks.assertion.encryption.alias";
public static final String IDP_KEY_PASSENCRYTPION = "sp.ks.assertion.encryption.keypassword";
- public static final String IDP_ISSUER_NAME = "idp.issuer.name";
-
- public static final String METADATA_FILE = "md.dir";
- public static final String METADATA_EXTENSION = "md.ext";
-
- public static final String IDP_ENTITY = "idp.entityid";
- public static final String IDP_ORG_NAME = "idp.org.name";
- public static final String IDP_ORG_DISPNAME = "idp.org.dispname";
- public static final String IDP_ORG_URL = "idp.org.url";
-
- public static final String IDP_PUBLIC_URL = "idp.public.url";
-
- public static final String IDP_TRUST_STORE = "idp.truststore";
- public static final String SP_TARGET_PREFIX = "sp.target.";
-
- public static final String IDP_CONTACT_PREFIX = "idp.contact";
- public static final String IDP_CONTACT_LIST = "idp.contact_list";
-
- public static final String IDP_CONTACT_SURNAME = "surname";
- public static final String IDP_CONTACT_GIVENNAME = "givenname";
- public static final String IDP_CONTACT_MAIL = "mail";
- public static final String IDP_CONTACT_TYPE = "type";
- public static final String IDP_CONTACT_COMPANY = "company";
- public static final String IDP_CONTACT_PHONE = "phone";
-
+ public static final String IDP_ISSUER_NAME = "servicename";
+
+ public static final String IDP_ORG_NAME = "org.name.short";
+ public static final String IDP_ORG_DISPNAME = "org.name.full";
+ public static final String IDP_ORG_URL = "org.url";
+
+ public static final String IDP_CONTACT_SURNAME = "contact.familyname";
+ public static final String IDP_CONTACT_GIVENNAME = "contact.givenname";
+ public static final String IDP_CONTACT_MAIL = "contact.mail";
+ public static final String IDP_CONTACT_TYPE = "contact.type";
+ public static final String IDP_CONTACT_COMPANY = "contact.company";
+ public static final String IDP_CONTACT_PHONE = "contact.phone";
+
private static String moaIDVersion = null;
//PVP2 generalpvpconfigdb;
@@ -211,28 +198,8 @@ public class PVPConfiguration {
moaIDVersion = parseMOAIDVersionFromManifest();
}
- return AuthConfigurationProviderFactory.getInstance().getGeneralPVP2DBConfig().getIssuerName() + moaIDVersion;
- }
-
- public List<String> getMetadataFiles() {
- String filter = props.getProperty(METADATA_EXTENSION);
-
- if (filter == null) {
- filter = ".mdxml";
- }
-
- List<String> files = new ArrayList<String>();
-
- File[] faFiles = new File(props.getProperty(METADATA_FILE)).listFiles();
- for (File file : faFiles) {
- if (!file.isDirectory()) {
- if (file.getName().endsWith(filter)) {
- files.add(file.getAbsolutePath());
- }
- }
- }
-
- return files;
+ return AuthConfigurationProviderFactory.getInstance().getConfigurationWithKey(
+ MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_SERVICENAMME) + moaIDVersion;
}
//TODO:
@@ -287,112 +254,100 @@ public class PVPConfiguration {
public List<ContactPerson> getIDPContacts() throws ConfigurationException {
List<ContactPerson> list = new ArrayList<ContactPerson>();
- List<Contact> contacts = AuthConfigurationProviderFactory.getInstance().getGeneralPVP2DBConfig().getContact();
+ Properties contacts = AuthConfigurationProviderFactory.getInstance().getConfigurationWithPrefix(
+ MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_CONTACT + ".");
- if (contacts != null) {
+ ContactPerson person = SAML2Utils
+ .createSAMLObject(ContactPerson.class);
+
+ String type = contacts.getProperty(IDP_CONTACT_TYPE);
+
+ if (type == null) {
+ Logger.error("IDP Contact with SurName " + contacts.getProperty(IDP_CONTACT_SURNAME)
+ + " has no type defined!");
+ }
+
+ ContactPersonTypeEnumeration enumType = null;
+
+ if (type.equals(ContactPersonTypeEnumeration.ADMINISTRATIVE
+ .toString())) {
+ enumType = ContactPersonTypeEnumeration.ADMINISTRATIVE;
+ } else if (type.equals(ContactPersonTypeEnumeration.BILLING
+ .toString())) {
+ enumType = ContactPersonTypeEnumeration.BILLING;
+ } else if (type.equals(ContactPersonTypeEnumeration.OTHER
+ .toString())) {
+ enumType = ContactPersonTypeEnumeration.OTHER;
+ } else if (type.equals(ContactPersonTypeEnumeration.SUPPORT
+ .toString())) {
+ enumType = ContactPersonTypeEnumeration.SUPPORT;
+ } else if (type.equals(ContactPersonTypeEnumeration.TECHNICAL
+ .toString())) {
+ enumType = ContactPersonTypeEnumeration.TECHNICAL;
+ }
+
+ if (enumType == null) {
+ Logger.error("IDP Contact with SurName " + contacts.getProperty(IDP_CONTACT_SURNAME)
+ + " has invalid type defined: " + type);
+ }
+
+ person.setType(enumType);
+
+ String givenName = contacts.getProperty(IDP_CONTACT_GIVENNAME);
+
+ if (givenName != null) {
+ GivenName name = SAML2Utils
+ .createSAMLObject(GivenName.class);
+ name.setName(givenName);
+ person.setGivenName(name);
+ }
+
+ String company = contacts.getProperty(IDP_CONTACT_COMPANY);
+
+ if (company != null) {
+ Company comp = SAML2Utils.createSAMLObject(Company.class);
+ comp.setName(company);
+ person.setCompany(comp);
+ }
+
+ String surname = contacts.getProperty(IDP_CONTACT_SURNAME);
+
+ if (surname != null) {
+ SurName name = SAML2Utils.createSAMLObject(SurName.class);
+ name.setName(surname);
+ person.setSurName(name);
+ }
+
+ String phone = contacts.getProperty(IDP_CONTACT_PHONE);
+ if (phone != null) {
+ TelephoneNumber telePhone = SAML2Utils
+ .createSAMLObject(TelephoneNumber.class);
+ telePhone.setNumber(phone);
+ person.getTelephoneNumbers().add(telePhone);
+ }
- for (Contact contact : contacts) {
-
- ContactPerson person = SAML2Utils
- .createSAMLObject(ContactPerson.class);
-
- String type = contact.getType();
-
- if (type == null) {
- Logger.error("IDP Contact with SurName " + contact.getSurName()
- + " has no type defined!");
- break;
- }
-
- ContactPersonTypeEnumeration enumType = null;
-
- if (type.equals(ContactPersonTypeEnumeration.ADMINISTRATIVE
- .toString())) {
- enumType = ContactPersonTypeEnumeration.ADMINISTRATIVE;
- } else if (type.equals(ContactPersonTypeEnumeration.BILLING
- .toString())) {
- enumType = ContactPersonTypeEnumeration.BILLING;
- } else if (type.equals(ContactPersonTypeEnumeration.OTHER
- .toString())) {
- enumType = ContactPersonTypeEnumeration.OTHER;
- } else if (type.equals(ContactPersonTypeEnumeration.SUPPORT
- .toString())) {
- enumType = ContactPersonTypeEnumeration.SUPPORT;
- } else if (type.equals(ContactPersonTypeEnumeration.TECHNICAL
- .toString())) {
- enumType = ContactPersonTypeEnumeration.TECHNICAL;
- }
-
- if (enumType == null) {
- Logger.error("IDP Contact with SurName " + contact.getSurName()
- + " has invalid type defined: " + type);
- break;
- }
-
- person.setType(enumType);
-
- String givenName = contact.getGivenName();
-
- if (givenName != null) {
- GivenName name = SAML2Utils
- .createSAMLObject(GivenName.class);
- name.setName(givenName);
- person.setGivenName(name);
- }
-
- String company = contact.getCompany();
-
- if (company != null) {
- Company comp = SAML2Utils.createSAMLObject(Company.class);
- comp.setName(company);
- person.setCompany(comp);
- }
-
- String surname = contact.getSurName();
-
- if (surname != null) {
- SurName name = SAML2Utils.createSAMLObject(SurName.class);
- name.setName(surname);
- person.setSurName(name);
- }
-
- List<String> phones = contact.getPhone();
- for (String phone : phones) {
- TelephoneNumber telePhone = SAML2Utils
- .createSAMLObject(TelephoneNumber.class);
- telePhone.setNumber(phone);
- person.getTelephoneNumbers().add(telePhone);
- }
-
- List<String> mails = contact.getMail();
- for (String mail : mails) {
- EmailAddress mailAddress = SAML2Utils
- .createSAMLObject(EmailAddress.class);
- mailAddress.setAddress(mail);
- person.getEmailAddresses().add(mailAddress);
- }
-
- list.add(person);
- }
+ String mail = contacts.getProperty(IDP_CONTACT_MAIL);
+ if (mail != null) {
+ EmailAddress mailAddress = SAML2Utils
+ .createSAMLObject(EmailAddress.class);
+ mailAddress.setAddress(mail);
+ person.getEmailAddresses().add(mailAddress);
}
+
+ list.add(person);
return list;
}
public Organization getIDPOrganisation() throws ConfigurationException {
Organization org = SAML2Utils.createSAMLObject(Organization.class);
- at.gv.egovernment.moa.id.commons.db.dao.config.Organization organisation = AuthConfigurationProviderFactory.getInstance().getGeneralPVP2DBConfig().getOrganization();
-
- String org_name = null;
- String org_dispname = null;
- String org_url = null;
-
- if (organisation != null) {
- org_name = organisation.getName();
- org_dispname = organisation.getDisplayName();
- org_url = organisation.getURL();
- }
+ Properties organisation = AuthConfigurationProviderFactory.getInstance().getConfigurationWithPrefix(
+ MOAIDConfigurationConstants.GENERAL_PROTOCOLS_PVP2X_METADATA_ORG + ".");
+ String org_name = organisation.getProperty(IDP_ORG_NAME);
+ String org_dispname = organisation.getProperty(IDP_ORG_DISPNAME);
+ String org_url = organisation.getProperty(IDP_ORG_URL);
+
if (org_name == null || org_dispname == null || org_url == null) {
return null;
}