Package org.jgroups.protocols
Class AUTH
- java.lang.Object
-
- org.jgroups.stack.Protocol
-
- org.jgroups.protocols.AUTH
-
public class AUTH extends Protocol
The AUTH protocol adds a layer of authentication to JGroups. It intercepts join and merge requests and rejects them if the joiner or merger is not permitted to join a or merge into a cluster. AUTH should be placed right belowGMSin the configuration.
Note that some of the AuthTokens (such as MD5Token, SimpleToken etc) cannot prevent rogue members from joining a cluster, and are thus deprecated. Read the manual for a detailed description of why.- Author:
- Chris Mills, Bela Ban
-
-
Field Summary
Fields Modifier and Type Field Description protected AuthTokenauth_tokenUsed on the coordinator to authentication joining member requests againstprotected booleanauthenticate_coordprotected static shortGMS_IDprotected Addresslocal_addrprotected java.util.List<UpHandler>up_handlersList of UpHandler which are called when an up event has been received.-
Fields inherited from class org.jgroups.stack.Protocol
after_creation_hook, down_prot, ergonomics, id, log, stack, stats, up_prot
-
-
Constructor Summary
Constructors Constructor Description AUTH()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voiddestroy()This method is called on aJChannel.close().java.lang.Objectdown(Event evt)An event is to be sent down the stack.java.lang.Objectdown(Message msg)A message is sent down the stack.AddressgetAddress()java.lang.StringgetAuthClass()AuthTokengetAuthToken()java.util.List<java.lang.Object>getConfigurableObjects()After configuring the protocol itself from the properties defined in the XML config, a protocol might have additional objects which need to be configured.protected static GMS.GmsHeadergetGMSHeader(Message msg)protected static JoinRspgetJoinResponse(Message msg)PhysicalAddressgetPhysicalAddress()protected booleanhandleAuthHeader(GMS.GmsHeader gms_hdr, AuthHeader auth_hdr, Message msg)Handles a GMS headervoidinit()Called after instance has been created (null constructor) and before protocol is started.protected booleanneedsAuthentication(Message msg, GMS.GmsHeader hdr)AUTHregister(UpHandler handler)Deprecated.protected voidsendJoinRejectionMessage(Address dest, java.lang.String error_msg)protected voidsendMergeRejectionMessage(Address dest)protected voidsendRejectionMessage(byte type, Address dest, java.lang.String error_msg)voidsetAuthClass(java.lang.String class_name)AUTHsetAuthCoord(boolean authenticateCoord)AUTHsetAuthToken(AuthToken token)voidstart()This method is called on aJChannel.connect(String).voidstop()This method is called on aJChannel.disconnect().AUTHunregister(UpHandler handler)Deprecated.java.lang.Objectup(Message msg)An event was received from the layer below.voidup(MessageBatch batch)Sends up a multiple messages in aMessageBatch.-
Methods inherited from class org.jgroups.stack.Protocol
accept, afterCreationHook, enableStats, 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, setProtocolStack, setSocketFactory, setUpProtocol, setValue, statsEnabled, up
-
-
-
-
Field Detail
-
auth_token
protected AuthToken auth_token
Used on the coordinator to authentication joining member requests against
-
GMS_ID
protected static final short GMS_ID
-
up_handlers
protected final java.util.List<UpHandler> up_handlers
List of UpHandler which are called when an up event has been received. Usually used by AuthToken impls
-
local_addr
protected Address local_addr
-
authenticate_coord
protected volatile boolean authenticate_coord
-
-
Method Detail
-
setAuthCoord
public AUTH setAuthCoord(boolean authenticateCoord)
-
setAuthClass
public void setAuthClass(java.lang.String class_name) throws java.lang.Exception- Throws:
java.lang.Exception
-
getAuthClass
public java.lang.String getAuthClass()
-
getAuthToken
public AuthToken getAuthToken()
-
getAddress
public Address getAddress()
-
getPhysicalAddress
public PhysicalAddress getPhysicalAddress()
-
getConfigurableObjects
public java.util.List<java.lang.Object> getConfigurableObjects()
Description copied from class:ProtocolAfter configuring the protocol itself from the properties defined in the XML config, a protocol might have additional objects which need to be configured. This callback allows a protocol developer to configure those other objects. This call is guaranteed to be invoked after the protocol itself has been configured. See AUTH for an example.- Overrides:
getConfigurableObjectsin classProtocol
-
init
public void init() throws java.lang.ExceptionDescription copied from class:ProtocolCalled after instance has been created (null constructor) and before protocol is started. Properties are already set. Other protocols are not yet connected and events cannot yet be sent.
-
start
public void start() throws java.lang.ExceptionDescription copied from class:ProtocolThis method is called on aJChannel.connect(String). Starts work. Protocols are connected and queues are ready to receive events. Will be called from bottom to top. This call will replace the START and START_OK events.- Overrides:
startin classProtocol- Throws:
java.lang.Exception- Thrown if protocol cannot be started successfully. This will cause the ProtocolStack to fail, soJChannel.connect(String)will throw an exception
-
stop
public void stop()
Description copied from class:ProtocolThis method is called on aJChannel.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 flushed
-
destroy
public void destroy()
Description copied from class:ProtocolThis method is called on aJChannel.close(). Does some cleanup; after the call the VM will terminate
-
up
public java.lang.Object up(Message msg)
An event was received from the layer below. Usually the current layer will want to examine the event type and - depending on its type - perform some computation (e.g. removing headers from a MSG event type, or updating the internal membership list when receiving a VIEW_CHANGE event). Finally the event is either a) discarded, or b) an event is sent down the stack usingdown_prot.down()or c) the event (or another event) is sent up the stack usingup_prot.up().
-
up
public void up(MessageBatch batch)
Description copied from class:ProtocolSends up a multiple messages in aMessageBatch. 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 (callingProtocol.accept(org.jgroups.Message)), and - if true - callsProtocol.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. usingMessageBatch.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.
-
down
public java.lang.Object down(Event evt)
An event is to be sent down the stack. The layer may want to examine its type and perform some action on it, depending on the event's type. If the event is a message MSG, then the layer may need to add a header to it (or do nothing at all) before sending it down the stack usingdown_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 usingup_prot.up().
-
down
public java.lang.Object down(Message msg)
Description copied from class:ProtocolA message is sent down the stack. Protocols may examine the message and do something (e.g. add a header) with it before passing it down.
-
needsAuthentication
protected boolean needsAuthentication(Message msg, GMS.GmsHeader hdr)
-
handleAuthHeader
protected boolean handleAuthHeader(GMS.GmsHeader gms_hdr, AuthHeader auth_hdr, Message msg)
Handles a GMS header- Returns:
- true if the message should be processed (= passed up), or else false
-
sendRejectionMessage
protected void sendRejectionMessage(byte type, Address dest, java.lang.String error_msg)
-
sendJoinRejectionMessage
protected void sendJoinRejectionMessage(Address dest, java.lang.String error_msg)
-
sendMergeRejectionMessage
protected void sendMergeRejectionMessage(Address dest)
-
getGMSHeader
protected static GMS.GmsHeader getGMSHeader(Message msg)
-
-