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 --- .../idp/auth/AbstractAuthenticationManager.java | 2 +- .../builder/AbstractAuthenticationDataBuilder.java | 20 +++++------ .../impl/idp/controller/protocols/RequestImpl.java | 42 ++++++++++++++++------ 3 files changed, 43 insertions(+), 21 deletions(-) (limited to 'eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp') diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/AbstractAuthenticationManager.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/AbstractAuthenticationManager.java index a4734e66..1fb4bf6b 100644 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/AbstractAuthenticationManager.java +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/AbstractAuthenticationManager.java @@ -236,7 +236,7 @@ public abstract class AbstractAuthenticationManager implements IAuthenticationMa log.debug("Find SSL-client-certificate on request --> Add it to context"); executionContext.put(EAAFConstants.PROCESS_ENGINE_SSL_CLIENT_CERTIFICATE, ((X509Certificate[])httpReq.getAttribute("javax.servlet.request.X509Certificate"))); - pendingReq.setGenericDataToSession(EAAFConstants.PROCESS_ENGINE_SSL_CLIENT_CERTIFICATE, + pendingReq.setRawDataToTransaction(EAAFConstants.PROCESS_ENGINE_SSL_CLIENT_CERTIFICATE, ((X509Certificate[])httpReq.getAttribute("javax.servlet.request.X509Certificate"))); } diff --git a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java index 94d9a810..c095135d 100644 --- a/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java +++ b/eaaf_core/src/main/java/at/gv/egiz/eaaf/core/impl/idp/auth/builder/AbstractAuthenticationDataBuilder.java @@ -440,16 +440,16 @@ public abstract class AbstractAuthenticationDataBuilder implements IAuthenticati */ private String getbPKTypeFromPVPAttribute(IAuthProcessDataContainer session) { String pvpbPKTypeAttr = session.getGenericDataFromSession(PVPAttributeDefinitions.EID_SECTOR_FOR_IDENTIFIER_NAME, String.class); - if (StringUtils.isNotEmpty(pvpbPKTypeAttr)) { - - //fix a wrong bPK-Type encoding, which was used in some PVP Standardportal implementations - if (pvpbPKTypeAttr.startsWith(EAAFConstants.URN_PREFIX_CDID) && - !pvpbPKTypeAttr.substring(EAAFConstants.URN_PREFIX_CDID.length(), - EAAFConstants.URN_PREFIX_CDID.length() + 1).equals("+")) { - log.warn("Receive uncorrect encoded bBKType attribute " + pvpbPKTypeAttr + " Starting attribute value correction ... "); - pvpbPKTypeAttr = EAAFConstants.URN_PREFIX_CDID + "+" + pvpbPKTypeAttr.substring(EAAFConstants.URN_PREFIX_CDID.length() + 1); - - } + + if (StringUtils.isNotEmpty(pvpbPKTypeAttr)) { +// //fix a wrong bPK-Type encoding, which was used in some PVP Standardportal implementations +// if (pvpbPKTypeAttr.startsWith(EAAFConstants.URN_PREFIX_CDID) && +// !pvpbPKTypeAttr.substring(EAAFConstants.URN_PREFIX_CDID.length(), +// EAAFConstants.URN_PREFIX_CDID.length() + 1).equals("+")) { +// log.warn("Receive uncorrect encoded bBKType attribute " + pvpbPKTypeAttr + " Starting attribute value correction ... "); +// pvpbPKTypeAttr = EAAFConstants.URN_PREFIX_CDID + "+" + pvpbPKTypeAttr.substring(EAAFConstants.URN_PREFIX_CDID.length() + 1); +// +// } log.debug("Find PVP-Attr: " + PVPAttributeDefinitions.EID_SECTOR_FOR_IDENTIFIER_FRIENDLY_NAME); return pvpbPKTypeAttr; } 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