-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae82c2a
commit 774ee37
Showing
13 changed files
with
1,645 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>at.asitplus.regkassen</groupId> | ||
<artifactId>regkassen-common</artifactId> | ||
<version>0.10</version> | ||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
<jackson.version>2.7.2</jackson.version> | ||
</properties> | ||
<dependencies> | ||
|
||
<!-- crypto library for handling certificates, AES encryptionm creating/verifying | ||
signatures REF: https://www.bouncycastle.org License: http://opensource.org/licenses/MIT --> | ||
<dependency> | ||
<groupId>org.bouncycastle</groupId> | ||
<artifactId>bcprov-jdk15on</artifactId> | ||
<version>1.52</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.bouncycastle</groupId> | ||
<artifactId>bcpkix-jdk15on</artifactId> | ||
<version>1.52</version> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-core</artifactId> | ||
<version>${jackson.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.dataformat</groupId> | ||
<artifactId>jackson-dataformat-xml</artifactId> | ||
<version>${jackson.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.datatype</groupId> | ||
<artifactId>jackson-datatype-joda</artifactId> | ||
<version>2.7.3</version> | ||
</dependency> | ||
|
||
|
||
<!-- Apache commons libraries for BASE64, BASE64, math operations etc. | ||
License: http://www.apache.org/licenses/LICENSE-2.0 --> | ||
<!--Ref: https://commons.apache.org/proper/commons-io/ --> | ||
<dependency> | ||
<groupId>commons-io</groupId> | ||
<artifactId>commons-io</artifactId> | ||
<version>2.4</version> | ||
</dependency> | ||
|
||
|
||
<!--Ref: https://commons.apache.org/proper/commons-math/ --> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-math3</artifactId> | ||
<version>3.4.1</version> | ||
</dependency> | ||
|
||
<!--Ref: https://commons.apache.org/proper/commons-codec/ --> | ||
<dependency> | ||
<groupId>commons-codec</groupId> | ||
<artifactId>commons-codec</artifactId> | ||
<version>1.10</version> | ||
</dependency> | ||
|
||
<!-- Use this version for Java 1.6 compatibility --> | ||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
<version>6.8.21</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.3</version> | ||
<configuration> | ||
<source>1.6</source> | ||
<target>1.6</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
|
||
</project> |
51 changes: 51 additions & 0 deletions
51
regkassen-common/src/main/java/at/asitplus/regkassen/common/MachineCodeValue.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright (C) 2015, 2016 | ||
* A-SIT Plus GmbH | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package at.asitplus.regkassen.common; | ||
|
||
/** | ||
* contains all types of values which are stored in the | ||
* QR-machine-code-representation | ||
*/ | ||
public enum MachineCodeValue { | ||
RK_SUITE(0), // Registrierkassenalgorithmuskennzeichen | ||
CASHBOX_ID(1), // Kassen-ID | ||
RECEIPT_IDENTIFIER(2), // Belegnummer | ||
RECEIPT_DATE_AND_TIME(3), // Beleg-Datum-Uhrzeit | ||
SUM_TAX_SET_NORMAL(4), // Betrag-Satz-Normal | ||
SUM_TAX_SET_ERMAESSIGT1(5), // Betrag-Satz-Ermaessigt-1 | ||
SUM_TAX_SET_ERMAESSIGT2(6), // Betrag-Satz-Ermaessigt-2 | ||
SUM_TAX_SET_NULL(7), // Betrag-Satz-Null | ||
SUM_TAX_SET_BESONDERS(8), // Betrag-Satz-Besonders | ||
ENCRYPTED_TURN_OVER_VALUE(9), // Stand-Umsatz-Zaehler-AES256-ICM | ||
CERTIFICATE_SERIAL_NUMBER_OR_COMPANYID_AND_KEYID(10), // Zertifikat-Seriennummer | ||
// (or Ordnungszahl | ||
// Unternehmen plus | ||
// KEY-ID) | ||
CHAINING_VALUE_PREVIOUS_RECEIPT(11), // Sig-Voriger-Beleg | ||
SIGNATURE_VALUE(12); // Signatur | ||
|
||
protected int index; | ||
|
||
public int getIndex() { | ||
return index; | ||
} | ||
|
||
MachineCodeValue(int index) { | ||
this.index = index; | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
regkassen-common/src/main/java/at/asitplus/regkassen/common/RKSuite.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* Copyright (C) 2015, 2016 | ||
* A-SIT Plus GmbH | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package at.asitplus.regkassen.common; | ||
|
||
public enum RKSuite { | ||
// RK Suite defined in Detailspezifikation/ABS 2 | ||
// suite for a closed system (closed systems are identified by the ZDA-ID | ||
// AT0) | ||
R1_AT0("1", "AT0", "ES256", "SHA-256", 8), | ||
R1_AT1("1", "AT1", "ES256", "SHA-256", 8), | ||
R1_AT2("1", "AT2", "ES256", "SHA-256", 8), | ||
R1_AT3("1", "AT3", "ES256", "SHA-256", 8), | ||
R1_AT4("1", "AT4", "ES256", "SHA-256", 8), | ||
R1_AT5("1", "AT5", "ES256", "SHA-256", 8), | ||
R1_AT6("1", "AT6", "ES256", "SHA-256", 8), | ||
R1_AT7("1", "AT7", "ES256", "SHA-256", 8), | ||
R1_AT8("1", "AT8", "ES256", "SHA-256", 8), | ||
R1_AT9("1", "AT9", "ES256", "SHA-256", 8), | ||
R1_AT10("1", "AT10", "ES256", "SHA-256", 8), | ||
|
||
// suite for an open system (in this case with the virtual ZDA identified by | ||
// AT100) | ||
R1_AT100("1", "AT100", "ES256", "SHA-256", 8); | ||
|
||
protected String suiteID; | ||
protected String zdaID; | ||
protected String jwsSignatureAlgorithm; | ||
protected String hashAlgorithmForPreviousSignatureValue; | ||
protected int numberOfBytesExtractedFromPrevSigHash; | ||
|
||
RKSuite(String suiteID, String zdaID, String jwsSignatureAlgorithm, | ||
String hashAlgorithmForPreviousSignatureValue, int numberOfBytesExtractedFromPrevSigHash) { | ||
this.suiteID = suiteID; | ||
this.zdaID = zdaID; | ||
this.jwsSignatureAlgorithm = jwsSignatureAlgorithm; | ||
this.hashAlgorithmForPreviousSignatureValue = hashAlgorithmForPreviousSignatureValue; | ||
this.numberOfBytesExtractedFromPrevSigHash = numberOfBytesExtractedFromPrevSigHash; | ||
} | ||
|
||
public String getSuiteID() { | ||
return "R" + suiteID + "-" + zdaID; | ||
} | ||
|
||
public String getZdaID() { | ||
return zdaID; | ||
} | ||
|
||
public String getJwsSignatureAlgorithm() { | ||
return jwsSignatureAlgorithm; | ||
} | ||
|
||
public String getHashAlgorithmForPreviousSignatureValue() { | ||
return hashAlgorithmForPreviousSignatureValue; | ||
} | ||
|
||
public int getNumberOfBytesExtractedFromPrevSigHash() { | ||
return numberOfBytesExtractedFromPrevSigHash; | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
regkassen-common/src/main/java/at/asitplus/regkassen/common/RKSuiteIdentifier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* Copyright (C) 2015, 2016 | ||
* A-SIT Plus GmbH | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package at.asitplus.regkassen.common; | ||
|
||
public enum RKSuiteIdentifier { | ||
// RK Suite defined in Detailspezifikation/ABS 2 | ||
R1("1", "ES256", "SHA-256", "SHA256withECDSA", "ECDSA", 8); | ||
|
||
public static final String[] SUPPORTED_PREFIXES = { | ||
"R1-AT" }; | ||
|
||
protected final String suiteID; | ||
protected final String jwsSignatureAlgorithm; | ||
protected final String javaSignatureAlgorithm; | ||
protected final String javaPublicKeySpec; | ||
|
||
protected final String hashAlgorithmForPreviousSignatureValue; | ||
protected final int numberOfBytesExtractedFromPrevSigHash; | ||
|
||
RKSuiteIdentifier(String suiteID, String jwsSignatureAlgorithm, | ||
String hashAlgorithmForPreviousSignatureValue, String javaSignatureAlgorithm, String javaPublicKeySpec, | ||
int numberOfBytesExtractedFromPrevSigHash) { | ||
this.suiteID = suiteID; | ||
this.jwsSignatureAlgorithm = jwsSignatureAlgorithm; | ||
this.hashAlgorithmForPreviousSignatureValue = hashAlgorithmForPreviousSignatureValue; | ||
this.numberOfBytesExtractedFromPrevSigHash = numberOfBytesExtractedFromPrevSigHash; | ||
this.javaSignatureAlgorithm = javaSignatureAlgorithm; | ||
this.javaPublicKeySpec = javaPublicKeySpec; | ||
} | ||
|
||
public String getJavaSignatureAlgorithm() { | ||
return javaSignatureAlgorithm; | ||
} | ||
|
||
public String getJavaPublicKeySpec() { | ||
return javaPublicKeySpec; | ||
} | ||
|
||
public String getSuiteID() { | ||
return "R" + suiteID; | ||
} | ||
|
||
public String getJwsSignatureAlgorithm() { | ||
return jwsSignatureAlgorithm; | ||
} | ||
|
||
public String getHashAlgorithmForPreviousSignatureValue() { | ||
return hashAlgorithmForPreviousSignatureValue; | ||
} | ||
|
||
public int getNumberOfBytesExtractedFromPrevSigHash() { | ||
return numberOfBytesExtractedFromPrevSigHash; | ||
} | ||
|
||
public static boolean isSupported(String rk) { | ||
return fromRKString(rk) != null; | ||
} | ||
|
||
public static RKSuiteIdentifier fromRKString(String rk) { | ||
if (rk == null || !prefixSupported(rk)) | ||
return null; | ||
try { | ||
String suiteID = rk.split("-")[0]; | ||
return RKSuiteIdentifier.valueOf(suiteID); | ||
} catch (Exception e) { | ||
return null; | ||
} | ||
} | ||
|
||
private static boolean prefixSupported(String mc) { | ||
if (mc == null) | ||
return false; | ||
for (String p : SUPPORTED_PREFIXES) { | ||
if (mc.startsWith(p)) | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
regkassen-common/src/main/java/at/asitplus/regkassen/common/SignatureDeviceType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright (C) 2015, 2016 | ||
* A-SIT Plus GmbH | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package at.asitplus.regkassen.common; | ||
|
||
public enum SignatureDeviceType { | ||
CERTIFICATE, | ||
PUBLIC_KEY; | ||
} |
33 changes: 33 additions & 0 deletions
33
regkassen-common/src/main/java/at/asitplus/regkassen/common/SignatureType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (C) 2015, 2016 | ||
* A-SIT Plus GmbH | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package at.asitplus.regkassen.common; | ||
|
||
public enum SignatureType { | ||
OFFLINE("Beim Erstellen des Belegs war die Sicherheitseinrichtung nicht funktionsfähig."), | ||
NORMAL("Formell valide Signatur"); | ||
|
||
private final String descrption; | ||
|
||
private SignatureType(String description) { | ||
this.descrption = description; | ||
} | ||
|
||
public String getDescrption() { | ||
return descrption; | ||
} | ||
} |
Oops, something went wrong.