public class ENCRYPT extends Protocol
Each message is identified as encrypted with a specific encryption header which identifies the type of encrypt header and an MD5 digest that identifies the version of the key being used to encrypt/decrypt the messages.
Note: the current version does not support the concept of perfect forward
encryption (PFE) which means that if a peer leaves the group the keys are
re-generated preventing the departed peer from decrypting future messages if
it chooses to listen in on the group. This is not included as it really
requires a suitable authentication scheme as well to make this feature useful
as there is nothing to stop the peer rejoining and receiving the new key. A
future release will address this issue.
Modifier and Type | Class and Description |
---|---|
static class |
ENCRYPT.EncryptHeader |
Modifier and Type | Field and Description |
---|---|
protected Lock |
decrypt_lock
To synchronize access to symDecodingCipher
|
Constructor and Description |
---|
ENCRYPT() |
Modifier and Type | Method and Description |
---|---|
static String |
byteArrayToHexString(byte[] b) |
Object |
down(Event evt)
An event is to be sent down the stack.
|
protected String |
getAsymAlgorithm() |
protected Cipher |
getAsymCipher() |
protected int |
getAsymInit() |
protected String |
getAsymProvider() |
protected SecretKey |
getDesKey() |
protected Address |
getKeyServerAddr() |
protected String |
getKeyStoreName() |
protected KeyPair |
getKpair() |
protected Address |
getLocal_addr() |
protected PublicKey |
getServerPubKey() |
protected String |
getSymAlgorithm() |
protected Cipher |
getSymDecodingCipher() |
protected Cipher |
getSymEncodingCipher() |
protected int |
getSymInit() |
protected String |
getSymProvider() |
protected void |
handleEncryptedMessage(Message msg,
Event evt,
ENCRYPT.EncryptHeader hdr) |
protected void |
handleUpEvent(Message msg,
ENCRYPT.EncryptHeader hdr) |
void |
init()
Called after instance has been created (null constructor) and before protocol is started.
|
void |
initKeyPair()
Generates the public/private key pair from the init params
|
void |
initSymKey()
Used to initialise the symmetric key if none is supplied in a keystore.
|
Object |
passItDown(Event evt) |
Object |
passItUp(Event evt) |
void |
reset()
Just remove if you don't need to reset any state
|
protected void |
setKeyServerAddr(Address keyServerAddr) |
protected void |
setLocal_addr(Address local_addr) |
void |
setObserver(org.jgroups.protocols.ENCRYPT.Observer o) |
Object |
up(Event evt)
An event was received from the layer below.
|
void |
up(MessageBatch batch)
Sends up a multiple messages in a
MessageBatch . |
accept, destroy, dumpStats, enableStats, getConfigurableObjects, getDownProtocol, getDownServices, getId, getIdsAbove, getLevel, getName, getProtocolStack, getSocketFactory, getThreadFactory, getTransport, getUpProtocol, getUpServices, getValue, isErgonomics, level, printStats, providedDownServices, providedUpServices, requiredDownServices, requiredUpServices, resetStatistics, resetStats, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, start, statsEnabled, stop
protected final Lock decrypt_lock
public void setObserver(org.jgroups.protocols.ENCRYPT.Observer o)
public void init() throws Exception
Protocol
public void initSymKey() throws Exception
Exception
public static String byteArrayToHexString(byte[] b)
public void initKeyPair() throws Exception
Exception
public void reset()
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 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 handleEncryptedMessage(Message msg, Event evt, ENCRYPT.EncryptHeader hdr) throws Exception
Exception
protected void handleUpEvent(Message msg, ENCRYPT.EncryptHeader hdr)
public 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()
.protected int getAsymInit()
protected String getAsymProvider()
protected SecretKey getDesKey()
protected KeyPair getKpair()
protected Cipher getAsymCipher()
protected PublicKey getServerPubKey()
protected String getSymAlgorithm()
protected int getSymInit()
protected String getSymProvider()
protected String getAsymAlgorithm()
protected String getKeyStoreName()
protected Cipher getSymDecodingCipher()
protected Cipher getSymEncodingCipher()
protected Address getLocal_addr()
protected void setLocal_addr(Address local_addr)
local_addr
- The local_addr to set.protected Address getKeyServerAddr()
protected void setKeyServerAddr(Address keyServerAddr)
keyServerAddr
- The keyServerAddr to set.Copyright © 2013 JBoss, a division of Red Hat. All rights reserved.