diff options
author | Thomas Lenz <tlenz@iaik.tugraz.at> | 2015-04-21 13:37:42 +0200 |
---|---|---|
committer | Thomas Lenz <tlenz@iaik.tugraz.at> | 2015-04-21 13:37:42 +0200 |
commit | ec2ab41165db55c77ebc203091f6d9f5effa95b5 (patch) | |
tree | 71b7aa1e16d5909e09076351ea138a502ed167e6 /id/server/idserverlib/src/main | |
parent | 6a5f48ae2f3a7c3c061e8d03105c1cb34d9643c2 (diff) | |
download | moa-id-spss-ec2ab41165db55c77ebc203091f6d9f5effa95b5.tar.gz moa-id-spss-ec2ab41165db55c77ebc203091f6d9f5effa95b5.tar.bz2 moa-id-spss-ec2ab41165db55c77ebc203091f6d9f5effa95b5.zip |
set transactionID to logger implementation which can be used by key "transactionId"
Diffstat (limited to 'id/server/idserverlib/src/main')
5 files changed, 66 insertions, 0 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/advancedlogging/TransactionIDUtils.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/advancedlogging/TransactionIDUtils.java new file mode 100644 index 000000000..d428cddd1 --- /dev/null +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/advancedlogging/TransactionIDUtils.java @@ -0,0 +1,46 @@ +/* + * Copyright 2014 Federal Chancellery Austria + * MOA-ID has been developed in a cooperation between BRZ, the Federal + * Chancellery Austria - ICT staff unit, and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://www.osor.eu/eupl/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ +package at.gv.egovernment.moa.id.advancedlogging; + +import org.slf4j.MDC; + +import at.gv.egovernment.moa.id.auth.MOAIDAuthConstants; + +/** + * @author tlenz + * + */ +public class TransactionIDUtils { + + public static void setTransactionId(String pendingRequestID) { + MDC.put(MOAIDAuthConstants.MDC_TRANSACTION_ID, + "TID-" + pendingRequestID); + + } + + public static void removeTransactionId() { + MDC.remove(MOAIDAuthConstants.MDC_TRANSACTION_ID); + + } + +} diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/MOAIDAuthConstants.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/MOAIDAuthConstants.java index 5223a181d..ac8d00ac8 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/MOAIDAuthConstants.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/MOAIDAuthConstants.java @@ -168,4 +168,5 @@ public interface MOAIDAuthConstants { public static final String REGEX_PATTERN_TARGET = "^[A-Za-z]{2}(-.*)?$"; + public static final String MDC_TRANSACTION_ID = "transactionId"; } diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/ProcessEngineSignalServlet.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/ProcessEngineSignalServlet.java index 43b6c03d4..49aa1c0f5 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/ProcessEngineSignalServlet.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/servlet/ProcessEngineSignalServlet.java @@ -7,7 +7,9 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringEscapeUtils;
+import org.slf4j.MDC;
+import at.gv.egovernment.moa.id.advancedlogging.TransactionIDUtils;
import at.gv.egovernment.moa.id.auth.AuthenticationServer;
import at.gv.egovernment.moa.id.auth.MOAIDAuthConstants;
import at.gv.egovernment.moa.id.auth.data.AuthenticationSession;
@@ -67,6 +69,9 @@ public class ProcessEngineSignalServlet extends AuthServlet { pendingRequestID = AuthenticationSessionStoreage.getPendingRequestID(sessionID);
AuthenticationSession session = AuthenticationServer.getSession(sessionID);
+ //add transactionID to Logger
+ TransactionIDUtils.setTransactionId(pendingRequestID);
+
// process instance is mandatory
if (session.getProcessInstanceId() == null) {
throw new IllegalStateException("MOA session does not provide process instance id.");
@@ -77,8 +82,11 @@ public class ProcessEngineSignalServlet extends AuthServlet { } catch (Exception ex) {
handleError(null, ex, req, resp, pendingRequestID);
+
} finally {
MOASessionDBUtils.closeSession();
+ TransactionIDUtils.removeTransactionId();
+
}
}
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/entrypoints/DispatcherServlet.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/entrypoints/DispatcherServlet.java index e3b7524ae..cce260d04 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/entrypoints/DispatcherServlet.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/entrypoints/DispatcherServlet.java @@ -31,6 +31,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import at.gv.egovernment.moa.id.advancedlogging.StatisticLogger; +import at.gv.egovernment.moa.id.advancedlogging.TransactionIDUtils; import at.gv.egovernment.moa.id.auth.MOAIDAuthInitializer; import at.gv.egovernment.moa.id.auth.builder.AuthenticationDataBuilder; import at.gv.egovernment.moa.id.auth.data.AuthenticationSession; @@ -545,6 +546,8 @@ public class DispatcherServlet extends AuthServlet{ finally { ConfigurationDBUtils.closeSession(); + TransactionIDUtils.removeTransactionId(); + } Logger.info("Clossing Dispatcher processing loop"); diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/moduls/RequestStorage.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/moduls/RequestStorage.java index 21b4e2b65..be8e2dc2a 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/moduls/RequestStorage.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/moduls/RequestStorage.java @@ -22,6 +22,7 @@ *******************************************************************************/ package at.gv.egovernment.moa.id.moduls; +import at.gv.egovernment.moa.id.advancedlogging.TransactionIDUtils; import at.gv.egovernment.moa.id.auth.exception.MOAIDException; import at.gv.egovernment.moa.id.commons.db.ex.MOADatabaseException; import at.gv.egovernment.moa.id.storage.AssertionStorage; @@ -34,6 +35,10 @@ public class RequestStorage { try { AssertionStorage storage = AssertionStorage.getInstance(); IRequest pendingRequest = storage.get(pendingReqID, IRequest.class); + + //set transactionID to Logger + TransactionIDUtils.setTransactionId(((IRequest)pendingRequest).getRequestID()); + return pendingRequest; } catch (MOADatabaseException e) { @@ -50,6 +55,9 @@ public class RequestStorage { if (pendingRequest instanceof IRequest) { storage.put(((IRequest)pendingRequest).getRequestID(), pendingRequest); + //set transactionID to Logger + TransactionIDUtils.setTransactionId(((IRequest)pendingRequest).getRequestID()); + } else { throw new MOAIDException("auth.20", null); |