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

public Class RSAPEMResourceKeyPairParser

extends AbstractPEMResourceKeyPairParser
Class Inheritance
Imports
java.io.IOException, .InputStream, .StreamCorruptedException, java.math.BigInteger, java.security.GeneralSecurityException, .KeyFactory, .KeyPair, .PrivateKey, .PublicKey, java.security.spec.RSAPrivateCrtKeySpec, .RSAPrivateKeySpec, .RSAPublicKeySpec, java.util.Collection, .Collections, .List, .Map, org.apache.sshd.common.NamedResource, org.apache.sshd.common.config.keys.FilePasswordProvider, .KeyUtils, org.apache.sshd.common.session.SessionContext, org.apache.sshd.common.util.io.der.ASN1Object, .ASN1Type, .DERParser, org.apache.sshd.common.util.io.input.NoCloseInputStream, org.apache.sshd.common.util.security.SecurityUtils

Author
Apache MINA SSHD Project
See Also
RFC-3279 section 2.3.1

Field Summary

Modifier and TypeField and Description
public static final String
public static final List<String>
public static final String
public static final List<String>
public static final RSAPEMResourceKeyPairParser
public static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static KeyPair

Returns:

The recovered KeyPair
decodeRSAKeyPair
(KeyFactory
The KeyFactory To use to generate the keys
kf
,
InputStream
The InputStream containing the encoded bytes
s
,
boolean
true if the method may close the input stream regardless of success or failure
okToClose
)

The ASN.1 syntax for the private key as per RFC-3447 section A.1.2:


RSAPrivateKey ::= SEQUENCE {
  version           Version,
  modulus           INTEGER,  -- n
  publicExponent    INTEGER,  -- e
  privateExponent   INTEGER,  -- d
  prime1            INTEGER,  -- p
  prime2            INTEGER,  -- q
  exponent1         INTEGER,  -- d mod (p-1)
  exponent2         INTEGER,  -- d mod (q-1)
  coefficient       INTEGER,  -- (inverse of q) mod p
  otherPrimeInfos   OtherPrimeInfos OPTIONAL
}

public Collection<KeyPair>
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
)

Implements abstract org.apache.sshd.common.config.keys.loader.AbstractKeyPairResourceParser.extractKeyPairs.

Inherited from org.apache.sshd.common.config.keys.loader.pem.AbstractPEMResourceKeyPairParser:
applyPrivateKeyCipherextractKeyPairsgetAlgorithmgetAlgorithmIdentifier

Field Detail

BEGIN_MARKERback to summary
public static final String BEGIN_MARKER
BEGINNERSback to summary
public static final List<String> BEGINNERS
END_MARKERback to summary
public static final String END_MARKER
ENDERSback to summary
public static final List<String> ENDERS
INSTANCEback to summary
public static final RSAPEMResourceKeyPairParser INSTANCE
RSA_OIDback to summary
public static final String RSA_OID

Constructor Detail

RSAPEMResourceKeyPairParserback to summary
public RSAPEMResourceKeyPairParser()

Method Detail

decodeRSAKeyPairback to summary
public static KeyPair decodeRSAKeyPair(KeyFactory kf, InputStream s, boolean okToClose) throws IOException, GeneralSecurityException

The ASN.1 syntax for the private key as per RFC-3447 section A.1.2:


RSAPrivateKey ::= SEQUENCE {
  version           Version,
  modulus           INTEGER,  -- n
  publicExponent    INTEGER,  -- e
  privateExponent   INTEGER,  -- d
  prime1            INTEGER,  -- p
  prime2            INTEGER,  -- q
  exponent1         INTEGER,  -- d mod (p-1)
  exponent2         INTEGER,  -- d mod (q-1)
  coefficient       INTEGER,  -- (inverse of q) mod p
  otherPrimeInfos   OtherPrimeInfos OPTIONAL
}

Parameters
kf:KeyFactory

The KeyFactory To use to generate the keys

s:InputStream

The InputStream containing the encoded bytes

okToClose:boolean

true if the method may close the input stream regardless of success or failure

Returns:KeyPair

The recovered KeyPair

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

Implements abstract org.apache.sshd.common.config.keys.loader.AbstractKeyPairResourceParser.extractKeyPairs.

Parameters
session:SessionContext

Doc from org.apache.sshd.common.config.keys.loader.AbstractKeyPairResourceParser.extractKeyPairs.

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

Doc from org.apache.sshd.common.config.keys.loader.AbstractKeyPairResourceParser.extractKeyPairs.

A hint as to the origin of the text lines

beginMarker:String

Doc from org.apache.sshd.common.config.keys.loader.AbstractKeyPairResourceParser.extractKeyPairs.

The line containing the begin marker

endMarker:String

Doc from org.apache.sshd.common.config.keys.loader.AbstractKeyPairResourceParser.extractKeyPairs.

The line containing the end marker

passwordProvider:FilePasswordProvider

Doc from org.apache.sshd.common.config.keys.loader.AbstractKeyPairResourceParser.extractKeyPairs.

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

stream:InputStream

Doc from org.apache.sshd.common.config.keys.loader.AbstractKeyPairResourceParser.extractKeyPairs.

The decoded data InputStream

headers:Map<String, String>

Doc from org.apache.sshd.common.config.keys.loader.AbstractKeyPairResourceParser.extractKeyPairs.

Any headers that may have been available when data was read

Returns:Collection<KeyPair>

Doc from org.apache.sshd.common.config.keys.loader.AbstractKeyPairResourceParser.extractKeyPairs.

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

Annotations
@Override
Exceptions
IOException:

Doc from org.apache.sshd.common.config.keys.loader.AbstractKeyPairResourceParser.extractKeyPairs.

If failed to parse the data

GeneralSecurityException:

Doc from org.apache.sshd.common.config.keys.loader.AbstractKeyPairResourceParser.extractKeyPairs.

If failed to generate the keys