Class IdentityBlock
- All Implemented Interfaces:
Serializable,Block,Dumpable
Represents an identity block of a vortexMessage.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsFields inherited from class net.messagevortex.asn1.AbstractBlock
CRLF -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new IdentityBlock with a medium security default key.IdentityBlock(byte[] b) Parses the given unecrypted identity block.IdentityBlock(byte[] b, AsymmetricKey ownIdentity) Parses the given identity block using the specified key.Generates a new IdentityBlock for the given key.IdentityBlock(org.bouncycastle.asn1.ASN1Encodable to) Create object from ASN.1 code.IdentityBlock(org.bouncycastle.asn1.ASN1Encodable to, AsymmetricKey ownIdentity) Create object from encrypted ASN.1 code. -
Method Summary
Modifier and TypeMethodDescriptiondumpValueNotation(String prefix) dumpValueNotation(String prefix, DumpType dumpType) Dumps the current block state in ASN.1 value notation.booleanGets the identity representation (asymmetric key) of the block.Gets the identity representation (asymmetric key) of the block.intGets the maximum number of replays for this block.longGet the serial of the identity block.Gets the currently set validity period of the block.inthashCode()protected final voidparse(org.bouncycastle.asn1.ASN1Encodable o) Sets the identity representation (asymmetric key) of the block.Sets the identity representation (asymmetric key) of the block.intsetReplay(int maxReplay) Sets the maximum number of replays for this block.voidsetRequests(HeaderRequest[] hr) longsetSerial(long serial) Set the serial of the identity block.setUsagePeriod(UsagePeriod valid) Sets the maximum usage period of the block.org.bouncycastle.asn1.ASN1ObjecttoAsn1Object(DumpType dumpType) Dumps the identity block as ASN.1 der encoded object.org.bouncycastle.asn1.ASN1ObjecttoAsn1Object(DumpType dumpType, AsymmetricKey targetIdentity) Dumps the identity block as ASN.1 der encoded object.toString()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:
-
-
Constructor Details
-
IdentityBlock
Creates a new IdentityBlock with a medium security default key.
This is a convenience wrapper for @see IdentityBlock(AsymmetricKey)
- Throws:
IOException- if generation of the key fails
-
IdentityBlock
Generates a new IdentityBlock for the given key.
The new identity block is characterized by 1 replay (not replayable), a random serial, a usage perod of 1 hour, and no requests.
- Parameters:
key- the key to be used- Throws:
IOException- if generation of the block fails
-
IdentityBlock
Parses the given identity block using the specified key.
- Parameters:
b- a byte array reflecting the encrypted IdentityBlockownIdentity- the identity to be used to decrypt the block- Throws:
IOException- if parsing fails for any reason
-
IdentityBlock
Parses the given unecrypted identity block.
- Parameters:
b- a byte array reflecting the IdentityBlock- Throws:
IOException- if parsing fails for any reason
-
IdentityBlock
Create object from ASN.1 code.
- Parameters:
to- the ASN.1 code- Throws:
IOException- if parsing of ASN.1 code fails
-
IdentityBlock
public IdentityBlock(org.bouncycastle.asn1.ASN1Encodable to, AsymmetricKey ownIdentity) throws IOException Create object from encrypted ASN.1 code.
- Parameters:
to- the ASN.1 codeownIdentity- the identity to be used to decrypt the block- Throws:
IOException- if parsing of ASN.1 code fails
-
-
Method Details
-
setRequests
-
parse
- Specified by:
parsein classAbstractBlock- Throws:
IOException
-
getReplay
public int getReplay()Gets the maximum number of replays for this block.
- Returns:
- the currently set maximum number of replays
-
setReplay
public int setReplay(int maxReplay) Sets the maximum number of replays for this block.
- Parameters:
maxReplay- the maximum nuber of replays to be set- Returns:
- the previously set maximum
-
getUsagePeriod
Gets the currently set validity period of the block.
- Returns:
- the previously set validity period
-
setUsagePeriod
Sets the maximum usage period of the block.
- Parameters:
valid- the new usage period to be set- Returns:
- the previously set usage period
-
getOwnIdentity
Gets the identity representation (asymmetric key) of the block.
- Returns:
- the previously set identity
-
setOwnIdentity
Sets the identity representation (asymmetric key) of the block.
- Parameters:
oid- the identity key- Returns:
- the previously set identity
-
getIdentityKey
Gets the identity representation (asymmetric key) of the block.
- Returns:
- the previously set identity
-
setIdentityKey
Sets the identity representation (asymmetric key) of the block.
- Parameters:
oid- the identity key- Returns:
- the previously set identity
-
toAsn1Object
Dumps the identity block as ASN.1 der encoded object.
- Specified by:
toAsn1Objectin interfaceDumpable- Parameters:
dumpType- the dump type to be used- Returns:
- the block as der encodable object
- Throws:
IOException- if the block is not encodable
-
toAsn1Object
public org.bouncycastle.asn1.ASN1Object toAsn1Object(DumpType dumpType, AsymmetricKey targetIdentity) throws IOException Dumps the identity block as ASN.1 der encoded object.
- Parameters:
dumpType- the type of dump to be usedtargetIdentity- the identity to be used to secure the Identity block (target identity)- Returns:
- the block as der encodable object
- Throws:
IOException- if the block is not encodable
-
dumpValueNotation
- Throws:
IOException
-
dumpValueNotation
Dumps the current block state in ASN.1 value notation.
- Specified by:
dumpValueNotationin interfaceBlock- Parameters:
prefix- the prefix to be prepended to each line (whitespaces for indentation)dumpType- the type of dump to be used- Returns:
- a String representing the ASN.1 value notation of the Block
- Throws:
IOException- if the block is not encodable
-
getSerial
public long getSerial()Get the serial of the identity block.
- Returns:
- the currently set serial number
-
setSerial
public long setSerial(long serial) Set the serial of the identity block.
- Parameters:
serial- the serial to be set- Returns:
- the previously set serial number
-
equals
-
hashCode
public int hashCode() -
toString
-