Package es.gob.jmulticard.asn1
Class Tlv
- java.lang.Object
-
- es.gob.jmulticard.asn1.Tlv
-
public final class Tlv extends java.lang.Object
Representación de un TLV (Tipo-Longitud-Valor) binario en forma ASN.1 DER.
-
-
Field Summary
Fields Modifier and Type Field Description private byte[]
bytes
Estructura binaria completa del TLV.private int
length
Longitud del valor.private byte
tag
Octeto de tipo (etiqueta).private int
valueOffset
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Tlv
decode(java.io.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
getLength()
Devuelve la longitud del valor del TLV.byte
getTag()
Devuelve el tipo (etiqueta) del TLV.byte[]
getValue()
Devuelve el valor del TLV.java.lang.String
toString()
-
-
-
Constructor Detail
-
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
public Tlv(byte[] buffer) throws TlvException
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 Detail
-
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
public static Tlv decode(java.io.ByteArrayInputStream recordOfTlv) throws java.io.IOException
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:
java.io.IOException
- Si ocurre un error durante la lectura del TLV.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-