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 |
private java.lang.String |
comment |
private java.util.Map<java.lang.String,java.lang.String> |
loginOptions |
private static long |
serialVersionUID |
COMMENT_CHAR, STD_KEYFILE_FOLDER_NAME
Constructor and Description |
---|
AuthorizedKeyEntry() |
Modifier and Type | Method and Description |
---|---|
static java.util.AbstractMap.SimpleImmutableEntry<java.lang.String,java.lang.String> |
addLoginOption(java.util.Map<java.lang.String,java.lang.String> optsMap,
java.lang.String option)
Parses and adds a new option to the options map.
|
java.security.PublicKey |
appendPublicKey(SessionContext session,
java.lang.Appendable sb,
PublicKeyEntryResolver fallbackResolver) |
boolean |
equals(java.lang.Object obj) |
java.lang.String |
getComment() |
java.util.Map<java.lang.String,java.lang.String> |
getLoginOptions() |
int |
hashCode() |
static AuthorizedKeyEntry |
parseAuthorizedKeyEntry(java.lang.String value) |
static AuthorizedKeyEntry |
parseAuthorizedKeyEntry(java.lang.String value,
PublicKeyEntryDataResolver resolver) |
static java.util.NavigableMap<java.lang.String,java.lang.String> |
parseLoginOptions(java.lang.String options)
Parses login options line according to
sshd(8) - AUTHORIZED_KEYS_FILE_FORMAT
guidelines.
|
static java.util.List<AuthorizedKeyEntry> |
readAuthorizedKeys(java.io.BufferedReader rdr) |
static java.util.List<AuthorizedKeyEntry> |
readAuthorizedKeys(java.io.InputStream in,
boolean okToClose)
Reads read the contents of an
authorized_keys file |
static java.util.List<AuthorizedKeyEntry> |
readAuthorizedKeys(java.nio.file.Path path,
java.nio.file.OpenOption... options)
Reads read the contents of an
authorized_keys file |
static java.util.List<AuthorizedKeyEntry> |
readAuthorizedKeys(java.io.Reader rdr,
boolean okToClose)
Reads read the contents of an
authorized_keys file |
static java.util.List<AuthorizedKeyEntry> |
readAuthorizedKeys(java.net.URL url)
Reads read the contents of an
authorized_keys file |
static java.util.AbstractMap.SimpleImmutableEntry<java.lang.String,java.lang.String> |
resolveEntryComponents(java.lang.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. |
java.security.PublicKey |
resolvePublicKey(SessionContext session,
PublicKeyEntryResolver fallbackResolver) |
void |
setComment(java.lang.String value) |
void |
setLoginOptions(java.util.Map<java.lang.String,java.lang.String> value) |
java.lang.String |
toString() |
appendPublicKeyEntry, appendPublicKeyEntry, getDefaultKeysFolderPath, getKeyData, getKeyDataEntryResolver, getKeyDataResolver, getKeyType, getRegisteredKeyDataEntryResolvers, isEquivalent, parsePublicKeyEntry, parsePublicKeyEntry, parsePublicKeyEntry, parsePublicKeyEntry, registerKeyDataEntryResolver, resolveKeyDataEntryResolver, resolvePublicKey, resolvePublicKeyEntries, resolvePublicKeyEntryDataResolver, setKeyData, setKeyDataResolver, setKeyType, toString, toString, unregisterKeyDataEntryResolver
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
groupByKeyType
public static final char BOOLEAN_OPTION_NEGATION_INDICATOR
private static final long serialVersionUID
private java.lang.String comment
private java.util.Map<java.lang.String,java.lang.String> loginOptions
public java.lang.String getComment()
public void setComment(java.lang.String value)
public java.util.Map<java.lang.String,java.lang.String> getLoginOptions()
public void setLoginOptions(java.util.Map<java.lang.String,java.lang.String> value)
public java.security.PublicKey resolvePublicKey(SessionContext session, PublicKeyEntryResolver fallbackResolver) throws java.io.IOException, java.security.GeneralSecurityException
session
- The SessionContext
for invoking this load command - may be null
if not invoked within a session context (e.g., offline tool or session unknown).fallbackResolver
- 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 be resolved.
Note: may be called only after key type and data bytes have been set or
exception(s) may be thrownjava.io.IOException
- If failed to decode the keyjava.security.GeneralSecurityException
- If failed to generate the keyPublicKeyEntry.resolvePublicKey(SessionContext, Map, PublicKeyEntryResolver)
public java.security.PublicKey appendPublicKey(SessionContext session, java.lang.Appendable sb, PublicKeyEntryResolver fallbackResolver) throws java.io.IOException, java.security.GeneralSecurityException
appendPublicKey
in class PublicKeyEntry
session
- The SessionContext
for invoking this command - may be null
if
not invoked within a session context (e.g., offline tool or session unknown).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 itjava.io.IOException
- If failed to decode/encode the keyjava.security.GeneralSecurityException
- If failed to generate the keyPublicKeyEntry.resolvePublicKey(SessionContext, Map, PublicKeyEntryResolver)
public int hashCode()
hashCode
in class PublicKeyEntry
public boolean equals(java.lang.Object obj)
equals
in class PublicKeyEntry
public java.lang.String toString()
toString
in class PublicKeyEntry
public static java.util.List<AuthorizedKeyEntry> readAuthorizedKeys(java.net.URL url) throws java.io.IOException
authorized_keys
fileurl
- The URL
to read fromList
of all the AuthorizedKeyEntry
-ies found therejava.io.IOException
- If failed to read or parse the entriesreadAuthorizedKeys(InputStream, boolean)
public static java.util.List<AuthorizedKeyEntry> readAuthorizedKeys(java.nio.file.Path path, java.nio.file.OpenOption... options) throws java.io.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 therejava.io.IOException
- If failed to read or parse the entriesreadAuthorizedKeys(InputStream, boolean)
,
Files.newInputStream(Path, OpenOption...)
public static java.util.List<AuthorizedKeyEntry> readAuthorizedKeys(java.io.InputStream in, boolean okToClose) throws java.io.IOException
authorized_keys
filein
- The InputStream
to use to read the contents of an authorized_keys
fileokToClose
- true
if method may close the input regardless success or failureList
of all the AuthorizedKeyEntry
-ies found therejava.io.IOException
- If failed to read or parse the entriesreadAuthorizedKeys(Reader, boolean)
public static java.util.List<AuthorizedKeyEntry> readAuthorizedKeys(java.io.Reader rdr, boolean okToClose) throws java.io.IOException
authorized_keys
filerdr
- The Reader
to use to read the contents of an authorized_keys
fileokToClose
- true
if method may close the input regardless success or failureList
of all the AuthorizedKeyEntry
-ies found therejava.io.IOException
- If failed to read or parse the entriesreadAuthorizedKeys(BufferedReader)
public static java.util.List<AuthorizedKeyEntry> readAuthorizedKeys(java.io.BufferedReader rdr) throws java.io.IOException
rdr
- The BufferedReader
to use to read the contents of an authorized_keys
fileList
of all the AuthorizedKeyEntry
-ies found therejava.io.IOException
- If failed to read or parse the entriesparseAuthorizedKeyEntry(String)
public static AuthorizedKeyEntry parseAuthorizedKeyEntry(java.lang.String value) throws java.lang.IllegalArgumentException
value
- Original line from an authorized_keys
fileAuthorizedKeyEntry
or null
if the line is null
/empty or
a comment linejava.lang.IllegalArgumentException
- If failed to parse/decode the lineparseAuthorizedKeyEntry(String, PublicKeyEntryDataResolver)
public static AuthorizedKeyEntry parseAuthorizedKeyEntry(java.lang.String value, PublicKeyEntryDataResolver resolver) throws java.lang.IllegalArgumentException
value
- Original line from an authorized_keys
fileresolver
- The PublicKeyEntryDataResolver
to use - if null
one will be
automatically resolved from the key typeAuthorizedKeyEntry
or null
if the line is null
/empty or
a comment linejava.lang.IllegalArgumentException
- If failed to parse/decode the linepublic static java.util.AbstractMap.SimpleImmutableEntry<java.lang.String,java.lang.String> resolveEntryComponents(java.lang.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 java.util.NavigableMap<java.lang.String,java.lang.String> parseLoginOptions(java.lang.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 java.util.AbstractMap.SimpleImmutableEntry<java.lang.String,java.lang.String> addLoginOption(java.util.Map<java.lang.String,java.lang.String> optsMap, java.lang.String option)
optsMap
- Options map to add tooption
- The option data to parse - ignored if null
/empty/blanknull
if no option updated in the mapjava.lang.IllegalStateException
- If a boolean option is re-specified