KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgroups > protocols > AuthHeader


1 package org.jgroups.protocols;
2
3 import org.jgroups.Header;
4 import org.jgroups.auth.AuthToken;
5 import org.jgroups.util.Streamable;
6 import org.jgroups.util.Util;
7
8 import java.io.*;
9 /**
10  * AuthHeader is a holder object for the token that is passed from the joiner to the coordinator
11  * @author Chris Mills
12  */

13 public class AuthHeader extends Header implements Streamable{
14     private AuthToken token=null;
15     
16     public AuthHeader(){
17     }
18     /**
19      * Sets the token value to that of the passed in token object
20      * @param token the new authentication token
21      */

22     public void setToken(AuthToken token){
23         this.token = token;
24     }
25
26     /**
27      * Used to get the token from the AuthHeader
28      * @return the token found inside the AuthHeader
29      */

30     public AuthToken getToken(){
31         return this.token;
32     }
33
34     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException JavaDoc {
35         this.token = (AuthToken)in.readObject();
36     }
37
38     public void writeExternal(ObjectOutput out) throws IOException {
39         out.writeObject(this.token);
40     }
41
42     public void writeTo(DataOutputStream out) throws IOException {
43         Util.writeAuthToken(this.token, out);
44     }
45
46     public void readFrom(DataInputStream in) throws IOException, IllegalAccessException JavaDoc, InstantiationException JavaDoc {
47         this.token = Util.readAuthToken(in);
48     }
49     public int size(){
50         //need to fix this
51
return Util.sizeOf(this);
52     }
53 }
54
55
Popular Tags