Package es.gob.jmulticard.asn1
Class Tlv
java.lang.Object
es.gob.jmulticard.asn1.Tlv
Representación de un TLV (Tipo-Longitud-Valor) binario en forma ASN.1 DER.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final byte[]
Estructura binaria completa del TLV.private final int
Longitud del valor.private final byte
Octeto de tipo (etiqueta).private final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Tlv
decode
(ByteArrayInputStream recordOfTlv) Obtiene un TLV de un flujo de entrada, leyendo del mismo únicamente los octetos correspondientes al TLV en cuestión.byte[]
getBytes()
Devuelve el TLV directamente en binario.int
Devuelve la longitud del valor del TLV.byte
getTag()
Devuelve el tipo (etiqueta) del TLV.byte[]
getValue()
Devuelve el valor del TLV.toString()
-
Field Details
-
tag
private final byte tagOcteto de tipo (etiqueta). -
length
private final int lengthLongitud del valor. -
bytes
private final byte[] bytesEstructura binaria completa del TLV. -
valueOffset
private final transient int valueOffset
-
-
Constructor Details
-
Tlv
public Tlv(byte t, byte[] value) Construye un TLV simple con etiqueta y longitud de un solo octeto cada uno.- Parameters:
t
- Etiqueta (tipo) del TLV.value
- Valor del TLV.
-
Tlv
Construye un TLV simple a partir de su representación binaria directa.- Parameters:
buffer
- Representación binaria del TLV.- Throws:
TlvException
- En caso de error analizando el TLV.
-
-
Method Details
-
getBytes
public byte[] getBytes()Devuelve el TLV directamente en binario.- Returns:
- Valor binario completo del TLV.
-
getLength
public int getLength()Devuelve la longitud del valor del TLV.- Returns:
- Longitud del valor del TLV.
-
getTag
public byte getTag()Devuelve el tipo (etiqueta) del TLV.- Returns:
- Tipo (etiqueta) del TLV.
-
getValue
public byte[] getValue()Devuelve el valor del TLV.- Returns:
- Valor del del TLV.
-
decode
Obtiene un TLV de un flujo de entrada, leyendo del mismo únicamente los octetos correspondientes al TLV en cuestión.- Parameters:
recordOfTlv
- Flujo de entrada.- Returns:
- TLV recuperado del flujo.
- Throws:
IOException
- Si ocurre un error durante la lectura del TLV.
-
toString
-