public class PublicKeyEntry extends Object implements Serializable
Represents a PublicKey whose data is formatted according to
the OpenSSH format:
<key-type> <base64-encoded-public-key-data>
| Modifier and Type | Field and Description |
|---|---|
static char |
COMMENT_CHAR
Character used to denote a comment line in the keys file
|
static String |
STD_KEYFILE_FOLDER_NAME
Standard folder name used by OpenSSH to hold key files
|
| Constructor and Description |
|---|
PublicKeyEntry() |
PublicKeyEntry(String keyType,
byte... keyData) |
| Modifier and Type | Method and Description |
|---|---|
PublicKey |
appendPublicKey(Appendable sb) |
static <A extends Appendable> |
appendPublicKeyEntry(A sb,
PublicKey key)
Encodes a public key data the same way as the
parsePublicKeyEntry(String) expects it |
boolean |
equals(Object obj) |
static File |
getDefaultKeysFolder() |
byte[] |
getKeyData() |
String |
getKeyType() |
int |
hashCode() |
protected boolean |
isEquivalent(PublicKeyEntry e) |
static <E extends PublicKeyEntry> |
parsePublicKeyEntry(E entry,
String data) |
static PublicKeyEntry |
parsePublicKeyEntry(String data) |
PublicKey |
resolvePublicKey() |
void |
setKeyData(byte[] value) |
void |
setKeyType(String value) |
String |
toString() |
static String |
toString(PublicKey key) |
public static final char COMMENT_CHAR
public static final String STD_KEYFILE_FOLDER_NAME
public PublicKeyEntry()
public PublicKeyEntry(String keyType, byte... keyData)
public String getKeyType()
public void setKeyType(String value)
public byte[] getKeyData()
public void setKeyData(byte[] value)
public PublicKey resolvePublicKey() throws IOException, GeneralSecurityException
PublicKey - never null.
Note: may be called only after key type and data bytes have
been set or exception(s) may be thrownIOException - If failed to decode the keyGeneralSecurityException - If failed to generate the keypublic PublicKey appendPublicKey(Appendable sb) throws IOException, GeneralSecurityException
sb - The Appendable instance to encode the data intoPublicKeyIOException - If failed to decode/encode the keyGeneralSecurityException - If failed to generate the keyresolvePublicKey()protected boolean isEquivalent(PublicKeyEntry e)
public static final PublicKeyEntry parsePublicKeyEntry(String data) throws IllegalArgumentException
data - Assumed to contain at least key-type base64-data (anything
beyond the BASE64 data is ignored) - ignored if null/emptyPublicKeyEntry or null if no dataIllegalArgumentException - if bad format foundparsePublicKeyEntry(PublicKeyEntry, String)public static final <E extends PublicKeyEntry> E parsePublicKeyEntry(E entry, String data) throws IllegalArgumentException
E - The generic entry typeentry - The PublicKeyEntry whose contents are to be
updated - ignored if nulldata - Assumed to contain at least key-type base64-data (anything
beyond the BASE64 data is ignored) - ignored if null/emptyIllegalArgumentException - if bad format foundpublic static String toString(PublicKey key) throws IllegalArgumentException
key - The PublicKeyOpenSSH encoded dataIllegalArgumentException - If failed to encodeappendPublicKeyEntry(Appendable, PublicKey)public static <A extends Appendable> A appendPublicKeyEntry(A sb, PublicKey key) throws IOException
parsePublicKeyEntry(String) expects itA - The generic appendable classsb - The Appendable instance to encode the data intokey - The PublicKeyIOException - If failed to append the datapublic static File getDefaultKeysFolder()
known_hosts, authorized_keys, etc.Copyright © 2008–2015 The Apache Software Foundation. All rights reserved.