Interface OpenSshCertificate
-
- All Superinterfaces:
javax.security.auth.Destroyable,java.security.Key,java.security.PrivateKey,java.security.PublicKey,java.io.Serializable,SshPublicKey
- All Known Implementing Classes:
OpenSshCertificateImpl
public interface OpenSshCertificate extends SshPublicKey, java.security.PrivateKey
An OpenSSH certificate key as specified by OpenSSH.- See Also:
- PROTOCOL.certkeys
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classOpenSshCertificate.CertificateOptionCertificate Options are a set of bytes that isstatic classOpenSshCertificate.TypeOpenSshCertificates have a type indicating whether the certificate if for a host key (certifying a host identity) or for a user key (certifying a user identity).
-
Field Summary
Fields Modifier and Type Field Description static longINFINITYThe maximumgetValidAfter()orgetValidBefore()value.static longMIN_EPOCH
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description java.security.PublicKeygetCaPubKey()Retrieves the CA public key of this certificate.java.security.PublicKeygetCertPubKey()Retrieves the certified public key.java.util.List<OpenSshCertificate.CertificateOption>getCriticalOptions()Retrieves the critical options set in the certificate.java.util.SortedMap<java.lang.String,java.lang.String>getCriticalOptionsMap()Retrieves the critical options set in the certificate.java.util.List<OpenSshCertificate.CertificateOption>getExtensions()Retrieves the extensions set in the certificate.java.util.SortedMap<java.lang.String,java.lang.String>getExtensionsMap()Retrieves the extensions set in the certificate.java.lang.StringgetId()Retrieves a free-form text set by the CA when the certificate was generated; intended to identify the identity principal in log message.byte[]getMessage()Retrieves the raw byte content of the certificate, minus the signature.byte[]getNonce()Retrieves the nonce of this certificate.java.util.Collection<java.lang.String>getPrincipals()Retrieves the principals mentioned in the certificate.java.lang.StringgetRawKeyType()Retrieves the raw SSH key type of this certificate.byte[]getRawSignature()Retrieves the raw signature bytes, without the signature algorithm.java.lang.StringgetReserved()Retrieves the "reserved" field of the certificate.longgetSerial()Retrieves the serial number of this certificate.byte[]getSignature()Retrieves the signature of the certificate, including the signature algorithm.java.lang.StringgetSignatureAlgorithm()Retrieves the signature algorithm used for the signature.OpenSshCertificate.TypegetType()Retrieves the type of certificate.longgetValidAfter()Retrieves the time in number of seconds since theInstant.EPOCHat which this certificate becomes or became valid.longgetValidBefore()Retrieves the time in number of seconds since theInstant.EPOCHat which this certificate becomes or became invalid.static booleanisValidAt(OpenSshCertificate cert, java.time.Instant time)Determines whether the givenOpenSshCertificateis valid at the givenInstant.static booleanisValidNow(OpenSshCertificate cert)Determines whether the givenOpenSshCertificateis valid at the current local system time.-
Methods inherited from interface org.apache.sshd.common.config.keys.SshPublicKey
getKeyType
-
-
-
-
Field Detail
-
MIN_EPOCH
static final long MIN_EPOCH
- See Also:
- Constant Field Values
-
INFINITY
static final long INFINITY
The maximumgetValidAfter()orgetValidBefore()value.Note that timestamps in OpenSSH certificates are unsigned 64-bit values.
-
-
Method Detail
-
getRawKeyType
java.lang.String getRawKeyType()
Retrieves the raw SSH key type of this certificate.- Returns:
- the key type, for instance "ssh-rsa" for a "ssh-rsa-cert-v01@openssh.com" certificate
-
getNonce
byte[] getNonce()
Retrieves the nonce of this certificate.- Returns:
- the nonce.
-
getCertPubKey
java.security.PublicKey getCertPubKey()
Retrieves the certified public key.- Returns:
- the
PublicKey
-
getSerial
long getSerial()
Retrieves the serial number of this certificate.- Returns:
- the serial number
-
getType
OpenSshCertificate.Type getType()
Retrieves the type of certificate.- Returns:
- the
OpenSshCertificate.Type
-
getId
java.lang.String getId()
Retrieves a free-form text set by the CA when the certificate was generated; intended to identify the identity principal in log message.- Returns:
- the id; never
nullbut may be empty.
-
getPrincipals
java.util.Collection<java.lang.String> getPrincipals()
Retrieves the principals mentioned in the certificate.- Returns:
- the collection of principals, never
nullbut possibly empty
-
getValidAfter
long getValidAfter()
Retrieves the time in number of seconds since theInstant.EPOCHat which this certificate becomes or became valid.- Returns:
- the number of seconds since the
Instant.EPOCHas an unsigned 64bit value - See Also:
isValidNow(OpenSshCertificate)
-
getValidBefore
long getValidBefore()
Retrieves the time in number of seconds since theInstant.EPOCHat which this certificate becomes or became invalid.- Returns:
- the number of seconds since the
Instant.EPOCHas an unsigned 64bit value - See Also:
isValidNow(OpenSshCertificate)
-
getCriticalOptions
java.util.List<OpenSshCertificate.CertificateOption> getCriticalOptions()
Retrieves the critical options set in the certificate.- Returns:
- the critical options as an unmodifiable list, never
nullbut possibly empty - See Also:
getCriticalOptionsMap()
-
getCriticalOptionsMap
java.util.SortedMap<java.lang.String,java.lang.String> getCriticalOptionsMap()
Retrieves the critical options set in the certificate.- Returns:
- the critical options as an unmodifiable map, never
nullbut possibly empty
-
getExtensions
java.util.List<OpenSshCertificate.CertificateOption> getExtensions()
Retrieves the extensions set in the certificate.- Returns:
- the extensions as an unmodifiable list, never
nullbut possibly empty - See Also:
getExtensionsMap()
-
getExtensionsMap
java.util.SortedMap<java.lang.String,java.lang.String> getExtensionsMap()
Retrieves the extensions set in the certificate.- Returns:
- the extensions as an unmodifiable map, never
nullbut possibly empty
-
getReserved
java.lang.String getReserved()
Retrieves the "reserved" field of the certificate. OpenSSH currently doesn't use it and ignores it.- Returns:
- the "reserved" field.
-
getCaPubKey
java.security.PublicKey getCaPubKey()
Retrieves the CA public key of this certificate.- Returns:
- the
PublicKey
-
getMessage
byte[] getMessage()
Retrieves the raw byte content of the certificate, minus the signature. This is the data that was signed.- Returns:
- the part of the certificate raw data that was signed
-
getSignature
byte[] getSignature()
Retrieves the signature of the certificate, including the signature algorithm.- Returns:
- the signature bytes
- See Also:
getRawSignature()
-
getSignatureAlgorithm
java.lang.String getSignatureAlgorithm()
Retrieves the signature algorithm used for the signature.- Returns:
- the signature algorithm as recorded in the certificate
-
getRawSignature
byte[] getRawSignature()
Retrieves the raw signature bytes, without the signature algorithm.- Returns:
- the signature bytes
- See Also:
getSignature()
-
isValidNow
static boolean isValidNow(OpenSshCertificate cert)
Determines whether the givenOpenSshCertificateis valid at the current local system time.- Parameters:
cert- to check- Returns:
trueif the certificate is valid according to its timestamps,falseotherwise
-
isValidAt
static boolean isValidAt(OpenSshCertificate cert, java.time.Instant time)
Determines whether the givenOpenSshCertificateis valid at the givenInstant.- Parameters:
cert- to check- Returns:
trueif the certificate is valid according to its timestamps,falseotherwise
-
-