Author: dennisl
Date: Sat Aug 10 22:11:32 2013
New Revision: 1512829
URL: http://svn.apache.org/r1512829
Log:
Add a method that allows you to access the key ID of the first key in the
secret keyring. By default this is the key that is used when signing, unless it
has been configured otherwise. I'm working on a pure Java signing
implementation for Maven GPG Plugin and need to get hold of this ID.
Modified:
commons/sandbox/openpgp/trunk/src/main/java/org/apache/commons/openpgp/BouncyCastleKeyRing.java
commons/sandbox/openpgp/trunk/src/main/java/org/apache/commons/openpgp/KeyRing.java
Modified:
commons/sandbox/openpgp/trunk/src/main/java/org/apache/commons/openpgp/BouncyCastleKeyRing.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/openpgp/trunk/src/main/java/org/apache/commons/openpgp/BouncyCastleKeyRing.java?rev=1512829&r1=1512828&r2=1512829&view=diff
==============================================================================
---
commons/sandbox/openpgp/trunk/src/main/java/org/apache/commons/openpgp/BouncyCastleKeyRing.java
(original)
+++
commons/sandbox/openpgp/trunk/src/main/java/org/apache/commons/openpgp/BouncyCastleKeyRing.java
Sat Aug 10 22:11:32 2013
@@ -38,6 +38,8 @@ import org.bouncycastle.openpgp.PGPUtil;
*/
public class BouncyCastleKeyRing implements KeyRing
{
+ private String firstKeyId;
+
private final Map<Long, PGPSecretKey> pgpSec = new HashMap<Long,
PGPSecretKey>();
private char[] password;
@@ -93,6 +95,11 @@ public class BouncyCastleKeyRing impleme
PGPSecretKeyRing pgpSecret = (PGPSecretKeyRing) obj;
long key = pgpSecret.getSecretKey().getKeyID() & MASK;
+ if ( pgpSec.isEmpty() )
+ {
+ // Convert the keyId to a hexadecimal upper case String
+ firstKeyId = Long.toHexString( key ).toUpperCase();
+ }
pgpSec.put( key, pgpSecret.getSecretKey() );
}
@@ -100,6 +107,11 @@ public class BouncyCastleKeyRing impleme
this.password = password;
}
+ public String getFirstKeyId()
+ {
+ return firstKeyId.toString();
+ }
+
public char[] getPassword()
{
return password;
Modified:
commons/sandbox/openpgp/trunk/src/main/java/org/apache/commons/openpgp/KeyRing.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/openpgp/trunk/src/main/java/org/apache/commons/openpgp/KeyRing.java?rev=1512829&r1=1512828&r2=1512829&view=diff
==============================================================================
---
commons/sandbox/openpgp/trunk/src/main/java/org/apache/commons/openpgp/KeyRing.java
(original)
+++
commons/sandbox/openpgp/trunk/src/main/java/org/apache/commons/openpgp/KeyRing.java
Sat Aug 10 22:11:32 2013
@@ -36,6 +36,11 @@ public interface KeyRing
String ROLE = KeyRing.class.getName();
/**
+ * Get the key ID of the first secret key that was added to the keyring.
+ */
+ String getFirstKeyId();
+
+ /**
* @return
* @todo seems like the wrong place
*/