summaryrefslogtreecommitdiff
path: root/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/protocols/RequestImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/protocols/RequestImpl.java')
-rw-r--r--eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/controller/protocols/RequestImpl.java42
1 files changed, 32 insertions, 10 deletions
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<String, Object> genericFullDataStorage() {
- return this.genericDataStorage;
+ public final <T> T getSessionData(final Class<T> 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> T getGenericData(String key, final Class<T> clazz) {
+ public final <T> T getRawData(String key, final Class<T> 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<String, Object> map) throws EAAFStorageException {
+ public final void setRawDataToTransaction(Map<String, Object> 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<String, Object> el : map.entrySet())
- setGenericDataToSession(el.getKey(), el.getValue());
+ setRawDataToTransaction(el.getKey(), el.getValue());
}