use of org.mozilla.jss.asn1.PrintableString in project jss by dogtagpki.
the class Name method main.
public static void main(String[] args) {
try {
if (args.length == 0) {
Name name = new Name();
OBJECT_IDENTIFIER oid;
oid = new OBJECT_IDENTIFIER(new long[] { 2, 5, 4, 10 });
AVA ava = new AVA(oid, new PrintableString("Netscape"));
name.addElement(ava);
oid = new OBJECT_IDENTIFIER(new long[] { 2, 5, 4, 3 });
ava = new AVA(oid, new PrintableString("moi"));
name.addElement(ava);
name.encode(System.out);
} else {
Name.Template temp = new Name.Template();
Name name;
FileInputStream fis = new FileInputStream(args[0]);
try (BufferedInputStream bis = new BufferedInputStream(fis)) {
name = (Name) temp.decode(bis);
}
System.out.println("Got name.");
for (int i = 0; i < name.size(); i++) {
AVA a = name.elementAt(i).at(0);
PrintableString.Template pst = new PrintableString.Template();
PrintableString ps = (PrintableString) pst.decode(new ByteArrayInputStream(a.getValue().getEncoded()));
System.out.println("OID: " + a.getOID() + ", String: " + ps);
}
System.out.println("End of name");
}
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations