aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/verification
diff options
context:
space:
mode:
authorThomas Lenz <tlenz@iaik.tugraz.at>2013-09-23 14:13:58 +0200
committerThomas Lenz <tlenz@iaik.tugraz.at>2013-09-23 14:13:58 +0200
commit816bd3d051a7c8fc7aba535361550d62fb5af2cc (patch)
tree00f3282d786797a566850af085b2749b0b69d1a1 /id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/verification
parent1984a9914bb024bdd7b486ec6dd6ba4144c0c70b (diff)
downloadmoa-id-spss-816bd3d051a7c8fc7aba535361550d62fb5af2cc.tar.gz
moa-id-spss-816bd3d051a7c8fc7aba535361550d62fb5af2cc.tar.bz2
moa-id-spss-816bd3d051a7c8fc7aba535361550d62fb5af2cc.zip
ReImplement MOAMetadataProvider to add and remove HTTPMetadataProvider dynamically from configuration database.
Diffstat (limited to 'id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/verification')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/verification/MetadataSignatureFilter.java41
1 files changed, 36 insertions, 5 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/verification/MetadataSignatureFilter.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/verification/MetadataSignatureFilter.java
index fb1f08132..ffc3f9b29 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/verification/MetadataSignatureFilter.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/verification/MetadataSignatureFilter.java
@@ -14,6 +14,8 @@ import org.opensaml.xml.security.credential.Credential;
import org.opensaml.xml.security.x509.BasicX509Credential;
import at.gv.egovernment.moa.id.MOAIDException;
+import at.gv.egovernment.moa.id.commons.db.ConfigurationDBUtils;
+import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.NoCredentialsException;
import at.gv.egovernment.moa.logging.Logger;
public class MetadataSignatureFilter implements MetadataFilter {
@@ -48,11 +50,37 @@ public class MetadataSignatureFilter implements MetadataFilter {
}
Iterator<EntityDescriptor> entIT = desc.getEntityDescriptors().iterator();
-
-
- //TODO: check this!!!!
- while(entID.hasNext()) {
- processEntityDescriptorr(entIT.next());
+
+ //check every Entity
+ while(entIT.hasNext()) {
+
+ EntityDescriptor entity = entIT.next();
+ String entityID = entity.getEntityID();
+
+ //CHECK if Entity also match MetaData signature.
+ /*This check is necessary to prepend declaration of counterfeit OA metadata!!*/
+ byte[] entityCert = EntityVerifier.fetchSavedCredential(entityID);
+
+ if (entityCert != null) {
+
+ X509Certificate cert;
+ try {
+ cert = new X509Certificate(entityCert);
+ BasicX509Credential entityCrendential = new BasicX509Credential();
+ entityCrendential.setEntityCertificate(cert);
+
+ EntityVerifier.verify(desc, entityCrendential);
+
+ } catch (Exception e) {
+ throw new MOAIDException("The App", null, e);
+ }
+
+ } else {
+ throw new NoCredentialsException("NO Certificate found for OA " + entityID);
+ }
+
+ //TODO: insert to support signed Entity-Elements
+ //processEntityDescriptorr(entIT.next());
}
}
@@ -70,6 +98,9 @@ public class MetadataSignatureFilter implements MetadataFilter {
} */else {
throw new MOAIDException("Invalid Metadata file Root element is no EntitiesDescriptor", null);
}
+
+ ConfigurationDBUtils.closeSession();
+
Logger.info("Metadata Filter done OK");
} catch (MOAIDException e) {
e.printStackTrace();