Class EncryptInterceptor
- java.lang.Object
- 
- org.apache.catalina.tribes.group.ChannelInterceptorBase
- 
- org.apache.catalina.tribes.group.interceptors.EncryptInterceptor
 
 
- 
- All Implemented Interfaces:
- ChannelInterceptor,- EncryptInterceptorMBean,- Heartbeat,- MembershipListener
 
 public class EncryptInterceptor extends ChannelInterceptorBase implements EncryptInterceptorMBean Adds encryption using a pre-shared key. The length of the key (in bytes) must be acceptable for the encryption algorithm being used. For example, for AES, you must use a key of either 16 bytes (128 bits, 24 bytes 192 bits), or 32 bytes (256 bits). You can supply the raw key bytes by callingsetEncryptionKey(byte[])or the hex-encoded binary bytes by callingsetEncryptionKey(String).
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from interface org.apache.catalina.tribes.ChannelInterceptorChannelInterceptor.InterceptorEvent
 
- 
 - 
Field SummaryFields Modifier and Type Field Description protected static StringManagersm- 
Fields inherited from class org.apache.catalina.tribes.group.ChannelInterceptorBaseoptionFlag
 
- 
 - 
Constructor SummaryConstructors Constructor Description EncryptInterceptor()
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetEncryptionAlgorithm()Gets the encryption algorithm being used to encrypt and decrypt channel messages.byte[]getEncryptionKey()Gets the encryption key being used for encryption and decryption.java.lang.StringgetEncryptionKeyString()java.lang.StringgetProviderName()Gets the JCA provider name used for cryptographic activities.voidmessageReceived(ChannelMessage msg)themessageReceivedis invoked when a message is received.voidsendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload)ThesendMessagemethod is called when a message is being sent to one more destinations.voidsetEncryptionAlgorithm(java.lang.String algorithm)Sets the encryption algorithm to be used for encrypting and decrypting channel messages.voidsetEncryptionKey(byte[] key)Sets the encryption key for encryption and decryption.voidsetEncryptionKey(java.lang.String keyBytes)Gets the encryption key being used for encryption and decryption.voidsetEncryptionKeyString(java.lang.String encryptionKeyString)voidsetProviderName(java.lang.String provider)Sets the JCA provider name used for cryptographic activities.voidstart(int svc)Starts up the channel.voidstop(int svc)Shuts down the channel.- 
Methods inherited from class org.apache.catalina.tribes.group.ChannelInterceptorBasefireInterceptorEvent, getChannel, getLocalMember, getMember, getMembers, getNext, getOptionFlag, getPrevious, hasMembers, heartbeat, memberAdded, memberDisappeared, okToProcess, setChannel, setNext, setOptionFlag, setPrevious
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.apache.catalina.tribes.group.interceptors.EncryptInterceptorMBeangetOptionFlag, setOptionFlag
 
- 
 
- 
- 
- 
Field Detail- 
smprotected static final StringManager sm 
 
- 
 - 
Method Detail- 
startpublic void start(int svc) throws ChannelExceptionDescription copied from class:ChannelInterceptorBaseStarts up the channel. This can be called multiple times for individual services to start The svc parameter can be the logical or value of any constants- Specified by:
- startin interface- ChannelInterceptor
- Overrides:
- startin class- ChannelInterceptorBase
- Parameters:
- svc- int value of
 DEFAULT - will start all services
 MBR_RX_SEQ - starts the membership receiver
 MBR_TX_SEQ - starts the membership broadcaster
 SND_TX_SEQ - starts the replication transmitter
 SND_RX_SEQ - starts the replication receiver
- Throws:
- ChannelException- if a startup error occurs or the service is already started.
- See Also:
- Channel
 
 - 
stoppublic void stop(int svc) throws ChannelExceptionDescription copied from class:ChannelInterceptorBaseShuts down the channel. This can be called multiple times for individual services to shutdown The svc parameter can be the logical or value of any constants- Specified by:
- stopin interface- ChannelInterceptor
- Overrides:
- stopin class- ChannelInterceptorBase
- Parameters:
- svc- int value of
 DEFAULT - will shutdown all services
 MBR_RX_SEQ - stops the membership receiver
 MBR_TX_SEQ - stops the membership broadcaster
 SND_TX_SEQ - stops the replication transmitter
 SND_RX_SEQ - stops the replication receiver
- Throws:
- ChannelException- if a startup error occurs or the service is already started.
- See Also:
- Channel
 
 - 
sendMessagepublic void sendMessage(Member[] destination, ChannelMessage msg, InterceptorPayload payload) throws ChannelException Description copied from interface:ChannelInterceptorThesendMessagemethod is called when a message is being sent to one more destinations. The interceptor can modify any of the parameters and then pass on the message down the stack by invokinggetNext().sendMessage(destination,msg,payload)
 Alternatively the interceptor can stop the message from being sent by not invokinggetNext().sendMessage(destination,msg,payload)
 If the message is to be sent asynchronous the application can be notified of completion and errors by passing in an error handler attached to a payload object.
 The ChannelMessage.getAddress contains Channel.getLocalMember, and can be overwritten to simulate a message sent from another node.- Specified by:
- sendMessagein interface- ChannelInterceptor
- Overrides:
- sendMessagein class- ChannelInterceptorBase
- Parameters:
- destination- Member[] - the destination for this message
- msg- ChannelMessage - the message to be sent
- payload- InterceptorPayload - the payload, carrying an error handler and future useful data, can be null
- Throws:
- ChannelException- if a serialization error happens.
- See Also:
- ErrorHandler,- InterceptorPayload
 
 - 
messageReceivedpublic void messageReceived(ChannelMessage msg) Description copied from interface:ChannelInterceptorthemessageReceivedis invoked when a message is received.ChannelMessage.getAddress()is the sender, or the reply-to address if it has been overwritten.- Specified by:
- messageReceivedin interface- ChannelInterceptor
- Overrides:
- messageReceivedin class- ChannelInterceptorBase
- Parameters:
- msg- ChannelMessage
 
 - 
setEncryptionAlgorithmpublic void setEncryptionAlgorithm(java.lang.String algorithm) Sets the encryption algorithm to be used for encrypting and decrypting channel messages. You must specify thealgorithm/mode/padding. Information on standard algorithm names may be found in the Java documentation. Default isAES/CBC/PKCS5Padding.- Specified by:
- setEncryptionAlgorithmin interface- EncryptInterceptorMBean
- Parameters:
- algorithm- The algorithm to use.
 
 - 
getEncryptionAlgorithmpublic java.lang.String getEncryptionAlgorithm() Gets the encryption algorithm being used to encrypt and decrypt channel messages.- Specified by:
- getEncryptionAlgorithmin interface- EncryptInterceptorMBean
- Returns:
- The algorithm being used, including the algorithm mode and padding.
 
 - 
setEncryptionKeypublic void setEncryptionKey(byte[] key) Sets the encryption key for encryption and decryption. The length of the key must be appropriate for the algorithm being used.- Specified by:
- setEncryptionKeyin interface- EncryptInterceptorMBean
- Parameters:
- key- The encryption key.
 
 - 
setEncryptionKeypublic void setEncryptionKey(java.lang.String keyBytes) Gets the encryption key being used for encryption and decryption. The key is encoded using hex-encoding where e.g. the byte0xabwill be shown as "ab". The length of the string in characters will be twice the length of the key in bytes.- Parameters:
- keyBytes- The encryption key.
 
 - 
getEncryptionKeypublic byte[] getEncryptionKey() Gets the encryption key being used for encryption and decryption.- Specified by:
- getEncryptionKeyin interface- EncryptInterceptorMBean
- Returns:
- The encryption key.
 
 - 
getEncryptionKeyStringpublic java.lang.String getEncryptionKeyString() 
 - 
setEncryptionKeyStringpublic void setEncryptionKeyString(java.lang.String encryptionKeyString) 
 - 
setProviderNamepublic void setProviderName(java.lang.String provider) Sets the JCA provider name used for cryptographic activities. Default is the JVM platform default.- Specified by:
- setProviderNamein interface- EncryptInterceptorMBean
- Parameters:
- provider- The name of the JCA provider.
 
 - 
getProviderNamepublic java.lang.String getProviderName() Gets the JCA provider name used for cryptographic activities. Default is the JVM platform default.- Specified by:
- getProviderNamein interface- EncryptInterceptorMBean
- Returns:
- The name of the JCA provider.
 
 
- 
 
-