Package net.schmizz.sshj.common
Class KeyType.CertUtils
- java.lang.Object
-
- net.schmizz.sshj.common.KeyType.CertUtils
-
- Enclosing class:
- KeyType
public static class KeyType.CertUtils extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.List<Factory.Named<Signature>>
ALL_SIGNATURES
-
Constructor Summary
Constructors Constructor Description CertUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.util.Date
dateFromEpoch(java.math.BigInteger seconds)
private static java.math.BigInteger
epochFromDate(java.util.Date date)
(package private) static boolean
isCertificateOfType(java.security.Key key, KeyType innerKeyType)
static boolean
matchPattern(java.lang.String target, java.lang.String pattern)
This method must work exactly as match_pattern from match.c of OpenSSH.private static byte[]
packList(java.lang.Iterable<java.lang.String> strings)
private static byte[]
packMap(java.util.Map<java.lang.String,java.lang.String> map)
private static byte[]
packString(java.lang.String data)
(package private) static <T extends java.security.PublicKey>
Certificate<T>readPubKey(Buffer<?> buf, KeyType innerKeyType)
(package private) static Certificate<java.security.PublicKey>
toCertificate(java.security.PublicKey key)
private static java.util.List<java.lang.String>
unpackList(byte[] packedString)
private static java.util.Map<java.lang.String,java.lang.String>
unpackMap(byte[] packedString)
private static java.lang.String
unpackString(byte[] packedString)
static java.lang.String
verifyHostCertificate(byte[] certRaw, Certificate<?> cert, java.lang.String hostname)
(package private) static void
writePubKeyContentsIntoBuffer(java.security.PublicKey publicKey, KeyType innerKeyType, Buffer<?> buf)
-
-
-
Field Detail
-
ALL_SIGNATURES
public static final java.util.List<Factory.Named<Signature>> ALL_SIGNATURES
-
-
Method Detail
-
readPubKey
static <T extends java.security.PublicKey> Certificate<T> readPubKey(Buffer<?> buf, KeyType innerKeyType) throws java.security.GeneralSecurityException
- Throws:
java.security.GeneralSecurityException
-
writePubKeyContentsIntoBuffer
static void writePubKeyContentsIntoBuffer(java.security.PublicKey publicKey, KeyType innerKeyType, Buffer<?> buf)
-
verifyHostCertificate
public static java.lang.String verifyHostCertificate(byte[] certRaw, Certificate<?> cert, java.lang.String hostname) throws Buffer.BufferException, SSHRuntimeException
- Parameters:
certRaw
- Already serialized host certificate that was received as a packet. Can be restored simply by callingnew Buffer.PlainBuffer().putPublicKey(cert)
cert
- A key with a certificate received from a server.hostname
- A hostname of the server. It is juxtaposed to the principals of the certificate.- Returns:
- null if the certificate is valid, an error message if it is not valid.
- Throws:
Buffer.BufferException
- If something fromcertRaw
orcert
can't be parsed.SSHRuntimeException
-
matchPattern
public static boolean matchPattern(java.lang.String target, java.lang.String pattern)
This method must work exactly as match_pattern from match.c of OpenSSH. If it works differently, consider it as a bug that must be fixed.
-
isCertificateOfType
static boolean isCertificateOfType(java.security.Key key, KeyType innerKeyType)
-
toCertificate
static Certificate<java.security.PublicKey> toCertificate(java.security.PublicKey key)
-
dateFromEpoch
private static java.util.Date dateFromEpoch(java.math.BigInteger seconds)
-
epochFromDate
private static java.math.BigInteger epochFromDate(java.util.Date date)
-
unpackString
private static java.lang.String unpackString(byte[] packedString) throws Buffer.BufferException
- Throws:
Buffer.BufferException
-
unpackList
private static java.util.List<java.lang.String> unpackList(byte[] packedString) throws Buffer.BufferException
- Throws:
Buffer.BufferException
-
unpackMap
private static java.util.Map<java.lang.String,java.lang.String> unpackMap(byte[] packedString) throws Buffer.BufferException
- Throws:
Buffer.BufferException
-
packString
private static byte[] packString(java.lang.String data)
-
packList
private static byte[] packList(java.lang.Iterable<java.lang.String> strings)
-
packMap
private static byte[] packMap(java.util.Map<java.lang.String,java.lang.String> map)
-
-