Skip to content

Instantly share code, notes, and snippets.

@typelogic
Created September 18, 2020 11:43
Show Gist options
  • Save typelogic/40b46c82161e9f243f663c9b5470ae55 to your computer and use it in GitHub Desktop.
Save typelogic/40b46c82161e9f243f663c9b5470ae55 to your computer and use it in GitHub Desktop.
gen.java
@Test
public void test_jgenerate_florence_id() throws IDPassException, IOException {
byte[] photo = Files.readAllBytes(Paths.get("testdata/florence_ID_Photo.jpg"));
Ident ident = Ident.newBuilder()
.setPhoto(ByteString.copyFrom(photo))
.setGivenName("MARION FLORENCE")
.setSurName("DUPONT")
.setPin("1234")
.setDateOfBirth(Dat.newBuilder().setYear(1985).setMonth(1).setDay(1))
.addPubExtra(KV.newBuilder().setKey("Sex").setValue("F"))
.addPubExtra(KV.newBuilder().setKey("Nationality").setValue("French"))
.addPubExtra(KV.newBuilder().setKey("Date Of Issue").setValue("02 JAN 2025"))
.addPubExtra(KV.newBuilder().setKey("Date Of Expiry").setValue("01 JAN 2035"))
.addPubExtra(KV.newBuilder().setKey("ID").setValue("SA437277"))
.addPrivExtra(KV.newBuilder().setKey("SS Number").setValue("2 85 01 75 116 001 42"))
.build();
IDPassReader reader = new IDPassReader(m_keyset, m_rootcerts);
reader.setRootKey(m_rootkey);
reader.setDetailsVisible(
IDPassReader.DETAIL_GIVENNAME |
IDPassReader.DETAIL_SURNAME |
IDPassReader.DETAIL_DATEOFBIRTH);
Card card = reader.newCard(ident,m_certchain);
File outputfile = new File("florence_idpass.png");
ImageIO.write(card.asQRCode(), "png", outputfile);
File outputfile3 = new File("florence_idpass.svg");
Files.write(outputfile3.toPath(), card.asQRCodeSVG().getBytes(StandardCharsets.UTF_8));
reader.saveConfiguration("alias0","demokeys.cfg.p12", "changeit");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment