public abstract class Encrypt<E extends KeyStore.Entry> extends Protocol
SYM_ENCRYPT
) and asymmetric (ASYM_ENCRYPT
) encryption protocols.Modifier and Type | Class and Description |
---|---|
protected class |
Encrypt.Decrypter
Decrypts all messages in a batch, replacing encrypted messages in-place with their decrypted versions
|
Modifier and Type | Field and Description |
---|---|
protected String |
asym_algorithm |
protected int |
asym_keylength |
protected int |
cipher_pool_size |
protected BlockingQueue<Cipher> |
decoding_ciphers |
protected static String |
DEFAULT_SYM_ALGO |
protected BlockingQueue<Cipher> |
encoding_ciphers |
protected boolean |
encrypt_entire_message |
protected Map<AsciiString,Cipher> |
key_map |
protected int |
key_map_max_size |
protected Address |
local_addr |
protected String |
provider |
protected Key |
secret_key |
protected boolean |
sign_msgs |
protected 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, stack, stats, up_prot
Constructor and Description |
---|
Encrypt() |
Modifier and Type | Method and Description |
---|---|
protected Message |
_decrypt(Cipher cipher,
Message msg,
EncryptHeader hdr) |
boolean |
adler() |
<T extends Encrypt<E>> |
adler(boolean flag) |
String |
asymAlgorithm() |
<T extends Encrypt<E>> |
asymAlgorithm(String alg) |
int |
asymKeylength() |
<T extends Encrypt<E>> |
asymKeylength(int len) |
protected byte[] |
code(byte[] buf,
int offset,
int length,
boolean decode) |
protected long |
computeChecksum(byte[] input,
int offset,
int length) |
protected Checksum |
createChecksummer() |
protected Cipher |
createCipher(int mode,
Key secret_key,
String algorithm) |
protected long |
decryptChecksum(Cipher cipher,
byte[] input,
int offset,
int length) |
protected Message |
decryptMessage(Cipher cipher,
Message msg)
Does the actual work for decrypting - if version does not match current cipher then tries the previous cipher
|
Object |
down(Event evt)
An event is to be sent down the stack.
|
Object |
down(Message msg)
A message is sent down the stack.
|
protected void |
encryptAndSend(Message msg) |
protected byte[] |
encryptChecksum(long checksum) |
boolean |
encryptEntireMessage() |
<T extends Encrypt<E>> |
encryptEntireMessage(boolean b) |
protected static String |
getAlgorithm(String s) |
protected Object |
handleEncryptedMessage(Message msg) |
protected void |
handleUnknownVersion(byte[] version)
Called when the version shipped in the header can't be found
|
protected Object |
handleUpEvent(Message msg,
EncryptHeader hdr) |
protected 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(String algorithm,
Key secret)
Initialises the ciphers for both encryption and decryption using the generated or supplied secret key
|
protected boolean |
inView(Address sender,
String error_msg) |
<T extends Encrypt<E>> |
localAddress(Address addr) |
protected boolean |
process(Message msg)
Whether or not to process this received message
|
Key |
secretKey() |
abstract void |
setKeyStoreEntry(E entry)
Sets the key store entry used to configure this protocol.
|
boolean |
signMessages() |
<T extends Encrypt<E>> |
signMessages(boolean flag) |
String |
symAlgorithm() |
<T extends Encrypt<E>> |
symAlgorithm(String alg) |
int |
symKeylength() |
<T extends Encrypt<E>> |
symKeylength(int len) |
byte[] |
symVersion() |
Object |
up(Event evt)
An event was received from the protocol below.
|
Object |
up(Message msg)
A single message was received.
|
void |
up(MessageBatch batch)
Sends up a multiple messages in a
MessageBatch . |
String |
version() |
accept, afterCreationHook, destroy, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getLog, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, parse, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStatistics, resetStats, setDownProtocol, setErgonomics, setId, setLevel, setProperties, setProtocolStack, setSocketFactory, setUpProtocol, setValue, start, statsEnabled, stop
protected static final String DEFAULT_SYM_ALGO
protected String provider
protected String asym_algorithm
protected 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 BlockingQueue<Cipher> encoding_ciphers
protected BlockingQueue<Cipher> decoding_ciphers
protected volatile byte[] sym_version
protected volatile Key secret_key
protected Map<AsciiString,Cipher> key_map
public abstract void setKeyStoreEntry(E entry)
entry
- a key store entrypublic int asymKeylength()
public int symKeylength()
public Key secretKey()
public String symAlgorithm()
public String asymAlgorithm()
public byte[] symVersion()
public boolean encryptEntireMessage()
public boolean signMessages()
public boolean adler()
public String version()
public void init() throws Exception
Protocol
public Object down(Event evt)
Protocol
down_prot.down()
.public Object down(Message msg)
Protocol
public 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 Object up(Message msg)
Protocol
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(String algorithm, Key secret) throws Exception
Exception
protected Cipher createCipher(int mode, Key secret_key, String algorithm) throws Exception
Exception
protected Object handleEncryptedMessage(Message msg) throws Exception
Exception
protected Object handleUpEvent(Message msg, EncryptHeader hdr)
protected boolean process(Message msg)
protected void handleView(View view)
protected Checksum createChecksummer()
protected Message decryptMessage(Cipher cipher, Message msg) throws Exception
Exception
protected Message _decrypt(Cipher cipher, Message msg, EncryptHeader hdr) throws Exception
Exception
protected byte[] code(byte[] buf, int offset, int length, boolean decode) throws Exception
Exception
protected long computeChecksum(byte[] input, int offset, int length)
protected long decryptChecksum(Cipher cipher, byte[] input, int offset, int length) throws Exception
Exception
protected void handleUnknownVersion(byte[] version)
Copyright © 2018 JBoss, a division of Red Hat. All rights reserved.