From aee52550868c56de7f7063e4ca153b031dedecb0 Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Fri, 13 Jul 2018 15:49:38 +0200 Subject: some updates and bugfixes --- .../impl/idp/controller/protocols/RequestImpl.java | 42 ++++++++++++++++------ 1 file changed, 32 insertions(+), 10 deletions(-) (limited to 'eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/protocols/RequestImpl.java') diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/protocols/RequestImpl.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/protocols/RequestImpl.java index a453a8a3..7d59f043 100644 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/protocols/RequestImpl.java +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/protocols/RequestImpl.java @@ -27,6 +27,7 @@ package at.gv.egiz.eaaf.core.impl.idp.controller.protocols; import java.io.Serializable; +import java.lang.reflect.InvocationTargetException; import java.net.MalformedURLException; import java.net.URL; import java.util.Date; @@ -48,6 +49,7 @@ import at.gv.egiz.eaaf.core.api.idp.ISPConfiguration; import at.gv.egiz.eaaf.core.exceptions.EAAFAuthenticationException; import at.gv.egiz.eaaf.core.exceptions.EAAFException; import at.gv.egiz.eaaf.core.exceptions.EAAFStorageException; +import at.gv.egiz.eaaf.core.impl.idp.auth.data.AuthProcessDataWrapper; import at.gv.egiz.eaaf.core.impl.utils.HTTPUtils; import at.gv.egiz.eaaf.core.impl.utils.Random; import at.gv.egiz.eaaf.core.impl.utils.TransactionIDUtils; @@ -141,7 +143,7 @@ public abstract class RequestImpl implements IRequest, Serializable{ //set requester's IP address try { - setGenericDataToSession(DATAID_REQUESTER_IP_ADDRESS, req.getRemoteAddr()); + setRawDataToTransaction(DATAID_REQUESTER_IP_ADDRESS, req.getRemoteAddr()); } catch (EAAFStorageException e) { log.info("Can NOT store remote IP address into 'pendingRequest'." , e); @@ -215,11 +217,31 @@ public abstract class RequestImpl implements IRequest, Serializable{ this.internalSSOSessionId = internalSSOSessionId; } - + @Override - public final Map genericFullDataStorage() { - return this.genericDataStorage; + public final T getSessionData(final Class wrapper) { + if (wrapper != null) { + if (AuthProcessDataWrapper.class.isAssignableFrom(wrapper)) { + try { + return wrapper.getConstructor(Map.class).newInstance(this.genericDataStorage); + + } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException + | IllegalArgumentException | InvocationTargetException e) { + log.error("Can NOT instance wrapper: " + wrapper.getName(), e); + + } + + } + + log.error("Can NOT wrap generic data into session data. " + + "Reason: Wrapper " + wrapper.getName() + " is NOT a valid wrapper"); + throw new RuntimeException("Can NOT wrap generic data into session data. " + + "Reason: Wrapper " + wrapper.getName() + " is NOT a valid wrapper"); + + } + return null; + } @Override @@ -346,7 +368,7 @@ public abstract class RequestImpl implements IRequest, Serializable{ } @Override - public final Object getGenericData(String key) { + public final Object getRawData(String key) { if (StringUtils.isNotEmpty(key)) { return genericDataStorage.get(key); @@ -357,7 +379,7 @@ public abstract class RequestImpl implements IRequest, Serializable{ } @Override - public final T getGenericData(String key, final Class clazz) { + public final T getRawData(String key, final Class clazz) { if (StringUtils.isNotEmpty(key)) { Object data = genericDataStorage.get(key); @@ -383,13 +405,13 @@ public abstract class RequestImpl implements IRequest, Serializable{ } @Override - public final void setGenericDataToSession(String key, Object object) throws EAAFStorageException { + public final void setRawDataToTransaction(String key, Object object) throws EAAFStorageException { if (StringUtils.isEmpty(key)) { log.info("Generic request-data can not be stored with a 'null' key"); throw new EAAFStorageException("Generic request-data can not be stored with a 'null' key", null); } - + if (object != null) { if (!Serializable.class.isInstance(object)) { log.warn("Generic request-data can only store objects which implements the 'Seralizable' interface"); @@ -408,7 +430,7 @@ public abstract class RequestImpl implements IRequest, Serializable{ } @Override - public final void setGenericDataToSession(Map map) throws EAAFStorageException { + public final void setRawDataToTransaction(Map map) throws EAAFStorageException { if (map == null) { log.info("Generic request-data can not be stored with a 'null' map"); throw new EAAFStorageException("Generic request-data can not be stored with a 'null' map", null); @@ -417,7 +439,7 @@ public abstract class RequestImpl implements IRequest, Serializable{ //validate and store values for (Entry el : map.entrySet()) - setGenericDataToSession(el.getKey(), el.getValue()); + setRawDataToTransaction(el.getKey(), el.getValue()); } -- cgit v1.2.3