diff options
author | Thomas <> | 2021-03-22 18:40:26 +0100 |
---|---|---|
committer | Thomas <> | 2021-03-22 18:40:26 +0100 |
commit | 578ad0d6bc408edf9e6c875156054374f5fd8337 (patch) | |
tree | 11ca8a04bd045e20d4b381fc76762d21b9e5abaa /moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api | |
parent | eb37b2c969c85ca966f0a0ad1d8b9941647a7f6a (diff) | |
download | moa-sig-578ad0d6bc408edf9e6c875156054374f5fd8337.tar.gz moa-sig-578ad0d6bc408edf9e6c875156054374f5fd8337.tar.bz2 moa-sig-578ad0d6bc408edf9e6c875156054374f5fd8337.zip |
change to EGIZ codestyle
Diffstat (limited to 'moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api')
7 files changed, 209 insertions, 204 deletions
diff --git a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiC.java b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiC.java index 759e910..d8bf4d9 100644 --- a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiC.java +++ b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiC.java @@ -4,11 +4,15 @@ import java.util.Collection; import java.util.List; public interface ASiC { - public ASiCFormat getFormat(); - public boolean isXAdES(); - public boolean isCAdES(); + ASiCFormat getFormat(); - public List<ASiCEntry> getSignaturesEntries(); - public Collection<ASiCEntry> getDataEntries(); - public List<ASiCEntry> getInformationEntries(); + boolean isXAdES(); + + boolean isCAdES(); + + List<ASiCEntry> getSignaturesEntries(); + + Collection<ASiCEntry> getDataEntries(); + + List<ASiCEntry> getInformationEntries(); } diff --git a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCConstants.java b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCConstants.java index 02baf40..b987346 100644 --- a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCConstants.java +++ b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCConstants.java @@ -4,6 +4,6 @@ package at.gv.egiz.asic.api; * Created by afitzek on 6/15/16. */ public interface ASiCConstants { - public static final String FILE_MIME_TYPE = "mimetype"; - public static final String FILE_META_INF = "META-INF/"; + String FILE_MIME_TYPE = "mimetype"; + String FILE_META_INF = "META-INF/"; } diff --git a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCEntry.java b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCEntry.java index 7c026cf..f0a9edd 100644 --- a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCEntry.java +++ b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCEntry.java @@ -7,32 +7,32 @@ import java.io.InputStream; */ public class ASiCEntry { - private String entryName; - private InputStream contents; - - public ASiCEntry() { - } - - public String getEntryName() { - return entryName; - } - - public void setEntryName(String entryName) { - this.entryName = entryName; - } - - public InputStream getContents() { - return contents; - } - - public void setContents(InputStream contents) { - this.contents = contents; - } - - @Override - public String toString() { - return "ASiCEntry{" + - "entryName='" + entryName + '\'' + - '}'; - } + private String entryName; + private InputStream contents; + + public ASiCEntry() { + } + + public String getEntryName() { + return entryName; + } + + public void setEntryName(String entryName) { + this.entryName = entryName; + } + + public InputStream getContents() { + return contents; + } + + public void setContents(InputStream contents) { + this.contents = contents; + } + + @Override + public String toString() { + return "ASiCEntry{" + + "entryName='" + entryName + '\'' + + '}'; + } } diff --git a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCFactory.java b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCFactory.java index 661e418..ccab9a4 100644 --- a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCFactory.java +++ b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCFactory.java @@ -1,16 +1,5 @@ package at.gv.egiz.asic.api; -import at.gv.egiz.asic.exceptions.ASiCException; -import at.gv.egiz.asic.impl.ASiCBaseFormatFactory; -import at.gv.egiz.asic.impl.ASiCExtendedFormatFactory; -import at.gv.egiz.asic.impl.ASiCSimpleFormatFactory; -import at.gv.egiz.asic.impl.ZipCommentReaderStream; -import at.gv.egovernment.moa.spss.MOAApplicationException; -import at.gv.egovernment.moa.spss.MOAException; -import org.apache.commons.io.IOUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -18,147 +7,158 @@ import java.io.InputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; +import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.gv.egiz.asic.impl.ASiCBaseFormatFactory; +import at.gv.egiz.asic.impl.ASiCExtendedFormatFactory; +import at.gv.egiz.asic.impl.ASiCSimpleFormatFactory; +import at.gv.egiz.asic.impl.ZipCommentReaderStream; +import at.gv.egovernment.moa.spss.MOAApplicationException; +import at.gv.egovernment.moa.spss.MOAException; + /** * Created by afitzek on 6/15/16. */ public class ASiCFactory { - private static final Logger logger = LoggerFactory.getLogger(ASiCFactory.class); - - private static final String MIMETYPE_FORMAT_E = "application/vnd.etsi.asic-e+zip"; - private static final String MIMETYPE_FORMAT_S = "application/vnd.etsi.asic-s+zip"; - - public static ASiC parseASiC(InputStream is, ASiCFormat format) throws MOAException { - - InputStream newInputStream = is; - - - // Try to determine the asic format! - if (!newInputStream.markSupported()) { - ByteArrayOutputStream asicContainer = new ByteArrayOutputStream(); - - try { - IOUtils.copy(newInputStream, asicContainer); - } catch (IOException e) { - throw new MOAApplicationException("asic.0003", null); - } - newInputStream = new ByteArrayInputStream(asicContainer.toByteArray()); - } - - String mimeTypeFile = null; - ZipCommentReaderStream commentReaderStream = new ZipCommentReaderStream(newInputStream); - byte[] buffer = new byte[8096]; - try { - while (commentReaderStream.read(buffer) >= 0) { - } - newInputStream.reset(); - } catch (IOException e) { - throw new MOAApplicationException("asic.0003", null); - } - - ZipInputStream zipInputStream = new ZipInputStream(newInputStream); - - try { - for (ZipEntry entry = zipInputStream.getNextEntry(); entry != null; entry = zipInputStream.getNextEntry()) { - String entryName = entry.getName(); - - if("mimetype".equalsIgnoreCase(entryName)) { - if(mimeTypeFile == null) { - mimeTypeFile = IOUtils.toString(zipInputStream, "UTF-8"); - } else { - logger.warn("multiple mimetype files found in archiv"); - } - } - } - newInputStream.reset(); - } catch (IOException e) { - throw new MOAApplicationException("asic.0007", null); - } - - String fileComment = commentReaderStream.getFileComment(); - ASiCFormat fileCommentFormat = null; - if (fileComment != null) { - logger.debug("Found file comment in ASiC {}", fileComment); - if(fileComment.startsWith("mimetype=")) { - String fileCommentMimeType = fileComment.substring("mimetype=".length()); - if(fileCommentMimeType.startsWith(MIMETYPE_FORMAT_E)) { - fileCommentFormat = ASiCFormat.ASiCE; - } else if(fileCommentMimeType.startsWith(MIMETYPE_FORMAT_S)) { - fileCommentFormat = ASiCFormat.ASiCS; - } - } - } else { - logger.info("No file comment in ASiC"); - } - - - ASiCFormat mimeTypeFileFormat = null; - if (mimeTypeFile != null) { - logger.debug("Found mimetype file in ASiC {}", mimeTypeFile); - if(MIMETYPE_FORMAT_E.equalsIgnoreCase(mimeTypeFile)) { - mimeTypeFileFormat = ASiCFormat.ASiCE; - } else if(MIMETYPE_FORMAT_S.equalsIgnoreCase(mimeTypeFile)) { - mimeTypeFileFormat = ASiCFormat.ASiCS; - } - } else { - logger.info("No mimetype file in ASiC"); - } - - if (format == null) { - if (fileCommentFormat != null && mimeTypeFileFormat != null) { - // both are set - if (fileCommentFormat == mimeTypeFileFormat) { - format = fileCommentFormat; - } else { - throw new MOAApplicationException("asic.0009", null); - } - } else if (fileCommentFormat != null) { - format = fileCommentFormat; - } else if (mimeTypeFileFormat != null) { - format = mimeTypeFileFormat; - } else { - throw new MOAApplicationException("asic.0008", null); - } - } else { - // format is provided, only check for missmatches - if (fileCommentFormat != null && fileCommentFormat != format) { - logger.warn("ASiC format missmatch file comment {} vs provided {}", fileCommentFormat, format); - throw new MOAApplicationException("asic.0009", null); - } - if (mimeTypeFileFormat != null && mimeTypeFileFormat != format) { - logger.warn("ASiC format missmatch mimetype file {} vs provided {}", mimeTypeFileFormat, format); - throw new MOAApplicationException("asic.0009", null); - } - - if (fileCommentFormat != null && mimeTypeFileFormat != null) { - // both are set - if (fileCommentFormat != mimeTypeFileFormat) { - logger.warn("ASiC format missmatch file comment {} vs mimetype file {}", fileCommentFormat, mimeTypeFileFormat); - throw new MOAApplicationException("asic.0009", null); - } - } - } + private static final Logger logger = LoggerFactory.getLogger(ASiCFactory.class); - ASiCBaseFormatFactory formatFactory = null; + private static final String MIMETYPE_FORMAT_E = "application/vnd.etsi.asic-e+zip"; + private static final String MIMETYPE_FORMAT_S = "application/vnd.etsi.asic-s+zip"; - if (format == null) { - throw new MOAApplicationException("asic.0008", null); + public static ASiC parseASiC(InputStream is, ASiCFormat format) throws MOAException { + + InputStream newInputStream = is; + + // Try to determine the asic format! + if (!newInputStream.markSupported()) { + final ByteArrayOutputStream asicContainer = new ByteArrayOutputStream(); + + try { + IOUtils.copy(newInputStream, asicContainer); + } catch (final IOException e) { + throw new MOAApplicationException("asic.0003", null); + } + newInputStream = new ByteArrayInputStream(asicContainer.toByteArray()); + } + + String mimeTypeFile = null; + final ZipCommentReaderStream commentReaderStream = new ZipCommentReaderStream(newInputStream); + final byte[] buffer = new byte[8096]; + try { + while (commentReaderStream.read(buffer) >= 0) { + } + newInputStream.reset(); + } catch (final IOException e) { + throw new MOAApplicationException("asic.0003", null); + } + + final ZipInputStream zipInputStream = new ZipInputStream(newInputStream); + + try { + for (ZipEntry entry = zipInputStream.getNextEntry(); entry != null; entry = zipInputStream + .getNextEntry()) { + final String entryName = entry.getName(); + + if ("mimetype".equalsIgnoreCase(entryName)) { + if (mimeTypeFile == null) { + mimeTypeFile = IOUtils.toString(zipInputStream, "UTF-8"); + } else { + logger.warn("multiple mimetype files found in archiv"); + } } + } + newInputStream.reset(); + } catch (final IOException e) { + throw new MOAApplicationException("asic.0007", null); + } - switch (format) { - case ASiCE: - formatFactory = new ASiCExtendedFormatFactory(); - break; - case ASiCS: - formatFactory = new ASiCSimpleFormatFactory(); - break; + final String fileComment = commentReaderStream.getFileComment(); + ASiCFormat fileCommentFormat = null; + if (fileComment != null) { + logger.debug("Found file comment in ASiC {}", fileComment); + if (fileComment.startsWith("mimetype=")) { + final String fileCommentMimeType = fileComment.substring("mimetype=".length()); + if (fileCommentMimeType.startsWith(MIMETYPE_FORMAT_E)) { + fileCommentFormat = ASiCFormat.ASiCE; + } else if (fileCommentMimeType.startsWith(MIMETYPE_FORMAT_S)) { + fileCommentFormat = ASiCFormat.ASiCS; } + } + } else { + logger.info("No file comment in ASiC"); + } - if (formatFactory == null) { - throw new MOAApplicationException("asic.0008", null); + ASiCFormat mimeTypeFileFormat = null; + if (mimeTypeFile != null) { + logger.debug("Found mimetype file in ASiC {}", mimeTypeFile); + if (MIMETYPE_FORMAT_E.equalsIgnoreCase(mimeTypeFile)) { + mimeTypeFileFormat = ASiCFormat.ASiCE; + } else if (MIMETYPE_FORMAT_S.equalsIgnoreCase(mimeTypeFile)) { + mimeTypeFileFormat = ASiCFormat.ASiCS; + } + } else { + logger.info("No mimetype file in ASiC"); + } + + if (format == null) { + if (fileCommentFormat != null && mimeTypeFileFormat != null) { + // both are set + if (fileCommentFormat == mimeTypeFileFormat) { + format = fileCommentFormat; + } else { + throw new MOAApplicationException("asic.0009", null); } + } else if (fileCommentFormat != null) { + format = fileCommentFormat; + } else if (mimeTypeFileFormat != null) { + format = mimeTypeFileFormat; + } else { + throw new MOAApplicationException("asic.0008", null); + } + } else { + // format is provided, only check for missmatches + if (fileCommentFormat != null && fileCommentFormat != format) { + logger.warn("ASiC format missmatch file comment {} vs provided {}", fileCommentFormat, format); + throw new MOAApplicationException("asic.0009", null); + } + if (mimeTypeFileFormat != null && mimeTypeFileFormat != format) { + logger.warn("ASiC format missmatch mimetype file {} vs provided {}", mimeTypeFileFormat, format); + throw new MOAApplicationException("asic.0009", null); + } + + if (fileCommentFormat != null && mimeTypeFileFormat != null) { + // both are set + if (fileCommentFormat != mimeTypeFileFormat) { + logger.warn("ASiC format missmatch file comment {} vs mimetype file {}", fileCommentFormat, + mimeTypeFileFormat); + throw new MOAApplicationException("asic.0009", null); + } + } + } + + ASiCBaseFormatFactory formatFactory = null; - return formatFactory.createASiC(newInputStream); + if (format == null) { + throw new MOAApplicationException("asic.0008", null); } + switch (format) { + case ASiCE: + formatFactory = new ASiCExtendedFormatFactory(); + break; + case ASiCS: + formatFactory = new ASiCSimpleFormatFactory(); + break; + } + + if (formatFactory == null) { + throw new MOAApplicationException("asic.0008", null); + } + + return formatFactory.createASiC(newInputStream); + } + } diff --git a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCFormat.java b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCFormat.java index 8106944..cc72f58 100644 --- a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCFormat.java +++ b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCFormat.java @@ -4,6 +4,6 @@ package at.gv.egiz.asic.api; * Created by Andreas Fitzek on 6/15/16. */ public enum ASiCFormat { - ASiCS, - ASiCE + ASiCS, + ASiCE } diff --git a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCVerificationResult.java b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCVerificationResult.java index ce8f374..a29b5c2 100644 --- a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCVerificationResult.java +++ b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCVerificationResult.java @@ -1,41 +1,43 @@ package at.gv.egiz.asic.api; +import java.util.ArrayList; +import java.util.List; + import at.gv.egiz.asic.impl.AsicSignedFilesContainer; import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureResponse; import at.gv.egovernment.moa.spss.api.xmlverify.VerifyXMLSignatureResponse; -import java.util.ArrayList; -import java.util.List; - /** * Created by Andreas Fitzek on 6/16/16. */ public class ASiCVerificationResult { - private List<AsicSignedFilesContainer> signedFiles = new ArrayList<AsicSignedFilesContainer>(); + private List<AsicSignedFilesContainer> signedFiles = new ArrayList<>(); - private VerifyCMSSignatureResponse cmsResult = null; - private VerifyXMLSignatureResponse xmlResult = null; + private VerifyCMSSignatureResponse cmsResult = null; + private VerifyXMLSignatureResponse xmlResult = null; - public ASiCVerificationResult(List<AsicSignedFilesContainer> references, VerifyCMSSignatureResponse cmsResult) { - this.signedFiles = references; - this.cmsResult = cmsResult; - } + public ASiCVerificationResult(List<AsicSignedFilesContainer> references, + VerifyCMSSignatureResponse cmsResult) { + this.signedFiles = references; + this.cmsResult = cmsResult; + } - public ASiCVerificationResult(List<AsicSignedFilesContainer> references, VerifyXMLSignatureResponse xmlResult) { - this.signedFiles = references; - this.xmlResult = xmlResult; - } + public ASiCVerificationResult(List<AsicSignedFilesContainer> references, + VerifyXMLSignatureResponse xmlResult) { + this.signedFiles = references; + this.xmlResult = xmlResult; + } - public List<AsicSignedFilesContainer> getSignedFiles() { - return signedFiles; - } + public List<AsicSignedFilesContainer> getSignedFiles() { + return signedFiles; + } - public VerifyXMLSignatureResponse getXmlResult() { - return xmlResult; - } + public VerifyXMLSignatureResponse getXmlResult() { + return xmlResult; + } - public VerifyCMSSignatureResponse getCmsResult() { - return cmsResult; - } + public VerifyCMSSignatureResponse getCmsResult() { + return cmsResult; + } } diff --git a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCVerifier.java b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCVerifier.java index 77bc61d..fc8de87 100644 --- a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCVerifier.java +++ b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/api/ASiCVerifier.java @@ -1,16 +1,15 @@ package at.gv.egiz.asic.api; -import at.gv.egovernment.moa.spss.MOAException; -import at.gv.egovernment.moa.spss.api.cmsverify.VerifyCMSSignatureResponse; - import java.util.Date; import java.util.List; +import at.gv.egovernment.moa.spss.MOAException; + /** * Created by Andreas Fitzek on 6/15/16. */ public interface ASiCVerifier { - public List<ASiCVerificationResult> verify(ASiC asic, String trustProfileID, Date date) throws MOAException; + List<ASiCVerificationResult> verify(ASiC asic, String trustProfileID, Date date) throws MOAException; } |