java.lang.Object
net.i2p.data.DataStructureImpl
net.i2p.data.Certificate
net.i2p.data.Certificate.NullCert
- All Implemented Interfaces:
Serializable, DataStructure
- Enclosing class:
Certificate
An immutable null certificate.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final byte[]The bytes of the empty certificate.private static final intBytes in the empty certificate.Fields inherited from class Certificate
_payload, _type, CERTIFICATE_LENGTH_SIGNED_WITH_HASH, CERTIFICATE_TYPE_HIDDEN, CERTIFICATE_TYPE_KEY, CERTIFICATE_TYPE_MULTIPLE, CERTIFICATE_TYPE_NULL, CERTIFICATE_TYPE_SIGNED, NULL_CERTModifier and TypeFieldDescriptionprotected byte[]Certificate payload data.protected intCertificate type identifier.static final intLength of signed certificate with hash (signature + hash).static final intWe should not be used for anything (don't use us in the netDb, in tunnels, or tell others about us).static final intKey certificate type.static final intContains multiple certs.static final intSpecifies a null certificate type with no payload.static final intSigned with 40-byte Signature and (optional) 32-byte hash.static final CertificateNull certificate singleton.Constructor Summary
ConstructorsMethod Summary
All MethodsModifier and TypeMethodDescriptioninthashCode()Overridden for efficiency.intreadBytes(byte[] source, int offset) Prevent mutation of the immutable null certificate.voidreadBytes(InputStream in) Prevent mutation of the immutable null certificate.voidsetCertificateType(int type) Prevent mutation of the immutable null certificate.voidsetPayload(byte[] payload) Prevent mutation of the immutable null certificate.intsize()Overridden for efficiency.intwriteBytes(byte[] target, int offset) Overridden for efficiency.voidwriteBytes(OutputStream out) Overridden for efficiency.Methods inherited from class Certificate
create, create, equals, getCertificateType, getPayload, toKeyCertificate, toStringModifier and TypeMethodDescriptionstatic Certificatecreate(byte[] data, int off) If null, P256 key, or Ed25519 key cert, return immutable static instance, else create new.static Certificatecreate(InputStream in) If null, P256 key, or Ed25519 key cert, return immutable static instance, else create new.booleanintCertificate type.byte[]Payload carried by this certificate.Up-convert this to a KeyCertificate.toString()Methods inherited from class DataStructureImpl
calculateHash, fromBase64, fromByteArray, read, toBase64, toByteArrayModifier and TypeMethodDescriptionCalculate the SHA256 value of this object (useful for a few scenarios).voidfromBase64(String data) Load the structure from the provided base64 string.voidfromByteArray(byte[] data) Loads structure from the data providedprotected intread(InputStream in, byte[] target) Repeated reads until buffer is full or IOException is thrown.toBase64()Render the structure into modified base 64 notation.byte[]Convert the structure to a byte array.
Field Details
NULL_LENGTH
NULL_DATA
private static final byte[] NULL_DATAThe bytes of the empty certificate.
Constructor Details
NullCert
public NullCert()The certificate that carries nothing.
Method Details
setCertificateType
public void setCertificateType(int type) Prevent mutation of the immutable null certificate.- Overrides:
setCertificateTypein classCertificate- Parameters:
type- the certificate type to set
setPayload
public void setPayload(byte[] payload) Prevent mutation of the immutable null certificate.- Overrides:
setPayloadin classCertificate- Parameters:
payload- the payload to set
readBytes
Prevent mutation of the immutable null certificate.- Specified by:
readBytesin interfaceDataStructure- Overrides:
readBytesin classCertificate- Parameters:
in- stream to read from- Throws:
DataFormatException- if the data is improperly formattedIOException- if there was a problem reading the stream
writeBytes
Overridden for efficiency.- Specified by:
writeBytesin interfaceDataStructure- Overrides:
writeBytesin classCertificate- Parameters:
out- stream to write to- Throws:
IOException- if there was a problem writing to the stream
writeBytes
public int writeBytes(byte[] target, int offset) Overridden for efficiency.- Overrides:
writeBytesin classCertificate- Parameters:
target- the output arrayoffset- the starting offset in the target- Returns:
- the written length (NOT the new offset)
readBytes
Prevent mutation of the immutable null certificate.- Overrides:
readBytesin classCertificate- Parameters:
source- the array holding the certificate dataoffset- the starting offset in the source- Returns:
- the bytes consumed
- Throws:
DataFormatException- if the data is malformed
size
public int size()Overridden for efficiency.- Overrides:
sizein classCertificate- Returns:
- the size in bytes: 3 plus the payload length
hashCode