Skip to content

Commit b77aabc

Browse files
committed
OpenPGPKey.getSecretKeys(): Preserve order of keys
1 parent e5d15d8 commit b77aabc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pg/src/main/java/org/bouncycastle/openpgp/api/OpenPGPKey.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.Date;
66
import java.util.HashMap;
77
import java.util.Iterator;
8+
import java.util.LinkedHashMap;
89
import java.util.List;
910
import java.util.Map;
1011

@@ -74,7 +75,7 @@ public OpenPGPKey(PGPSecretKeyRing keyRing, OpenPGPImplementation implementation
7475
super(keyRing, implementation, policy);
7576

7677
// Process and map secret keys
77-
this.secretKeys = new HashMap<KeyIdentifier, OpenPGPSecretKey>();
78+
this.secretKeys = new LinkedHashMap<KeyIdentifier, OpenPGPSecretKey>();
7879
for (Iterator it = getKeys().iterator(); it.hasNext(); )
7980
{
8081
OpenPGPComponentKey key = (OpenPGPComponentKey)it.next();
@@ -147,7 +148,7 @@ public OpenPGPSecretKey getPrimarySecretKey()
147148
*/
148149
public Map<KeyIdentifier, OpenPGPSecretKey> getSecretKeys()
149150
{
150-
return new HashMap<KeyIdentifier, OpenPGPSecretKey>(secretKeys);
151+
return new LinkedHashMap<KeyIdentifier, OpenPGPSecretKey>(secretKeys);
151152
}
152153

153154
/**

0 commit comments

Comments
 (0)