From ed01c37fe18f98c25b7515c459ae446efa8232ca Mon Sep 17 00:00:00 2001 From: Bahtiar `kalkin-` Gadimov Date: Wed, 25 Dec 2013 18:14:38 +0100 Subject: Added shortifyFingerprint() to PGPHelper --- .../src/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java') diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java index e2d89bfab..5a3d332c4 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java @@ -40,6 +40,17 @@ import android.content.Context; public class PgpKeyHelper { + /** + * Returns the last 9 chars of a fingerprint + * + * @param fingerprint + * String containing short or long fingerprint + * @return + */ + public static String shortifyFingerprint(String fingerprint) { + return fingerprint.substring(41); + } + public static Date getCreationDate(PGPPublicKey key) { return key.getCreationTime(); } -- cgit v1.2.3 From 52c55aaabeac7f35b4800e4cbf0ca098d3d6c54e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Tue, 31 Dec 2013 01:41:37 +0100 Subject: code styling --- .../keychain/pgp/PgpKeyHelper.java | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java') diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java index 5a3d332c4..daba94b99 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java @@ -40,16 +40,16 @@ import android.content.Context; public class PgpKeyHelper { - /** - * Returns the last 9 chars of a fingerprint - * - * @param fingerprint - * String containing short or long fingerprint - * @return - */ - public static String shortifyFingerprint(String fingerprint) { - return fingerprint.substring(41); - } + /** + * Returns the last 9 chars of a fingerprint + * + * @param fingerprint + * String containing short or long fingerprint + * @return + */ + public static String shortifyFingerprint(String fingerprint) { + return fingerprint.substring(41); + } public static Date getCreationDate(PGPPublicKey key) { return key.getCreationTime(); -- cgit v1.2.3 From face67d64b06f14913fff9ce61ae4a23421cec28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Sch=C3=BCrmann?= Date: Mon, 13 Jan 2014 00:39:51 +0100 Subject: key view is working --- .../keychain/pgp/PgpKeyHelper.java | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java') diff --git a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java index daba94b99..edb30496a 100644 --- a/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java +++ b/OpenPGP-Keychain/src/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java @@ -22,6 +22,8 @@ import java.util.Date; import java.util.GregorianCalendar; import java.util.Locale; import java.util.Vector; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.spongycastle.bcpg.sig.KeyFlags; import org.spongycastle.openpgp.PGPPublicKey; @@ -524,4 +526,32 @@ public class PgpKeyHelper { return (Long.parseLong(s1, 16) << 32) | Long.parseLong(s2, 16); } + /** + * Splits userId string into naming part, email part, and comment part + * + * @param userId + * @return array with naming (0), email (1), comment (2) + */ + public static String[] splitUserId(String userId) { + String[] result = new String[] { "", "", "" }; + + Pattern withComment = Pattern.compile("^(.*) \\((.*)\\) <(.*)>$"); + Matcher matcher = withComment.matcher(userId); + if (matcher.matches()) { + result[0] = matcher.group(1); + result[1] = matcher.group(3); + result[2] = matcher.group(2); + return result; + } + + Pattern withoutComment = Pattern.compile("^(.*) <(.*)>$"); + matcher = withoutComment.matcher(userId); + if (matcher.matches()) { + result[0] = matcher.group(1); + result[1] = matcher.group(2); + return result; + } + return result; + } + } -- cgit v1.2.3