From db52e4d66d60184d53a27ba4d6772461daacc03d Mon Sep 17 00:00:00 2001 From: tknall Date: Fri, 22 Mar 2013 08:57:51 +0000 Subject: Maintenance update (bugfixes, new features, cleanup...) Refer to /dok/RELEASE_NOTES-3.3.txt for further information. git-svn-id: https://joinup.ec.europa.eu/svn/pdf-as/pdf-as/trunk@931 7b5415b0-85f9-ee4d-85bd-d5d0c3b42d1c --- .../pdfas/framework/logging/StatisticData.java | 314 +++++++++++++++++++++ 1 file changed, 314 insertions(+) create mode 100644 pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/logging/StatisticData.java (limited to 'pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/logging/StatisticData.java') diff --git a/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/logging/StatisticData.java b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/logging/StatisticData.java new file mode 100644 index 0000000..3cb1c66 --- /dev/null +++ b/pdf-as-lib/src/main/java/at/gv/egiz/pdfas/framework/logging/StatisticData.java @@ -0,0 +1,314 @@ +/** + * Copyright 2006 by Know-Center, Graz, Austria + * PDF-AS has been contracted by the E-Government Innovation Center EGIZ, a + * joint initiative of the Federal Chancellery Austria 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.egiz.pdfas.framework.logging; + +import at.gv.egiz.pdfas.api.analyze.AnalyzeParameters; +import at.gv.egiz.pdfas.api.commons.Constants; +import at.gv.egiz.pdfas.api.sign.SignParameters; +import at.gv.egiz.pdfas.api.verify.VerifyAfterAnalysisParameters; +import at.gv.egiz.pdfas.api.verify.VerifyAfterReconstructXMLDsigParameters; +import at.gv.egiz.pdfas.api.verify.VerifyParameters; +import at.gv.egiz.pdfas.api.xmldsig.ReconstructXMLDsigAfterAnalysisParameters; +import at.gv.egiz.pdfas.api.xmldsig.ReconstructXMLDsigParameters; + +public class StatisticData { + + String operation; + String connector; + String signatureMode; + String signatureProfileId; + Integer fileSize; + Long duration; + String userAgent; + Exception exception; + + /** + * Creates new data for statistical logging purposes. + */ + public StatisticData() { + } + + /** + * Creates new data for statistical logging purposes. + * + * @param operation + * The operation (one of 'SIGN' and 'VERIFY'). + * @param connector + * The connector being used for the certain operation (one of {@link Constants#SIGNATURE_DEVICE_BKU}, + * {@link Constants#SIGNATURE_DEVICE_MOA}, {@link Constants#SIGNATURE_DEVICE_MOC}, + * {@link Constants#SIGNATURE_DEVICE_MOBILE}...) + * @param fileSize + * The size of the file being processed. + * @param signatureMode + * The signature mode (one of {@link Constants#SIGNATURE_TYPE_BINARY}, + * {@link Constants#SIGNATURE_TYPE_BINARY} or {@code null} in case of verification. + * @param duration + * The duration the certain operation took (in ms). + * @param userAgent + * The user agent String. + * @param errorCode + * The error code resulting from the current operation (0 means no error). + */ + public StatisticData(String operation, String connector, Integer fileSize, String signatureMode, Long duration, + String userAgent, Integer errorCode) { + this(); + this.operation = operation; + this.connector = connector; + this.signatureMode = signatureMode; + this.fileSize = fileSize; + this.duration = duration; + this.userAgent = userAgent; + } + + /** + * Creates new data for statistical logging purposes. + * + * @param operation + * The operation (one of 'SIGN' and 'VERIFY'). + * @param connector + * The connector being used for the certain operation (one of {@link Constants#SIGNATURE_DEVICE_BKU}, + * {@link Constants#SIGNATURE_DEVICE_MOA}, {@link Constants#SIGNATURE_DEVICE_MOC}, + * {@link Constants#SIGNATURE_DEVICE_MOBILE}...) + * @param fileSize + * The size of the file being processed. + */ + public StatisticData(String operation, String connector, Integer fileSize) { + this(); + this.operation = operation; + this.connector = connector; + this.fileSize = fileSize; + } + + /** + * Creates new data for statistical logging purposes. + * + * @param operation + * The operation (one of 'SIGN' and 'VERIFY'). + * @param connector + * The connector being used for the certain operation (one of {@link Constants#SIGNATURE_DEVICE_BKU}, + * {@link Constants#SIGNATURE_DEVICE_MOA}, {@link Constants#SIGNATURE_DEVICE_MOC}, + * {@link Constants#SIGNATURE_DEVICE_MOBILE}...) + * @param fileSize + * The size of the file being processed. + * @param signatureMode + * The signature mode (one of {@link Constants#SIGNATURE_TYPE_BINARY}, + * {@link Constants#SIGNATURE_TYPE_BINARY} or {@code null} in case of verification. + * @param duration + * The duration the certain operation took (in ms). + * @param userAgent + * The user agent String. + */ + public StatisticData(String operation, String connector, Integer fileSize, String signatureMode, Long duration, + String userAgent) { + this(operation, connector, fileSize, signatureMode, duration, userAgent, null); + } + + /** + * Creates statistical data based on given sign parameters. + * + * @param signParameters + * The given sign parameters. + */ + public StatisticData(SignParameters signParameters) { + this(); + operation = "SIGN"; + connector = signParameters.getSignatureDevice(); + signatureMode = signParameters.getSignatureType(); + fileSize = signParameters.getDocument().getLength(); + signatureProfileId = signParameters.getSignatureProfileId(); + } + + /** + * Creates statistical data based on given verify parameters. + * + * @param verifyParameters + * The given verify parameters. + */ + public StatisticData(VerifyParameters verifyParameters) { + this(); + operation = "VERIFY"; + connector = verifyParameters.getSignatureDevice(); + fileSize = verifyParameters.getDocument().getLength(); + } + + /** + * Creates statistical data based on given analyze parameters. + * + * @param varxdp + * The given analyze parameters. + */ + public StatisticData(AnalyzeParameters analyzeParameters) { + this(); + operation = "ANALYZE"; + fileSize = analyzeParameters.getDocument().getLength(); + } + + /** + * Creates statistical data based on given reconstruction parameters. + * + * @param rxdaap + * The given reconstruction parameters. + */ + public StatisticData(ReconstructXMLDsigAfterAnalysisParameters rxdaap) { + this(); + operation = "RECONSTRUCT"; + connector = rxdaap.getSignatureDevice(); + } + + /** + * Creates statistical data based on given reconstruction parameters. + * + * @param reconstructParameters + * The given reconstruction parameters. + */ + public StatisticData(ReconstructXMLDsigParameters reconstructParameters) { + this(); + operation = "RECONSTRUCT"; + fileSize = reconstructParameters.getDocument().getLength(); + connector = reconstructParameters.getSignatureDevice(); + } + + /** + * Creates statistical data based on given parameters. + * + * @param vaaParameters + * The given verify parameters after analysis. + */ + public StatisticData(VerifyAfterAnalysisParameters vaaParameters) { + this(); + operation = "VERIFY"; + connector = vaaParameters.getSignatureDevice(); + } + + /** + * Creates statistical data based on given verify parameters after reconstruction. + * + * @param varxdp + * The given verify parameters after reconstruction. + */ + public StatisticData(VerifyAfterReconstructXMLDsigParameters varxdp) { + this(); + operation = "VERIFY"; + connector = varxdp.getSignatureDevice(); + } + + /** + * Sets the current operation name. + * + * @param operation + * The operation name. + */ + public StatisticData setOperation(String operation) { + this.operation = operation; + return this; + } + + /** + * Sets the connector. + * + * @param connector + * The connector. + */ + public StatisticData setConnector(String connector) { + this.connector = connector; + return this; + } + + /** + * Sets the file size of the processed document. + * + * @param fileSize + * The file size in bytes. + */ + public StatisticData setFileSize(Integer fileSize) { + this.fileSize = fileSize; + return this; + } + + /** + * Sets the duration of the performed operation. + * + * @param duration + * The duration in ms. + */ + public StatisticData setDuration(Long duration) { + this.duration = duration; + return this; + } + + /** + * Sets the user agent identifier. + * + * @param userAgent + * The user agent identifier. + */ + public StatisticData setUserAgent(String userAgent) { + this.userAgent = userAgent; + return this; + } + + /** + * Sets the signature mode. + * + * @param signatureMode + * The signature mode (one of {@link Constants#SIGNATURE_TYPE_TEXTUAL} and + * {@link Constants#SIGNATURE_TYPE_BINARY}). + */ + public StatisticData setSignatureMode(String signatureMode) { + this.signatureMode = signatureMode; + return this; + } + + /** + * Sets the profile id. + * + * @param profileId + * The profile id. + */ + public StatisticData setSignatureProfileId(String signatureProfileId) { + this.signatureProfileId = signatureProfileId; + return this; + } + + /** + * Sets the exception that has been thrown. + * + * @param exception + * The exception. + */ + public StatisticData setException(Exception exception) { + this.exception = exception; + return this; + } + + /** + * Returns {@code true} if an error condition has been set, {@code false} otherwise. + * + * @return {@code true} in case of an error, {@code false} if not. + */ + public boolean isError() { + return exception != null; + } + +} -- cgit v1.2.3