Package eu.europa.esig.dss.model.x509
Class Token
- java.lang.Object
-
- eu.europa.esig.dss.model.x509.Token
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
CertificateToken,RevocationToken,TimestampToken
public abstract class Token extends Object implements Serializable
This is the base class for the different types of tokens (certificate, OCSP, CRL, Timestamp) used in the process of signature validation.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected PublicKeypublicKeyOfTheSignerThe publicKey of the signed certificate(s)protected SignatureAlgorithmsignatureAlgorithmThe algorithm that was used to sign the token.protected StringsignatureInvalidityReasonIndicates the token signature invalidity reason.protected booleansignatureValidIndicates the token signature is valid.
-
Constructor Summary
Constructors Constructor Description Token()
-
Method Summary
Modifier and Type Method Description protected abstract booleancheckIsSignedBy(CertificateToken token)booleanequals(Object obj)StringgetAbbreviation()This method returns the DSS abbreviation of the token.abstract DategetCreationDate()Returns the creation date of this token.byte[]getDigest(DigestAlgorithm digestAlgorithm)Returns the digest value of the wrapped tokenTokenIdentifiergetDSSId()Returns a DSS unique token identifier.StringgetDSSIdAsString()Returns a string representation of the unique DSS token identifier.abstract byte[]getEncoded()Returns the encoded form of the wrapped token.abstract X500PrincipalgetIssuerX500Principal()Returns theX500Principalof the certificate which was used to sign this token.PublicKeygetPublicKeyOfTheSigner()This method returns the public key of the token signerSignatureAlgorithmgetSignatureAlgorithm()Returns the algorithm that was used to sign the token (ex: SHA1WithRSAEncryption, SHA1withRSA...).inthashCode()booleanisSelfSigned()Checks if the certificate is self-signed.booleanisSignatureValid()Indicates if the token's signature is intact.booleanisSignedBy(CertificateToken token)Checks if the token is signed by the given token in the parameter.StringtoString()abstract StringtoString(String indentStr)Returns a string representation of the token.
-
-
-
Field Detail
-
publicKeyOfTheSigner
protected PublicKey publicKeyOfTheSigner
The publicKey of the signed certificate(s)
-
signatureValid
protected boolean signatureValid
Indicates the token signature is valid.
-
signatureInvalidityReason
protected String signatureInvalidityReason
Indicates the token signature invalidity reason.
-
signatureAlgorithm
protected SignatureAlgorithm signatureAlgorithm
The algorithm that was used to sign the token.
-
-
Method Detail
-
isSelfSigned
public boolean isSelfSigned()
Checks if the certificate is self-signed. For all tokens different from CertificateToken this method always returns false. This method was introduced in order to manage in a uniform manner the different tokens.- Returns:
- true if the token is self-signed
-
getDSSId
public TokenIdentifier getDSSId()
Returns a DSS unique token identifier.- Returns:
- an instance of TokenIdentifier
-
getDSSIdAsString
public String getDSSIdAsString()
Returns a string representation of the unique DSS token identifier.- Returns:
- the unique string for the token
-
isSignedBy
public boolean isSignedBy(CertificateToken token)
Checks if the token is signed by the given token in the parameter.- Parameters:
token- the candidate to be tested- Returns:
- true if this token is signed by the given certificate token
-
checkIsSignedBy
protected abstract boolean checkIsSignedBy(CertificateToken token)
-
getIssuerX500Principal
public abstract X500Principal getIssuerX500Principal()
Returns theX500Principalof the certificate which was used to sign this token.- Returns:
- the issuer's
X500Principal
-
getCreationDate
public abstract Date getCreationDate()
Returns the creation date of this token. This date is mainly used to retrieve the correct issuer within a collection of renewed certificates (new certificate with the same key pair).- Returns:
- the creation date of the token (notBefore for a certificate, productionDate for revocation data,...)
-
getAbbreviation
public String getAbbreviation()
This method returns the DSS abbreviation of the token. It is used for debugging purpose.- Returns:
- an abbreviation for the certificate
-
getSignatureAlgorithm
public SignatureAlgorithm getSignatureAlgorithm()
Returns the algorithm that was used to sign the token (ex: SHA1WithRSAEncryption, SHA1withRSA...).- Returns:
- the used signature algorithm to sign this token
-
isSignatureValid
public boolean isSignatureValid()
Indicates if the token's signature is intact. For each kind of token the method isSignedBy(CertificateToken) must be called to set this flag.- Returns:
- true if the signature is valid
-
getPublicKeyOfTheSigner
public PublicKey getPublicKeyOfTheSigner()
This method returns the public key of the token signer- Returns:
- the public key which signed this token
-
toString
public abstract String toString(String indentStr)
Returns a string representation of the token.- Parameters:
indentStr- the indentation to use- Returns:
- string representation of the token
-
getEncoded
public abstract byte[] getEncoded()
Returns the encoded form of the wrapped token.- Returns:
- the encoded form of the wrapped token
-
getDigest
public byte[] getDigest(DigestAlgorithm digestAlgorithm)
Returns the digest value of the wrapped token- Parameters:
digestAlgorithm- the requested digest algorithm- Returns:
- the digest value in binaries
-
-