public abstract class EncryptBase extends Protocol
SYM_ENCRYPT
) and asymmetric (ASYM_ENCRYPT
) encryption protocols.Modifier and Type | Class and Description |
---|---|
protected class |
EncryptBase.Decrypter
Decrypts all messages in a batch, replacing encrypted messages in-place with their decrypted versions
|
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
asym_algorithm |
protected int |
asym_keylength |
protected int |
cipher_pool_size |
protected java.util.concurrent.BlockingQueue<javax.crypto.Cipher> |
decoding_ciphers |
protected static java.lang.String |
DEFAULT_SYM_ALGO |
protected java.util.concurrent.BlockingQueue<javax.crypto.Cipher> |
encoding_ciphers |
protected boolean |
encrypt_entire_message |
protected java.util.Map<AsciiString,javax.crypto.Cipher> |
key_map |
protected int |
key_map_max_size |
protected Address |
local_addr |
protected java.lang.String |
provider |
protected java.security.Key |
secret_key |
protected boolean |
sign_msgs |
protected java.lang.String |
sym_algorithm |
protected int |
sym_keylength |
protected byte[] |
sym_version |
protected boolean |
use_adler |
protected View |
view |
after_creation_hook, down_prot, ergonomics, id, log, name, stack, stats, up_prot
Constructor and Description |
---|
EncryptBase() |
Modifier and Type | Method and Description |
---|---|
protected Message |
_decrypt(javax.crypto.Cipher cipher,
Message msg,
EncryptHeader hdr) |
boolean |
adler() |
<T extends EncryptBase> |
adler(boolean flag) |
java.lang.String |
asymAlgorithm() |
<T extends EncryptBase> |
asymAlgorithm(java.lang.String alg) |
int |
asymKeylength() |
<T extends EncryptBase> |
asymKeylength(int len) |
protected byte[] |
code(byte[] buf,
int offset,
int length,
boolean decode) |
protected long |
computeChecksum(byte[] input,
int offset,
int length) |
protected java.util.zip.Checksum |
createChecksummer() |
protected javax.crypto.Cipher |
createCipher(int mode,
java.security.Key secret_key,
java.lang.String algorithm) |
protected long |
decryptChecksum(javax.crypto.Cipher cipher,
byte[] input,
int offset,
int length) |
protected Message |
decryptMessage(javax.crypto.Cipher cipher,
Message msg)
Does the actual work for decrypting - if version does not match current cipher then tries the previous cipher
|
java.lang.Object |
down(Event evt)
An event is to be sent down the stack.
|
protected void |
encryptAndSend(Message msg) |
protected byte[] |
encryptChecksum(long checksum) |
boolean |
encryptEntireMessage() |
<T extends EncryptBase> |
encryptEntireMessage(boolean b) |
protected static java.lang.String |
getAlgorithm(java.lang.String s) |
protected java.lang.Object |
handleEncryptedMessage(Message msg) |
protected void |
handleUnknownVersion(byte[] version)
Called when the version shipped in the header can't be found
|
protected java.lang.Object |
handleUpEvent(Message msg,
EncryptHeader hdr) |
protected java.lang.Object |
handleUpMessage(Message msg) |
protected void |
handleView(View view) |
void |
init()
Called after instance has been created (null constructor) and before protocol is started.
|
protected void |
initSymCiphers(java.lang.String algorithm,
java.security.Key secret)
Initialises the ciphers for both encryption and decryption using the generated or supplied secret key
|
protected boolean |
inView(Address sender,
java.lang.String error_msg) |
<T extends EncryptBase> |
localAddress(Address addr) |
protected boolean |
process(Message msg)
Whether or not to process this received message
|
java.security.Key |
secretKey() |
<T extends EncryptBase> |
secretKey(java.security.Key key) |
boolean |
signMessages() |
<T extends EncryptBase> |
signMessages(boolean flag) |
java.lang.String |
symAlgorithm() |
<T extends EncryptBase> |
symAlgorithm(java.lang.String alg) |
int |
symKeylength() |
<T extends EncryptBase> |
symKeylength(int len) |
byte[] |
symVersion() |
<T extends EncryptBase> |
symVersion(byte[] v) |
java.lang.Object |
up(Event evt)
An event was received from the layer below.
|
void |
up(MessageBatch batch)
Sends up a multiple messages in a
MessageBatch . |
java.lang.String |
version() |
accept, afterCreationHook, destroy, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, printStats, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStatistics, resetStats, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, start, statsEnabled, stop
protected static final java.lang.String DEFAULT_SYM_ALGO
protected java.lang.String provider
protected java.lang.String asym_algorithm
protected java.lang.String sym_algorithm
protected int asym_keylength
protected int sym_keylength
protected int cipher_pool_size
protected boolean encrypt_entire_message
protected boolean sign_msgs
protected boolean use_adler
protected int key_map_max_size
protected volatile Address local_addr
protected volatile View view
protected java.util.concurrent.BlockingQueue<javax.crypto.Cipher> encoding_ciphers
protected java.util.concurrent.BlockingQueue<javax.crypto.Cipher> decoding_ciphers
protected volatile byte[] sym_version
protected volatile java.security.Key secret_key
protected java.util.Map<AsciiString,javax.crypto.Cipher> key_map
public int asymKeylength()
public <T extends EncryptBase> T asymKeylength(int len)
public int symKeylength()
public <T extends EncryptBase> T symKeylength(int len)
public java.security.Key secretKey()
public <T extends EncryptBase> T secretKey(java.security.Key key)
public java.lang.String symAlgorithm()
public <T extends EncryptBase> T symAlgorithm(java.lang.String alg)
public java.lang.String asymAlgorithm()
public <T extends EncryptBase> T asymAlgorithm(java.lang.String alg)
public byte[] symVersion()
public <T extends EncryptBase> T symVersion(byte[] v)
public <T extends EncryptBase> T localAddress(Address addr)
public boolean encryptEntireMessage()
public <T extends EncryptBase> T encryptEntireMessage(boolean b)
public boolean signMessages()
public <T extends EncryptBase> T signMessages(boolean flag)
public boolean adler()
public <T extends EncryptBase> T adler(boolean flag)
public java.lang.String version()
public void init() throws java.lang.Exception
Protocol
public java.lang.Object down(Event evt)
Protocol
down_prot.down()
. In case of a GET_ADDRESS event (which tries to
retrieve the stack's address from one of the bottom layers), the layer may need to send
a new response event back up the stack using up_prot.up()
.public java.lang.Object up(Event evt)
Protocol
down_prot.down()
or c) the event (or another event) is sent up
the stack using up_prot.up()
.public void up(MessageBatch batch)
Protocol
MessageBatch
. The sender of the batch is always the same, and so is the
destination (null == multicast messages). Messages in a batch can be OOB messages, regular messages, or mixed
messages, although the transport itself will create initial MessageBatches that contain only either OOB or
regular messages.
The default processing below sends messages up the stack individually, based on a matching criteria
(calling Protocol.accept(org.jgroups.Message)
), and - if true - calls Protocol.up(org.jgroups.Event)
for that message and removes the message. If the batch is not empty, it is passed up, or else it is dropped.
Subclasses should check if there are any messages destined for them (e.g. using
MessageBatch.getMatchingMessages(short,boolean)
), then possibly remove and process them and finally pass
the batch up to the next protocol. Protocols can also modify messages in place, e.g. ENCRYPT could decrypt all
encrypted messages in the batch, not remove them, and pass the batch up when done.protected void initSymCiphers(java.lang.String algorithm, java.security.Key secret) throws java.lang.Exception
java.lang.Exception
protected javax.crypto.Cipher createCipher(int mode, java.security.Key secret_key, java.lang.String algorithm) throws java.lang.Exception
java.lang.Exception
protected java.lang.Object handleUpMessage(Message msg) throws java.lang.Exception
java.lang.Exception
protected java.lang.Object handleEncryptedMessage(Message msg) throws java.lang.Exception
java.lang.Exception
protected java.lang.Object handleUpEvent(Message msg, EncryptHeader hdr)
protected boolean process(Message msg)
protected void handleView(View view)
protected boolean inView(Address sender, java.lang.String error_msg)
protected java.util.zip.Checksum createChecksummer()
protected Message decryptMessage(javax.crypto.Cipher cipher, Message msg) throws java.lang.Exception
java.lang.Exception
protected Message _decrypt(javax.crypto.Cipher cipher, Message msg, EncryptHeader hdr) throws java.lang.Exception
java.lang.Exception
protected void encryptAndSend(Message msg) throws java.lang.Exception
java.lang.Exception
protected byte[] code(byte[] buf, int offset, int length, boolean decode) throws java.lang.Exception
java.lang.Exception
protected long computeChecksum(byte[] input, int offset, int length)
protected byte[] encryptChecksum(long checksum) throws java.lang.Exception
java.lang.Exception
protected long decryptChecksum(javax.crypto.Cipher cipher, byte[] input, int offset, int length) throws java.lang.Exception
java.lang.Exception
protected static java.lang.String getAlgorithm(java.lang.String s)
protected void handleUnknownVersion(byte[] version)
Copyright © 1998-2020 Red Hat. All Rights Reserved.