public class CashBoxUtils extends Object
Constructor and Description |
---|
CashBoxUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
calcCheckSumFromKey(String base64AESKey,
int numberOfBytes)
Calculation of check sum
|
static boolean |
checkReceiptForDamagedSigatureCreationDevice(String jwsCompactRepresentation)
check whether the JWS compact representation of signed receipt contains indicator for damaged signature creation device
|
static SecretKey |
createAESKey()
Generates a random AES key for encrypting/decrypting the turnover value
ATTENTION: In a real cash box this key would be generated during the init process and stored in a secure area
|
static String |
createAESKeyBase64() |
static long |
decryptTurnOverCounter(String encryptedTurnOverCounterBase64,
String hashAlgorithm,
String cashBoxIDUTF8String,
String receiptIdentifierUTF8String,
SecretKey aesKey)
decrypt the turnover counter with the given AES key, and parameters for IV creation
Ref: Detailspezifikation Abs 8/Abs 9/Abs 10
|
static long |
decryptTurnOverCounter(String encryptedTurnOverCounterBase64,
String hashAlgorithm,
String cashBoxIDUTF8String,
String receiptIdentifierUTF8String,
String aesKeyBase64) |
static double |
getDoubleFromTaxSet(String taxSetValue)
get double value from arbitrary String represent a double (0,00) or (0.00)
|
static String |
getJWSCompactRepresentationFromQRMachineCodeRepresentation(String qrMachineCodeRepresentation)
convert QR-machine-code representation of signed receipt to JWS compact representation
|
static String |
getPayloadFromQRCodeRepresentation(String qrCodeRepresentation)
extract the payload of the QR-Code (remove signature value)
|
static String |
getQRCodeRepresentationFromJWSCompactRepresentation(String jwsCompactRepresentationOfReceipt)
convert JWS compact representation to QR-machine-code representation of signed receipt
|
static double |
getTaxSetTurnOverSumFromQRMachineCodeRepresentation(String qrMachineCodeRepresentation,
boolean calcAbsValue)
get sum of all tax-set turnover values from QR-machine-code-representation of signed receipt
|
static String |
getValueFromMachineCode(String machineCodeRepresentation,
MachineCodeValue machineCodeValue)
get a value from the machine code representation
|
static boolean |
isJWSCompactRepStornoReceipt(String jwsCompactRepresentation)
determine wheter current receipt is "Stornobuchung", check via encrypted turnover value, (BASE64 encoding of STO)
|
static boolean |
isJWSCompactRepTrainingReceipt(String jwsCompactRepresentation)
determine wheter current receipt is "Trainingsbuchung", check via encrypted turnover value, (BASE64 encoding of TRA)
|
static boolean |
isQRCodeRepStornoReceipt(String qrMachineCodeRepresentation) |
static boolean |
isQRCodeRepTrainingReceipt(String qrMachineCodeRepresentation)
see above, same method, here: for machine code rep
|
static X509Certificate |
parseCertificate(String base64EncodedCertificate)
extract certificates from DEP Export Format String representation
|
static List<X509Certificate> |
parseCertificates(String[] base64EncodedCertificates)
extract certificates from DEP Export Format String representation
|
public static SecretKey createAESKey()
public static String createAESKeyBase64()
public static String calcCheckSumFromKey(String base64AESKey, int numberOfBytes)
base64AESKey
- numberOfBytes
- public static String getValueFromMachineCode(String machineCodeRepresentation, MachineCodeValue machineCodeValue)
machineCodeRepresentation
- machinecode representation (QR or OCR code)machineCodeValue
- which value? e.g. signature value, rk-suite etc.public static String getQRCodeRepresentationFromJWSCompactRepresentation(String jwsCompactRepresentationOfReceipt)
jwsCompactRepresentationOfReceipt
- JWS compact representation of signed receiptpublic static String getPayloadFromQRCodeRepresentation(String qrCodeRepresentation)
qrCodeRepresentation
- the QR-machine-code-representation of signed receiptpublic static String getJWSCompactRepresentationFromQRMachineCodeRepresentation(String qrMachineCodeRepresentation)
qrMachineCodeRepresentation
- the QR-machine-code-representation of signed receiptpublic static long decryptTurnOverCounter(String encryptedTurnOverCounterBase64, String hashAlgorithm, String cashBoxIDUTF8String, String receiptIdentifierUTF8String, String aesKeyBase64) throws Exception
Exception
public static long decryptTurnOverCounter(String encryptedTurnOverCounterBase64, String hashAlgorithm, String cashBoxIDUTF8String, String receiptIdentifierUTF8String, SecretKey aesKey) throws Exception
encryptedTurnOverCounterBase64
- encrypted turnover counterhashAlgorithm
- hash-algorithm used to generate IVcashBoxIDUTF8String
- cashbox-id, required for IV creationreceiptIdentifierUTF8String
- receiptidentifier, required for IV creationaesKey
- aes keyException
public static double getDoubleFromTaxSet(String taxSetValue) throws Exception
taxSetValue
- double value as StringException
public static boolean checkReceiptForDamagedSigatureCreationDevice(String jwsCompactRepresentation)
jwsCompactRepresentation
- JWS compact representation of signed receiptpublic static double getTaxSetTurnOverSumFromQRMachineCodeRepresentation(String qrMachineCodeRepresentation, boolean calcAbsValue) throws Exception
qrMachineCodeRepresentation
- QR-machine-code-representation of signed receiptcalcAbsValue
- flag which indicates whether abs(value) should be used, if set, this can be used to check whether
the sum is zero. this is needed for checking the first receipt of the DEP or the first receipt after
recovering from a failed signature creation device.Exception
public static X509Certificate parseCertificate(String base64EncodedCertificate) throws CertificateException
base64EncodedCertificate
- BASE64 encoded DER-encoded-certificateCertificateException
public static List<X509Certificate> parseCertificates(String[] base64EncodedCertificates) throws CertificateException
base64EncodedCertificates
- BASE64 encoded DER-encoded-certificatesCertificateException
public static boolean isJWSCompactRepTrainingReceipt(String jwsCompactRepresentation)
jwsCompactRepresentation
- JWS compact representation of signed receiptpublic static boolean isQRCodeRepTrainingReceipt(String qrMachineCodeRepresentation)
qrMachineCodeRepresentation
- public static boolean isJWSCompactRepStornoReceipt(String jwsCompactRepresentation)
jwsCompactRepresentation
- JWS compact representation of signed receiptpublic static boolean isQRCodeRepStornoReceipt(String qrMachineCodeRepresentation)
Copyright © 2021. All rights reserved.