public class AuthorizedKeyEntry extends PublicKeyEntry
authorized_keys file according
to the OpenSSH format.
Note: equals/hashCode check only the key type and data - the
comment and/or login options are not considered part of equality| Modifier and Type | Field and Description |
|---|---|
static String |
STD_AUTHORIZED_KEYS_FILENAME
Standard OpenSSH authorized keys file name
|
COMMENT_CHAR, STD_KEYFILE_FOLDER_NAME| Constructor and Description |
|---|
AuthorizedKeyEntry() |
appendPublicKeyEntry, equals, getDefaultKeysFolder, getKeyData, getKeyType, hashCode, isEquivalent, parsePublicKeyEntry, parsePublicKeyEntry, resolvePublicKey, setKeyData, setKeyType, toStringpublic static final String STD_AUTHORIZED_KEYS_FILENAME
public String getComment()
public void setComment(String value)
public PublicKey appendPublicKey(Appendable sb) throws IOException, GeneralSecurityException
appendPublicKey in class PublicKeyEntrysb - The Appendable instance to encode the data intoPublicKeyIOException - If failed to decode/encode the keyGeneralSecurityException - If failed to generate the keyPublicKeyEntry.resolvePublicKey()public String toString()
toString in class PublicKeyEntrypublic static PublickeyAuthenticator fromAuthorizedEntries(Collection<? extends AuthorizedKeyEntry> entries) throws IOException, GeneralSecurityException
IOExceptionGeneralSecurityExceptionpublic static List<PublicKey> resolveAuthorizedKeys(Collection<? extends AuthorizedKeyEntry> entries) throws IOException, GeneralSecurityException
IOExceptionGeneralSecurityExceptionpublic static File getDefaultAuthorizedKeysFile()
File location of the OpenSSH authorized keys filepublic static List<AuthorizedKeyEntry> readDefaultAuthorizedKeys() throws IOException
authorized_keys fileList of all the AuthorizedKeyEntry-ies found there -
or empty if file does not existIOException - If failed to read keys from filepublic static List<AuthorizedKeyEntry> readAuthorizedKeys(URL url) throws IOException
authorized_keys fileurl - The URL to read fromList of all the AuthorizedKeyEntry-ies found thereIOException - If failed to read or parse the entriesreadAuthorizedKeys(InputStream, boolean)public static List<AuthorizedKeyEntry> readAuthorizedKeys(File file) throws IOException
authorized_keys filefile - The File to read fromList of all the AuthorizedKeyEntry-ies found thereIOException - If failed to read or parse the entriesreadAuthorizedKeys(InputStream, boolean)public static List<AuthorizedKeyEntry> readAuthorizedKeys(Path path, OpenOption... options) throws IOException
authorized_keys filepath - Path to read fromoptions - The OpenOptions to use - if unspecified then appropriate
defaults assumedList of all the AuthorizedKeyEntry-ies found thereIOException - If failed to read or parse the entriesreadAuthorizedKeys(InputStream, boolean),
Files.newInputStream(Path, OpenOption...)public static List<AuthorizedKeyEntry> readAuthorizedKeys(String filePath) throws IOException
authorized_keys filefilePath - The file path to read fromList of all the AuthorizedKeyEntry-ies found thereIOException - If failed to read or parse the entriesreadAuthorizedKeys(InputStream, boolean)public static List<AuthorizedKeyEntry> readAuthorizedKeys(InputStream in, boolean okToClose) throws IOException
authorized_keys filein - The InputStreamokToClose - true if method may close the input stream
regardless of whether successful or failedList of all the AuthorizedKeyEntry-ies found thereIOException - If failed to read or parse the entriesreadAuthorizedKeys(Reader, boolean)public static List<AuthorizedKeyEntry> readAuthorizedKeys(Reader rdr, boolean okToClose) throws IOException
authorized_keys filerdr - The ReaderokToClose - true if method may close the input stream
regardless of whether successful or failedList of all the AuthorizedKeyEntry-ies found thereIOException - If failed to read or parse the entriesreadAuthorizedKeys(BufferedReader)public static List<AuthorizedKeyEntry> readAuthorizedKeys(BufferedReader rdr) throws IOException
rdr - The BufferedReader to use to read the contents of
an authorized_keys fileList of all the AuthorizedKeyEntry-ies found thereIOException - If failed to read or parse the entriesparseAuthorizedKeyEntry(String)public static AuthorizedKeyEntry parseAuthorizedKeyEntry(String line) throws IllegalArgumentException
line - Original line from an authorized_keys fileAuthorizedKeyEntry or null if the line is
null/empty or a comment lineIllegalArgumentException - If failed to parse/decode the linePublicKeyEntry.COMMENT_CHARCopyright © 2008–2015 The Apache Software Foundation. All rights reserved.