public class OpenSSHKeyPairResourceParser extends AbstractKeyPairResourceParser
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AUTH_MAGIC |
private static byte[] |
AUTH_MAGIC_BYTES |
static java.lang.String |
BEGIN_MARKER |
static java.util.List<java.lang.String> |
BEGINNERS |
private static java.util.Map<java.lang.Class<?>,PrivateKeyEntryDecoder<?,?>> |
BY_KEY_CLASS_DECODERS_MAP |
private static java.util.Map<java.lang.String,PrivateKeyEntryDecoder<?,?>> |
BY_KEY_TYPE_DECODERS_MAP |
static java.lang.String |
END_MARKER |
static java.util.List<java.lang.String> |
ENDERS |
static OpenSSHKeyPairResourceParser |
INSTANCE |
log
EMPTY
Constructor and Description |
---|
OpenSSHKeyPairResourceParser() |
Modifier and Type | Method and Description |
---|---|
java.util.Collection<java.security.KeyPair> |
extractKeyPairs(java.lang.String resourceKey,
java.lang.String beginMarker,
java.lang.String endMarker,
FilePasswordProvider passwordProvider,
java.io.InputStream stream) |
static PrivateKeyEntryDecoder<?,?> |
getPrivateKeyEntryDecoder(java.lang.Class<?> keyType) |
static PrivateKeyEntryDecoder<?,?> |
getPrivateKeyEntryDecoder(java.security.Key key) |
static PrivateKeyEntryDecoder<?,?> |
getPrivateKeyEntryDecoder(java.security.KeyPair kp) |
static PrivateKeyEntryDecoder<?,?> |
getPrivateKeyEntryDecoder(java.lang.String keyType) |
protected java.util.AbstractMap.SimpleImmutableEntry<java.security.PrivateKey,java.lang.String> |
readPrivateKey(java.lang.String resourceKey,
OpenSSHParserContext context,
java.lang.String keyType,
FilePasswordProvider passwordProvider,
java.io.InputStream stream) |
protected java.util.List<java.security.KeyPair> |
readPrivateKeys(java.lang.String resourceKey,
OpenSSHParserContext context,
java.util.Collection<? extends java.security.PublicKey> publicKeys,
FilePasswordProvider passwordProvider,
java.io.InputStream stream) |
protected java.security.PublicKey |
readPublicKey(java.lang.String resourceKey,
OpenSSHParserContext context,
java.io.InputStream stream) |
static void |
registerPrivateKeyEntryDecoder(PrivateKeyEntryDecoder<?,?> decoder) |
protected <S extends java.io.InputStream> |
validateStreamMagicMarker(java.lang.String resourceKey,
S stream) |
canExtractKeyPairs, extractKeyPairs, extractKeyPairs, getBeginners, getEnders, getEndingMarkers, loadKeyPairs
getSimplifiedLogger
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
aggregate, aggregate, containsMarkerLine, containsMarkerLine, extractDataBytes, findMarkerLine, findMarkerLine, joinDataLines
loadKeyPairs, loadKeyPairs, loadKeyPairs, loadKeyPairs, loadKeyPairs, loadKeyPairs, loadKeyPairs, loadKeyPairs, loadKeyPairs
public static final java.lang.String BEGIN_MARKER
public static final java.util.List<java.lang.String> BEGINNERS
public static final java.lang.String END_MARKER
public static final java.util.List<java.lang.String> ENDERS
public static final java.lang.String AUTH_MAGIC
public static final OpenSSHKeyPairResourceParser INSTANCE
private static final byte[] AUTH_MAGIC_BYTES
private static final java.util.Map<java.lang.String,PrivateKeyEntryDecoder<?,?>> BY_KEY_TYPE_DECODERS_MAP
private static final java.util.Map<java.lang.Class<?>,PrivateKeyEntryDecoder<?,?>> BY_KEY_CLASS_DECODERS_MAP
public java.util.Collection<java.security.KeyPair> extractKeyPairs(java.lang.String resourceKey, java.lang.String beginMarker, java.lang.String endMarker, FilePasswordProvider passwordProvider, java.io.InputStream stream) throws java.io.IOException, java.security.GeneralSecurityException
extractKeyPairs
in class AbstractKeyPairResourceParser
resourceKey
- A hint as to the origin of the text linesbeginMarker
- The line containing the begin markerendMarker
- The line containing the end markerpasswordProvider
- The FilePasswordProvider
to use
in case the data is encrypted - may be null
if no encryptedstream
- The decoded data InputStream
KeyPair
s - may be null
/empty if none.java.io.IOException
- If failed to parse the datajava.security.GeneralSecurityException
- If failed to generate the keysprotected java.security.PublicKey readPublicKey(java.lang.String resourceKey, OpenSSHParserContext context, java.io.InputStream stream) throws java.io.IOException, java.security.GeneralSecurityException
java.io.IOException
java.security.GeneralSecurityException
protected java.util.List<java.security.KeyPair> readPrivateKeys(java.lang.String resourceKey, OpenSSHParserContext context, java.util.Collection<? extends java.security.PublicKey> publicKeys, FilePasswordProvider passwordProvider, java.io.InputStream stream) throws java.io.IOException, java.security.GeneralSecurityException
java.io.IOException
java.security.GeneralSecurityException
protected java.util.AbstractMap.SimpleImmutableEntry<java.security.PrivateKey,java.lang.String> readPrivateKey(java.lang.String resourceKey, OpenSSHParserContext context, java.lang.String keyType, FilePasswordProvider passwordProvider, java.io.InputStream stream) throws java.io.IOException, java.security.GeneralSecurityException
java.io.IOException
java.security.GeneralSecurityException
protected <S extends java.io.InputStream> S validateStreamMagicMarker(java.lang.String resourceKey, S stream) throws java.io.IOException
java.io.IOException
public static void registerPrivateKeyEntryDecoder(PrivateKeyEntryDecoder<?,?> decoder)
decoder
- The decoder to registerjava.lang.IllegalArgumentException
- if no decoder or not key type or no
supported names for the decoderIdentityResourceLoader.getPublicKeyType()
,
IdentityResourceLoader.getSupportedTypeNames()
public static PrivateKeyEntryDecoder<?,?> getPrivateKeyEntryDecoder(java.lang.String keyType)
keyType
- The OpenSSH
key type string - e.g., ssh-rsa, ssh-dss
- ignored if null
/emptyPrivateKeyEntryDecoder
or {code null} if not foundpublic static PrivateKeyEntryDecoder<?,?> getPrivateKeyEntryDecoder(java.security.KeyPair kp)
kp
- The KeyPair
to examine - ignored if null
PrivateKeyEntryDecoder
provided both
the public and private keys have the same decoder - null
if no
match foundgetPrivateKeyEntryDecoder(Key)
public static PrivateKeyEntryDecoder<?,?> getPrivateKeyEntryDecoder(java.security.Key key)
key
- The Key
(public or private) - ignored if null
PrivateKeyEntryDecoder
for this key or {code null} if no match foundgetPrivateKeyEntryDecoder(Class)
public static PrivateKeyEntryDecoder<?,?> getPrivateKeyEntryDecoder(java.lang.Class<?> keyType)
keyType
- The key Class
- ignored if null
or not a Key
compatible typePrivateKeyEntryDecoder
or {code null} if no match found