PUB
- Type of PublicKey
PRV
- Type of PrivateKey
public abstract class AbstractPublicKeyEntryDecoder<PUB extends PublicKey,PRV extends PrivateKey> extends Object implements PublicKeyEntryDecoder<PUB,PRV>
OpenSSH
encoded key dataFAILING, IGNORING
Modifier | Constructor and Description |
---|---|
protected |
AbstractPublicKeyEntryDecoder(Class<PUB> pubType,
Class<PRV> prvType,
Collection<String> names) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
clonePrivateKey, clonePublicKey, encodePublicKey, getKeyFactoryInstance, getKeyPairGenerator
public final Class<PUB> getPublicKeyType()
getPublicKeyType
in interface PublicKeyEntryDecoder<PUB extends PublicKey,PRV extends PrivateKey>
Class
of the PublicKey
that is the result
of decodingpublic final Class<PRV> getPrivateKeyType()
getPrivateKeyType
in interface PublicKeyEntryDecoder<PUB extends PublicKey,PRV extends PrivateKey>
Class
of the PrivateKey
that matches the
public onepublic KeyPair cloneKeyPair(KeyPair kp) throws GeneralSecurityException
cloneKeyPair
in interface PublicKeyEntryDecoder<PUB extends PublicKey,PRV extends PrivateKey>
kp
- The KeyPair
to be cloned - ignored if null
null
if no original pair)GeneralSecurityException
- If failed to clone - e.g., provided key
pair does not contain keys of the expected typePublicKeyEntryDecoder.getPublicKeyType()
,
PublicKeyEntryDecoder.getPrivateKeyType()
public PublicKey resolve(String keyType, byte[] keyData) throws IOException, GeneralSecurityException
resolve
in interface PublicKeyEntryResolver
keyType
- The OpenSSH
reported key typekeyData
- The OpenSSH
encoded key dataPublicKey
- ignored if null
IOException
- If failed to parse the key dataGeneralSecurityException
- If failed to generate the keypublic Collection<String> getSupportedTypeNames()
getSupportedTypeNames
in interface PublicKeyEntryDecoder<PUB extends PublicKey,PRV extends PrivateKey>
Collection
of OpenSSH
key type names that
are supported by this decoder - e.g., ECDSA keys have several curve names.
Caveat: this collection may be un-modifiable...public PUB decodePublicKey(byte... keyData) throws IOException, GeneralSecurityException
decodePublicKey
in interface PublicKeyEntryDecoder<PUB extends PublicKey,PRV extends PrivateKey>
keyData
- The key data bytes in OpenSSH
format (after
BASE64 decoding) - ignored if null
/emptyPublicKey
- or null
if no dataIOException
- If failed to decode the keyGeneralSecurityException
- If failed to generate the keypublic PUB decodePublicKey(byte[] keyData, int offset, int length) throws IOException, GeneralSecurityException
decodePublicKey
in interface PublicKeyEntryDecoder<PUB extends PublicKey,PRV extends PrivateKey>
IOException
GeneralSecurityException
public PUB decodePublicKey(InputStream keyData) throws IOException, GeneralSecurityException
decodePublicKey
in interface PublicKeyEntryDecoder<PUB extends PublicKey,PRV extends PrivateKey>
IOException
GeneralSecurityException
public PUB generatePublicKey(KeySpec keySpec) throws GeneralSecurityException
GeneralSecurityException
public PRV generatePrivateKey(KeySpec keySpec) throws GeneralSecurityException
GeneralSecurityException
public abstract PUB decodePublicKey(String keyType, InputStream keyData) throws IOException, GeneralSecurityException
keyType
- The reported / encode key typekeyData
- The key data bytes stream positioned after the key type decoding
and making sure it is one of the supported typesPublicKey
IOException
- If failed to read from the data streamGeneralSecurityException
- If failed to generate the keypublic KeyPair generateKeyPair(int keySize) throws GeneralSecurityException
generateKeyPair
in interface PublicKeyEntryDecoder<PUB extends PublicKey,PRV extends PrivateKey>
keySize
- Key size in bitsKeyPair
with the specified key sizeGeneralSecurityException
- if unable to generate the pairpublic static int encodeString(OutputStream s, String v) throws IOException
IOException
public static int encodeString(OutputStream s, String v, String charset) throws IOException
IOException
public static int encodeString(OutputStream s, String v, Charset cs) throws IOException
IOException
public static int encodeBigInt(OutputStream s, BigInteger v) throws IOException
IOException
public static int writeRLEBytes(OutputStream s, byte... bytes) throws IOException
IOException
public static int writeRLEBytes(OutputStream s, byte[] bytes, int off, int len) throws IOException
IOException
public static byte[] encodeInt(OutputStream s, int v) throws IOException
IOException
public static String decodeString(InputStream s) throws IOException
IOException
public static String decodeString(InputStream s, String charset) throws IOException
IOException
public static String decodeString(InputStream s, Charset cs) throws IOException
IOException
public static BigInteger decodeBigInt(InputStream s) throws IOException
IOException
public static byte[] readRLEBytes(InputStream s) throws IOException
IOException
public static int decodeInt(InputStream s) throws IOException
IOException
Copyright © 2008–2016 The Apache Software Foundation. All rights reserved.