Skip to content

Commit

Permalink
Add a version to the library
Browse files Browse the repository at this point in the history
  • Loading branch information
martinpaljak committed Mar 2, 2016
1 parent c94b843 commit 771bbb3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
1 change: 1 addition & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
</target>
<!-- Package it into a nice little JAR -->
<target name="dist" depends="compile" description="generate the distribution">
<exec command="git describe --always --tags" output="build/org/esteid/version.txt"/>
<jar destfile="esteid.jar" level="9" basedir="build">
<fileset dir="src">
<include name="resources/*.pem"/>
Expand Down
23 changes: 21 additions & 2 deletions src/org/esteid/EstEID.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@
*/
package org.esteid;

import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.security.GeneralSecurityException;
Expand Down Expand Up @@ -343,7 +347,7 @@ public static CommandAPDU select_apdu(int fid) {
return new CommandAPDU(0x00, INS_SELECT, 0x01, 0x0C, fidbytes);
} else { // Select EF
return new CommandAPDU(0x00, INS_SELECT, 0x02, 0x0C, fidbytes);
}
}
}
// File handling. Returns FCI, if any
public byte[] select(int fid) throws CardException {
Expand Down Expand Up @@ -383,7 +387,7 @@ public byte[] read_certificate_bytes(int fid) throws CardException {
select(FID_EEEE);
select(fid);
return read_file(0x600);
}
}
private X509Certificate readCertificate(int fid) throws CardException {
try {
CertificateFactory cf = CertificateFactory.getInstance("X509");
Expand Down Expand Up @@ -519,6 +523,7 @@ public static void check(int sw) throws WrongPINException {
public byte getRemaining() {
return remaining;
}
@Override
public String toString() {
return "Wrong PIN: " + remaining + " tries remaining" + status;
}
Expand Down Expand Up @@ -635,4 +640,18 @@ public void pin_tests(String pin1, String pin2, String puk) throws CardException
unblock(PIN2);
System.out.println("UNBLOCK: OK");
}

public static String getVersion() {
String version = "unknown-development";
try (InputStream versionfile = EstEID.class.getResourceAsStream("version.txt")) {
if (versionfile != null) {
try (BufferedReader vinfo = new BufferedReader(new InputStreamReader(versionfile))) {
version = vinfo.readLine();
}
}
} catch (IOException e) {
version = "unknown-error";
}
return version;
}
}

0 comments on commit 771bbb3

Please sign in to comment.