Top Fields Constructors Methods
org.apache.sshd.common.config.keys.loader

public abstract Class AbstractKeyPairResourceParser

extends AbstractLoggingBean
implements KeyPairResourceParser
Class Inheritance
All Implemented Interfaces
org.apache.sshd.common.config.keys.loader.KeyPairResourceParser, org.apache.sshd.common.config.keys.loader.KeyPairResourceLoader
Known Direct Subclasses
org.apache.sshd.common.config.keys.loader.openssh.OpenSSHKeyPairResourceParser, org.apache.sshd.common.config.keys.loader.pem.AbstractPEMResourceKeyPairParser, org.apache.sshd.common.util.security.bouncycastle.BouncyCastleKeyPairResourceParser
Imports
java.io.ByteArrayInputStream, .IOException, .InputStream, .StreamCorruptedException, java.security.GeneralSecurityException, .KeyPair, java.util.AbstractMap.SimpleImmutableEntry, .ArrayList, .Arrays, .Collection, .Collections, .LinkedList, .List, .Map, java.util.logging.Level, org.apache.sshd.common.NamedResource, org.apache.sshd.common.config.keys.FilePasswordProvider, org.apache.sshd.common.session.SessionContext, org.apache.sshd.common.util.GenericUtils, .ValidateUtils, org.apache.sshd.common.util.buffer.BufferUtils, org.apache.sshd.common.util.logging.AbstractLoggingBean

Author
Apache MINA SSHD Project

Field Summary

Modifier and TypeField and Description
private final List<String>
private final List<String>
private final List<List<String>>
Inherited from org.apache.sshd.common.util.logging.AbstractLoggingBean:
log

Constructor Summary

AccessConstructor and Description
protected
AbstractKeyPairResourceParser(List<String>
The markers that indicate the beginning of a parsing block
beginners
,
List<String>
The matching (by position) markers that indicate the end of a parsing block
enders
)

Method Summary

Modifier and TypeMethod and Description
public boolean
canExtractKeyPairs(NamedResource
A hint as to the origin of the text lines
resourceKey
,
List<String>
The resource lines
lines
)

Implements org.apache.sshd.common.config.keys.loader.KeyPairResourceParser.canExtractKeyPairs.

public Collection<KeyPair>

Returns:

The extracted KeyPairs - may be null/empty if none.
extractKeyPairs
(SessionContext
The SessionContext for invoking this load command - may be null if not invoked within a session context (e.g., offline tool or session unknown).
session
,
NamedResource
A hint as to the origin of the text lines
resourceKey
,
String
The line containing the begin marker
beginMarker
,
String
The line containing the end marker
endMarker
,
FilePasswordProvider
The FilePasswordProvider to use in case the data is encrypted - may be null if no encrypted
passwordProvider
,
List<String>
The block of lines between the markers
lines
,
Map<String, String>
Any headers that may have been available when data was read
headers
)

Extracts the key pairs within a single delimited by markers block of lines.

public Collection<KeyPair>

Returns:

The extracted KeyPairs - may be null/empty if none.
extractKeyPairs
(SessionContext
The SessionContext for invoking this load command - may be null if not invoked within a session context (e.g., offline tool or session unknown).
session
,
NamedResource
A hint as to the origin of the text lines
resourceKey
,
String
The line containing the begin marker
beginMarker
,
String
The line containing the end marker
endMarker
,
FilePasswordProvider
The FilePasswordProvider to use in case the data is encrypted - may be null if no encrypted
passwordProvider
,
byte[]
The decoded bytes from the lines containing the data
bytes
,
Map<String, String>
Any headers that may have been available when data was read
headers
)

public abstract Collection<KeyPair>

Returns:

The extracted KeyPairs - may be null/empty if none.
extractKeyPairs
(SessionContext
The SessionContext for invoking this load command - may be null if not invoked within a session context (e.g., offline tool or session unknown).
session
,
NamedResource
A hint as to the origin of the text lines
resourceKey
,
String
The line containing the begin marker
beginMarker
,
String
The line containing the end marker
endMarker
,
FilePasswordProvider
The FilePasswordProvider to use in case the data is encrypted - may be null if no encrypted
passwordProvider
,
InputStream
The decoded data InputStream
stream
,
Map<String, String>
Any headers that may have been available when data was read
headers
)

public List<String>
public List<String>
public List<List<String>>

Returns:

A List of same size as the ending markers, where each ending marker is encapsulated inside a singleton list and resides as the same index as the marker it encapsulates
getEndingMarkers
()

public Collection<KeyPair>
loadKeyPairs(SessionContext
The SessionContext for invoking this load command - may be null if not invoked within a session context (e.g., offline tool or session unknown).
session
,
NamedResource
A hint as to the origin of the text lines
resourceKey
,
FilePasswordProvider
The FilePasswordProvider to use in case the data is encrypted - may be null if no encrypted data is expected
passwordProvider
,
List<String>
The List of lines as read from the resource
lines
)

Implements org.apache.sshd.common.config.keys.loader.KeyPairResourceLoader.loadKeyPairs.

Loads key pairs from the given resource text lines

protected Map.Entry<Map<String, String>, List<String>>
separateDataLinesFromHeaders(SessionContext session, NamedResource resourceKey, String startLine, String endLine, List<String> dataLines)

Inherited from org.apache.sshd.common.util.logging.AbstractLoggingBean:
debugdebugdebugdebugdebugerrorerrorerrorerrorerrorgetSimplifiedLoggerinfoinfowarnwarnwarnwarnwarnwarnwarnwarn

Field Detail

beginnersback to summary
private final List<String> beginners
endersback to summary
private final List<String> enders
endingMarkersback to summary
private final List<List<String>> endingMarkers

Constructor Detail

AbstractKeyPairResourceParserback to summary
protected AbstractKeyPairResourceParser(List<String> beginners, List<String> enders)
Parameters
beginners:List<String>

The markers that indicate the beginning of a parsing block

enders:List<String>

The matching (by position) markers that indicate the end of a parsing block

Method Detail

canExtractKeyPairsback to summary
public boolean canExtractKeyPairs(NamedResource resourceKey, List<String> lines) throws IOException, GeneralSecurityException

Implements org.apache.sshd.common.config.keys.loader.KeyPairResourceParser.canExtractKeyPairs.

Parameters
resourceKey:NamedResource

Doc from org.apache.sshd.common.config.keys.loader.KeyPairResourceParser.canExtractKeyPairs.

A hint as to the origin of the text lines

lines:List<String>

Doc from org.apache.sshd.common.config.keys.loader.KeyPairResourceParser.canExtractKeyPairs.

The resource lines

Returns:boolean

Doc from org.apache.sshd.common.config.keys.loader.KeyPairResourceParser.canExtractKeyPairs.

true if the parser can extract some key pairs from the lines

Annotations
@Override
Exceptions
IOException:

Doc from org.apache.sshd.common.config.keys.loader.KeyPairResourceParser.canExtractKeyPairs.

If failed to process the lines

GeneralSecurityException:

Doc from org.apache.sshd.common.config.keys.loader.KeyPairResourceParser.canExtractKeyPairs.

If failed to extract information regarding the possibility to extract the key pairs

extractKeyPairsback to summary
public Collection<KeyPair> extractKeyPairs(SessionContext session, NamedResource resourceKey, String beginMarker, String endMarker, FilePasswordProvider passwordProvider, List<String> lines, Map<String, String> headers) throws IOException, GeneralSecurityException

Extracts the key pairs within a single delimited by markers block of lines. By default cleans up the empty lines, joins them and converts them from BASE64

Parameters
session:SessionContext

The SessionContext for invoking this load command - may be null if not invoked within a session context (e.g., offline tool or session unknown).

resourceKey:NamedResource

A hint as to the origin of the text lines

beginMarker:String

The line containing the begin marker

endMarker:String

The line containing the end marker

passwordProvider:FilePasswordProvider

The FilePasswordProvider to use in case the data is encrypted - may be null if no encrypted

lines:List<String>

The block of lines between the markers

headers:Map<String, String>

Any headers that may have been available when data was read

Returns:Collection<KeyPair>

The extracted KeyPairs - may be null/empty if none.

Exceptions
IOException:
If failed to parse the data
GeneralSecurityException:
If failed to generate the keys
extractKeyPairsback to summary
public Collection<KeyPair> extractKeyPairs(SessionContext session, NamedResource resourceKey, String beginMarker, String endMarker, FilePasswordProvider passwordProvider, byte[] bytes, Map<String, String> headers) throws IOException, GeneralSecurityException
Parameters
session:SessionContext

The SessionContext for invoking this load command - may be null if not invoked within a session context (e.g., offline tool or session unknown).

resourceKey:NamedResource

A hint as to the origin of the text lines

beginMarker:String

The line containing the begin marker

endMarker:String

The line containing the end marker

passwordProvider:FilePasswordProvider

The FilePasswordProvider to use in case the data is encrypted - may be null if no encrypted

bytes:byte[]

The decoded bytes from the lines containing the data

headers:Map<String, String>

Any headers that may have been available when data was read

Returns:Collection<KeyPair>

The extracted KeyPairs - may be null/empty if none.

Exceptions
IOException:
If failed to parse the data
GeneralSecurityException:
If failed to generate the keys
extractKeyPairsback to summary
public abstract Collection<KeyPair> extractKeyPairs(SessionContext session, NamedResource resourceKey, String beginMarker, String endMarker, FilePasswordProvider passwordProvider, InputStream stream, Map<String, String> headers) throws IOException, GeneralSecurityException
Parameters
session:SessionContext

The SessionContext for invoking this load command - may be null if not invoked within a session context (e.g., offline tool or session unknown).

resourceKey:NamedResource

A hint as to the origin of the text lines

beginMarker:String

The line containing the begin marker

endMarker:String

The line containing the end marker

passwordProvider:FilePasswordProvider

The FilePasswordProvider to use in case the data is encrypted - may be null if no encrypted

stream:InputStream

The decoded data InputStream

headers:Map<String, String>

Any headers that may have been available when data was read

Returns:Collection<KeyPair>

The extracted KeyPairs - may be null/empty if none.

Exceptions
IOException:
If failed to parse the data
GeneralSecurityException:
If failed to generate the keys
getBeginnersback to summary
public List<String> getBeginners()
getEndersback to summary
public List<String> getEnders()
getEndingMarkersback to summary
public List<List<String>> getEndingMarkers()
Returns:List<List<String>>

A List of same size as the ending markers, where each ending marker is encapsulated inside a singleton list and resides as the same index as the marker it encapsulates

loadKeyPairsback to summary
public Collection<KeyPair> loadKeyPairs(SessionContext session, NamedResource resourceKey, FilePasswordProvider passwordProvider, List<String> lines) throws IOException, GeneralSecurityException

Implements org.apache.sshd.common.config.keys.loader.KeyPairResourceLoader.loadKeyPairs.

Doc from org.apache.sshd.common.config.keys.loader.KeyPairResourceLoader.loadKeyPairs.

Loads key pairs from the given resource text lines

Parameters
session:SessionContext

The SessionContext for invoking this load command - may be null if not invoked within a session context (e.g., offline tool or session unknown).

resourceKey:NamedResource

A hint as to the origin of the text lines

passwordProvider:FilePasswordProvider

The FilePasswordProvider to use in case the data is encrypted - may be null if no encrypted data is expected

lines:List<String>

The List of lines as read from the resource

Returns:Collection<KeyPair>

The extracted KeyPairs - may be null/empty if none

Note

the resource loader may decide to skip unknown lines if more than one key pair type is encoded in it

Annotations
@Override
Exceptions
IOException:
If failed to process the lines
GeneralSecurityException:
If failed to generate the keys from the parsed data
separateDataLinesFromHeadersback to summary
protected Map.Entry<Map<String, String>, List<String>> separateDataLinesFromHeaders(SessionContext session, NamedResource resourceKey, String startLine, String endLine, List<String> dataLines) throws IOException, GeneralSecurityException