Package net.messagevortex.asn1
Class PayloadChunk
java.lang.Object
net.messagevortex.asn1.AbstractBlock
net.messagevortex.asn1.PayloadChunk
- All Implemented Interfaces:
Serializable,Block,Dumpable
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final longFields inherited from class net.messagevortex.asn1.AbstractBlock
CRLF -
Constructor Summary
ConstructorsConstructorDescriptionCreates an empty payload block.PayloadChunk(int id, byte[] payload, UsagePeriod period) Creates a payload block from raw data.PayloadChunk(org.bouncycastle.asn1.ASN1Encodable to, UsagePeriod period) Creates a payload block from a ASN1 stream. -
Method Summary
Modifier and TypeMethodDescriptiondumpValueNotation(String prefix, DumpType dumpType) Dumps the current object as a value representation.booleanfinal intgetId()Gets the id of the payload chunk.final byte[]Gets the the currently set payload.final byte[]Gets the the currently set reply block.final UsagePeriodinthashCode()booleanbooleanisInUsagePeriod(Date reference) Checks if the usage period passed is fully embraced in the usage period.protected final voidparse(org.bouncycastle.asn1.ASN1Encodable to) final intsetId(int id) Sets the id of the payload chunk.final byte[]setPayload(byte[] b) Set a byte array as payload.final byte[]setReplyBlock(byte[] reply) Set a byte array as reply block.final UsagePeriodsetUsagePeriod(UsagePeriod period) Sets the usage period of the payload cunk.org.bouncycastle.asn1.ASN1ObjecttoAsn1Object(DumpType dumpType) Creates a der encoded ASN1 representation of the payload chunk.Methods inherited from class net.messagevortex.asn1.AbstractBlock
fromBase64, fromHex, parse, prepareDump, toBase64, toBitString, toBytes, toDer, toHex
-
Field Details
-
serialVersionUID
public static final long serialVersionUID- See Also:
-
MIN_VALID_ID
public static final int MIN_VALID_ID- See Also:
-
-
Constructor Details
-
PayloadChunk
public PayloadChunk()Creates an empty payload block.
-
PayloadChunk
Creates a payload block from a ASN1 stream.
- Parameters:
to- the ASN.1 object of the PayloadCunk to be parsedperiod- the validity period to be associated with- Throws:
IOException- if parsing fails
-
PayloadChunk
Creates a payload block from raw data.
- Parameters:
id- the payload locationpayload- the payload contentperiod- the validity period to be associated with
-
-
Method Details
-
toAsn1Object
Creates a der encoded ASN1 representation of the payload chunk.
- Specified by:
toAsn1Objectin interfaceDumpable- Parameters:
dumpType- the dump type to be used- Returns:
- the ASN.1 object
- Throws:
IOException- if id is too low or the payload has not been set
-
setPayload
public final byte[] setPayload(byte[] b) Set a byte array as payload.
- Parameters:
b- the payload to be set- Returns:
- the previously set payload (may have been a reply block)
-
getPayload
public final byte[] getPayload()Gets the the currently set payload.
- Returns:
- the payload as byte array or null if a replyblock has been set
-
setReplyBlock
public final byte[] setReplyBlock(byte[] reply) Set a byte array as reply block.
- Parameters:
reply- the reply block to be set- Returns:
- the previously set reply block (may have been a payload block)
-
getReplyBlock
public final byte[] getReplyBlock()Gets the the currently set reply block.
- Returns:
- the reply block as byte array or null if a payload block has been set
-
getUsagePeriod
-
setUsagePeriod
Sets the usage period of the payload cunk.
- Parameters:
period- the new usage period- Returns:
- the previously set usage period
-
parse
- Specified by:
parsein classAbstractBlock- Throws:
IOException
-
setId
public final int setId(int id) Sets the id of the payload chunk.
- Parameters:
id- the id to be set- Returns:
- the previously set id
-
getId
public final int getId()Gets the id of the payload chunk.
- Returns:
- the id currently set
-
dumpValueNotation
Dumps the current object as a value representation.
- Specified by:
dumpValueNotationin interfaceBlock- Parameters:
prefix- the prefix to be used (normally used for indentation)dumpType- the dump type to be used (@see DumpType)- Returns:
- the string representation of the ASN1 object
- Throws:
IOException- if the payload id is below MIN_VALID_ID or no payload/reply block has been set
-
isInUsagePeriod
public boolean isInUsagePeriod() -
isInUsagePeriod
Checks if the usage period passed is fully embraced in the usage period.
- Parameters:
reference- the usage period to be embraced- Returns:
- tre if embraced or no usage restriction
-
equals
-
hashCode
public int hashCode()
-