Class OpenSshCertificateImpl
- java.lang.Object
-
- org.apache.sshd.common.config.keys.OpenSshCertificateImpl
-
- All Implemented Interfaces:
java.io.Serializable,java.security.Key,java.security.PrivateKey,java.security.PublicKey,javax.security.auth.Destroyable,OpenSshCertificate,SshPublicKey
public class OpenSshCertificateImpl extends java.lang.Object implements OpenSshCertificate
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.sshd.common.config.keys.OpenSshCertificate
OpenSshCertificate.CertificateOption, OpenSshCertificate.Type
-
-
Field Summary
Fields Modifier and Type Field Description private java.security.PublicKeycaPubKeyprivate java.security.PublicKeycertificatePublicKeyprivate java.util.SortedMap<java.lang.String,java.lang.String>criticalOptionsprivate java.util.SortedMap<java.lang.String,java.lang.String>extensionsprivate java.lang.Stringidprivate java.lang.StringkeyTypeprivate byte[]messageprivate byte[]nonceprivate java.util.Collection<java.lang.String>principalsprivate java.lang.Stringreservedprivate longserialprivate static longserialVersionUIDprivate byte[]signatureprivate inttypeprivate longvalidAfterprivate longvalidBefore-
Fields inherited from interface org.apache.sshd.common.config.keys.OpenSshCertificate
INFINITY, MIN_EPOCH
-
-
Constructor Summary
Constructors Constructor Description OpenSshCertificateImpl()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddCriticalOption(java.lang.String name, java.lang.String value)Adds a critical option to the certificate, or removes it ifvalue == null.booleanaddExtension(java.lang.String name, java.lang.String value)Adds an extension to the certificate, or removes it ifvalue == null.java.lang.StringgetAlgorithm()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.byte[]getEncoded()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.StringgetFormat()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.java.lang.StringgetKeyType()Retrieves the SSH key type.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.voidsetCaPubKey(java.security.PublicKey caPubKey)voidsetCertPubKey(java.security.PublicKey certificatePublicKey)voidsetCriticalOptions(java.util.List<OpenSshCertificate.CertificateOption> criticalOptions)Sets the critical options of the certificate, overriding any options set earlier.voidsetCriticalOptions(java.util.Map<java.lang.String,java.lang.String> criticalOptions)Sets the critical options of the certificate, overriding any options set earlier.voidsetExtensions(java.util.List<OpenSshCertificate.CertificateOption> extensions)Sets the extensions of the certificate, overriding any extensions set earlier.voidsetExtensions(java.util.Map<java.lang.String,java.lang.String> extensions)Sets the extensions of the certificate, overriding any extensions set earlier.voidsetId(java.lang.String id)voidsetKeyType(java.lang.String keyType)voidsetMessage(byte[] message)voidsetNonce(byte[] nonce)voidsetPrincipals(java.util.Collection<java.lang.String> principals)voidsetReserved(java.lang.String reserved)voidsetSerial(long serial)voidsetSignature(byte[] signature)voidsetType(OpenSshCertificate.Type type)voidsetValidAfter(long validAfter)voidsetValidAfter(java.time.Instant validAfter)If null, usesOpenSshCertificate.MIN_EPOCHvoidsetValidBefore(long validBefore)voidsetValidBefore(java.time.Instant validBefore)If null, usesOpenSshCertificate.INFINITYprivate static java.lang.StringtoDate(long timestamp)java.lang.StringtoString()
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
keyType
private java.lang.String keyType
-
nonce
private byte[] nonce
-
certificatePublicKey
private java.security.PublicKey certificatePublicKey
-
serial
private long serial
-
type
private int type
-
id
private java.lang.String id
-
principals
private java.util.Collection<java.lang.String> principals
-
validAfter
private long validAfter
-
validBefore
private long validBefore
-
criticalOptions
private java.util.SortedMap<java.lang.String,java.lang.String> criticalOptions
-
extensions
private java.util.SortedMap<java.lang.String,java.lang.String> extensions
-
reserved
private java.lang.String reserved
-
caPubKey
private java.security.PublicKey caPubKey
-
message
private byte[] message
-
signature
private byte[] signature
-
-
Method Detail
-
getRawKeyType
public java.lang.String getRawKeyType()
Description copied from interface:OpenSshCertificateRetrieves the raw SSH key type of this certificate.- Specified by:
getRawKeyTypein interfaceOpenSshCertificate- Returns:
- the key type, for instance "ssh-rsa" for a "ssh-rsa-cert-v01@openssh.com" certificate
-
getNonce
public byte[] getNonce()
Description copied from interface:OpenSshCertificateRetrieves the nonce of this certificate.- Specified by:
getNoncein interfaceOpenSshCertificate- Returns:
- the nonce.
-
getKeyType
public java.lang.String getKeyType()
Description copied from interface:SshPublicKeyRetrieves the SSH key type.- Specified by:
getKeyTypein interfaceSshPublicKey- Returns:
- the SSH key type, never
null.
-
getCertPubKey
public java.security.PublicKey getCertPubKey()
Description copied from interface:OpenSshCertificateRetrieves the certified public key.- Specified by:
getCertPubKeyin interfaceOpenSshCertificate- Returns:
- the
PublicKey
-
getSerial
public long getSerial()
Description copied from interface:OpenSshCertificateRetrieves the serial number of this certificate.- Specified by:
getSerialin interfaceOpenSshCertificate- Returns:
- the serial number
-
getType
public OpenSshCertificate.Type getType()
Description copied from interface:OpenSshCertificateRetrieves the type of certificate.- Specified by:
getTypein interfaceOpenSshCertificate- Returns:
- the
OpenSshCertificate.Type
-
getId
public java.lang.String getId()
Description copied from interface:OpenSshCertificateRetrieves a free-form text set by the CA when the certificate was generated; intended to identify the identity principal in log message.- Specified by:
getIdin interfaceOpenSshCertificate- Returns:
- the id; never
nullbut may be empty.
-
getPrincipals
public java.util.Collection<java.lang.String> getPrincipals()
Description copied from interface:OpenSshCertificateRetrieves the principals mentioned in the certificate.- Specified by:
getPrincipalsin interfaceOpenSshCertificate- Returns:
- the collection of principals, never
nullbut possibly empty
-
getValidAfter
public long getValidAfter()
Description copied from interface:OpenSshCertificateRetrieves the time in number of seconds since theInstant.EPOCHat which this certificate becomes or became valid.- Specified by:
getValidAfterin interfaceOpenSshCertificate- Returns:
- the number of seconds since the
Instant.EPOCHas an unsigned 64bit value - See Also:
OpenSshCertificate.isValidNow(OpenSshCertificate)
-
getValidBefore
public long getValidBefore()
Description copied from interface:OpenSshCertificateRetrieves the time in number of seconds since theInstant.EPOCHat which this certificate becomes or became invalid.- Specified by:
getValidBeforein interfaceOpenSshCertificate- Returns:
- the number of seconds since the
Instant.EPOCHas an unsigned 64bit value - See Also:
OpenSshCertificate.isValidNow(OpenSshCertificate)
-
getCriticalOptions
public java.util.List<OpenSshCertificate.CertificateOption> getCriticalOptions()
Description copied from interface:OpenSshCertificateRetrieves the critical options set in the certificate.- Specified by:
getCriticalOptionsin interfaceOpenSshCertificate- Returns:
- the critical options as an unmodifiable list, never
nullbut possibly empty - See Also:
OpenSshCertificate.getCriticalOptionsMap()
-
getCriticalOptionsMap
public java.util.SortedMap<java.lang.String,java.lang.String> getCriticalOptionsMap()
Description copied from interface:OpenSshCertificateRetrieves the critical options set in the certificate.- Specified by:
getCriticalOptionsMapin interfaceOpenSshCertificate- Returns:
- the critical options as an unmodifiable map, never
nullbut possibly empty
-
getExtensions
public java.util.List<OpenSshCertificate.CertificateOption> getExtensions()
Description copied from interface:OpenSshCertificateRetrieves the extensions set in the certificate.- Specified by:
getExtensionsin interfaceOpenSshCertificate- Returns:
- the extensions as an unmodifiable list, never
nullbut possibly empty - See Also:
OpenSshCertificate.getExtensionsMap()
-
getExtensionsMap
public java.util.SortedMap<java.lang.String,java.lang.String> getExtensionsMap()
Description copied from interface:OpenSshCertificateRetrieves the extensions set in the certificate.- Specified by:
getExtensionsMapin interfaceOpenSshCertificate- Returns:
- the extensions as an unmodifiable map, never
nullbut possibly empty
-
getReserved
public java.lang.String getReserved()
Description copied from interface:OpenSshCertificateRetrieves the "reserved" field of the certificate. OpenSSH currently doesn't use it and ignores it.- Specified by:
getReservedin interfaceOpenSshCertificate- Returns:
- the "reserved" field.
-
getCaPubKey
public java.security.PublicKey getCaPubKey()
Description copied from interface:OpenSshCertificateRetrieves the CA public key of this certificate.- Specified by:
getCaPubKeyin interfaceOpenSshCertificate- Returns:
- the
PublicKey
-
getMessage
public byte[] getMessage()
Description copied from interface:OpenSshCertificateRetrieves the raw byte content of the certificate, minus the signature. This is the data that was signed.- Specified by:
getMessagein interfaceOpenSshCertificate- Returns:
- the part of the certificate raw data that was signed
-
getSignature
public byte[] getSignature()
Description copied from interface:OpenSshCertificateRetrieves the signature of the certificate, including the signature algorithm.- Specified by:
getSignaturein interfaceOpenSshCertificate- Returns:
- the signature bytes
- See Also:
OpenSshCertificate.getRawSignature()
-
getRawSignature
public byte[] getRawSignature()
Description copied from interface:OpenSshCertificateRetrieves the raw signature bytes, without the signature algorithm.- Specified by:
getRawSignaturein interfaceOpenSshCertificate- Returns:
- the signature bytes
- See Also:
OpenSshCertificate.getSignature()
-
getSignatureAlgorithm
public java.lang.String getSignatureAlgorithm()
Description copied from interface:OpenSshCertificateRetrieves the signature algorithm used for the signature.- Specified by:
getSignatureAlgorithmin interfaceOpenSshCertificate- Returns:
- the signature algorithm as recorded in the certificate
-
getAlgorithm
public java.lang.String getAlgorithm()
- Specified by:
getAlgorithmin interfacejava.security.Key
-
getFormat
public java.lang.String getFormat()
- Specified by:
getFormatin interfacejava.security.Key
-
getEncoded
public byte[] getEncoded()
- Specified by:
getEncodedin interfacejava.security.Key
-
setKeyType
public void setKeyType(java.lang.String keyType)
-
setNonce
public void setNonce(byte[] nonce)
-
setCertPubKey
public void setCertPubKey(java.security.PublicKey certificatePublicKey)
-
setSerial
public void setSerial(long serial)
-
setType
public void setType(OpenSshCertificate.Type type)
-
setId
public void setId(java.lang.String id)
-
setPrincipals
public void setPrincipals(java.util.Collection<java.lang.String> principals)
-
setValidAfter
public void setValidAfter(long validAfter)
-
setValidAfter
public void setValidAfter(java.time.Instant validAfter)
If null, usesOpenSshCertificate.MIN_EPOCH- Parameters:
validAfter-Instantto use for validAfter
-
setValidBefore
public void setValidBefore(long validBefore)
-
setValidBefore
public void setValidBefore(java.time.Instant validBefore)
If null, usesOpenSshCertificate.INFINITY- Parameters:
validBefore-Instantto use for validBefore
-
setCriticalOptions
public void setCriticalOptions(java.util.List<OpenSshCertificate.CertificateOption> criticalOptions)
Sets the critical options of the certificate, overriding any options set earlier.- Parameters:
criticalOptions- to set; may benullor empty to remove all previously set options
-
setCriticalOptions
public void setCriticalOptions(java.util.Map<java.lang.String,java.lang.String> criticalOptions)
Sets the critical options of the certificate, overriding any options set earlier.- Parameters:
criticalOptions- to set; may benullor empty to remove all previously set options
-
addCriticalOption
public boolean addCriticalOption(java.lang.String name, java.lang.String value)Adds a critical option to the certificate, or removes it ifvalue == null. To add an option with an empty value, use an empty string as value. If the certificate already has an option with the given name it is replaced.- Parameters:
name- of the option to setvalue- of the option- Returns:
trueif the map did not contain the name;falseif it did
-
setExtensions
public void setExtensions(java.util.List<OpenSshCertificate.CertificateOption> extensions)
Sets the extensions of the certificate, overriding any extensions set earlier.- Parameters:
extensions- to set; may benullor empty to remove all previously set extensions
-
setExtensions
public void setExtensions(java.util.Map<java.lang.String,java.lang.String> extensions)
Sets the extensions of the certificate, overriding any extensions set earlier.- Parameters:
extensions- to set; may benullor empty to remove all previously set extensions
-
addExtension
public boolean addExtension(java.lang.String name, java.lang.String value)Adds an extension to the certificate, or removes it ifvalue == null. To add an extension with an empty value, use an empty string as value. If the certificate already has an extension with the given name it is replaced.- Parameters:
name- of the extension to setvalue- of the extension- Returns:
trueif the map did not contain the name;falseif it did
-
setReserved
public void setReserved(java.lang.String reserved)
-
setCaPubKey
public void setCaPubKey(java.security.PublicKey caPubKey)
-
setMessage
public void setMessage(byte[] message)
-
setSignature
public void setSignature(byte[] signature)
-
toDate
private static java.lang.String toDate(long timestamp)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-