diff options
author | Tobias Kellner <tobias.kellner@iaik.tugraz.at> | 2014-12-03 18:14:21 +0100 |
---|---|---|
committer | Tobias Kellner <tobias.kellner@iaik.tugraz.at> | 2014-12-03 18:14:21 +0100 |
commit | d74a1c548cdc9c1617810779deb5aab6aa3c59a2 (patch) | |
tree | 989ff19dbf4333109d23e25998304b5bc911d926 /pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit | |
parent | 8e56cd2c9a300f7f9251263d6aceb2b00453324b (diff) | |
download | pdf-over-d74a1c548cdc9c1617810779deb5aab6aa3c59a2.tar.gz pdf-over-d74a1c548cdc9c1617810779deb5aab6aa3c59a2.tar.bz2 pdf-over-d74a1c548cdc9c1617810779deb5aab6aa3c59a2.zip |
Don't log all requests/responses
Diffstat (limited to 'pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit')
-rw-r--r-- | pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4BKUSLConnector.java | 289 |
1 files changed, 145 insertions, 144 deletions
diff --git a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4BKUSLConnector.java b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4BKUSLConnector.java index 33221285..89ec7331 100644 --- a/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4BKUSLConnector.java +++ b/pdf-over-signer/pdf-over-sigpdfas4/src/main/java/at/asit/pdfover/signer/pdfas/PdfAs4BKUSLConnector.java @@ -1,144 +1,145 @@ -/*
- * Copyright 2012 by A-SIT, Secure Information Technology Center Austria
- *
- * 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://joinup.ec.europa.eu/software/page/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.
- */
-package at.asit.pdfover.signer.pdfas;
-
-// Imports
-import javax.xml.bind.JAXBElement;
-import javax.xml.bind.JAXBException;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import at.asit.pdfover.signator.BkuSlConnector;
-import at.asit.pdfover.signator.SignatureException;
-import at.asit.pdfover.signer.pdfas.exceptions.PdfAs4SLRequestException;
-import at.gv.egiz.pdfas.common.exceptions.PDFIOException;
-import at.gv.egiz.pdfas.common.exceptions.PdfAsException;
-import at.gv.egiz.pdfas.common.exceptions.SLPdfAsException;
-import at.gv.egiz.pdfas.lib.api.sign.SignParameter;
-import at.gv.egiz.sl.schema.CreateCMSSignatureResponseType;
-import at.gv.egiz.sl.schema.ErrorResponseType;
-import at.gv.egiz.sl.schema.InfoboxReadRequestType;
-import at.gv.egiz.sl.schema.InfoboxReadResponseType;
-import at.gv.egiz.sl.util.BaseSLConnector;
-import at.gv.egiz.sl.util.RequestPackage;
-import at.gv.egiz.sl.util.SLMarschaller;
-
-/**
- *
- */
-public class PdfAs4BKUSLConnector extends BaseSLConnector {
- /**
- * SLF4J Logger instance
- **/
- private static final Logger log = LoggerFactory
- .getLogger(PdfAs4BKUSLConnector.class);
-
- private BkuSlConnector connector;
-
- /**
- * Constructor
- * @param connector the BKU SL Connector
- */
- public PdfAs4BKUSLConnector(BkuSlConnector connector) {
- this.connector = connector;
- }
-
-
- /* (non-Javadoc)
- * @see at.gv.egiz.sl.util.ISLConnector#sendInfoboxReadRequest(at.gv.egiz.sl.schema.InfoboxReadRequestType, at.gv.egiz.pdfas.lib.api.sign.SignParameter)
- */
- @Override
- public InfoboxReadResponseType sendInfoboxReadRequest(
- InfoboxReadRequestType request, SignParameter parameter)
- throws PdfAsException {
- JAXBElement<?> element = null;
- try {
- String slRequestString = SLMarschaller.marshalToString(this.of.createInfoboxReadRequest(request));
- log.trace(slRequestString);
-
- PdfAs4SLRequest slRequest = new PdfAs4SLRequest(slRequestString, null);
- String slResponse = this.connector.handleSLRequest(slRequest).getSLRespone();
-
- element = (JAXBElement<?>) SLMarschaller
- .unmarshalFromString(slResponse);
- } catch (JAXBException e) {
- throw new PDFIOException("error.pdf.io.03", e);
- } catch (PdfAs4SLRequestException e) {
- throw new PDFIOException("error.pdf.io.03", e);
- } catch (SignatureException e) {
- throw new PDFIOException("error.pdf.io.03", e);
- }
-
- if (element == null) {
- throw new PDFIOException("error.pdf.io.04");
- }
-
- if (element.getValue() instanceof InfoboxReadResponseType) {
- InfoboxReadResponseType infoboxReadResponseType = (InfoboxReadResponseType) element
- .getValue();
- return infoboxReadResponseType;
- } else if (element.getValue() instanceof ErrorResponseType) {
- ErrorResponseType errorResponseType = (ErrorResponseType) element
- .getValue();
- throw new SLPdfAsException(errorResponseType.getErrorCode(),
- errorResponseType.getInfo());
- }
- throw new PdfAsException("error.pdf.io.03");
- }
-
- /* (non-Javadoc)
- * @see at.gv.egiz.sl.util.ISLConnector#sendCMSRequest(at.gv.egiz.sl.util.RequestPackage, at.gv.egiz.pdfas.lib.api.sign.SignParameter)
- */
- @Override
- public CreateCMSSignatureResponseType sendCMSRequest(RequestPackage pack,
- SignParameter parameter) throws PdfAsException {
- JAXBElement<?> element = null;
- try {
- String slRequestString = SLMarschaller.marshalToString(this.of.createCreateCMSSignatureRequest(pack.getRequestType()));
- log.debug(slRequestString);
-
- PdfAs4SLRequest slRequest = new PdfAs4SLRequest(slRequestString, pack.getSignatureData());
- String slResponse = this.connector.handleSLRequest(slRequest).getSLRespone();
-
- element = (JAXBElement<?>) SLMarschaller
- .unmarshalFromString(slResponse);
- } catch (JAXBException e) {
- throw new PDFIOException("error.pdf.io.03", e);
- } catch (PdfAs4SLRequestException e) {
- throw new PDFIOException("error.pdf.io.03", e);
- } catch (SignatureException e) {
- throw new PDFIOException("error.pdf.io.03", e);
- }
-
- if (element == null) {
- throw new PDFIOException("error.pdf.io.05");
- }
-
- if (element.getValue() instanceof CreateCMSSignatureResponseType) {
- CreateCMSSignatureResponseType createCMSSignatureResponseType = (CreateCMSSignatureResponseType) element
- .getValue();
- log.debug(createCMSSignatureResponseType.toString());
- return createCMSSignatureResponseType;
- } else if (element.getValue() instanceof ErrorResponseType) {
- ErrorResponseType errorResponseType = (ErrorResponseType) element
- .getValue();
- throw new SLPdfAsException(errorResponseType.getErrorCode(),
- errorResponseType.getInfo());
- }
- throw new PdfAsException("error.pdf.io.03");
- }
-}
+/* + * Copyright 2012 by A-SIT, Secure Information Technology Center Austria + * + * 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://joinup.ec.europa.eu/software/page/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. + */ +package at.asit.pdfover.signer.pdfas; + +// Imports +import javax.xml.bind.JAXBElement; +import javax.xml.bind.JAXBException; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.asit.pdfover.signator.BkuSlConnector; +import at.asit.pdfover.signator.SignatureException; +import at.asit.pdfover.signer.pdfas.exceptions.PdfAs4SLRequestException; +import at.gv.egiz.pdfas.common.exceptions.PDFIOException; +import at.gv.egiz.pdfas.common.exceptions.PdfAsException; +import at.gv.egiz.pdfas.common.exceptions.SLPdfAsException; +import at.gv.egiz.pdfas.lib.api.sign.SignParameter; +import at.gv.egiz.sl.schema.CreateCMSSignatureResponseType; +import at.gv.egiz.sl.schema.ErrorResponseType; +import at.gv.egiz.sl.schema.InfoboxReadRequestType; +import at.gv.egiz.sl.schema.InfoboxReadResponseType; +import at.gv.egiz.sl.util.BaseSLConnector; +import at.gv.egiz.sl.util.RequestPackage; +import at.gv.egiz.sl.util.SLMarschaller; + +/** + * + */ +public class PdfAs4BKUSLConnector extends BaseSLConnector { + /** + * SLF4J Logger instance + **/ + @SuppressWarnings("unused") + private static final Logger log = LoggerFactory + .getLogger(PdfAs4BKUSLConnector.class); + + private BkuSlConnector connector; + + /** + * Constructor + * @param connector the BKU SL Connector + */ + public PdfAs4BKUSLConnector(BkuSlConnector connector) { + this.connector = connector; + } + + + /* (non-Javadoc) + * @see at.gv.egiz.sl.util.ISLConnector#sendInfoboxReadRequest(at.gv.egiz.sl.schema.InfoboxReadRequestType, at.gv.egiz.pdfas.lib.api.sign.SignParameter) + */ + @Override + public InfoboxReadResponseType sendInfoboxReadRequest( + InfoboxReadRequestType request, SignParameter parameter) + throws PdfAsException { + JAXBElement<?> element = null; + try { + String slRequestString = SLMarschaller.marshalToString(this.of.createInfoboxReadRequest(request)); + //log.trace(slRequestString); + + PdfAs4SLRequest slRequest = new PdfAs4SLRequest(slRequestString, null); + String slResponse = this.connector.handleSLRequest(slRequest).getSLRespone(); + + element = (JAXBElement<?>) SLMarschaller + .unmarshalFromString(slResponse); + } catch (JAXBException e) { + throw new PDFIOException("error.pdf.io.03", e); + } catch (PdfAs4SLRequestException e) { + throw new PDFIOException("error.pdf.io.03", e); + } catch (SignatureException e) { + throw new PDFIOException("error.pdf.io.03", e); + } + + if (element == null) { + throw new PDFIOException("error.pdf.io.04"); + } + + if (element.getValue() instanceof InfoboxReadResponseType) { + InfoboxReadResponseType infoboxReadResponseType = (InfoboxReadResponseType) element + .getValue(); + return infoboxReadResponseType; + } else if (element.getValue() instanceof ErrorResponseType) { + ErrorResponseType errorResponseType = (ErrorResponseType) element + .getValue(); + throw new SLPdfAsException(errorResponseType.getErrorCode(), + errorResponseType.getInfo()); + } + throw new PdfAsException("error.pdf.io.03"); + } + + /* (non-Javadoc) + * @see at.gv.egiz.sl.util.ISLConnector#sendCMSRequest(at.gv.egiz.sl.util.RequestPackage, at.gv.egiz.pdfas.lib.api.sign.SignParameter) + */ + @Override + public CreateCMSSignatureResponseType sendCMSRequest(RequestPackage pack, + SignParameter parameter) throws PdfAsException { + JAXBElement<?> element = null; + try { + String slRequestString = SLMarschaller.marshalToString(this.of.createCreateCMSSignatureRequest(pack.getRequestType())); + //log.trace(slRequestString); + + PdfAs4SLRequest slRequest = new PdfAs4SLRequest(slRequestString, pack.getSignatureData()); + String slResponse = this.connector.handleSLRequest(slRequest).getSLRespone(); + + element = (JAXBElement<?>) SLMarschaller + .unmarshalFromString(slResponse); + } catch (JAXBException e) { + throw new PDFIOException("error.pdf.io.03", e); + } catch (PdfAs4SLRequestException e) { + throw new PDFIOException("error.pdf.io.03", e); + } catch (SignatureException e) { + throw new PDFIOException("error.pdf.io.03", e); + } + + if (element == null) { + throw new PDFIOException("error.pdf.io.05"); + } + + if (element.getValue() instanceof CreateCMSSignatureResponseType) { + CreateCMSSignatureResponseType createCMSSignatureResponseType = (CreateCMSSignatureResponseType) element + .getValue(); + //log.trace(createCMSSignatureResponseType.toString()); + return createCMSSignatureResponseType; + } else if (element.getValue() instanceof ErrorResponseType) { + ErrorResponseType errorResponseType = (ErrorResponseType) element + .getValue(); + throw new SLPdfAsException(errorResponseType.getErrorCode(), + errorResponseType.getInfo()); + } + throw new PdfAsException("error.pdf.io.03"); + } +} |