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 equalityModifier and Type | Field and Description |
---|---|
static char |
BOOLEAN_OPTION_NEGATION_INDICATOR |
COMMENT_CHAR, STD_KEYFILE_FOLDER_NAME
Constructor and Description |
---|
AuthorizedKeyEntry() |
Modifier and Type | Method and Description |
---|---|
static AbstractMap.SimpleImmutableEntry<String,String> |
addLoginOption(Map<String,String> optsMap,
String option)
Parses and adds a new option to the options map.
|
PublicKey |
appendPublicKey(Appendable sb,
PublicKeyEntryResolver fallbackResolver) |
boolean |
equals(Object obj) |
static PublickeyAuthenticator |
fromAuthorizedEntries(PublicKeyEntryResolver fallbackResolver,
Collection<? extends AuthorizedKeyEntry> entries) |
String |
getComment() |
Map<String,String> |
getLoginOptions() |
int |
hashCode() |
static AuthorizedKeyEntry |
parseAuthorizedKeyEntry(String value) |
static NavigableMap<String,String> |
parseLoginOptions(String options)
Parses login options line according to
sshd(8) - AUTHORIZED_KEYS_FILE_FORMAT
guidelines.
|
static List<AuthorizedKeyEntry> |
readAuthorizedKeys(BufferedReader rdr) |
static List<AuthorizedKeyEntry> |
readAuthorizedKeys(File file)
Reads read the contents of an
authorized_keys file |
static List<AuthorizedKeyEntry> |
readAuthorizedKeys(InputStream in,
boolean okToClose)
Reads read the contents of an
authorized_keys file |
static List<AuthorizedKeyEntry> |
readAuthorizedKeys(Path path,
OpenOption... options)
Reads read the contents of an
authorized_keys file |
static List<AuthorizedKeyEntry> |
readAuthorizedKeys(Reader rdr,
boolean okToClose)
Reads read the contents of an
authorized_keys file |
static List<AuthorizedKeyEntry> |
readAuthorizedKeys(String filePath)
Reads read the contents of an
authorized_keys file |
static List<AuthorizedKeyEntry> |
readAuthorizedKeys(URL url)
Reads read the contents of an
authorized_keys file |
static List<PublicKey> |
resolveAuthorizedKeys(PublicKeyEntryResolver fallbackResolver,
Collection<? extends AuthorizedKeyEntry> entries) |
static AbstractMap.SimpleImmutableEntry<String,String> |
resolveEntryComponents(String entryLine)
Parses a single line from an
authorized_keys file that is known
to contain login options and separates it to the options and the rest of the line. |
void |
setComment(String value) |
void |
setLoginOptions(Map<String,String> value) |
String |
toString() |
appendPublicKeyEntry, getDefaultKeysFolderPath, getKeyData, getKeyType, isEquivalent, parsePublicKeyEntry, parsePublicKeyEntry, resolvePublicKey, setKeyData, setKeyType, toString
public static final char BOOLEAN_OPTION_NEGATION_INDICATOR
public String getComment()
public void setComment(String value)
public PublicKey appendPublicKey(Appendable sb, PublicKeyEntryResolver fallbackResolver) throws IOException, GeneralSecurityException
appendPublicKey
in class PublicKeyEntry
sb
- The Appendable
instance to encode the data intofallbackResolver
- The PublicKeyEntryResolver
to consult if
none of the built-in ones can be used. If null
and no built-in
resolver can be used then an InvalidKeySpecException
is thrown.PublicKey
or null
if could not resolve itIOException
- If failed to decode/encode the keyGeneralSecurityException
- If failed to generate the keyPublicKeyEntry.resolvePublicKey(PublicKeyEntryResolver)
public int hashCode()
hashCode
in class PublicKeyEntry
public boolean equals(Object obj)
equals
in class PublicKeyEntry
public String toString()
toString
in class PublicKeyEntry
public static PublickeyAuthenticator fromAuthorizedEntries(PublicKeyEntryResolver fallbackResolver, Collection<? extends AuthorizedKeyEntry> entries) throws IOException, GeneralSecurityException
IOException
GeneralSecurityException
public static List<PublicKey> resolveAuthorizedKeys(PublicKeyEntryResolver fallbackResolver, Collection<? extends AuthorizedKeyEntry> entries) throws IOException, GeneralSecurityException
IOException
GeneralSecurityException
public 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 OpenOption
s 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 InputStream
okToClose
- 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 Reader
okToClose
- 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 value) throws IllegalArgumentException
value
- 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_CHAR
public static AbstractMap.SimpleImmutableEntry<String,String> resolveEntryComponents(String entryLine)
authorized_keys
file that is known
to contain login options and separates it to the options and the rest of the line.entryLine
- The line to be parsedAbstractMap.SimpleImmutableEntry
representing the parsed data where key=login options part
and value=rest of the data - null
if no data in line or line starts with comment characterpublic static NavigableMap<String,String> parseLoginOptions(String options)
Parses login options line according to sshd(8) - AUTHORIZED_KEYS_FILE_FORMAT guidelines. Note:
true/false
- according
to the BOOLEAN_OPTION_NEGATION_INDICATOR
.
options
- The options line to parse - ignored if null
/empty/blankNavigableMap
where key=case insensitive option name and value=the parsed value.addLoginOption
public static AbstractMap.SimpleImmutableEntry<String,String> addLoginOption(Map<String,String> optsMap, String option)
optsMap
- Options map to add tooption
- The option data to parse - ignored if null
/empty/blanknull
if no option updated in the mapIllegalStateException
- If a boolean option is re-specifiedCopyright © 2008–2019 The Apache Software Foundation. All rights reserved.