mangstadt/ez-vcard

Support for OPENPGP4FPR URIs in KEY property

Closed this issue · 5 comments

Hello,

Is there a way to insert OpenPGP key fingerprint as a KEY property using openpgp4fpr URI scheme?

There are quite a few apps (most notably OpenKeychain) using VCards with this kind of property. For example:

BEGIN:VCARD
FN:Linus Torvalds
EMAIL:torvalds.at.kernel.org
KEY:OPENPGP4FPR:ABAF11C65A2970B130ABE3C479BE3E4300411886
END:VCARD

For more details about this scheme see https://metacode.biz/openpgp/openpgp4fpr

Probably the best solution at the moment would be to add it as an extended property:

VCard vcard = new VCard();
vcard.addExtendedProperty("KEY", "OPENPGP4FPR:ABAF11C65A2970B130ABE3C479BE3E4300411886");

Thanks @mangstadt!

What do you think about allowing construction of Keys from URIs? I could work on a PR to allow that...

I'm working on it now, but thanks for offering. :)

See commit: 4dd4ed1

Ok, so I have basically just adjusted the Javadocs to dual-purpose the existing "URL" constructor/field in the class.

VCard vcard = new VCard();
Key key = new Key("OPENPGP4FPR:ABAF11C65A2970B130ABE3C479BE3E4300411886", null);
key.getUrl(); //returns the URI

Using the URI class would be a little problematic because that code is shared via inheritance, and I would hate to break the API at this point without good reason.

It would also complicate the parsing logic because it would need to handle the edge case of when an input string can't be parsed into a URI object.

Let me know your thoughts!

Yes, I did try it out (SNAPSHOT from master) and it works well! The null at the end surprised me a little but I guess this is OK.

My test vCard
BEGIN:VCARD
VERSION:4.0
PRODID:ez-vcard 0.10.6-SNAPSHOT
N:Doe;Jonathan;;Mr;
FN:John Doe
KEY:OPENPGP4FPR:ABAF11C65A2970B130ABE3C479BE3E4300411886
END:VCARD

Thanks a lot for your quick implementation! 👍

(I'll close the ticket as this is already done).