org.jgroups.auth
Class DemoToken

java.lang.Object
  extended by org.jgroups.auth.AuthToken
      extended by org.jgroups.auth.DemoToken
All Implemented Interfaces:
AUTH.UpHandler, Streamable

public class DemoToken
extends AuthToken
implements AUTH.UpHandler

AuthToken implementation which shows how to send messages back and forth in order to perform authentication. Could be used as a template for a challenge-response based AuthToken impl.

Since:
3.3
Author:
Bela Ban

Nested Class Summary
static class DemoToken.DemoHeader
           
protected static class DemoToken.Entry
           
 
Field Summary
protected  long block_time
           
protected static short ID
           
protected  java.util.Map<Address,DemoToken.Entry> pending_requests
           
 
Fields inherited from class org.jgroups.auth.AuthToken
auth, log
 
Constructor Summary
DemoToken()
           
 
Method Summary
 boolean authenticate(AuthToken token, Message msg)
          This method should be implemented to perform the actual authentication of joining members.
protected static byte[] encrypt(byte[] buf)
           
protected static byte[] generateRandomBytes()
           
 java.lang.String getName()
          Used to return the full package and class name of the implementation.
 boolean handleUpEvent(Event evt)
          Called when an up event has been received
protected static long hash(byte[] buf)
           
 void init()
           
 void readFrom(java.io.DataInput in)
          Read the state of the current object (including superclasses) from instream Note that the input stream must not be closed
 int size()
          The size of the marshalled AuthToken
 void writeTo(java.io.DataOutput out)
          Write the entire state of the current object (including superclasses) to outstream.
 
Methods inherited from class org.jgroups.auth.AuthToken
setAuth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID

protected static final short ID
See Also:
Constant Field Values

block_time

protected long block_time

pending_requests

protected final java.util.Map<Address,DemoToken.Entry> pending_requests
Constructor Detail

DemoToken

public DemoToken()
Method Detail

getName

public java.lang.String getName()
Description copied from class: AuthToken
Used to return the full package and class name of the implementation. This is used by the AUTH protocol to create an instance of the implementation.

Specified by:
getName in class AuthToken
Returns:
a java.lang.String object of the package and class name

init

public void init()
Overrides:
init in class AuthToken

authenticate

public boolean authenticate(AuthToken token,
                            Message msg)
Description copied from class: AuthToken
This method should be implemented to perform the actual authentication of joining members.

Specified by:
authenticate in class AuthToken
Parameters:
token - the token sent by the joiner
msg - the Message object containing the actual JOIN_REQ
Returns:
true if authenticaion passed or false if it failed.

writeTo

public void writeTo(java.io.DataOutput out)
             throws java.lang.Exception
Description copied from interface: Streamable
Write the entire state of the current object (including superclasses) to outstream. Note that the output stream must not be closed

Specified by:
writeTo in interface Streamable
Throws:
java.lang.Exception

readFrom

public void readFrom(java.io.DataInput in)
              throws java.lang.Exception
Description copied from interface: Streamable
Read the state of the current object (including superclasses) from instream Note that the input stream must not be closed

Specified by:
readFrom in interface Streamable
Throws:
java.lang.Exception

size

public int size()
Description copied from class: AuthToken
The size of the marshalled AuthToken

Specified by:
size in class AuthToken

handleUpEvent

public boolean handleUpEvent(Event evt)
Description copied from interface: AUTH.UpHandler
Called when an up event has been received

Specified by:
handleUpEvent in interface AUTH.UpHandler
Parameters:
evt - the event
Returns:
true if the event should be pass up, else false

generateRandomBytes

protected static byte[] generateRandomBytes()

encrypt

protected static byte[] encrypt(byte[] buf)

hash

protected static long hash(byte[] buf)


Copyright © 1998-2012 Bela Ban / Red Hat. All Rights Reserved.