diff options
author | CGantert345 <57003061+CGantert345@users.noreply.github.com> | 2024-06-18 15:42:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-18 15:42:51 +0200 |
commit | 6b9254296a5b3b323c2e103db40865c01ffad005 (patch) | |
tree | a02e7adfe7c44ab01feaf94cd26689f9e09bfc62 /src | |
parent | Merge pull request #81 from UnionInternationalCheminsdeFer/fix_test_for_year_with_feb29 (diff) | |
parent | Create MAVticketTest.java (diff) | |
download | UIC-barcode-6b9254296a5b3b323c2e103db40865c01ffad005.tar UIC-barcode-6b9254296a5b3b323c2e103db40865c01ffad005.tar.gz UIC-barcode-6b9254296a5b3b323c2e103db40865c01ffad005.tar.bz2 UIC-barcode-6b9254296a5b3b323c2e103db40865c01ffad005.tar.lz UIC-barcode-6b9254296a5b3b323c2e103db40865c01ffad005.tar.xz UIC-barcode-6b9254296a5b3b323c2e103db40865c01ffad005.tar.zst UIC-barcode-6b9254296a5b3b323c2e103db40865c01ffad005.zip |
Diffstat (limited to '')
93 files changed, 590 insertions, 410 deletions
diff --git a/src/main/java/org/uic/barcode/Decoder.java b/src/main/java/org/uic/barcode/Decoder.java index d9f20ff..1e0a02d 100644 --- a/src/main/java/org/uic/barcode/Decoder.java +++ b/src/main/java/org/uic/barcode/Decoder.java @@ -56,7 +56,17 @@ public class Decoder { /** The data. */
byte[] data = null;
+ private Provider defaultProvider = null;
+
+ public Provider getDefaultProvider() {
+ return defaultProvider;
+ }
+
+ public void setDefaultProvider(Provider defaultProvider) {
+ this.defaultProvider = defaultProvider;
+ }
+
/**
* Instantiates a new decoder.
*
@@ -67,6 +77,11 @@ public class Decoder { */
public Decoder (byte[] data) throws IOException, EncodingFormatException, DataFormatException {
this.data = data;
+
+ if (defaultProvider == null) {
+ defaultProvider = SecurityUtils.getDefaultProvider();
+ }
+
decode(data);
}
@@ -86,22 +101,7 @@ public class Decoder { * @deprecated
*/
public int validateLevel1(PublicKey key) throws InvalidKeyException, NoSuchAlgorithmException, SignatureException, IllegalArgumentException, UnsupportedOperationException, IOException, EncodingFormatException {
- if (dynamicFrame != null) {
- return dynamicFrame.validateLevel1(key) ;
- } else if (staticFrame != null) {
- if (staticFrame.verifyByAlgorithmOid(key,null)) {
- return Constants.LEVEL1_VALIDATION_OK;
- } else {
- return Constants.LEVEL1_VALIDATION_FRAUD;
- }
- } else if (ssbFrame!= null) {
- if (ssbFrame.verifyByAlgorithmOid(key,null, null)) {
- return Constants.LEVEL1_VALIDATION_OK;
- } else {
- return Constants.LEVEL1_VALIDATION_FRAUD;
- }
- }
- return Constants.LEVEL1_VALIDATION_NO_SIGNATURE;
+ return validateLevel1(key,null, defaultProvider);
}
/**
@@ -120,22 +120,7 @@ public class Decoder { * @deprecated
*/
public int validateLevel1(PublicKey key, String signingAlg) throws InvalidKeyException, NoSuchAlgorithmException, SignatureException, IllegalArgumentException, UnsupportedOperationException, IOException, EncodingFormatException {
- if (dynamicFrame != null ) {
- return dynamicFrame.validateLevel1(key, signingAlg) ;
- } else if (staticFrame != null) {
- if (staticFrame.verifyByAlgorithmOid(key,signingAlg)) {
- return Constants.LEVEL1_VALIDATION_OK;
- } else {
- return Constants.LEVEL1_VALIDATION_FRAUD;
- }
- } else if (ssbFrame!= null) {
- if (ssbFrame.verifyByAlgorithmOid(key,signingAlg, null)) {
- return Constants.LEVEL1_VALIDATION_OK;
- } else {
- return Constants.LEVEL1_VALIDATION_FRAUD;
- }
- }
- return Constants.LEVEL1_VALIDATION_NO_SIGNATURE;
+ return validateLevel1(key, signingAlg, defaultProvider);
}
/**
@@ -184,11 +169,7 @@ public class Decoder { * @deprecated
*/
public int validateLevel2() throws EncodingFormatException {
- if (!isStaticHeader(data) && dynamicFrame != null) {
- return dynamicFrame.validateLevel2() ;
- } else {
- return Constants.LEVEL2_VALIDATION_NO_SIGNATURE;
- }
+ return validateLevel2(defaultProvider);
}
/*
diff --git a/src/main/java/org/uic/barcode/Encoder.java b/src/main/java/org/uic/barcode/Encoder.java index 3eb2faf..e9874cf 100644 --- a/src/main/java/org/uic/barcode/Encoder.java +++ b/src/main/java/org/uic/barcode/Encoder.java @@ -29,6 +29,7 @@ import org.uic.barcode.ticket.EncodingFormatException; import org.uic.barcode.ticket.UicRailTicketCoder;
import org.uic.barcode.ticket.api.spec.IUicRailTicket;
import org.uic.barcode.utils.ECKeyEncoder;
+import org.uic.barcode.utils.SecurityUtils;
/**
@@ -59,6 +60,17 @@ public class Encoder { /** The UIC bar code type SSB. */
public static String UIC_BARCODE_TYPE_SSB = "UIC_SSB";
+ private Provider defaultProvider = null;
+
+
+ public Provider getDefaultProvider() {
+ return defaultProvider;
+ }
+
+ public void setDefaultProvider(Provider defaultProvider) {
+ this.defaultProvider = defaultProvider;
+ }
+
/**
* Instantiates a new encoder.
*
@@ -72,6 +84,10 @@ public class Encoder { */
public Encoder(IUicRailTicket ticket, TicketLayout layout, String barcodeType, int version, int fcbVersion) throws IOException, EncodingFormatException {
+ if (defaultProvider == null) {
+ defaultProvider = SecurityUtils.getDefaultProvider();
+ }
+
if (barcodeType == UIC_BARCODE_TYPE_CLASSIC) {
staticFrame = new StaticFrame();
@@ -145,6 +161,9 @@ public class Encoder { */
public Encoder(byte[] level1DataBin, byte[] signatureLevel1, int version) throws IOException, EncodingFormatException {
+ if (defaultProvider == null) {
+ defaultProvider = SecurityUtils.getDefaultProvider();
+ }
dynamicFrame = new SimpleDynamicFrame();
dynamicFrame.setLevel2Data(new SimpleLevel2Data());
@@ -189,6 +208,10 @@ public class Encoder { */
public Encoder(byte[] encoded, int version) throws IOException, EncodingFormatException, DataFormatException {
+ if (defaultProvider == null) {
+ defaultProvider = SecurityUtils.getDefaultProvider();
+ }
+
Decoder decoder = new Decoder(encoded);
if (decoder.getDynamicFrame() == null) {
@@ -237,9 +260,7 @@ public class Encoder { * @deprecated
*/
public void signLevel2(PrivateKey key) throws Exception {
- if (dynamicFrame != null) {
- dynamicFrame.signLevel2(key);
- }
+ signLevel2(key, defaultProvider);
}
/**
@@ -371,32 +392,7 @@ public class Encoder { * @deprecated
*/
public void signLevel1(String securityProvider,PrivateKey key,String signingAlg, String keyId) throws Exception {
- if (dynamicFrame != null) {
- if (securityProvider != null && securityProvider.length() > 0) {
- dynamicFrame.getLevel2Data().getLevel1Data().setSecurityProvider(securityProvider);
- }
- dynamicFrame.getLevel2Data().getLevel1Data().setLevel1SigningAlg(signingAlg);
- dynamicFrame.getLevel2Data().getLevel1Data().setKeyId(Long.parseLong(keyId));
- dynamicFrame.signLevel1(key);
- } else if (staticFrame != null) {
- staticFrame.setSignatureKey(keyId);
- staticFrame.setSecurityProvider(securityProvider);
- if (securityProvider != null &&
- securityProvider.length() > 0 &&
- staticFrame.getHeaderRecord()!= null) {
- staticFrame.getHeaderRecord().setIssuer(securityProvider);
- }
- if (securityProvider != null &&
- securityProvider.length() > 0 &&
- staticFrame.getuFlex() != null &&
- staticFrame.getuFlex().getTicket() != null &&
- staticFrame.getuFlex().getTicket().getIssuerDetails() != null) {
- staticFrame.getuFlex().getTicket().getIssuerDetails().setSecurityProvider(securityProvider);
- }
- staticFrame.signByAlgorithmOID(key,signingAlg);
- } else if (ssbFrame != null) {
- ssbFrame.signLevel1(key, null, keyId, signingAlg);
- }
+ signLevel1(securityProvider,key,signingAlg, keyId, defaultProvider);
}
/**
@@ -418,9 +414,17 @@ public class Encoder { } else if (staticFrame != null) {
staticFrame.setSignatureKey(keyId);
staticFrame.setSecurityProvider(securityProvider);
- if (staticFrame.getHeaderRecord()!= null && staticFrame.getHeaderRecord().getIssuer() == null) {
+ if (staticFrame.getHeaderRecord()!= null &&
+ staticFrame.getHeaderRecord().getIssuer() == null) {
staticFrame.getHeaderRecord().setIssuer(securityProvider);
}
+ if (securityProvider != null &&
+ securityProvider.length() > 0 &&
+ staticFrame.getuFlex() != null &&
+ staticFrame.getuFlex().getTicket() != null &&
+ staticFrame.getuFlex().getTicket().getIssuerDetails() != null) {
+ staticFrame.getuFlex().getTicket().getIssuerDetails().setSecurityProvider(securityProvider);
+ }
staticFrame.signByAlgorithmOID(key,signingAlg,prov);
} else if (ssbFrame != null) {
ssbFrame.signLevel1(key, prov, keyId, signingAlg);
diff --git a/src/main/java/org/uic/barcode/asn1/datatypes/Asn1Integer.java b/src/main/java/org/uic/barcode/asn1/datatypes/Asn1Integer.java index e12f8ec..e5cfb4c 100644 --- a/src/main/java/org/uic/barcode/asn1/datatypes/Asn1Integer.java +++ b/src/main/java/org/uic/barcode/asn1/datatypes/Asn1Integer.java @@ -19,7 +19,7 @@ public class Asn1Integer { } public Long longObject () { - return new Long(value()); + return Long.valueOf(value()); } public Asn1Integer(Long num) { diff --git a/src/main/java/org/uic/barcode/asn1/datatypesimpl/SequenceOfUnrestrictedLong.java b/src/main/java/org/uic/barcode/asn1/datatypesimpl/SequenceOfUnrestrictedLong.java index 6af7352..fdd72e8 100644 --- a/src/main/java/org/uic/barcode/asn1/datatypesimpl/SequenceOfUnrestrictedLong.java +++ b/src/main/java/org/uic/barcode/asn1/datatypesimpl/SequenceOfUnrestrictedLong.java @@ -17,7 +17,7 @@ public class SequenceOfUnrestrictedLong extends Asn1SequenceOf<Long> { public SequenceOfUnrestrictedLong(List<Long> numbers) {
super();
for (Long number: numbers){
- this.add(new Long(number));
+ this.add(Long.valueOf(number));
}
}
diff --git a/src/main/java/org/uic/barcode/asn1/uper/BitStringCoder.java b/src/main/java/org/uic/barcode/asn1/uper/BitStringCoder.java index 6f435c4..0b6c9bd 100644 --- a/src/main/java/org/uic/barcode/asn1/uper/BitStringCoder.java +++ b/src/main/java/org/uic/barcode/asn1/uper/BitStringCoder.java @@ -36,7 +36,8 @@ class BitStringCoder implements Decoder, Encoder { throw new AssertionError("Field should be a list of booleans!"); } - List<Boolean> list = (List<Boolean>)obj; + @SuppressWarnings("unchecked") + List<Boolean> list = (List<Boolean>)obj; if (list.size() != size.value()) { throw new AssertionError( "Declared size (" + size.value() + diff --git a/src/main/java/org/uic/barcode/asn1/uper/BooleanCoder.java b/src/main/java/org/uic/barcode/asn1/uper/BooleanCoder.java index 892f851..9f88e37 100644 --- a/src/main/java/org/uic/barcode/asn1/uper/BooleanCoder.java +++ b/src/main/java/org/uic/barcode/asn1/uper/BooleanCoder.java @@ -23,7 +23,7 @@ class BooleanCoder implements Decoder, Encoder { @Override public <T> T decode(BitBuffer bitbuffer, Class<T> classOfT, Field field, Annotation[] extraAnnotations, AsnExtractor extractor) { - Boolean result = new Boolean(bitbuffer.get()); + Boolean result = Boolean.valueOf(bitbuffer.get()); UperEncoder.logger.debug(String.format("BOOL: decoded as %s",result)); return (T) result; } diff --git a/src/main/java/org/uic/barcode/asn1/uper/ByteCoder.java b/src/main/java/org/uic/barcode/asn1/uper/ByteCoder.java index 5ecb925..4d722de 100644 --- a/src/main/java/org/uic/barcode/asn1/uper/ByteCoder.java +++ b/src/main/java/org/uic/barcode/asn1/uper/ByteCoder.java @@ -23,7 +23,7 @@ class ByteCoder implements Decoder, Encoder { Class<T> classOfT, Field field, Annotation[] extraAnnotations, AsnExtractor extractor) { UperEncoder.logger.debug("BYTE"); - return (T) new Byte((byte) UperEncoder.decodeConstrainedInt(bitbuffer, UperEncoder.newRange(0, 255, false))); + return (T) Byte.valueOf((byte) UperEncoder.decodeConstrainedInt(bitbuffer, UperEncoder.newRange(0, 255, false))); } @Override diff --git a/src/main/java/org/uic/barcode/asn1/uper/UperEncoder.java b/src/main/java/org/uic/barcode/asn1/uper/UperEncoder.java index c256b4f..647a550 100644 --- a/src/main/java/org/uic/barcode/asn1/uper/UperEncoder.java +++ b/src/main/java/org/uic/barcode/asn1/uper/UperEncoder.java @@ -334,7 +334,7 @@ public final class UperEncoder { parameterTypes[i] = parameters[i].getClass(); } Constructor<T> constructor = findConsturctor(classOfT, parameters); - boolean constructorIsAccessible = constructor.isAccessible(); + //boolean constructorIsAccessible = constructor.isAccessible(); constructor.setAccessible(true); T result; try { @@ -342,7 +342,7 @@ public final class UperEncoder { } catch (IllegalArgumentException | InvocationTargetException | InstantiationException | IllegalAccessException e) { throw new IllegalArgumentException("Can't instantiate " + classOfT.getName(), e); } - constructor.setAccessible(constructorIsAccessible); + //constructor.setAccessible(constructorIsAccessible); return result; } @@ -441,7 +441,7 @@ public final class UperEncoder { List<Field> optionalOrdinaryFields = new ArrayList<>(); List<Field> allFields = new ArrayList<>(); // Excluding test instrumentation. - Map<Field, Boolean> originalAccess = new HashMap<>(); + //Map<Field, Boolean> originalAccess = new HashMap<>(); Asn1ContainerFieldSorter(Class<?> type) { @@ -472,7 +472,7 @@ public final class UperEncoder { if (isTestInstrumentation(f) || isNonAsn1Field(f) ) { continue; } - originalAccess.put(f, f.isAccessible()); + //originalAccess.put(f, f.isAccessible()); f.setAccessible(true); if (isExtension(f)) { extensionFields.add(f); @@ -496,10 +496,13 @@ public final class UperEncoder { } } + public void revertAccess() { + /* for (Entry<Field, Boolean> entry : originalAccess.entrySet()) { entry.getKey().setAccessible(entry.getValue()); } + */ } } diff --git a/src/main/java/org/uic/barcode/dynamicFrame/v1/DynamicFrame.java b/src/main/java/org/uic/barcode/dynamicFrame/v1/DynamicFrame.java index 7dbd131..aad76d7 100644 --- a/src/main/java/org/uic/barcode/dynamicFrame/v1/DynamicFrame.java +++ b/src/main/java/org/uic/barcode/dynamicFrame/v1/DynamicFrame.java @@ -1,8 +1,5 @@ package org.uic.barcode.dynamicFrame.v1;
-import java.security.PrivateKey;
-import java.security.Provider;
-import java.security.Signature;
import org.uic.barcode.asn1.datatypes.Asn1Optional;
import org.uic.barcode.asn1.datatypes.CharacterRestriction;
import org.uic.barcode.asn1.datatypes.FieldOrder;
@@ -14,7 +11,6 @@ import org.uic.barcode.dynamicContent.api.DynamicContentCoder; import org.uic.barcode.dynamicContent.api.IUicDynamicContent;
import org.uic.barcode.dynamicContent.fdc1.UicDynamicContentDataFDC1;
import org.uic.barcode.ticket.EncodingFormatException;
-import org.uic.barcode.utils.AlgorithmNameResolver;
/**
diff --git a/src/main/java/org/uic/barcode/dynamicFrame/v1/DynamicFrameCoderV1.java b/src/main/java/org/uic/barcode/dynamicFrame/v1/DynamicFrameCoderV1.java index 71de58e..cdc1843 100644 --- a/src/main/java/org/uic/barcode/dynamicFrame/v1/DynamicFrameCoderV1.java +++ b/src/main/java/org/uic/barcode/dynamicFrame/v1/DynamicFrameCoderV1.java @@ -2,8 +2,6 @@ package org.uic.barcode.dynamicFrame.v1; import org.uic.barcode.asn1.datatypesimpl.OctetString;
import org.uic.barcode.asn1.uper.UperEncoder;
-import org.uic.barcode.dynamicFrame.v1.DynamicFrame;
-import org.uic.barcode.dynamicFrame.v1.Level1DataType;
import org.uic.barcode.ticket.EncodingFormatException;
import org.uic.barcode.dynamicFrame.api.IData;
import org.uic.barcode.dynamicFrame.api.IDynamicFrame;
diff --git a/src/main/java/org/uic/barcode/dynamicFrame/v2/DynamicFrame.java b/src/main/java/org/uic/barcode/dynamicFrame/v2/DynamicFrame.java index cb5c37a..7237110 100644 --- a/src/main/java/org/uic/barcode/dynamicFrame/v2/DynamicFrame.java +++ b/src/main/java/org/uic/barcode/dynamicFrame/v2/DynamicFrame.java @@ -7,10 +7,6 @@ import org.uic.barcode.asn1.datatypes.RestrictedString; import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.OctetString;
import org.uic.barcode.asn1.uper.UperEncoder;
-import org.uic.barcode.dynamicContent.api.DynamicContentCoder;
-import org.uic.barcode.dynamicContent.api.IUicDynamicContent;
-import org.uic.barcode.dynamicContent.fdc1.UicDynamicContentDataFDC1;
-import org.uic.barcode.ticket.EncodingFormatException;
/**
diff --git a/src/main/java/org/uic/barcode/dynamicFrame/v2/DynamicFrameCoderV2.java b/src/main/java/org/uic/barcode/dynamicFrame/v2/DynamicFrameCoderV2.java index 5d980dd..c6ff7c7 100644 --- a/src/main/java/org/uic/barcode/dynamicFrame/v2/DynamicFrameCoderV2.java +++ b/src/main/java/org/uic/barcode/dynamicFrame/v2/DynamicFrameCoderV2.java @@ -2,7 +2,6 @@ package org.uic.barcode.dynamicFrame.v2; import org.uic.barcode.asn1.datatypesimpl.OctetString;
import org.uic.barcode.asn1.uper.UperEncoder;
-import org.uic.barcode.dynamicFrame.v2.DynamicFrame;
import org.uic.barcode.dynamicFrame.api.IData;
import org.uic.barcode.dynamicFrame.api.IDynamicFrame;
import org.uic.barcode.dynamicFrame.api.ILevel1Data;
@@ -10,10 +9,6 @@ import org.uic.barcode.dynamicFrame.api.ILevel2Data; import org.uic.barcode.dynamicFrame.api.SimpleData;
import org.uic.barcode.dynamicFrame.api.SimpleLevel1Data;
import org.uic.barcode.dynamicFrame.api.SimpleLevel2Data;
-import org.uic.barcode.dynamicFrame.v2.Level2DataType;
-import org.uic.barcode.dynamicFrame.v2.DataType;
-import org.uic.barcode.dynamicFrame.v2.Level1DataType;
-import org.uic.barcode.dynamicFrame.v2.SequenceOfDataType;
import org.uic.barcode.ticket.EncodingFormatException;
public class DynamicFrameCoderV2 {
diff --git a/src/main/java/org/uic/barcode/dynamicFrame/v2/Level1DataType.java b/src/main/java/org/uic/barcode/dynamicFrame/v2/Level1DataType.java index b42e9dc..a7d4b01 100644 --- a/src/main/java/org/uic/barcode/dynamicFrame/v2/Level1DataType.java +++ b/src/main/java/org/uic/barcode/dynamicFrame/v2/Level1DataType.java @@ -323,11 +323,11 @@ public class Level1DataType { Calendar cal = Calendar.getInstance();
cal.setTime(date);
- this.endOfValidityYear = new Long( cal.get(Calendar.YEAR));
- this.endOfValidityDay = new Long (cal.get(Calendar.DAY_OF_YEAR));
+ this.endOfValidityYear = Long.valueOf( cal.get(Calendar.YEAR));
+ this.endOfValidityDay = Long.valueOf (cal.get(Calendar.DAY_OF_YEAR));
int time = cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE);
if (time >= 0) {
- this.endOfValidityTime = new Long (time );
+ this.endOfValidityTime = Long.valueOf (time );
}
TimeZone.setDefault(local);
diff --git a/src/main/java/org/uic/barcode/ssbFrame/SsbFrame.java b/src/main/java/org/uic/barcode/ssbFrame/SsbFrame.java index 2c8f66f..b7c5501 100644 --- a/src/main/java/org/uic/barcode/ssbFrame/SsbFrame.java +++ b/src/main/java/org/uic/barcode/ssbFrame/SsbFrame.java @@ -359,13 +359,18 @@ public class SsbFrame { } } } - } if (algo == null) { throw new NoSuchAlgorithmException("No service for algorithm found: " + signingAlg); } - Signature sig = Signature.getInstance(algo); + + Signature sig = null; + if (prov != null) { + sig = Signature.getInstance(algo,prov); + } else { + sig = Signature.getInstance(algo); + } sig.initVerify(key); sig.update(getDataForSignature()); diff --git a/src/main/java/org/uic/barcode/staticFrame/StaticFrame.java b/src/main/java/org/uic/barcode/staticFrame/StaticFrame.java index a8d7651..c0f03c8 100644 --- a/src/main/java/org/uic/barcode/staticFrame/StaticFrame.java +++ b/src/main/java/org/uic/barcode/staticFrame/StaticFrame.java @@ -705,22 +705,41 @@ public class StaticFrame { * @throws EncodingFormatException
* @throws IOException
*/
- public boolean verifyByAlgorithmOid(PublicKey key, String signingAlg, Provider prov) throws InvalidKeyException, NoSuchAlgorithmException, SignatureException, IllegalArgumentException, UnsupportedOperationException, IOException, EncodingFormatException {
+ public boolean verifyByAlgorithmOid(PublicKey key, String signatureAlgorithmOid, Provider prov) throws InvalidKeyException, NoSuchAlgorithmException, SignatureException, IllegalArgumentException, UnsupportedOperationException, IOException, EncodingFormatException {
- if ((signingAlg == null || signingAlg.length() < 1) && this.getSignature() != null) {
- signingAlg = SecurityUtils.getDsaAlgorithm(this.getSignature());
+ if ((signatureAlgorithmOid == null || signatureAlgorithmOid.length() < 1) && this.getSignature() != null) {
+ signatureAlgorithmOid = SecurityUtils.getDsaAlgorithm(this.getSignature());
}
//find the algorithm name for the signature OID
String algo = null;
- Service service = prov.getService("Signature",signingAlg);
- if (service != null) {
- algo = service.getAlgorithm();
- }
+ if (prov != null) {
+ Service service = prov.getService("Signature",signatureAlgorithmOid);
+ if (service != null) {
+ algo = service.getAlgorithm();
+ }
+ } else {
+ Provider[] provs = Security.getProviders();
+ for (Provider p : provs) {
+ if (algo == null) {
+ Service service = p.getService("Signature",signatureAlgorithmOid);
+ if (service != null) {
+ algo = service.getAlgorithm();
+ }
+ }
+ }
+ }
if (algo == null) {
- throw new NoSuchAlgorithmException("No service for algorithm found: " + signingAlg);
+ throw new NoSuchAlgorithmException("No service for algorithm found: " + signatureAlgorithmOid);
}
- Signature sig = Signature.getInstance(algo);
+
+ Signature sig = null;
+ if (prov != null) {
+ sig = Signature.getInstance(algo,prov);
+ } else {
+ sig = Signature.getInstance(algo);
+ }
+
sig.initVerify(key);
sig.update(getDataForSignature());
return sig.verify(this.getSignature());
@@ -739,13 +758,23 @@ public class StaticFrame { * @throws SignatureException the signature exception
* @throws EncodingFormatException
* @throws IOException
+ * @deprecated
*/
- public void signByAlgorithmOID(PrivateKey key,String signingAlg) throws NoSuchAlgorithmException, InvalidKeyException, SignatureException, IOException, EncodingFormatException {
+ public void signByAlgorithmOID(PrivateKey key,String signatureAlgorithmOid) throws NoSuchAlgorithmException, InvalidKeyException, SignatureException, IOException, EncodingFormatException {
+ //find the algorithm name for the signature OID
//find the algorithm name for the signature OID
String algo = null;
- algo = getAlgo(signingAlg);
+ Provider[] provs = Security.getProviders();
+ for (Provider p : provs) {
+ if (algo == null) {
+ Service service = p.getService("Signature",signatureAlgorithmOid);
+ if (service != null) {
+ algo = service.getAlgorithm();
+ }
+ }
+ }
if (algo == null) {
- throw new NoSuchAlgorithmException("No service for algorthm found: " + signingAlg);
+ throw new NoSuchAlgorithmException("No service for algorithm found: " + signatureAlgorithmOid);
}
Signature sig = Signature.getInstance(algo);
sig.initSign(key);
@@ -754,16 +783,7 @@ public class StaticFrame { signature = sig.sign();
}
- private String getAlgo(String signingAlg) {
- Provider[] provs = Security.getProviders();
- for (Provider prov : provs) {
- Service service = prov.getService("Signature",signingAlg);
- if (service != null) {
- return service.getAlgorithm();
- }
- }
- return null;
- }
+
@@ -781,17 +801,36 @@ public class StaticFrame { * @throws EncodingFormatException
* @throws IOException
*/
- public void signByAlgorithmOID(PrivateKey key,String signingAlg, Provider prov) throws NoSuchAlgorithmException, InvalidKeyException, SignatureException, IOException, EncodingFormatException {
+ public void signByAlgorithmOID(PrivateKey key,String signatureAlgorithmOid, Provider prov) throws NoSuchAlgorithmException, InvalidKeyException, SignatureException, IOException, EncodingFormatException {
+
//find the algorithm name for the signature OID
String algo = null;
- Service service = prov.getService("Signature",signingAlg);
- if (service != null) {
- algo = service.getAlgorithm();
- }
+ if (prov != null) {
+ Service service = prov.getService("Signature",signatureAlgorithmOid);
+ if (service != null) {
+ algo = service.getAlgorithm();
+ }
+ } else {
+ Provider[] provs = Security.getProviders();
+ for (Provider p : provs) {
+ if (algo == null) {
+ Service service = p.getService("Signature",signatureAlgorithmOid);
+ if (service != null) {
+ algo = service.getAlgorithm();
+ }
+ }
+ }
+ }
if (algo == null) {
- throw new NoSuchAlgorithmException("No service for algorthm found: " + signingAlg);
+ throw new NoSuchAlgorithmException("No service for algorithm found: " + signatureAlgorithmOid);
+ }
+
+ Signature sig = null;
+ if (prov == null) {
+ sig = Signature.getInstance(algo);
+ } else {
+ sig = Signature.getInstance(algo,prov);
}
- Signature sig = Signature.getInstance(algo,prov);
sig.initSign(key);
signedData = getDataForSignature();
@@ -813,6 +852,7 @@ public class StaticFrame { * @throws SignatureException the signature exception
* @throws EncodingFormatException
* @throws IOException
+ * @deprecated
*/
public void signUsingAlgorithmName(PrivateKey key,String algo) throws NoSuchAlgorithmException, InvalidKeyException, SignatureException, IOException, EncodingFormatException {
Signature sig = Signature.getInstance(algo);
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/CarCarriageReservationData.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/CarCarriageReservationData.java index 6729d08..a55b619 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/CarCarriageReservationData.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/CarCarriageReservationData.java @@ -33,7 +33,6 @@ import org.uic.barcode.asn1.datatypes.IntRange; import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
-import org.uic.barcode.ticket.api.asn.omv1.SequenceOfCarrierNum;
import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@@ -232,7 +231,7 @@ public class CarCarriageReservationData extends Object { public Long getBeginLoadingTime() {
- if (beginLoadingTime == null) return new Long(0);
+ if (beginLoadingTime == null) return Long.valueOf(0);
return beginLoadingTime;
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/CustomerCardData.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/CustomerCardData.java index 0d8bdcd..ae9d513 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/CustomerCardData.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/CustomerCardData.java @@ -244,8 +244,8 @@ public class CustomerCardData extends Object { fromCal.clear();
fromCal.setTime(fromDate);
- this.validFromYear = new Long( fromCal.get(Calendar.YEAR));
- this.validFromDay = new Long (fromCal.get(Calendar.DAY_OF_YEAR));
+ this.validFromYear = Long.valueOf( fromCal.get(Calendar.YEAR));
+ this.validFromDay = Long.valueOf(fromCal.get(Calendar.DAY_OF_YEAR));
if (untilDate == null) return;
@@ -256,8 +256,8 @@ public class CustomerCardData extends Object { int untildays = untilCal.get(Calendar.DAY_OF_YEAR);
int yearDiff = untilCal.get(Calendar.YEAR) - fromCal.get(Calendar.YEAR);
- this.validUntilYear = new Long( yearDiff);
- this.validUntilDay = new Long (untildays);
+ this.validUntilYear = Long.valueOf( yearDiff);
+ this.validUntilDay = Long.valueOf (untildays);
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/DelayConfirmation.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/DelayConfirmation.java index a3df48b..32e6c97 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/DelayConfirmation.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/DelayConfirmation.java @@ -282,11 +282,11 @@ public class DelayConfirmation extends Object { Calendar cal = Calendar.getInstance();
cal.setTime(date);
- this.plannedArrivalYear = new Long( cal.get(Calendar.YEAR));
- this.plannedArrivalDay = new Long (cal.get(Calendar.DAY_OF_YEAR));
+ this.plannedArrivalYear = Long.valueOf( cal.get(Calendar.YEAR));
+ this.plannedArrivalDay = Long.valueOf (cal.get(Calendar.DAY_OF_YEAR));
int time = cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE);
if (time > 0) {
- this.plannedArrivalTime = new Long (time );
+ this.plannedArrivalTime = Long.valueOf (time );
}
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/IssuingData.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/IssuingData.java index 5a150dc..4c3a5ff 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/IssuingData.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/IssuingData.java @@ -184,7 +184,7 @@ public class IssuingData extends Object { public Long getCurrencyFract() {
if (currencyFract == null) {
- return new Long(2);
+ return Long.valueOf(2);
}
return this.currencyFract;
}
@@ -323,11 +323,11 @@ public class IssuingData extends Object { Calendar cal = Calendar.getInstance();
cal.setTime(date);
- this.issuingYear = new Long( cal.get(Calendar.YEAR));
- this.issuingDay = new Long (cal.get(Calendar.DAY_OF_YEAR));
+ this.issuingYear = Long.valueOf( cal.get(Calendar.YEAR));
+ this.issuingDay = Long.valueOf (cal.get(Calendar.DAY_OF_YEAR));
int time = cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE);
if (time >= 0) {
- this.issuingTime = new Long (time );
+ this.issuingTime = Long.valueOf (time );
}
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/LuggageRestrictionType.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/LuggageRestrictionType.java index 04f4309..86f75d9 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/LuggageRestrictionType.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/LuggageRestrictionType.java @@ -54,7 +54,7 @@ public class LuggageRestrictionType extends Object { public Long getMaxHandLuggagePieces() {
if (maxHandLuggagePieces == null) {
- return new Long(3);
+ return Long.valueOf(3);
}
return this.maxHandLuggagePieces;
@@ -63,7 +63,7 @@ public class LuggageRestrictionType extends Object { public Long getMaxNonHandLuggagePieces() {
if (maxNonHandLuggagePieces == null) {
- return new Long(1);
+ return Long.valueOf(1);
}
return this.maxNonHandLuggagePieces;
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/ReservationData.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/ReservationData.java index b1b2be4..d60dee1 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/ReservationData.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/ReservationData.java @@ -314,7 +314,7 @@ public class ReservationData extends Object { public Long getArrivalDate() {
if (arrivalDate == null) {
- return new Long(0);
+ return Long.valueOf(0);
}
return this.arrivalDate;
@@ -397,7 +397,7 @@ public class ReservationData extends Object { public Long getTypeOfSupplement() {
if (typeOfSupplement == null){
- return new Long(0);
+ return Long.valueOf(0);
}
@@ -407,7 +407,7 @@ public class ReservationData extends Object { public Long getNumberOfSupplements() {
if (numberOfSupplements == null) {
- return new Long(0);
+ return Long.valueOf(0);
}
return this.numberOfSupplements;
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/SequenceOfActivatedDays.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/SequenceOfActivatedDays.java index 2d1eebd..775d145 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/SequenceOfActivatedDays.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/SequenceOfActivatedDays.java @@ -14,7 +14,7 @@ public class SequenceOfActivatedDays extends Asn1SequenceOf<Long> { public SequenceOfActivatedDays(List<Long> numbers) {
super();
for (Long number: numbers){
- this.add(new Long(number));
+ this.add(Long.valueOf(number));
}
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/SequenceOfCarrierNum.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/SequenceOfCarrierNum.java index 9d75e83..8d8d708 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/SequenceOfCarrierNum.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/SequenceOfCarrierNum.java @@ -15,7 +15,7 @@ public class SequenceOfCarrierNum extends Asn1SequenceOf<Long> { public SequenceOfCarrierNum(List<Long> numbers) {
super();
for (Long number: numbers){
- this.add(new Long(number));
+ this.add(Long.valueOf(number));
}
}
public static SequenceOfCarrierNum getSequence(List<Long> numList) {
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/SequenceOfCountries.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/SequenceOfCountries.java index e6dd46b..ea3213c 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/SequenceOfCountries.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/SequenceOfCountries.java @@ -15,7 +15,7 @@ public class SequenceOfCountries extends Asn1SequenceOf<Long> { public SequenceOfCountries(List<Long> numbers) {
super();
for (Long number: numbers){
- this.add(new Long(number));
+ this.add(Long.valueOf(number));
}
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/SequenceOfPlaceNum.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/SequenceOfPlaceNum.java index c8ec7ce..07d7950 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/SequenceOfPlaceNum.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/SequenceOfPlaceNum.java @@ -16,7 +16,7 @@ public class SequenceOfPlaceNum extends Asn1SequenceOf<Long> { public SequenceOfPlaceNum(List<Long> numbers) {
super();
for (Long number: numbers){
- this.add(new Long(number));
+ this.add(Long.valueOf(number));
}
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/SequenceOfServiceBrands.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/SequenceOfServiceBrands.java index 3edd7fb..e8fde5a 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/SequenceOfServiceBrands.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/SequenceOfServiceBrands.java @@ -15,7 +15,7 @@ public class SequenceOfServiceBrands extends Asn1SequenceOf<Long> { public SequenceOfServiceBrands(List<Long> numbers) {
super();
for (Long number: numbers){
- this.add(new Long(number));
+ this.add(Long.valueOf(number));
}
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/SequenceOfTravelerId.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/SequenceOfTravelerId.java index 3a1b1ec..b1d61ba 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/SequenceOfTravelerId.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/SequenceOfTravelerId.java @@ -14,7 +14,7 @@ public class SequenceOfTravelerId extends Asn1SequenceOf<Long> { public SequenceOfTravelerId(List<Long> numbers) {
super();
for (Long number: numbers){
- this.add(new Long(number));
+ this.add(Long.valueOf(number));
}
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/TariffType.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/TariffType.java index 66cb399..6927416 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/TariffType.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/TariffType.java @@ -82,7 +82,7 @@ public class TariffType extends Object { public Long getNumberOfPassengers() {
if (numberOfPassengers == null) {
- return new Long(1);
+ return Long.valueOf(1);
}
return this.numberOfPassengers;
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/TicketDetailData.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/TicketDetailData.java index 7a86d56..b137f4c 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/TicketDetailData.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/TicketDetailData.java @@ -24,8 +24,6 @@ package org.uic.barcode.ticket.api.asn.omv1; import org.uic.barcode.asn1.datatypes.Choice;
import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.HasExtensionMarker;
-import org.uic.barcode.ticket.api.asn.omv1.DelayConfirmation;
-import org.uic.barcode.ticket.api.asn.omv1.ExtensionData;
@Choice
@HasExtensionMarker
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/TrainLinkType.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/TrainLinkType.java index 6cc1c42..9bd4fe4 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/TrainLinkType.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/TrainLinkType.java @@ -43,7 +43,7 @@ public class TrainLinkType extends Object { @Asn1Optional public String trainIA5;
@FieldOrder(order = 2)
- @IntRange(minValue=0,maxValue=370)
+ @IntRange(minValue=-1,maxValue=370)
public Long travelDate;
@FieldOrder(order = 3)
@@ -168,7 +168,7 @@ public class TrainLinkType extends Object { public void setDepartureTimeZone(Date dateLocal, Date dateUTC ) {
// -- (UTC = local + offset * 15 Minutes)
- this.departureUTCOffset = new Long(dateLocal.getTime() - dateUTC.getTime()) / (1000 * 60 * 15);
+ this.departureUTCOffset = Long.valueOf(dateLocal.getTime() - dateUTC.getTime()) / (1000 * 60 * 15);
}
public Date getDepartureDate(Date issuingDate){
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/TravelerType.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/TravelerType.java index 7f512fc..f9663c5 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/TravelerType.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/TravelerType.java @@ -295,8 +295,8 @@ public class TravelerType extends Object { Calendar cal = Calendar.getInstance();
cal.setTime(date);
- this.yearOfBirth = new Long( cal.get(Calendar.YEAR));
- this.dayOfBirth = new Long (cal.get(Calendar.DAY_OF_YEAR));
+ this.yearOfBirth = Long.valueOf ( cal.get(Calendar.YEAR));
+ this.dayOfBirth = Long.valueOf (cal.get(Calendar.DAY_OF_YEAR));
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/ValidityPeriodType.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/ValidityPeriodType.java index a72d55b..e9a0ce8 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/ValidityPeriodType.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/ValidityPeriodType.java @@ -62,7 +62,7 @@ public class ValidityPeriodType extends Object { public Long getValidFromDay() {
if (validFromDay == null) {
- return new Long(0);
+ return Long.valueOf(0);
}
return this.validFromDay;
@@ -76,7 +76,7 @@ public class ValidityPeriodType extends Object { public Long getValidUntilDay() {
if (validUntilDay == null) {
- return new Long(0);
+ return Long.valueOf(0);
}
return this.validUntilDay;
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/VoucherData.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/VoucherData.java index 521f32a..796e15e 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv1/VoucherData.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv1/VoucherData.java @@ -241,8 +241,8 @@ public class VoucherData extends Object { fromCal.clear();
fromCal.setTime(fromDate);
- this.validFromYear = new Long( fromCal.get(Calendar.YEAR));
- this.validFromDay = new Long (fromCal.get(Calendar.DAY_OF_YEAR));
+ this.validFromYear = Long.valueOf( fromCal.get(Calendar.YEAR));
+ this.validFromDay = Long.valueOf (fromCal.get(Calendar.DAY_OF_YEAR));
if (untilDate == null) return;
@@ -250,8 +250,8 @@ public class VoucherData extends Object { untilCal.clear();
untilCal.setTime(untilDate);
- this.validUntilYear = new Long( untilCal.get(Calendar.YEAR));
- this.validUntilDay = new Long (untilCal.get(Calendar.DAY_OF_YEAR));
+ this.validUntilYear = Long.valueOf( untilCal.get(Calendar.YEAR));
+ this.validUntilDay = Long.valueOf(untilCal.get(Calendar.DAY_OF_YEAR));
}
@@ -264,8 +264,8 @@ public class VoucherData extends Object { fromCal.clear();
fromCal.setTime(fromDate);
- this.validFromYear = new Long( fromCal.get(Calendar.YEAR));
- this.validFromDay = new Long (fromCal.get(Calendar.DAY_OF_YEAR));
+ this.validFromYear = Long.valueOf( fromCal.get(Calendar.YEAR));
+ this.validFromDay = Long.valueOf(fromCal.get(Calendar.DAY_OF_YEAR));
}
@@ -277,8 +277,8 @@ public class VoucherData extends Object { untilCal.clear();
untilCal.setTime(untilDate);
- this.validUntilYear = new Long( untilCal.get(Calendar.YEAR));
- this.validUntilDay = new Long (untilCal.get(Calendar.DAY_OF_YEAR));
+ this.validUntilYear = Long.valueOf( untilCal.get(Calendar.YEAR));
+ this.validUntilDay = Long.valueOf (untilCal.get(Calendar.DAY_OF_YEAR));
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/CarCarriageReservationData.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/CarCarriageReservationData.java index 4e0bb5f..5a3af74 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/CarCarriageReservationData.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/CarCarriageReservationData.java @@ -231,7 +231,7 @@ public class CarCarriageReservationData extends Object { public Long getBeginLoadingTime() {
- if (beginLoadingTime == null) return new Long(0);
+ if (beginLoadingTime == null) return Long.valueOf(0);
return beginLoadingTime;
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/CustomerCardData.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/CustomerCardData.java index 5d8603f..161106d 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/CustomerCardData.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/CustomerCardData.java @@ -242,8 +242,8 @@ public class CustomerCardData extends Object { fromCal.clear();
fromCal.setTime(fromDate);
- this.validFromYear = new Long( fromCal.get(Calendar.YEAR));
- this.validFromDay = new Long (fromCal.get(Calendar.DAY_OF_YEAR));
+ this.validFromYear = Long.valueOf( fromCal.get(Calendar.YEAR));
+ this.validFromDay = Long.valueOf (fromCal.get(Calendar.DAY_OF_YEAR));
if (untilDate == null) return;
@@ -255,8 +255,8 @@ public class CustomerCardData extends Object { int yearDiff = untilCal.get(Calendar.YEAR) - fromCal.get(Calendar.YEAR);
- this.validUntilYear = new Long( yearDiff);
- this.validUntilDay = new Long (untildays);
+ this.validUntilYear = Long.valueOf( yearDiff);
+ this.validUntilDay = Long.valueOf (untildays);
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/DelayConfirmation.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/DelayConfirmation.java index acf99d5..0fe13c4 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/DelayConfirmation.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/DelayConfirmation.java @@ -281,11 +281,11 @@ public class DelayConfirmation extends Object { Calendar cal = Calendar.getInstance();
cal.setTime(date);
- this.plannedArrivalYear = new Long( cal.get(Calendar.YEAR));
- this.plannedArrivalDay = new Long (cal.get(Calendar.DAY_OF_YEAR));
+ this.plannedArrivalYear = Long.valueOf( cal.get(Calendar.YEAR));
+ this.plannedArrivalDay = Long.valueOf (cal.get(Calendar.DAY_OF_YEAR));
int time = cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE);
if (time > 0) {
- this.plannedArrivalTime = new Long (time );
+ this.plannedArrivalTime = Long.valueOf (time );
}
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/IncludedOpenTicketType.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/IncludedOpenTicketType.java index 4cfe708..3a301d1 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/IncludedOpenTicketType.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/IncludedOpenTicketType.java @@ -385,12 +385,12 @@ public class IncludedOpenTicketType extends Object { public void setValidFromTimeZone(Date dateLocal, Date dateUTC ) {
// -- (UTC = local + offset * 15 Minutes)
- this.validFromUTCOffset = new Long(dateLocal.getTime() - dateUTC.getTime()) / (1000 * 60 * 15);
+ this.validFromUTCOffset = Long.valueOf(dateLocal.getTime() - dateUTC.getTime()) / (1000 * 60 * 15);
}
public void setValidUntilTimeZone(Date dateLocal, Date dateUTC ) {
// -- (UTC = local + offset * 15 Minutes)
- this.validUntilUTCOffset = new Long(dateLocal.getTime() - dateUTC.getTime()) / (1000 * 60 * 15);
+ this.validUntilUTCOffset = Long.valueOf(dateLocal.getTime() - dateUTC.getTime()) / (1000 * 60 * 15);
if (this.validFromUTCOffset.longValue() == this.validUntilUTCOffset.longValue()) {
this.validUntilUTCOffset = null;
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/IssuingData.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/IssuingData.java index 74c516c..82e3d69 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/IssuingData.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/IssuingData.java @@ -184,7 +184,7 @@ public class IssuingData extends Object { public Long getCurrencyFract() {
if (currencyFract == null) {
- return new Long(2);
+ return Long.valueOf(2);
}
return this.currencyFract;
}
@@ -323,11 +323,11 @@ public class IssuingData extends Object { Calendar cal = Calendar.getInstance();
cal.setTime(date);
- this.issuingYear = new Long( cal.get(Calendar.YEAR));
- this.issuingDay = new Long (cal.get(Calendar.DAY_OF_YEAR));
+ this.issuingYear = Long.valueOf( cal.get(Calendar.YEAR));
+ this.issuingDay = Long.valueOf (cal.get(Calendar.DAY_OF_YEAR));
int time = cal.get(Calendar.HOUR_OF_DAY) * 60 + cal.get(Calendar.MINUTE);
if (time >= 0) {
- this.issuingTime = new Long (time );
+ this.issuingTime = Long.valueOf (time );
}
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/LuggageRestrictionType.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/LuggageRestrictionType.java index caa1caa..403afc0 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/LuggageRestrictionType.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/LuggageRestrictionType.java @@ -54,7 +54,7 @@ public class LuggageRestrictionType extends Object { public Long getMaxHandLuggagePieces() {
if (maxHandLuggagePieces == null) {
- return new Long(3);
+ return Long.valueOf(3);
}
return this.maxHandLuggagePieces;
@@ -63,7 +63,7 @@ public class LuggageRestrictionType extends Object { public Long getMaxNonHandLuggagePieces() {
if (maxNonHandLuggagePieces == null) {
- return new Long(1);
+ return Long.valueOf(1);
}
return this.maxNonHandLuggagePieces;
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/OpenTicketData.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/OpenTicketData.java index 3b5ae99..f69155e 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/OpenTicketData.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/OpenTicketData.java @@ -35,7 +35,6 @@ import org.uic.barcode.asn1.datatypes.RestrictedString; import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypes.SizeRange;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
-import org.uic.barcode.ticket.api.asn.omv2.SequenceOfActivatedDays;
import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/PassData.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/PassData.java index 3a8c3b1..ab86564 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/PassData.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/PassData.java @@ -34,7 +34,6 @@ import org.uic.barcode.asn1.datatypes.IntRange; import org.uic.barcode.asn1.datatypes.RestrictedString;
import org.uic.barcode.asn1.datatypes.Sequence;
import org.uic.barcode.asn1.datatypesimpl.SequenceOfStringIA5;
-import org.uic.barcode.ticket.api.asn.omv2.SequenceOfActivatedDays;
import org.uic.barcode.ticket.api.utils.DateTimeUtils;
@Sequence
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/ReservationData.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/ReservationData.java index a42a3e1..604717f 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/ReservationData.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/ReservationData.java @@ -314,7 +314,7 @@ public class ReservationData extends Object { public Long getArrivalDate() {
if (arrivalDate == null) {
- return new Long(0);
+ return Long.valueOf(0);
}
return this.arrivalDate;
@@ -397,7 +397,7 @@ public class ReservationData extends Object { public Long getTypeOfSupplement() {
if (typeOfSupplement == null){
- return new Long(0);
+ return Long.valueOf(0);
}
@@ -407,7 +407,7 @@ public class ReservationData extends Object { public Long getNumberOfSupplements() {
if (numberOfSupplements == null) {
- return new Long(0);
+ return Long.valueOf(0);
}
return this.numberOfSupplements;
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfActivatedDays.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfActivatedDays.java index 776c774..7b632bb 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfActivatedDays.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfActivatedDays.java @@ -14,7 +14,7 @@ public class SequenceOfActivatedDays extends Asn1SequenceOf<Long> { public SequenceOfActivatedDays(List<Long> numbers) {
super();
for (Long number: numbers){
- this.add(new Long(number));
+ this.add(Long.valueOf(number));
}
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfCarrierNum.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfCarrierNum.java index 53417c2..09f1861 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfCarrierNum.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfCarrierNum.java @@ -15,7 +15,7 @@ public class SequenceOfCarrierNum extends Asn1SequenceOf<Long> { public SequenceOfCarrierNum(List<Long> numbers) {
super();
for (Long number: numbers){
- this.add(new Long(number));
+ this.add(Long.valueOf(number));
}
}
public static SequenceOfCarrierNum getSequence(List<Long> numList) {
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfCountries.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfCountries.java index 2dca27a..a4ee40b 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfCountries.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfCountries.java @@ -15,7 +15,7 @@ public class SequenceOfCountries extends Asn1SequenceOf<Long> { public SequenceOfCountries(List<Long> numbers) {
super();
for (Long number: numbers){
- this.add(new Long(number));
+ this.add(Long.valueOf(number));
}
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfPlaceNum.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfPlaceNum.java index 3cc6471..9b8afcb 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfPlaceNum.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfPlaceNum.java @@ -16,7 +16,7 @@ public class SequenceOfPlaceNum extends Asn1SequenceOf<Long> { public SequenceOfPlaceNum(List<Long> numbers) {
super();
for (Long number: numbers){
- this.add(new Long(number));
+ this.add(Long.valueOf(number));
}
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfServiceBrands.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfServiceBrands.java index 4eb829b..30a2d48 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfServiceBrands.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfServiceBrands.java @@ -15,7 +15,7 @@ public class SequenceOfServiceBrands extends Asn1SequenceOf<Long> { public SequenceOfServiceBrands(List<Long> numbers) {
super();
for (Long number: numbers){
- this.add(new Long(number));
+ this.add(Long.valueOf(number));
}
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfTransportTypes.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfTransportTypes.java index b8e2b64..19b4b2b 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfTransportTypes.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfTransportTypes.java @@ -15,7 +15,7 @@ public class SequenceOfTransportTypes extends Asn1SequenceOf<Long> { public SequenceOfTransportTypes(List<Long> numbers) {
super();
for (Long number: numbers){
- this.add(new Long(number));
+ this.add(Long.valueOf(number));
}
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfTravelerId.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfTravelerId.java index eb9c3e2..16c57ce 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfTravelerId.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/SequenceOfTravelerId.java @@ -14,7 +14,7 @@ public class SequenceOfTravelerId extends Asn1SequenceOf<Long> { public SequenceOfTravelerId(List<Long> numbers) {
super();
for (Long number: numbers){
- this.add(new Long(number));
+ this.add(Long.valueOf(number));
}
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/TariffType.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/TariffType.java index efc5d3b..2834b4e 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/TariffType.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/TariffType.java @@ -81,7 +81,7 @@ public class TariffType extends Object { public Long getNumberOfPassengers() {
if (numberOfPassengers == null) {
- return new Long(1);
+ return Long.valueOf(1);
}
return this.numberOfPassengers;
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/TicketDetailData.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/TicketDetailData.java index 47c48da..9e54a20 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/TicketDetailData.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/TicketDetailData.java @@ -24,8 +24,6 @@ package org.uic.barcode.ticket.api.asn.omv2; import org.uic.barcode.asn1.datatypes.Choice;
import org.uic.barcode.asn1.datatypes.FieldOrder;
import org.uic.barcode.asn1.datatypes.HasExtensionMarker;
-import org.uic.barcode.ticket.api.asn.omv2.DelayConfirmation;
-import org.uic.barcode.ticket.api.asn.omv2.ExtensionData;
@Choice
@HasExtensionMarker
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/TrainLinkType.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/TrainLinkType.java index 4724db6..ed2ee12 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/TrainLinkType.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/TrainLinkType.java @@ -168,7 +168,7 @@ public class TrainLinkType extends Object { public void setDepartureTimeZone(Date dateLocal, Date dateUTC ) {
// -- (UTC = local + offset * 15 Minutes)
- this.departureUTCOffset = new Long(dateLocal.getTime() - dateUTC.getTime()) / (1000 * 60 * 15);
+ this.departureUTCOffset = Long.valueOf(dateLocal.getTime() - dateUTC.getTime()) / (1000 * 60 * 15);
}
public Date getDepartureDate(Date issuingDate){
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/TravelerType.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/TravelerType.java index 2522355..8c3ba01 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/TravelerType.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/TravelerType.java @@ -305,9 +305,9 @@ public class TravelerType extends Object { Calendar cal = Calendar.getInstance();
cal.setTime(date);
- this.yearOfBirth = new Long( cal.get(Calendar.YEAR));
- this.monthOfBirth = new Long(cal.get(Calendar.MONTH) + 1);
- this.dayOfBirth = new Long (cal.get(Calendar.DAY_OF_MONTH));
+ this.yearOfBirth = Long.valueOf( cal.get(Calendar.YEAR));
+ this.monthOfBirth = Long.valueOf(cal.get(Calendar.MONTH) + 1);
+ this.dayOfBirth = Long.valueOf(cal.get(Calendar.DAY_OF_MONTH));
}
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/ValidityPeriodType.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/ValidityPeriodType.java index e22cf3b..392da59 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/ValidityPeriodType.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/ValidityPeriodType.java @@ -62,7 +62,7 @@ public class ValidityPeriodType extends Object { public Long getValidFromDay() {
if (validFromDay == null) {
- return new Long(0);
+ return Long.valueOf(0);
}
return this.validFromDay;
@@ -76,7 +76,7 @@ public class ValidityPeriodType extends Object { public Long getValidUntilDay() {
if (validUntilDay == null) {
- return new Long(0);
+ return Long.valueOf(0);
}
return this.validUntilDay;
diff --git a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/VoucherData.java b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/VoucherData.java index 1395976..a4b3328 100644 --- a/src/main/java/org/uic/barcode/ticket/api/asn/omv2/VoucherData.java +++ b/src/main/java/org/uic/barcode/ticket/api/asn/omv2/VoucherData.java @@ -239,8 +239,8 @@ public class VoucherData extends Object { fromCal.clear();
fromCal.setTime(fromDate);
- this.validFromYear = new Long( fromCal.get(Calendar.YEAR));
- this.validFromDay = new Long (fromCal.get(Calendar.DAY_OF_YEAR));
+ this.validFromYear = Long.valueOf( fromCal.get(Calendar.YEAR));
+ this.validFromDay = Long.valueOf(fromCal.get(Calendar.DAY_OF_YEAR));
if (untilDate == null) return;
@@ -248,8 +248,8 @@ public class VoucherData extends Object { untilCal.clear();
untilCal.setTime(untilDate);
- this.validUntilYear = new Long( untilCal.get(Calendar.YEAR));
- this.validUntilDay = new Long (untilCal.get(Calendar.DAY_OF_YEAR));
+ this.validUntilYear = Long.valueOf( untilCal.get(Calendar.YEAR));
+ this.validUntilDay = Long.valueOf(untilCal.get(Calendar.DAY_OF_YEAR));
}
@@ -262,8 +262,8 @@ public class VoucherData extends Object { fromCal.clear();
fromCal.setTime(fromDate);
- this.validFromYear = new Long( fromCal.get(Calendar.YEAR));
- this.validFromDay = new Long (fromCal.get(Calendar.DAY_OF_YEAR));
+ this.validFromYear = Long.valueOf( fromCal.get(Calendar.YEAR));
+ this.validFromDay = Long.valueOf(fromCal.get(Calendar.DAY_OF_YEAR));
}
@@ -275,8 +275,8 @@ public class VoucherData extends Object { untilCal.clear();
untilCal.setTime(untilDate);
- this.validUntilYear = new Long( untilCal.get(Calendar.YEAR));
- this.validUntilDay = new Long (untilCal.get(Calendar.DAY_OF_YEAR));
+ this.validUntilYear = Long.valueOf( untilCal.get(Calendar.YEAR));
+ this.validUntilDay = Long.valueOf(untilCal.get(Calendar.DAY_OF_YEAR));
}
diff --git a/src/main/java/org/uic/barcode/utils/SecurityUtils.java b/src/main/java/org/uic/barcode/utils/SecurityUtils.java index 8f19e4b..b17bbb9 100644 --- a/src/main/java/org/uic/barcode/utils/SecurityUtils.java +++ b/src/main/java/org/uic/barcode/utils/SecurityUtils.java @@ -348,4 +348,15 @@ public class SecurityUtils { return Constants.DSA_SHA1;
}
}
+
+ /*
+ * get a default security provider to be used in case a provider is missing
+ * bouncyCastle is assumed to be implemented
+ * if bouncyCastel is missing in the environment the provider stays empty.
+ */
+ public static Provider getDefaultProvider() {
+
+ return Security.getProvider("BC");
+
+ }
}
diff --git a/src/test/java/org/uic/barcode/asn1/test/BinaryStringTest.java b/src/test/java/org/uic/barcode/asn1/test/BinaryStringTest.java index bb06eae..6129db3 100644 --- a/src/test/java/org/uic/barcode/asn1/test/BinaryStringTest.java +++ b/src/test/java/org/uic/barcode/asn1/test/BinaryStringTest.java @@ -41,7 +41,7 @@ public class BinaryStringTest { 0b0000_0001,
};
String bs3 = AsnUtils.toBooleanString(mask);
- byte[] bytes2 = AsnUtils.fromBooleanString(bs3);
+ //byte[] bytes2 = AsnUtils.fromBooleanString(bs3);
byte[] mask2 = new byte[] {
@@ -51,7 +51,7 @@ public class BinaryStringTest { 0b0001_0000,
};
String bs4 = AsnUtils.toBooleanString(mask2);
- byte[] bytes3 = AsnUtils.fromBooleanString(bs4);
+ //byte[] bytes3 = AsnUtils.fromBooleanString(bs4);
assert(bs4.equals(ms2));
diff --git a/src/test/java/org/uic/barcode/asn1/test/TestSequenceOfLong.java b/src/test/java/org/uic/barcode/asn1/test/TestSequenceOfLong.java index 61af5fa..821bf2b 100644 --- a/src/test/java/org/uic/barcode/asn1/test/TestSequenceOfLong.java +++ b/src/test/java/org/uic/barcode/asn1/test/TestSequenceOfLong.java @@ -13,7 +13,7 @@ public class TestSequenceOfLong extends Asn1SequenceOf<Long> { public TestSequenceOfLong(List<Long> numbers) {
super();
for (Long number: numbers){
- this.add(new Long(number));
+ this.add(Long.valueOf(number));
}
}
diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeBooleanTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeBooleanTest.java index dea2716..de39e5c 100644 --- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeBooleanTest.java +++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeBooleanTest.java @@ -43,7 +43,7 @@ public class UperEncodeBooleanTest { } @Test public void testTrue() throws IllegalArgumentException, IllegalAccessException { - TestRecord record = new TestRecord(new Boolean(true)); + TestRecord record = new TestRecord(Boolean.valueOf(true)); byte[] encoded = UperEncoder.encode(record); String hex = UperEncoder.hexStringFromBytes(encoded); UperEncoder.logger.log(Level.FINEST,String.format("data hex: %s", hex)); @@ -51,7 +51,7 @@ public class UperEncodeBooleanTest { } @Test public void testFalse() throws IllegalArgumentException, IllegalAccessException { - TestRecord record = new TestRecord(new Boolean(false)); + TestRecord record = new TestRecord(Boolean.valueOf(false)); byte[] encoded = UperEncoder.encode(record); String hex = UperEncoder.hexStringFromBytes(encoded); UperEncoder.logger.log(Level.FINEST,String.format("data hex: %s", hex)); @@ -59,7 +59,7 @@ public class UperEncodeBooleanTest { } @Test public void testDecodeTrue() throws IllegalArgumentException, IllegalAccessException { - TestRecord record = new TestRecord(new Boolean(true)); + TestRecord record = new TestRecord(Boolean.valueOf(true)); byte[] encoded = UperEncoder.encode(record); String hex = UperEncoder.hexStringFromBytes(encoded); UperEncoder.logger.log(Level.FINEST,String.format("data hex: %s", hex)); @@ -70,7 +70,7 @@ public class UperEncodeBooleanTest { } @Test public void testDecodeFalse() throws IllegalArgumentException, IllegalAccessException { - TestRecord record = new TestRecord(new Boolean(false)); + TestRecord record = new TestRecord(Boolean.valueOf(false)); byte[] encoded = UperEncoder.encode(record); String hex = UperEncoder.hexStringFromBytes(encoded); UperEncoder.logger.log(Level.FINEST,String.format("data hex: %s", hex)); diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerConstrainedTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerConstrainedTest.java index 2f46046..bde99fe 100644 --- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerConstrainedTest.java +++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerConstrainedTest.java @@ -42,7 +42,7 @@ public class UperEncodeIntegerConstrainedTest { public TestRecord() { - this(new Long(63L)); + this(Long.valueOf(63L)); } public TestRecord(Long num) { diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerSmallTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerSmallTest.java index 39bfb32..d6600fe 100644 --- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerSmallTest.java +++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerSmallTest.java @@ -33,7 +33,7 @@ public class UperEncodeIntegerSmallTest { public Integer value2; public TestRecord() { - this(new Long(12345678909999899L)); + this(Long.valueOf(12345678909999899L)); } public TestRecord(Long num) { diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerTest.java index 412689b..3e10fc7 100644 --- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerTest.java +++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeIntegerTest.java @@ -30,7 +30,7 @@ public class UperEncodeIntegerTest { Asn1BigInteger value; public TestRecord() { - this(new Long(12345678909999899L)); + this(Long.valueOf(12345678909999899L)); } public TestRecord(Long num) { diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeRestrictedIntegerTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeRestrictedIntegerTest.java index f806c88..3f0f08a 100644 --- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeRestrictedIntegerTest.java +++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeRestrictedIntegerTest.java @@ -31,7 +31,7 @@ TestRecord ::= [APPLICATION 0] IMPLICIT SEQUENCE { Long value; public TestRecord() { - this(new Long(33005)); + this(Long.valueOf(33005)); } public TestRecord(Long num) { diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfIntegerTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfIntegerTest.java index 3213b1e..ea0d955 100644 --- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfIntegerTest.java +++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfIntegerTest.java @@ -46,8 +46,8 @@ TestRecord ::= [APPLICATION 0] IMPLICIT SEQUENCE { @Test public void test() throws IllegalArgumentException, IllegalAccessException { ArrayList<Long> nums = new ArrayList<Long>(); - nums.add(new Long(12345678909999899L)); - nums.add(new Long(12345678909999899L)); + nums.add(Long.valueOf(12345678909999899L)); + nums.add(Long.valueOf(12345678909999899L)); TestRecord record = new TestRecord(nums); byte[] encoded = UperEncoder.encode(record); String hex = UperEncoder.hexStringFromBytes(encoded); @@ -59,8 +59,8 @@ TestRecord ::= [APPLICATION 0] IMPLICIT SEQUENCE { @Test public void testDecode() throws IllegalArgumentException, IllegalAccessException { ArrayList<Long> nums = new ArrayList<Long>(); - nums.add(new Long(12345678909999899L)); - nums.add(new Long(12345678909999899L)); + nums.add(Long.valueOf(12345678909999899L)); + nums.add(Long.valueOf(12345678909999899L)); TestRecord record = new TestRecord(nums); byte[] encoded = UperEncoder.encode(record); String hex = UperEncoder.hexStringFromBytes(encoded); diff --git a/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfRestrictedIntegerTest.java b/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfRestrictedIntegerTest.java index 33e9b9f..fffffd4 100644 --- a/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfRestrictedIntegerTest.java +++ b/src/test/java/org/uic/barcode/asn1/test/UperEncodeSequenceOfRestrictedIntegerTest.java @@ -49,8 +49,8 @@ TestRecord ::= [APPLICATION 0] IMPLICIT SEQUENCE { TestRecord record = new TestRecord(); - record.addNumber(new Long(9500001L)); - record.addNumber(new Long(9699999L)); + record.addNumber(Long.valueOf(9500001L)); + record.addNumber(Long.valueOf(9699999L)); byte[] encoded = UperEncoder.encode(record); @@ -63,8 +63,8 @@ TestRecord ::= [APPLICATION 0] IMPLICIT SEQUENCE { TestRecord record = new TestRecord(); - record.addNumber(new Long(9500001L)); - record.addNumber(new Long(9699999L)); + record.addNumber(Long.valueOf(9500001L)); + record.addNumber(Long.valueOf(9699999L)); byte[] encoded = UperEncoder.encode(record); diff --git a/src/test/java/org/uic/barcode/test/DynamicContentCoderTest.java b/src/test/java/org/uic/barcode/test/DynamicContentCoderTest.java index 07147bf..1fb8bb9 100644 --- a/src/test/java/org/uic/barcode/test/DynamicContentCoderTest.java +++ b/src/test/java/org/uic/barcode/test/DynamicContentCoderTest.java @@ -2,9 +2,6 @@ package org.uic.barcode.test; import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.TimeZone;
-
import org.junit.Before;
import org.junit.Test;
import org.uic.barcode.asn1.uper.UperEncoder;
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureCompressedCurveTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureCompressedCurveTest.java index 3a3f7d2..344f55f 100644 --- a/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureCompressedCurveTest.java +++ b/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureCompressedCurveTest.java @@ -87,7 +87,7 @@ public class DynamicFrameDoubleSignatureCompressedCurveTest { try {
enc.setLevel1Algs(signatureAlgorithmOID, keyPairAlgorithmOID);
enc.setLevel2Algs(signatureAlgorithmOID, keyPairAlgorithmOID,keyPairLevel2.getPublic(), ECKeyEncoder.ENCODING_X962_COMPRESSED);
- enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1", provider);
} catch (Exception e) {
assert(false);
}
@@ -98,7 +98,7 @@ public class DynamicFrameDoubleSignatureCompressedCurveTest { IData level2Data = Level2TestDataFactory.getLevel2SimpleTestData();
try {
enc.setLevel2Data(level2Data);
- enc.signLevel2(keyPairLevel2.getPrivate());
+ enc.signLevel2(keyPairLevel2.getPrivate(),provider);
} catch (Exception e) {
assert(false);
}
@@ -127,7 +127,7 @@ public class DynamicFrameDoubleSignatureCompressedCurveTest { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(), null);
+ signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(), null, provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
@@ -136,7 +136,7 @@ public class DynamicFrameDoubleSignatureCompressedCurveTest { signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel2();
+ signatureCheck = dec.validateLevel2(provider);
} catch (Exception e) {
assert(false);
}
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureCurve2Test.java b/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureCurve2Test.java index f118026..2f2a185 100644 --- a/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureCurve2Test.java +++ b/src/test/java/org/uic/barcode/test/DynamicFrameDoubleSignatureCurve2Test.java @@ -86,7 +86,7 @@ public class DynamicFrameDoubleSignatureCurve2Test { try {
enc.setLevel1Algs(signatureAlgorithmOID, keyPairAlgorithmOID);
enc.setLevel2Algs(signatureAlgorithmOID, keyPairAlgorithmOID,keyPairLevel2.getPublic());
- enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1", provider);
} catch (Exception e) {
assert(false);
}
@@ -97,7 +97,7 @@ public class DynamicFrameDoubleSignatureCurve2Test { IData level2Data = Level2TestDataFactory.getLevel2SimpleTestData();
try {
enc.setLevel2Data(level2Data);
- enc.signLevel2(keyPairLevel2.getPrivate());
+ enc.signLevel2(keyPairLevel2.getPrivate(),provider);
} catch (Exception e) {
assert(false);
}
@@ -126,7 +126,7 @@ public class DynamicFrameDoubleSignatureCurve2Test { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(), null);
+ signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(), null, provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
@@ -135,7 +135,7 @@ public class DynamicFrameDoubleSignatureCurve2Test { signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel2();
+ signatureCheck = dec.validateLevel2(provider);
} catch (Exception e) {
assert(false);
}
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentApiTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentApiTest.java index da701bd..5906f8c 100644 --- a/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentApiTest.java +++ b/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentApiTest.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -44,6 +45,8 @@ public class DynamicFrameDynamicContentApiTest { public byte[] passIdHash = "PassId".getBytes();
public byte[] phoneIdHash = "myPhone".getBytes();
+ public Provider provider = null;
+
public IUicRailTicket testFCBticket = null;
@@ -58,7 +61,8 @@ public class DynamicFrameDynamicContentApiTest { testFCBticket = SimpleUICTestTicket.getUicTestTicket();
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPairLevel1 = generateECKeys(keyPairAlgorithmOID, elipticCurve);
@@ -91,14 +95,14 @@ public class DynamicFrameDynamicContentApiTest { enc.setLevel2Algs(signatureAlgorithmOID, keyPairAlgorithmOID, keyPairLevel2.getPublic());
try {
- enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
try {
enc.setDynamicData(DynamicTestContent.createDynamicTestContent());
- enc.signLevel2(keyPairLevel2.getPrivate());
+ enc.signLevel2(keyPairLevel2.getPrivate(),provider);
} catch (Exception e) {
assert(false);
@@ -135,14 +139,14 @@ public class DynamicFrameDynamicContentApiTest { enc.setLevel2Algs(signatureAlgorithmOID, keyPairAlgorithmOID, keyPairLevel2.getPublic());
try {
- enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
try {
enc.setDynamicData(DynamicTestContent.createDynamicTestContent());
- enc.signLevel2(keyPairLevel2.getPrivate());
+ enc.signLevel2(keyPairLevel2.getPrivate(),provider);
} catch (Exception e) {
assert(false);
}
@@ -171,7 +175,7 @@ public class DynamicFrameDynamicContentApiTest { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(),null);
+ signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(),null,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
@@ -183,7 +187,7 @@ public class DynamicFrameDynamicContentApiTest { int level2check = 0;
try {
- level2check = dec.validateLevel2();
+ level2check = dec.validateLevel2(provider);
} catch (Exception e) {
assert(false);
}
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentTest.java index b91cd0c..a7ea2ea 100644 --- a/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentTest.java +++ b/src/test/java/org/uic/barcode/test/DynamicFrameDynamicContentTest.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -48,9 +49,13 @@ public class DynamicFrameDynamicContentTest { ZonedDateTime originalTimeStamp = ZonedDateTime.now(ZoneId.of("UTC"));
+ public Provider provider = null;
+
public IUicRailTicket testFCBticket = null;
+
+
@Before public void initialize() {
LoggerFactory.setActivateConsoleLog(true);
@@ -61,7 +66,8 @@ public class DynamicFrameDynamicContentTest { testFCBticket = SimpleUICTestTicket.getUicTestTicket();
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPairLevel1 = generateECKeys(keyPairAlgorithmOID, elipticCurve);
@@ -94,7 +100,7 @@ public class DynamicFrameDynamicContentTest { enc.setLevel2Algs(signatureAlgorithmOID, keyPairAlgorithmOID, keyPairLevel2.getPublic());
try {
- enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1", provider);
} catch (Exception e) {
assert(false);
}
@@ -115,7 +121,7 @@ public class DynamicFrameDynamicContentTest { dcd.setGeoCoordinate(geo);
enc.setDynamicContentDataUIC1(dcd);
- enc.signLevel2(keyPairLevel2.getPrivate());
+ enc.signLevel2(keyPairLevel2.getPrivate(),provider);
} catch (Exception e) {
assert(false);
}
@@ -151,7 +157,7 @@ public class DynamicFrameDynamicContentTest { enc.setLevel2Algs(signatureAlgorithmOID, keyPairAlgorithmOID, keyPairLevel2.getPublic());
try {
- enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -173,7 +179,7 @@ public class DynamicFrameDynamicContentTest { dcd.setTimeStamp(ts);
enc.setDynamicContentDataUIC1(dcd);
- enc.signLevel2(keyPairLevel2.getPrivate());
+ enc.signLevel2(keyPairLevel2.getPrivate(),provider);
} catch (Exception e) {
assert(false);
}
@@ -202,7 +208,7 @@ public class DynamicFrameDynamicContentTest { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(),null);
+ signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(),null,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
@@ -214,7 +220,7 @@ public class DynamicFrameDynamicContentTest { int level2check = 0;
try {
- level2check = dec.validateLevel2();
+ level2check = dec.validateLevel2(provider);
} catch (Exception e) {
assert(false);
}
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion1Test.java b/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion1Test.java index dafeb49..b71487e 100644 --- a/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion1Test.java +++ b/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion1Test.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -36,6 +37,8 @@ public class DynamicFrameFcbVersion1Test { public IUicRailTicket testFCBticket = null;
+ public Provider provider = null;
+
@Before public void initialize() {
@@ -47,7 +50,8 @@ public class DynamicFrameFcbVersion1Test { testFCBticket = SimpleUICTestTicket.getUicTestTicket();
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = generateECKeys(Constants.KG_EC, elipticCurve);
@@ -76,7 +80,7 @@ public class DynamicFrameFcbVersion1Test { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -109,7 +113,7 @@ public class DynamicFrameFcbVersion1Test { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -138,7 +142,7 @@ public class DynamicFrameFcbVersion1Test { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPair.getPublic(),null);
+ signatureCheck = dec.validateLevel1(keyPair.getPublic(),null,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion3Test.java b/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion3Test.java index 7f03658..08b6df8 100644 --- a/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion3Test.java +++ b/src/test/java/org/uic/barcode/test/DynamicFrameFcbVersion3Test.java @@ -1,12 +1,11 @@ package org.uic.barcode.test;
import java.io.IOException;
-import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -36,6 +35,8 @@ public class DynamicFrameFcbVersion3Test { public IUicRailTicket testFCBticket = null;
+ public Provider provider = null;
+
@Before public void initialize() {
@@ -47,7 +48,8 @@ public class DynamicFrameFcbVersion3Test { testFCBticket = SimpleUICTestTicket.getUicTestTicket();
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = generateECKeys(Constants.KG_EC, elipticCurve);
@@ -76,7 +78,7 @@ public class DynamicFrameFcbVersion3Test { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -109,7 +111,7 @@ public class DynamicFrameFcbVersion3Test { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -138,7 +140,7 @@ public class DynamicFrameFcbVersion3Test { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPair.getPublic());
+ signatureCheck = dec.validateLevel1(keyPair.getPublic(),null,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameSimpleTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameSimpleTest.java index 931324d..ff552cb 100644 --- a/src/test/java/org/uic/barcode/test/DynamicFrameSimpleTest.java +++ b/src/test/java/org/uic/barcode/test/DynamicFrameSimpleTest.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -35,6 +36,8 @@ public class DynamicFrameSimpleTest { public IUicRailTicket testFCBticket = null;
+ public Provider provider = null;
+
@Before public void initialize() {
@@ -46,7 +49,8 @@ public class DynamicFrameSimpleTest { testFCBticket = SimpleUICTestTicket.getUicTestTicket();
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = generateECKeys(Constants.KG_EC, elipticCurve);
@@ -75,7 +79,7 @@ public class DynamicFrameSimpleTest { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -109,7 +113,7 @@ public class DynamicFrameSimpleTest { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -138,7 +142,7 @@ public class DynamicFrameSimpleTest { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPair.getPublic(),null);
+ signatureCheck = dec.validateLevel1(keyPair.getPublic(),null,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameV2FcbVersion3Test.java b/src/test/java/org/uic/barcode/test/DynamicFrameV2FcbVersion3Test.java index ab4c39e..f9afaef 100644 --- a/src/test/java/org/uic/barcode/test/DynamicFrameV2FcbVersion3Test.java +++ b/src/test/java/org/uic/barcode/test/DynamicFrameV2FcbVersion3Test.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -36,6 +37,8 @@ public class DynamicFrameV2FcbVersion3Test { public IUicRailTicket testFCBticket = null;
+ public Provider provider = null;
+
@Before public void initialize() {
@@ -47,7 +50,8 @@ public class DynamicFrameV2FcbVersion3Test { testFCBticket = SimpleUICTestTicket.getUicTestTicket();
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = generateECKeys(Constants.KG_EC, elipticCurve);
@@ -76,7 +80,7 @@ public class DynamicFrameV2FcbVersion3Test { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -109,7 +113,7 @@ public class DynamicFrameV2FcbVersion3Test { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -138,7 +142,7 @@ public class DynamicFrameV2FcbVersion3Test { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPair.getPublic(),null);
+ signatureCheck = dec.validateLevel1(keyPair.getPublic(),null,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsert2Test.java b/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsert2Test.java index 5b5a8ae..bae03f9 100644 --- a/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsert2Test.java +++ b/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsert2Test.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -46,6 +47,8 @@ public class DynamicFrameV2SignatureInsert2Test { public IUicRailTicket testFCBticket = null;
+ public Provider provider = null;
+
ZonedDateTime originalTimeStamp = ZonedDateTime.now(ZoneId.of("UTC"));
@Before public void initialize() {
@@ -58,7 +61,8 @@ public class DynamicFrameV2SignatureInsert2Test { testFCBticket = SimpleUICTestTicket.getUicTestTicket();
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPairLevel1 = generateECKeys(keyPairAlgorithmOID, elipticCurve);
@@ -97,7 +101,7 @@ public class DynamicFrameV2SignatureInsert2Test { //sign level 1 data
try {
- enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -139,7 +143,7 @@ public class DynamicFrameV2SignatureInsert2Test { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(),null);
+ signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(),null,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
@@ -169,7 +173,7 @@ public class DynamicFrameV2SignatureInsert2Test { //-----------
// sign level 2
try {
- enc.signLevel2(keyPairLevel2.getPrivate());
+ enc.signLevel2(keyPairLevel2.getPrivate(),provider);
} catch (Exception e) {
assert(false);
}
@@ -204,7 +208,7 @@ public class DynamicFrameV2SignatureInsert2Test { signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(),null);
+ signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(),null,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
@@ -215,7 +219,7 @@ public class DynamicFrameV2SignatureInsert2Test { signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel2();
+ signatureCheck = dec.validateLevel2(provider);
} catch (Exception e) {
assert(false);
}
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsertTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsertTest.java index 68be52e..f539bfa 100644 --- a/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsertTest.java +++ b/src/test/java/org/uic/barcode/test/DynamicFrameV2SignatureInsertTest.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -46,6 +47,8 @@ public class DynamicFrameV2SignatureInsertTest { public IUicRailTicket testFCBticket = null;
+ public Provider provider = null;
+
ZonedDateTime originalTimeStamp = ZonedDateTime.now(ZoneId.of("UTC"));
@Before public void initialize() {
@@ -58,7 +61,8 @@ public class DynamicFrameV2SignatureInsertTest { testFCBticket = SimpleUICTestTicket.getUicTestTicket();
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPairLevel1 = generateECKeys(keyPairAlgorithmOID, elipticCurve);
@@ -97,7 +101,7 @@ public class DynamicFrameV2SignatureInsertTest { //sign level 1 data
try {
- enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPairLevel1.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -139,7 +143,7 @@ public class DynamicFrameV2SignatureInsertTest { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(),null);
+ signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(),null,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
@@ -188,7 +192,7 @@ public class DynamicFrameV2SignatureInsertTest { //-----------
// sign level 2
try {
- enc.signLevel2(keyPairLevel2.getPrivate());
+ enc.signLevel2(keyPairLevel2.getPrivate(),provider);
} catch (Exception e) {
assert(false);
}
@@ -223,7 +227,7 @@ public class DynamicFrameV2SignatureInsertTest { signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(),null);
+ signatureCheck = dec.validateLevel1(keyPairLevel1.getPublic(),null,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
@@ -234,7 +238,7 @@ public class DynamicFrameV2SignatureInsertTest { signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel2();
+ signatureCheck = dec.validateLevel2(provider);
} catch (Exception e) {
assert(false);
}
diff --git a/src/test/java/org/uic/barcode/test/DynamicFrameV2ValidityDateTest.java b/src/test/java/org/uic/barcode/test/DynamicFrameV2ValidityDateTest.java index a198b97..56272d3 100644 --- a/src/test/java/org/uic/barcode/test/DynamicFrameV2ValidityDateTest.java +++ b/src/test/java/org/uic/barcode/test/DynamicFrameV2ValidityDateTest.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -40,6 +41,8 @@ public class DynamicFrameV2ValidityDateTest { public IUicRailTicket testFCBticket = null;
+ public Provider provider = null;
+
@Before public void initialize() {
@@ -51,7 +54,8 @@ public class DynamicFrameV2ValidityDateTest { testFCBticket = SimpleUICTestTicket.getUicTestTicket();
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = generateECKeys(Constants.KG_EC, elipticCurve);
@@ -93,7 +97,7 @@ public class DynamicFrameV2ValidityDateTest { enc.getDynamicFrame().getLevel2Data().getLevel1Data().setValidityDuration(100L);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -139,7 +143,7 @@ public class DynamicFrameV2ValidityDateTest { enc.getDynamicFrame().getLevel2Data().getLevel1Data().setValidityDuration(100L);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), signatureAlgorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -168,7 +172,7 @@ public class DynamicFrameV2ValidityDateTest { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPair.getPublic(),null);
+ signatureCheck = dec.validateLevel1(keyPair.getPublic(),null,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
diff --git a/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestGroup.java b/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestGroup.java index f6ec58b..b0f1589 100644 --- a/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestGroup.java +++ b/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestGroup.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -40,6 +41,8 @@ public class SsbFrameBarcodeTestGroup { public SsbFrame ssbFrame = null;
+ public Provider provider = null;
+
/**
* Initialize.
*
@@ -55,7 +58,8 @@ public class SsbFrameBarcodeTestGroup { algorithmOID = Constants.DSA_SHA224;
keySize = 1024;
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = generateDSAKeys(keySize);
@@ -90,7 +94,7 @@ public class SsbFrameBarcodeTestGroup { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -129,7 +133,7 @@ public class SsbFrameBarcodeTestGroup { assert(enc != null);
try {
- enc.signLevel1("4711", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("4711", keyPair.getPrivate(), algorithmOID, "1", provider);
} catch (Exception e) {
assert(false);
}
@@ -158,7 +162,7 @@ public class SsbFrameBarcodeTestGroup { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID);
+ signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
diff --git a/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestNonUic.java b/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestNonUic.java index 2a28d80..201e417 100644 --- a/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestNonUic.java +++ b/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestNonUic.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -38,6 +39,8 @@ public class SsbFrameBarcodeTestNonUic { public SsbFrame ssbFrame = null;
+
+ public Provider provider = null;
/**
@@ -55,7 +58,8 @@ public class SsbFrameBarcodeTestNonUic { algorithmOID = Constants.DSA_SHA224;
keySize = 1024;
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = generateDSAKeys(keySize);
@@ -90,7 +94,7 @@ public class SsbFrameBarcodeTestNonUic { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -129,7 +133,7 @@ public class SsbFrameBarcodeTestNonUic { assert(enc != null);
try {
- enc.signLevel1("4711", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("4711", keyPair.getPrivate(), algorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -158,7 +162,7 @@ public class SsbFrameBarcodeTestNonUic { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID);
+ signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
diff --git a/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestNrt.java b/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestNrt.java index 2000ee1..f0e7d79 100644 --- a/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestNrt.java +++ b/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestNrt.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -38,6 +39,8 @@ public class SsbFrameBarcodeTestNrt { public SsbFrame ssbFrame = null;
+
+ public Provider provider = null;
/**
@@ -55,7 +58,8 @@ public class SsbFrameBarcodeTestNrt { algorithmOID = Constants.DSA_SHA224;
keySize = 1024;
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = generateDSAKeys(keySize);
@@ -90,7 +94,7 @@ public class SsbFrameBarcodeTestNrt { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -129,7 +133,7 @@ public class SsbFrameBarcodeTestNrt { assert(enc != null);
try {
- enc.signLevel1("4711", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("4711", keyPair.getPrivate(), algorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -158,7 +162,7 @@ public class SsbFrameBarcodeTestNrt { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID);
+ signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
diff --git a/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestPass.java b/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestPass.java index dd2101a..ff78d01 100644 --- a/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestPass.java +++ b/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestPass.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -38,6 +39,8 @@ public class SsbFrameBarcodeTestPass { public SsbFrame ssbFrame = null;
+
+ public Provider provider = null;
/**
@@ -55,7 +58,8 @@ public class SsbFrameBarcodeTestPass { algorithmOID = Constants.DSA_SHA224;
keySize = 1024;
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = generateDSAKeys(keySize);
@@ -90,7 +94,7 @@ public class SsbFrameBarcodeTestPass { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -129,7 +133,7 @@ public class SsbFrameBarcodeTestPass { assert(enc != null);
try {
- enc.signLevel1("4711", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("4711", keyPair.getPrivate(), algorithmOID, "1", provider);
} catch (Exception e) {
assert(false);
}
@@ -158,7 +162,7 @@ public class SsbFrameBarcodeTestPass { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID);
+ signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
diff --git a/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestReservation.java b/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestReservation.java index 5f9e11e..e81bcb4 100644 --- a/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestReservation.java +++ b/src/test/java/org/uic/barcode/test/SsbFrameBarcodeTestReservation.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -39,6 +40,8 @@ public class SsbFrameBarcodeTestReservation { public SsbFrame ssbFrame = null;
+ public Provider provider = null;
+
/**
* Initialize.
@@ -55,7 +58,8 @@ public class SsbFrameBarcodeTestReservation { algorithmOID = Constants.DSA_SHA224;
keySize = 1024;
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = generateDSAKeys(keySize);
@@ -90,7 +94,7 @@ public class SsbFrameBarcodeTestReservation { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -129,7 +133,7 @@ public class SsbFrameBarcodeTestReservation { assert(enc != null);
try {
- enc.signLevel1("4711", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("4711", keyPair.getPrivate(), algorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -158,7 +162,7 @@ public class SsbFrameBarcodeTestReservation { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID);
+ signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
diff --git a/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTest.java b/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTest.java index 0aafc3b..2162b71 100644 --- a/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTest.java +++ b/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTest.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -43,6 +44,8 @@ public class StaticFrameBarcodeTest { public TicketLayout testLayout = null;
+ public Provider provider = null;
+
/**
* Initialize.
@@ -61,7 +64,8 @@ public class StaticFrameBarcodeTest { testFCBticket = SimpleUICTestTicket.getUicTestTicket();
testLayout = SimpleTestTicketLayout.getSimpleTestTicketLayout();
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = generateDSAKeys(keySize);
@@ -96,7 +100,7 @@ public class StaticFrameBarcodeTest { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -136,7 +140,7 @@ public class StaticFrameBarcodeTest { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1", provider);
} catch (Exception e) {
assert(false);
}
@@ -165,7 +169,7 @@ public class StaticFrameBarcodeTest { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID);
+ signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID, provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
diff --git a/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTestFCB2.java b/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTestFCB2.java index 0a0c245..ab6c2b4 100644 --- a/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTestFCB2.java +++ b/src/test/java/org/uic/barcode/test/StaticFrameBarcodeTestFCB2.java @@ -7,6 +7,7 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
@@ -43,6 +44,8 @@ public class StaticFrameBarcodeTestFCB2 { public TicketLayout testLayout = null;
+ public Provider provider = null;
+
/**
* Initialize.
@@ -61,7 +64,8 @@ public class StaticFrameBarcodeTestFCB2 { testFCBticket = SimpleUICTestTicket.getUicTestTicket();
testLayout = SimpleTestTicketLayout.getSimpleTestTicketLayout();
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = generateDSAKeys(keySize);
@@ -96,7 +100,7 @@ public class StaticFrameBarcodeTestFCB2 { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -136,7 +140,7 @@ public class StaticFrameBarcodeTestFCB2 { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1", provider);
} catch (Exception e) {
assert(false);
}
@@ -165,7 +169,7 @@ public class StaticFrameBarcodeTestFCB2 { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID);
+ signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
diff --git a/src/test/java/org/uic/barcode/test/TimeStampTest.java b/src/test/java/org/uic/barcode/test/TimeStampTest.java index 8c07b06..c2c1d19 100644 --- a/src/test/java/org/uic/barcode/test/TimeStampTest.java +++ b/src/test/java/org/uic/barcode/test/TimeStampTest.java @@ -65,8 +65,8 @@ public class TimeStampTest { //implementation not available on older android versions:
ZonedDateTime now = ZonedDateTime.now(ZoneId.of("UTC"));
- long day = new Long(now.get(ChronoField.DAY_OF_YEAR));
- long secondOfDay = new Long(now.get(ChronoField.SECOND_OF_DAY));
+ long day = Long.valueOf(now.get(ChronoField.DAY_OF_YEAR));
+ long secondOfDay = Long.valueOf(now.get(ChronoField.SECOND_OF_DAY));
//alternative implementation
Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
diff --git a/src/test/java/org/uic/barcode/ticket/api/test/SecurityProviderTestV1.java b/src/test/java/org/uic/barcode/ticket/api/test/SecurityProviderTestV1.java index 240907c..d0fc191 100644 --- a/src/test/java/org/uic/barcode/ticket/api/test/SecurityProviderTestV1.java +++ b/src/test/java/org/uic/barcode/ticket/api/test/SecurityProviderTestV1.java @@ -1,6 +1,5 @@ package org.uic.barcode.ticket.api.test;
-import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
@@ -8,11 +7,10 @@ import java.security.KeyPair; import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.SecureRandom;
import java.security.Security;
import java.security.SignatureException;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactory;
import java.util.zip.DataFormatException;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
@@ -46,6 +44,8 @@ public class SecurityProviderTestV1 { public TicketLayout testLayout = null;
+ public Provider provider = null;
+
/**
* Initialize.
@@ -66,8 +66,8 @@ public class SecurityProviderTestV1 { testFCBticket.getIssuerDetails().setSecurityProvider("1080");
testFCBticket.getIssuerDetails().setIssuer("4711");
-
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = generateDSAKeys(keySize);
@@ -105,7 +105,7 @@ public class SecurityProviderTestV1 { assert(enc != null);
try {
- enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1");
+ enc.signLevel1("1080", keyPair.getPrivate(), algorithmOID, "1",provider);
} catch (Exception e) {
assert(false);
}
@@ -134,7 +134,7 @@ public class SecurityProviderTestV1 { int signatureCheck = 0;
try {
- signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID);
+ signatureCheck = dec.validateLevel1(keyPair.getPublic(),algorithmOID,provider);
} catch (InvalidKeyException | NoSuchAlgorithmException | SignatureException | IllegalArgumentException
| UnsupportedOperationException | IOException | EncodingFormatException e) {
assert(false);
diff --git a/src/test/java/org/uic/barcode/ticketTestDB/BahnCardTest.java b/src/test/java/org/uic/barcode/ticketTestDB/BahnCardTest.java index 8a0dd8d..f89e7e7 100644 --- a/src/test/java/org/uic/barcode/ticketTestDB/BahnCardTest.java +++ b/src/test/java/org/uic/barcode/ticketTestDB/BahnCardTest.java @@ -61,7 +61,7 @@ public class BahnCardTest { assert(card.getCardTypeDescr().equals("My BahnCard 50 (2. Klasse)")); assert(card.getClassCode().equals(ITravelClassType.second)); assert(card.getExtension() != null); - assert(card.getIncludedServices().contains(new Integer(1))); + assert(card.getIncludedServices().contains(Integer.valueOf(1))); Assert.assertNotNull(card.getCustomer() != null); diff --git a/src/test/java/org/uic/barcode/ticketTestDB/DecodeSparpreisTicketDBTest.java b/src/test/java/org/uic/barcode/ticketTestDB/DecodeSparpreisTicketDBTest.java index 2898b59..90e33c1 100644 --- a/src/test/java/org/uic/barcode/ticketTestDB/DecodeSparpreisTicketDBTest.java +++ b/src/test/java/org/uic/barcode/ticketTestDB/DecodeSparpreisTicketDBTest.java @@ -98,7 +98,7 @@ public class DecodeSparpreisTicketDBTest { Assert.assertNotNull(tl); assert(tl.getTrain().equals("ICE973")); String departureDate = tl.getDepartureDateTime().toString(); - assert(departureDate.equals("Fri Nov 06 11:58:00 CET 2020")); + assert(departureDate.equals("Thu Nov 05 11:58:00 CET 2020")); Assert.assertNull(layout); Assert.assertNotNull(decoder); } diff --git a/src/test/java/org/uic/barcode/ticketTestDB/EncodeSparpreisTicketDBTest.java b/src/test/java/org/uic/barcode/ticketTestDB/EncodeSparpreisTicketDBTest.java index 2cb6d69..cddcd60 100644 --- a/src/test/java/org/uic/barcode/ticketTestDB/EncodeSparpreisTicketDBTest.java +++ b/src/test/java/org/uic/barcode/ticketTestDB/EncodeSparpreisTicketDBTest.java @@ -5,6 +5,7 @@ import java.security.InvalidAlgorithmParameterException; import java.security.KeyPair;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.Provider;
import java.security.Security;
import java.util.TimeZone;
import java.util.zip.DataFormatException;
@@ -39,6 +40,8 @@ public class EncodeSparpreisTicketDBTest { public IUicRailTicket ticket = null;
TimeZone defaulttimeZone = null;
+
+ public Provider provider = null;
/**
* Prepare tickets.
@@ -57,7 +60,8 @@ public class EncodeSparpreisTicketDBTest { algorithmOID = Constants.DSA_SHA1;
keySize = 1024;
- Security.addProvider(new BouncyCastleProvider());
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
try {
keyPair = TestUtils.generateDSAKeys(keySize);
@@ -88,7 +92,7 @@ public class EncodeSparpreisTicketDBTest { public void testDecoder() throws Exception {
Encoder encoder = new Encoder(ticket, null, Encoder.UIC_BARCODE_TYPE_CLASSIC, 1, 2);
- encoder.signLevel1(securityProvider, keyPair.getPrivate(), algorithmOID, "1");
+ encoder.signLevel1(securityProvider, keyPair.getPrivate(), algorithmOID, "1", null);
byte[] encoded = encoder.encode();
diff --git a/src/test/java/org/uic/barcode/ticketTestDB/EurailPassTest.java b/src/test/java/org/uic/barcode/ticketTestDB/EurailPassTest.java index b75f248..cc317b8 100644 --- a/src/test/java/org/uic/barcode/ticketTestDB/EurailPassTest.java +++ b/src/test/java/org/uic/barcode/ticketTestDB/EurailPassTest.java @@ -1,7 +1,6 @@ package org.uic.barcode.ticketTestDB; -import java.util.Base64; import java.util.TimeZone; import org.junit.After; @@ -12,7 +11,6 @@ import org.uic.barcode.Decoder; import org.uic.barcode.logger.LoggerFactory; import org.uic.barcode.staticFrame.ticketLayoutBarcode.TicketLayout; import org.uic.barcode.test.utils.TestUtils; -import org.uic.barcode.ticket.api.spec.IUicRailTicket; public class EurailPassTest { @@ -70,7 +68,7 @@ public class EurailPassTest { // try to decode Decoder decoder = new Decoder(content); TicketLayout layout = decoder.getLayout(); - IUicRailTicket ticket = decoder.getUicTicket(); + //IUicRailTicket ticket = decoder.getUicTicket(); Assert.assertNotNull(layout); //Assert.assertNotNull(ticket); diff --git a/src/test/java/org/uic/barcode/ticketTestDB/SignatureValidationDBTicketTest.java b/src/test/java/org/uic/barcode/ticketTestDB/SignatureValidationDBTicketTest.java index e8922d2..d4b262f 100644 --- a/src/test/java/org/uic/barcode/ticketTestDB/SignatureValidationDBTicketTest.java +++ b/src/test/java/org/uic/barcode/ticketTestDB/SignatureValidationDBTicketTest.java @@ -2,6 +2,7 @@ package org.uic.barcode.ticketTestDB; import java.io.ByteArrayInputStream;
import java.security.NoSuchAlgorithmException;
+import java.security.Provider;
import java.security.PublicKey;
import java.security.Security;
import java.security.cert.CertificateException;
@@ -23,6 +24,8 @@ import org.uic.barcode.logger.LoggerFactory; public class SignatureValidationDBTicketTest {
TimeZone defaulttimeZone = null;
+
+ Provider provider= null;
/**
* Prepare tickets.
@@ -30,8 +33,9 @@ public class SignatureValidationDBTicketTest { @Before public void prepare() {
LoggerFactory.setActivateConsoleLog(true);
-
- Security.addProvider(new BouncyCastleProvider());
+
+ provider = new BouncyCastleProvider();
+ Security.addProvider(provider);
defaulttimeZone = TimeZone.getDefault();
//decode in local CET time zone
@@ -63,7 +67,7 @@ public class SignatureValidationDBTicketTest { String algorithmOID = Constants.DSA_SHA256;
- int result = decoder.validateLevel1(getPublicKey2(), algorithmOID);
+ int result = decoder.validateLevel1(getPublicKey2(), algorithmOID,provider);
assert(result == 0);
diff --git a/src/test/java/org/uic/barcode/ticketTests/MAVticketTest.java b/src/test/java/org/uic/barcode/ticketTests/MAVticketTest.java new file mode 100644 index 0000000..df90931 --- /dev/null +++ b/src/test/java/org/uic/barcode/ticketTests/MAVticketTest.java @@ -0,0 +1,87 @@ +package org.uic.barcode.ticketTests; + + +import java.util.TimeZone; + +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.uic.barcode.Decoder; +import org.uic.barcode.dynamicFrame.api.IDynamicFrame; +import org.uic.barcode.logger.LoggerFactory; +import org.uic.barcode.staticFrame.ticketLayoutBarcode.TicketLayout; +import org.uic.barcode.test.utils.TestUtils; +import org.uic.barcode.ticket.api.spec.IUicRailTicket; + +public class MAVticketTest { + + TimeZone defaulttimeZone = null; + + + + String ticketHex = "2355543031313135345454303031" + + "302C02140501D652A1F1F70BB3065D14801ECAC6B1DB7B7D0214918A522B1B1FACC567BB4E3052F7B1116B9D2EC600000000" + + "30343035" + + "789C5551C16E9C3010ED99AFF03141CA32B6B159A26A2503CE424C01D98696BD449B64B5425D51A9" + + "CAAE947FC867E5C36A236DABCEE9F9CDCC7B33E3FEA994A2000CC028C62C0E1D48EE80D02FFF0233" + + "5813C01C03E12C3785EC9F6C2D46D71403D7B92500900201B6302E62AF048009C434756FC61FAB5D" + + "211B258207516A9397B26A82A03BEDDFA6687B3EBD4DC77B046405E9CAFBDC01BD42D7EB44B017C1" + + "3C008C8AD674B21E23A9BFAF803B07BC2481755A9402388DAFCC3AEB0BD149638173EE26639E740D" + + "6B8769B254E0A112E8AB1F7673538A21D36D11E52BAB65761B66BA6943D5DBF166AB6F7D0DDF645A" + + "D8CAD46210E156D4A1D9B5994F063ECB36A10F3F10D0C52A89875C9846A0EBEE480EBAED44F45069" + + "63D1B7AAE9AD44B2779C74B7F87599E6F91D5D4EFB9FD1EE7C7C9EE6D7F37C44B241719260EACE40" + + "96BD489C1FE63D628C20F51274BFA7970322E075FC1EBD75FE1852F508980DA351EDE74755A36E7F" + + "399C54E1F6C72A074C317210A5E91AC53C510A808FC2FC30D016FEE67F3FC255DD0314AD27E9FFE4" + + "1FC2CF86380000000000000000000000000000000000000000000000000000000000000000"; + + + /** + * Prepare tickets. + */ + @Before public void prepare() { + + LoggerFactory.setActivateConsoleLog(true); + + defaulttimeZone = TimeZone.getDefault(); + //decode in local CET time zone + TimeZone.setDefault(TimeZone.getTimeZone("CET")); + } + + + /** + * clean up + */ + @After public void resetTimeZone() { + TimeZone.setDefault(defaulttimeZone); + } + + @Test + public void testDecoder() throws Exception { + + + //byte[] content = Base64.getDecoder().decode(ticketBase64); + + byte[] content = TestUtils.hexStringToByteArray(ticketHex); + + // try to decode + Decoder decoder = new Decoder(content); + TicketLayout layout = decoder.getLayout(); + IUicRailTicket ticket = decoder.getUicTicket(); + IDynamicFrame frame = decoder.getDynamicFrame(); + + + Assert.assertNotNull(layout); + Assert.assertNull(frame); + Assert.assertNull(ticket); + //Assert.assertNotNull(frame.getLevel2Data()); + //Assert.assertNotNull(frame.getLevel2Data().getLevel1Data()); + + //Assert.assertNotNull(frame.getLevel2Data().getLevel1Signature()); + //assert(frame.getFormat().equals(Constants.DYNAMIC_BARCODE_FORMAT_VERSION_2)); + + + } + + +}
\ No newline at end of file diff --git a/src/test/java/org/uic/barcode/ticketTests/TIticketTest.java b/src/test/java/org/uic/barcode/ticketTests/TIticketTest.java index b205e16..a428995 100644 --- a/src/test/java/org/uic/barcode/ticketTests/TIticketTest.java +++ b/src/test/java/org/uic/barcode/ticketTests/TIticketTest.java @@ -1,75 +1,78 @@ -package org.uic.barcode.ticketTests; - - -import java.util.Base64; -import java.util.TimeZone; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.uic.barcode.Decoder; -import org.uic.barcode.dynamicFrame.Constants; -import org.uic.barcode.dynamicFrame.api.IDynamicFrame; -import org.uic.barcode.logger.LoggerFactory; -import org.uic.barcode.staticFrame.ticketLayoutBarcode.TicketLayout; -import org.uic.barcode.ticket.api.spec.IUicRailTicket; - -public class TIticketTest { - - TimeZone defaulttimeZone = null; - - String ticketBase64 = "AVVlV4hJ4ABQCCRocJknuREASeB6KmwhTRgwYMGrRg4coAqB4AROT01FB0NP" - + "R05PTUVPAEAEEgFYWAAAFAO5r+0lA5zvA32uCITK5NwUtOrK5NLG0ECQxJ3AidwAAAQVQyRn" - + "HoGAg4SwQyQAsoGCAYCEFUMkZx6CAYEtmCyYCYMDlUMkZx6BAIMEFUMkZx6BgIOBoQACIdM/" - + "3NC/C94syIud9wO7mYNByejQ4l/ik6HEhi7t3XV7vuPZQox/T2r6zccEDw3Ri48MO0LAjOH6" - + "sdzYk9CRfgMaOYIoEQM8jg15cDXzeO2ixAMSKKNvwfo2Fa5brPyMkyd0o0EpmBEIBRkK7smz" - + "ZoF34ztlSrOxWZs5itVsgL3PIlWZ/yhVOgpo"; - - - - - /** - * Prepare tickets. - */ - @Before public void prepare() { - - LoggerFactory.setActivateConsoleLog(true); - - defaulttimeZone = TimeZone.getDefault(); - //decode in local CET time zone - TimeZone.setDefault(TimeZone.getTimeZone("CET")); - } - - - /** - * clean up - */ - @After public void resetTimeZone() { - TimeZone.setDefault(defaulttimeZone); - } - - @Test - public void testDecoder() throws Exception { - - - byte[] content = Base64.getDecoder().decode(ticketBase64); - - // try to decode - Decoder decoder = new Decoder(content); - TicketLayout layout = decoder.getLayout(); - IUicRailTicket ticket = decoder.getUicTicket(); - IDynamicFrame frame = decoder.getDynamicFrame(); - - Assert.assertNotNull(frame); - Assert.assertNotNull(frame.getLevel2Data()); - Assert.assertNotNull(frame.getLevel2Data().getLevel1Data()); - - Assert.assertNotNull(frame.getLevel2Data().getLevel1Signature()); - assert(frame.getFormat().equals(Constants.DYNAMIC_BARCODE_FORMAT_VERSION_2)); - - - } - - +package org.uic.barcode.ticketTests;
+
+
+import java.util.Base64;
+import java.util.TimeZone;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.uic.barcode.Decoder;
+import org.uic.barcode.dynamicFrame.Constants;
+import org.uic.barcode.dynamicFrame.api.IDynamicFrame;
+import org.uic.barcode.logger.LoggerFactory;
+import org.uic.barcode.staticFrame.ticketLayoutBarcode.TicketLayout;
+import org.uic.barcode.ticket.api.spec.IUicRailTicket;
+
+public class TIticketTest {
+
+ TimeZone defaulttimeZone = null;
+
+ String ticketBase64 = "AVVlV4hJ4ABQCCRocJknuREASeB6KmwhTRgwYMGrRg4coAqB4AROT01FB0NP"
+ + "R05PTUVPAEAEEgFYWAAAFAO5r+0lA5zvA32uCITK5NwUtOrK5NLG0ECQxJ3AidwAAAQVQyRn"
+ + "HoGAg4SwQyQAsoGCAYCEFUMkZx6CAYEtmCyYCYMDlUMkZx6BAIMEFUMkZx6BgIOBoQACIdM/"
+ + "3NC/C94syIud9wO7mYNByejQ4l/ik6HEhi7t3XV7vuPZQox/T2r6zccEDw3Ri48MO0LAjOH6"
+ + "sdzYk9CRfgMaOYIoEQM8jg15cDXzeO2ixAMSKKNvwfo2Fa5brPyMkyd0o0EpmBEIBRkK7smz"
+ + "ZoF34ztlSrOxWZs5itVsgL3PIlWZ/yhVOgpo";
+
+
+
+
+ /**
+ * Prepare tickets.
+ */
+ @Before public void prepare() {
+
+ LoggerFactory.setActivateConsoleLog(true);
+
+ defaulttimeZone = TimeZone.getDefault();
+ //decode in local CET time zone
+ TimeZone.setDefault(TimeZone.getTimeZone("CET"));
+ }
+
+
+ /**
+ * clean up
+ */
+ @After public void resetTimeZone() {
+ TimeZone.setDefault(defaulttimeZone);
+ }
+
+ @Test
+ public void testDecoder() throws Exception {
+
+
+ byte[] content = Base64.getDecoder().decode(ticketBase64);
+
+ // try to decode
+ Decoder decoder = new Decoder(content);
+ TicketLayout layout = decoder.getLayout();
+ IUicRailTicket ticket = decoder.getUicTicket();
+ IDynamicFrame frame = decoder.getDynamicFrame();
+
+ Assert.assertNotNull(frame);
+ Assert.assertNotNull(frame.getLevel2Data());
+ Assert.assertNotNull(frame.getLevel2Data().getLevel1Data());
+
+ Assert.assertNotNull(ticket);
+ Assert.assertNull(layout);
+
+ Assert.assertNotNull(frame.getLevel2Data().getLevel1Signature());
+ assert(frame.getFormat().equals(Constants.DYNAMIC_BARCODE_FORMAT_VERSION_2));
+
+
+ }
+
+
}
\ No newline at end of file |