aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src/main/java
diff options
context:
space:
mode:
authorThomas Lenz <tlenz@iaik.tugraz.at>2015-07-03 12:55:34 +0200
committerThomas Lenz <tlenz@iaik.tugraz.at>2015-07-03 12:55:34 +0200
commit91dfafd601d12d91347b1c09efb47d8f14da8760 (patch)
treeaa9605403509392018dd06465a385b0a6d9ab327 /id/server/idserverlib/src/main/java
parenta1ee0567607fe43909cd7fc1b75ace3197a2fa0b (diff)
downloadmoa-id-spss-91dfafd601d12d91347b1c09efb47d8f14da8760.tar.gz
moa-id-spss-91dfafd601d12d91347b1c09efb47d8f14da8760.tar.bz2
moa-id-spss-91dfafd601d12d91347b1c09efb47d8f14da8760.zip
fix problems with dynamic PVP2X metadata refresh
Diffstat (limited to 'id/server/idserverlib/src/main/java')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/binding/PostBinding.java11
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/binding/RedirectBinding.java4
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/metadata/MOAMetadataProvider.java42
3 files changed, 47 insertions, 10 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/binding/PostBinding.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/binding/PostBinding.java
index 1a268c812..5402e3dce 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/binding/PostBinding.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/binding/PostBinding.java
@@ -62,6 +62,7 @@ import at.gv.egovernment.moa.id.protocols.pvp2x.signer.CredentialProvider;
import at.gv.egovernment.moa.id.protocols.pvp2x.signer.CredentialsNotAvailableException;
import at.gv.egovernment.moa.id.util.VelocityProvider;
import at.gv.egovernment.moa.logging.Logger;
+import at.gv.egovernment.moa.util.MiscUtil;
public class PostBinding implements IDecoder, IEncoder {
@@ -170,10 +171,12 @@ public class PostBinding implements IDecoder, IEncoder {
RequestAbstractType inboundMessage = (RequestAbstractType) messageContext
.getInboundMessage();
msg = new MOARequest(inboundMessage, getSAML2BindingName());
+ msg.setEntityID(inboundMessage.getIssuer().getValue());
} else if (messageContext.getInboundMessage() instanceof StatusResponseType){
- StatusResponseType inboundMessage = (StatusResponseType) messageContext.getInboundMessage();
+ StatusResponseType inboundMessage = (StatusResponseType) messageContext.getInboundMessage();
msg = new MOAResponse(inboundMessage);
+ msg.setEntityID(inboundMessage.getIssuer().getValue());
} else
//create empty container if request type is unknown
@@ -182,8 +185,10 @@ public class PostBinding implements IDecoder, IEncoder {
if (messageContext.getPeerEntityMetadata() != null)
msg.setEntityID(messageContext.getPeerEntityMetadata().getEntityID());
- else
- Logger.info("No Metadata found for OA with EntityID " + messageContext.getInboundMessageIssuer());
+ else {
+ if (MiscUtil.isEmpty(msg.getEntityID()))
+ Logger.info("No Metadata found for OA with EntityID " + messageContext.getInboundMessageIssuer());
+ }
msg.setVerified(false);
msg.setRelayState(messageContext.getRelayState());
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/binding/RedirectBinding.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/binding/RedirectBinding.java
index 0b6cb6eea..81863f48f 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/binding/RedirectBinding.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/binding/RedirectBinding.java
@@ -178,12 +178,12 @@ public class RedirectBinding implements IDecoder, IEncoder {
signatureRule.evaluate(messageContext);
} catch (SecurityException e) {
- if (MiscUtil.isEmpty(messageContext.getPeerEntityId())) {
+ if (MiscUtil.isEmpty(messageContext.getInboundMessageIssuer())) {
throw e;
}
Logger.debug("PVP2X message validation FAILED. Relead metadata for entityID: " + messageContext.getPeerEntityId());
- if (!MOAMetadataProvider.getInstance().refreshMetadataProvider(messageContext.getPeerEntityId()))
+ if (!MOAMetadataProvider.getInstance().refreshMetadataProvider(messageContext.getInboundMessageIssuer()))
throw e;
else {
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/metadata/MOAMetadataProvider.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/metadata/MOAMetadataProvider.java
index c2127a2af..389b9825f 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/metadata/MOAMetadataProvider.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/pvp2x/metadata/MOAMetadataProvider.java
@@ -26,12 +26,14 @@ import java.io.IOException;
import java.security.cert.CertificateException;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.concurrent.CopyOnWriteArrayList;
import java.util.Timer;
import javax.net.ssl.SSLHandshakeException;
@@ -46,6 +48,8 @@ import org.opensaml.saml2.metadata.provider.HTTPMetadataProvider;
import org.opensaml.saml2.metadata.provider.MetadataFilter;
import org.opensaml.saml2.metadata.provider.MetadataProvider;
import org.opensaml.saml2.metadata.provider.MetadataProviderException;
+import org.opensaml.saml2.metadata.provider.ObservableMetadataProvider;
+import org.opensaml.saml2.metadata.provider.ObservableMetadataProvider.Observer;
import org.opensaml.xml.XMLObject;
import org.opensaml.xml.parse.BasicParserPool;
@@ -66,11 +70,12 @@ import at.gv.egovernment.moa.logging.Logger;
import at.gv.egovernment.moa.util.Base64Utils;
import at.gv.egovernment.moa.util.MiscUtil;
-public class MOAMetadataProvider implements MetadataProvider {
+public class MOAMetadataProvider implements ObservableMetadataProvider{
private static MOAMetadataProvider instance = null;
-
private static Object mutex = new Object();
+ private List<ObservableMetadataProvider.Observer> observers;
+
public static MOAMetadataProvider getInstance() {
if (instance == null) {
@@ -111,7 +116,6 @@ public class MOAMetadataProvider implements MetadataProvider {
MetadataProvider internalProvider;
-
public boolean refreshMetadataProvider(String entityID) {
try {
OAAuthParameter oaParam =
@@ -142,6 +146,9 @@ public class MOAMetadataProvider implements MetadataProvider {
cert));
chainProvider.addMetadataProvider(newMetadataProvider);
+
+ emitChangeEvent();
+
Logger.info("PVP2X metadata for onlineApplication: "
+ entityID + " is added.");
return true;
@@ -299,6 +306,8 @@ public class MOAMetadataProvider implements MetadataProvider {
try {
chainProvider.setProviders(new ArrayList<MetadataProvider>(providersinuse.values()));
+ emitChangeEvent();
+
} catch (MetadataProviderException e) {
Logger.warn("ReInitalize MOAMetaDataProvider is not possible! MOA-ID Instance has to be restarted manualy", e);
@@ -328,7 +337,9 @@ public class MOAMetadataProvider implements MetadataProvider {
} else {
Logger.warn("MetadataProvider can not be destroyed.");
}
- }
+ }
+
+ this.observers = Collections.emptyList();
instance = null;
} else {
Logger.warn("ReInitalize MOAMetaDataProvider is not possible! MOA-ID Instance has to be restarted manualy");
@@ -337,10 +348,12 @@ public class MOAMetadataProvider implements MetadataProvider {
private MOAMetadataProvider() {
ChainingMetadataProvider chainProvider = new ChainingMetadataProvider();
- Logger.info("Loading metadata");
+ this.observers = new CopyOnWriteArrayList<Observer>();
+ Logger.info("Loading metadata");
Map<String, MetadataProvider> providersinuse = new HashMap<String, MetadataProvider>();
try {
+ //TODO: database search does not work!!!!!
Map<String, String> allOAs = AuthConfigurationProviderFactory.getInstance().getConfigurationWithWildCard(
MOAIDConfigurationConstants.PREFIX_SERVICES
+ ".%."
@@ -550,4 +563,23 @@ public class MOAMetadataProvider implements MetadataProvider {
return internalProvider.getRole(entityID, roleName, supportedProtocol);
}
+ /* (non-Javadoc)
+ * @see org.opensaml.saml2.metadata.provider.ObservableMetadataProvider#getObservers()
+ */
+ @Override
+ public List<Observer> getObservers() {
+ return ((ChainingMetadataProvider) internalProvider).getObservers();
+ }
+
+ protected void emitChangeEvent() {
+ if ((getObservers() == null) || (getObservers().size() == 0)) {
+ return;
+ }
+
+ List<Observer> tempObserverList = new ArrayList<Observer>(getObservers());
+ for (ObservableMetadataProvider.Observer observer : tempObserverList)
+ if (observer != null)
+ observer.onEvent(this);
+ }
+
}