aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/advancedlogging/StatisticLogger.java
diff options
context:
space:
mode:
Diffstat (limited to 'id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/advancedlogging/StatisticLogger.java')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/advancedlogging/StatisticLogger.java232
1 files changed, 124 insertions, 108 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/advancedlogging/StatisticLogger.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/advancedlogging/StatisticLogger.java
index 72aef5fed..f642cddc7 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/advancedlogging/StatisticLogger.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/advancedlogging/StatisticLogger.java
@@ -43,22 +43,25 @@ import org.springframework.transaction.annotation.Transactional;
import at.gv.e_government.reference.namespace.mandates._20040701_.Mandate;
import at.gv.e_government.reference.namespace.mandates._20040701_.Mandator;
import at.gv.e_government.reference.namespace.persondata._20020228_.CorporateBodyType;
-import at.gv.egovernment.moa.id.auth.exception.BKUException;
-import at.gv.egovernment.moa.id.auth.exception.MISSimpleClientException;
+import at.gv.egiz.eaaf.core.api.IRequest;
+import at.gv.egiz.eaaf.core.api.idp.IAuthData;
+import at.gv.egiz.eaaf.core.api.logging.IStatisticLogger;
+import at.gv.egovernment.moa.id.auth.data.AuthenticationSessionWrapper;
import at.gv.egovernment.moa.id.auth.exception.ServiceException;
import at.gv.egovernment.moa.id.client.SZRGWClientException;
import at.gv.egovernment.moa.id.commons.api.AuthConfiguration;
import at.gv.egovernment.moa.id.commons.api.IOAAuthParameters;
-import at.gv.egovernment.moa.id.commons.api.IRequest;
import at.gv.egovernment.moa.id.commons.api.data.IAuthenticationSession;
import at.gv.egovernment.moa.id.commons.api.data.IMISMandate;
+import at.gv.egovernment.moa.id.commons.api.exceptions.BKUException;
import at.gv.egovernment.moa.id.commons.api.exceptions.ConfigurationException;
+import at.gv.egovernment.moa.id.commons.api.exceptions.MISSimpleClientException;
import at.gv.egovernment.moa.id.commons.api.exceptions.MOAIDException;
import at.gv.egovernment.moa.id.commons.db.dao.statistic.StatisticLog;
import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException;
-import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;
-import at.gv.egovernment.moa.id.data.IAuthData;
-import at.gv.egovernment.moa.id.moduls.RequestImpl;
+import at.gv.egovernment.moa.id.config.auth.OAAuthParameterDecorator;
+import at.gv.egovernment.moa.id.data.IMOAAuthData;
+import at.gv.egovernment.moa.id.moduls.SSOManager;
import at.gv.egovernment.moa.id.storage.IAuthenticationSessionStoreage;
import at.gv.egovernment.moa.logging.Logger;
import at.gv.egovernment.moa.util.MiscUtil;
@@ -91,7 +94,9 @@ public class StatisticLogger implements IStatisticLogger{
private EntityManager entityManager;
- public void testConnection() throws Exception {
+ @Override
+ //TODO: update tests!!!!
+ public void internalTesting() throws Exception {
Date expioredate = new Date(new Date().getTime() - 120);
Query query = entityManager.createNamedQuery("getAllEntriesNotBeforeTimeStamp");
query.setParameter("timeout", expioredate);
@@ -105,7 +110,7 @@ public class StatisticLogger implements IStatisticLogger{
if ( authConfig.isAdvancedLoggingActive() && protocolRequest != null && authData != null) {
IOAAuthParameters dbOA = null;
- dbOA = protocolRequest.getOnlineApplicationConfiguration();
+ dbOA = protocolRequest.getServiceProviderConfiguration(OAAuthParameterDecorator.class);
if (dbOA == null) {
Logger.warn("Advanced logging failed: OA can not be found in database.");
@@ -128,88 +133,95 @@ public class StatisticLogger implements IStatisticLogger{
Logger.warn("Can not extract some information for StatisticLogger.", e);
}
- dblog.setOatarget(authData.getBPKType());
-
-
- boolean isFederatedAuthentication = protocolRequest.getGenericData(RequestImpl.DATAID_INTERFEDERATIOIDP_RESPONSE) != null;
- dblog.setInterfederatedSSOSession(isFederatedAuthentication);
-
- if (isFederatedAuthentication) {
- dblog.setBkutype(IOAAuthParameters.INDERFEDERATEDIDP);
- dblog.setBkuurl(protocolRequest.getGenericData(RequestImpl.DATAID_INTERFEDERATIOIDP_ENTITYID, String.class));
-
- } else {
- dblog.setBkuurl(authData.getBkuURL());
- dblog.setBkutype(findBKUType(authData.getBkuURL(), dbOA));
-
- }
-
dblog.setProtocoltype(protocolRequest.requestedModule());
dblog.setProtocolsubtype(protocolRequest.requestedAction());
dblog.setSsosession(isSSOSession);
- //log MandateInforamtion
- if (authData.isUseMandate()) {
- dblog.setMandatelogin(authData.isUseMandate());
+ if (authData instanceof IMOAAuthData) {
+ IMOAAuthData moaAuthData = (IMOAAuthData) authData;
+ dblog.setOatarget(moaAuthData.getBPKType());
+
+ boolean isFederatedAuthentication = protocolRequest.getRawData(SSOManager.DATAID_INTERFEDERATIOIDP_RESPONSE) != null;
+ dblog.setInterfederatedSSOSession(isFederatedAuthentication);
- IMISMandate mandate = authData.getMISMandate();
- if (mandate != null) {
+ if (isFederatedAuthentication) {
+ dblog.setBkutype(IOAAuthParameters.INDERFEDERATEDIDP);
+ dblog.setBkuurl(protocolRequest.getRawData(SSOManager.DATAID_INTERFEDERATIOIDP_ENTITYID, String.class));
- if (MiscUtil.isNotEmpty(mandate.getProfRep())) {
- dblog.setMandatetype(mandate.getProfRep());
- dblog.setPv(true);
- dblog.setPvOID(mandate.getProfRep());
-
- } else {
- dblog.setPv(false);
- }
+ } else if (moaAuthData.isForeigner()) {
+ dblog.setBkutype(IOAAuthParameters.EIDAS);
- InputStream is = null;
- try {
- is = new ByteArrayInputStream(mandate.getMandate());
+ } else {
+ dblog.setBkuurl(moaAuthData.getBkuURL());
+ dblog.setBkutype(findBKUType(moaAuthData.getBkuURL(), dbOA));
+
+ }
+
+ //log MandateInforamtion
+ if (moaAuthData.isUseMandate()) {
+ dblog.setMandatelogin(moaAuthData.isUseMandate());
+
+ IMISMandate mandate = moaAuthData.getMISMandate();
+ if (mandate != null) {
- JAXBContext jc = JAXBContext.newInstance(Mandate.class);
- Unmarshaller u = jc.createUnmarshaller();
- Object mismandateobj = u.unmarshal(is);
+ if (MiscUtil.isNotEmpty(mandate.getProfRep())) {
+ dblog.setMandatetype(mandate.getProfRep());
+ dblog.setPv(true);
+ dblog.setPvOID(mandate.getProfRep());
+
+ } else {
+ dblog.setPv(false);
+ }
- if (mismandateobj != null && mismandateobj instanceof Mandate) {
- Mandate mismandate = (Mandate) mismandateobj;
+ InputStream is = null;
+ try {
+ is = new ByteArrayInputStream(mandate.getMandate());
- if (MiscUtil.isEmpty(mandate.getProfRep()))
- dblog.setMandatetype(mismandate.getAnnotation());
+ JAXBContext jc = JAXBContext.newInstance(Mandate.class);
+ Unmarshaller u = jc.createUnmarshaller();
+ Object mismandateobj = u.unmarshal(is);
- Mandator mandator = mismandate.getMandator();
- CorporateBodyType corp = mandator.getCorporateBody();
- if (corp != null) {
- dblog.setMandatortype(MANTATORTYPE_JUR);
+ if (mismandateobj != null && mismandateobj instanceof Mandate) {
+ Mandate mismandate = (Mandate) mismandateobj;
+
+ if (MiscUtil.isEmpty(mandate.getProfRep()))
+ dblog.setMandatetype(mismandate.getAnnotation());
+
+ Mandator mandator = mismandate.getMandator();
+ CorporateBodyType corp = mandator.getCorporateBody();
+ if (corp != null) {
+ dblog.setMandatortype(MANTATORTYPE_JUR);
+
+ } else {
+ dblog.setMandatortype(MANTATORTYPE_NAT);
+ }
+
} else {
- dblog.setMandatortype(MANTATORTYPE_NAT);
+ Logger.warn("Advancted logging can not unmarshall MISMandate");
}
-
-
- } else {
- Logger.warn("Advancted logging can not unmarshall MISMandate");
- }
- } catch (JAXBException e) {
- Logger.warn("Advancted logging can not parse mandate.", e);
-
- } finally {
- if (is!=null) {
- try {
- is.close();
-
- } catch (IOException e) {
- Logger.warn("Close InputStream failed." , e);
-
+ } catch (JAXBException e) {
+ Logger.warn("Advancted logging can not parse mandate.", e);
+
+ } finally {
+ if (is!=null) {
+ try {
+ is.close();
+
+ } catch (IOException e) {
+ Logger.warn("Close InputStream failed." , e);
+
+ }
}
}
- }
- }
- }
-
+ }
+ }
+
+ } else
+ Logger.info("'AuthData' is NOT of type 'IMOAAuthData'. StatisticLogger logs only basic infos");
+
try {
entityManager.persist(dblog);
@@ -258,13 +270,13 @@ public class StatisticLogger implements IStatisticLogger{
dblog.setTimestamp(new Date());
- dblog.setOaurlprefix(getMessageWithMaxLength(errorRequest.getOAURL(), MAXOAIDENTIFIER_LENGTH));
+ dblog.setOaurlprefix(getMessageWithMaxLength(errorRequest.getSPEntityId(), MAXOAIDENTIFIER_LENGTH));
dblog.setProtocoltype(errorRequest.requestedModule());
dblog.setProtocolsubtype(errorRequest.requestedAction());
generateErrorLogFormThrowable(throwable, dblog);
- IOAAuthParameters dbOA = errorRequest.getOnlineApplicationConfiguration();
+ IOAAuthParameters dbOA = errorRequest.getServiceProviderConfiguration(OAAuthParameterDecorator.class);
if (dbOA != null) {
dblog.setOaurlprefix(getMessageWithMaxLength(dbOA.getPublicURLPrefix(), MAXOAIDENTIFIER_LENGTH));
dblog.setOafriendlyName(dbOA.getFriendlyName());
@@ -290,7 +302,9 @@ public class StatisticLogger implements IStatisticLogger{
} else {
Logger.debug("Use MOA session information from pending-req for ErrorLogging");
- moasession = errorRequest.getMOASession();
+ moasession = (IAuthenticationSession) errorRequest.getSessionData(AuthenticationSessionWrapper.class);
+
+
}
@@ -383,45 +397,47 @@ public class StatisticLogger implements IStatisticLogger{
private String findBKUType(String bkuURL, IOAAuthParameters dbOA) {
- if (dbOA != null) {
- if (bkuURL.equals(dbOA.getBKUURL(OAAuthParameter.HANDYBKU)))
- return IOAAuthParameters.HANDYBKU;
-
- if (bkuURL.equals(dbOA.getBKUURL(OAAuthParameter.LOCALBKU)))
- return IOAAuthParameters.LOCALBKU;
-
- if (bkuURL.equals(dbOA.getBKUURL(OAAuthParameter.THIRDBKU)))
- return IOAAuthParameters.THIRDBKU;
- }
-
- Logger.trace("Staticic Log search BKUType from DefaultBKUs");
-
- try {
- if (bkuURL.equals(authConfig.getDefaultBKUURL(IOAAuthParameters.THIRDBKU)))
- return IOAAuthParameters.THIRDBKU;
+ if (bkuURL != null) {
+ if (dbOA != null) {
+ if (bkuURL.equals(dbOA.getBKUURL(OAAuthParameterDecorator.HANDYBKU)))
+ return IOAAuthParameters.HANDYBKU;
+
+ if (bkuURL.equals(dbOA.getBKUURL(OAAuthParameterDecorator.LOCALBKU)))
+ return IOAAuthParameters.LOCALBKU;
+
+ if (bkuURL.equals(dbOA.getBKUURL(OAAuthParameterDecorator.THIRDBKU)))
+ return IOAAuthParameters.THIRDBKU;
+ }
- if (bkuURL.equals(authConfig.getDefaultBKUURL(IOAAuthParameters.LOCALBKU)))
+ Logger.trace("Staticic Log search BKUType from DefaultBKUs");
+
+ try {
+ if (bkuURL.equals(authConfig.getDefaultBKUURL(IOAAuthParameters.THIRDBKU)))
+ return IOAAuthParameters.THIRDBKU;
+
+ if (bkuURL.equals(authConfig.getDefaultBKUURL(IOAAuthParameters.LOCALBKU)))
+ return IOAAuthParameters.LOCALBKU;
+
+ if (bkuURL.equals(authConfig.getDefaultBKUURL(IOAAuthParameters.HANDYBKU)))
+ return IOAAuthParameters.HANDYBKU;
+
+ } catch (ConfigurationException e) {
+ Logger.info("Advanced Logging: Default BKUs read failed");
+ }
+
+ Logger.debug("Staticic Log search BKUType from generneric Parameters");
+
+ if (bkuURL.endsWith(GENERIC_LOCALBKU)) {
+ Logger.debug("BKUURL " + bkuURL + " is mapped to " + IOAAuthParameters.LOCALBKU);
return IOAAuthParameters.LOCALBKU;
+ }
- if (bkuURL.equals(authConfig.getDefaultBKUURL(IOAAuthParameters.HANDYBKU)))
+ if (bkuURL.startsWith(GENERIC_HANDYBKU)) {
+ Logger.debug("BKUURL " + bkuURL + " is mapped to " + IOAAuthParameters.HANDYBKU);
return IOAAuthParameters.HANDYBKU;
-
- } catch (ConfigurationException e) {
- Logger.info("Advanced Logging: Default BKUs read failed");
- }
-
- Logger.debug("Staticic Log search BKUType from generneric Parameters");
-
- if (bkuURL.endsWith(GENERIC_LOCALBKU)) {
- Logger.debug("BKUURL " + bkuURL + " is mapped to " + IOAAuthParameters.LOCALBKU);
- return IOAAuthParameters.LOCALBKU;
+ }
}
- if (bkuURL.startsWith(GENERIC_HANDYBKU)) {
- Logger.debug("BKUURL " + bkuURL + " is mapped to " + IOAAuthParameters.HANDYBKU);
- return IOAAuthParameters.HANDYBKU;
- }
-
Logger.debug("BKUURL " + bkuURL + " is mapped to " + IOAAuthParameters.AUTHTYPE_OTHERS);
return IOAAuthParameters.AUTHTYPE_OTHERS;
}