public class Capsule
extends java.lang.Object
It consists of two arbitrary container, public one and private one. Private one could be acceed only by the parties having in disposal corresponding key. Private data are encrypted and signed using most secure EtA algorythm. For private part either public keys or symmetric keys are allowed in any combination and quantity.
Public part id available to anybody and is, normally signed or sealed. Siging and sealing is done only with private keys. Sealed capsule has signers key mentioned in the signed part, so it is impossible to add seal later unless it was intended by adding public keys is already mentioned in the public data.
Regular signatures can be added later to the capsule, with own timestamp. These have less significance than seals, though.
Capsule are encoded with bit-efficient binary typed format Boss and are transfered as
packed binary paks.
Created by sergeych on 15.12.16.
| Modifier and Type | Class | Description |
|---|---|---|
class |
Capsule.BadSignatureException |
|
class |
Capsule.DecryptionFailedException |
|
class |
Capsule.FormatException |
|
static interface |
Capsule.KeySource |
| Constructor | Description |
|---|---|
Capsule() |
|
Capsule(byte[] packed,
Capsule.KeySource keySource) |
|
Capsule(byte[] packed,
Capsule.KeySource keySource,
boolean allowPartiallySigned,
boolean allowOnlyPublic) |
|
Capsule(java.lang.String password,
byte[] packed) |
Try to decrypt the capsule with password.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
addKeys(AbstractKey... keys) |
|
void |
addKeys(java.util.Collection<AbstractKey> keys) |
|
java.lang.String |
addSigner(AbstractKey key,
net.sergeych.tools.Binder signerData) |
Add single signer key with associated data.
|
void |
addSigners(AbstractKey... keys) |
|
void |
addSigners(java.util.Collection<AbstractKey> signers) |
|
void |
clearKeys() |
|
void |
clearSigners() |
|
boolean |
decryptionFailed() |
|
boolean |
equals(java.lang.Object obj) |
|
net.sergeych.tools.Binder |
getPrivateData() |
|
net.sergeych.tools.Binder |
getPublicData() |
|
net.sergeych.tools.Binder |
getSignerData(AbstractKey key) |
Retreive extra information of the signer.
|
net.sergeych.tools.Binder |
getSignerData(java.lang.String signerKeyId) |
|
java.util.Map<java.lang.String,net.sergeych.tools.Binder> |
getSigners() |
|
java.util.Collection<AbstractKey> |
getSigningKeys() |
|
boolean |
isPartiallySigned() |
|
boolean |
isSigned() |
Sets to true only after unpacking binary coffer which was signed - if it was signed properly.
|
Capsule |
load(byte[] packedCoffer,
Capsule.KeySource keySource,
boolean allowPartiallySigned,
boolean allowOnlyPublic) |
|
byte[] |
pack() |
|
void |
setPrivateData(java.lang.Object... keysAndValues) |
|
void |
setPrivateData(net.sergeych.tools.Binder privateData) |
|
void |
setPublicData(java.lang.Object... keysAndValues) |
|
void |
setPublicData(net.sergeych.tools.Binder publicData) |
|
java.lang.String |
toString() |
public Capsule(java.lang.String password,
byte[] packed)
throws EncryptionError,
Capsule.BadSignatureException
password - to unencrypt the capsulepacked - ninary packed capsuleEncryptionError - if it failed to decryptCapsule.BadSignatureException - if the signature present but the data is broken or tampered with.public Capsule()
public Capsule(byte[] packed,
Capsule.KeySource keySource)
throws Capsule.BadSignatureException,
java.io.IOException
Capsule.BadSignatureExceptionjava.io.IOExceptionpublic Capsule(byte[] packed,
Capsule.KeySource keySource,
boolean allowPartiallySigned,
boolean allowOnlyPublic)
throws Capsule.BadSignatureException,
java.io.IOException
Capsule.BadSignatureExceptionjava.io.IOExceptionpublic boolean isPartiallySigned()
public boolean decryptionFailed()
public void setPrivateData(java.lang.Object... keysAndValues)
public boolean isSigned()
public java.util.Collection<AbstractKey> getSigningKeys()
public java.util.Map<java.lang.String,net.sergeych.tools.Binder> getSigners()
public Capsule load(byte[] packedCoffer, Capsule.KeySource keySource, boolean allowPartiallySigned, boolean allowOnlyPublic) throws Capsule.BadSignatureException, EncryptionError
public void setPublicData(net.sergeych.tools.Binder publicData)
public net.sergeych.tools.Binder getPublicData()
public void setPrivateData(net.sergeych.tools.Binder privateData)
public net.sergeych.tools.Binder getPrivateData()
public void clearSigners()
public void addSigners(java.util.Collection<AbstractKey> signers)
public void addSigners(AbstractKey... keys)
public java.lang.String addSigner(AbstractKey key, net.sergeych.tools.Binder signerData)
key - signerData - public net.sergeych.tools.Binder getSignerData(AbstractKey key)
key - Binder instance if there is no
associated informationjava.lang.IllegalArgumentException - if key is not foundpublic net.sergeych.tools.Binder getSignerData(java.lang.String signerKeyId)
public void clearKeys()
public void addKeys(java.util.Collection<AbstractKey> keys)
public void addKeys(AbstractKey... keys)
public byte[] pack()
throws EncryptionError
EncryptionErrorpublic void setPublicData(java.lang.Object... keysAndValues)
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object