public class ASYM_ENCRYPT extends EncryptBase
NAKACK2
, so that most important
headers are encrypted as well, to prevent replay attacks.AUTH
.EncryptBase.Decrypter
Modifier and Type | Field and Description |
---|---|
protected javax.crypto.Cipher |
asym_cipher |
protected boolean |
change_key_on_leave |
protected static short |
GMS_ID |
protected java.security.KeyPair |
key_pair |
protected ResponseCollectorTask<java.lang.Boolean> |
key_requesters |
protected Address |
key_server_addr |
protected long |
key_server_interval |
protected long |
last_key_request |
protected long |
min_time_between_key_requests |
protected java.util.concurrent.locks.Lock |
queue_lock |
protected boolean |
queue_up_msgs |
protected java.util.concurrent.BlockingQueue<Message> |
up_queue |
protected boolean |
use_external_key_exchange |
asym_algorithm, asym_keylength, cipher_pool_size, decoding_ciphers, DEFAULT_SYM_ALGO, encoding_ciphers, encrypt_entire_message, key_map, key_map_max_size, local_addr, provider, secret_key, sign_msgs, sym_algorithm, sym_keylength, sym_version, use_adler, view
after_creation_hook, down_prot, ergonomics, id, log, name, stack, stats, up_prot
Constructor and Description |
---|
ASYM_ENCRYPT() |
Modifier and Type | Method and Description |
---|---|
javax.crypto.Cipher |
asymCipher() |
protected void |
createNewKey() |
protected javax.crypto.SecretKey |
createSecretKey()
Initialise the symmetric key if none is supplied in a keystore
|
protected javax.crypto.spec.SecretKeySpec |
decodeKey(byte[] encodedKey) |
java.lang.Object |
down(Event evt)
An event is to be sent down the stack.
|
protected byte[] |
encryptSecretKey(java.security.Key secret_key,
java.security.PublicKey public_key)
Encrypts the current secret key with the requester's public key (the requester will decrypt it with its private key)
|
protected boolean |
enqueue(Message msg) |
protected java.security.PublicKey |
generatePubKey(byte[] encodedKey)
Used to reconstitute public key sent in byte form from peer
|
protected Address |
getCoordinator(Message msg,
GMS.GmsHeader hdr)
Tries to find out if this is a JOIN_RSP or INSTALL_MERGE_VIEW message and returns the coordinator of the view
|
java.lang.String |
getKeyServerAddress() |
protected void |
handleNewKeyServer(Address old_key_server,
boolean merge_view,
boolean left_mbrs)
If the keyserver changed, send a request for the secret key to the keyserver
|
protected void |
handleSecretKeyRequest(Message msg) |
protected void |
handleSecretKeyResponse(Message msg,
byte[] key_version) |
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 void |
handleView(View v) |
void |
init()
Called after instance has been created (null constructor) and before protocol is started.
|
protected void |
initKeyPair()
Generates the public/private key pair from the init params
|
boolean |
isKeyServer() |
java.security.KeyPair |
keyPair() |
Address |
keyServerAddr() |
ASYM_ENCRYPT |
keyServerAddr(Address key_srv) |
protected boolean |
keyServerChanged(Address old_keyserver) |
long |
minTimeBetweenKeyRequests() |
ASYM_ENCRYPT |
minTimeBetweenKeyRequests(long t) |
protected boolean |
process(Message msg)
Whether or not to process this received message
|
java.util.List<java.lang.Integer> |
providedDownServices()
List of events that are provided to layers below (they will be handled when sent down below)
|
int |
queueSize() |
void |
sendKeyRequest() |
protected void |
sendKeyRequest(Address key_server)
send client's public key to server and request server's public key
|
protected void |
sendNewKeyserverAck(Address dest) |
protected void |
sendSecretKey(java.security.Key secret_key,
java.security.PublicKey public_key,
Address source) |
protected void |
setKeys(javax.crypto.SecretKey key,
byte[] version) |
protected static boolean |
skip(Message msg)
Checks if a message needs to be encrypted/decrypted.
|
protected void |
startQueueing() |
void |
stop()
This method is called on a
Channel.disconnect() . |
protected void |
stopQueueing() |
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 . |
_decrypt, adler, adler, asymAlgorithm, asymAlgorithm, asymKeylength, asymKeylength, code, computeChecksum, createChecksummer, createCipher, decryptChecksum, decryptMessage, encryptAndSend, encryptChecksum, encryptEntireMessage, encryptEntireMessage, getAlgorithm, handleEncryptedMessage, handleUpMessage, initSymCiphers, inView, localAddress, secretKey, secretKey, signMessages, signMessages, symAlgorithm, symAlgorithm, symKeylength, symKeylength, symVersion, symVersion, 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, providedUpServices, requiredDownServices, requiredUpServices, resetStatistics, resetStats, setDownProtocol, setErgonomics, setId, setLevel, setProtocolStack, setSocketFactory, setUpProtocol, setValue, setValues, start, statsEnabled
protected static final short GMS_ID
protected boolean change_key_on_leave
protected boolean use_external_key_exchange
protected long key_server_interval
protected volatile Address key_server_addr
protected java.security.KeyPair key_pair
protected javax.crypto.Cipher asym_cipher
protected final java.util.concurrent.locks.Lock queue_lock
protected boolean queue_up_msgs
protected final java.util.concurrent.BlockingQueue<Message> up_queue
protected long min_time_between_key_requests
protected volatile long last_key_request
protected ResponseCollectorTask<java.lang.Boolean> key_requesters
public java.security.KeyPair keyPair()
public javax.crypto.Cipher asymCipher()
public Address keyServerAddr()
public ASYM_ENCRYPT keyServerAddr(Address key_srv)
public long minTimeBetweenKeyRequests()
public ASYM_ENCRYPT minTimeBetweenKeyRequests(long t)
public java.util.List<java.lang.Integer> providedDownServices()
Protocol
providedDownServices
in class Protocol
public int queueSize()
public java.lang.String getKeyServerAddress()
public void sendKeyRequest()
public boolean isKeyServer()
public void init() throws java.lang.Exception
Protocol
init
in class EncryptBase
java.lang.Exception
- Thrown if protocol cannot be initialized successfully. This will cause the
ProtocolStack to fail, so the channel constructor will throw an exceptionpublic void stop()
Protocol
Channel.disconnect()
. Stops work (e.g. by closing multicast socket).
Will be called from top to bottom. This means that at the time of the method invocation the
neighbor protocol below is still working. This method will replace the
STOP, STOP_OK, CLEANUP and CLEANUP_OK events. The ProtocolStack guarantees that
when this method is called all messages in the down queue will have been flushedpublic 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()
.down
in class EncryptBase
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()
.up
in class EncryptBase
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.up
in class EncryptBase
batch
- The message batchprotected Address getCoordinator(Message msg, GMS.GmsHeader hdr)
protected static boolean skip(Message msg)
AUTH
protected java.lang.Object handleUpEvent(Message msg, EncryptHeader hdr)
handleUpEvent
in class EncryptBase
protected boolean process(Message msg)
EncryptBase
process
in class EncryptBase
protected void handleSecretKeyRequest(Message msg)
protected void handleSecretKeyResponse(Message msg, byte[] key_version)
protected javax.crypto.SecretKey createSecretKey() throws java.lang.Exception
java.lang.Exception
protected void initKeyPair() throws java.lang.Exception
java.lang.Exception
protected void handleView(View v)
handleView
in class EncryptBase
protected void createNewKey()
protected void handleNewKeyServer(Address old_key_server, boolean merge_view, boolean left_mbrs)
protected boolean keyServerChanged(Address old_keyserver)
protected void setKeys(javax.crypto.SecretKey key, byte[] version) throws java.lang.Exception
java.lang.Exception
protected void sendSecretKey(java.security.Key secret_key, java.security.PublicKey public_key, Address source) throws java.lang.Exception
java.lang.Exception
protected byte[] encryptSecretKey(java.security.Key secret_key, java.security.PublicKey public_key) throws java.lang.Exception
java.lang.Exception
protected void sendKeyRequest(Address key_server)
protected void sendNewKeyserverAck(Address dest)
protected javax.crypto.spec.SecretKeySpec decodeKey(byte[] encodedKey) throws java.lang.Exception
java.lang.Exception
protected void startQueueing()
protected boolean enqueue(Message msg)
protected void stopQueueing()
protected void handleUnknownVersion(byte[] version)
EncryptBase
handleUnknownVersion
in class EncryptBase
protected java.security.PublicKey generatePubKey(byte[] encodedKey)
Copyright © 1998-2020 Red Hat. All Rights Reserved.