01: package org.jgroups.protocols;
02:
03: import org.jgroups.Header;
04: import org.jgroups.Address;
05: import org.jgroups.auth.AuthToken;
06: import org.jgroups.util.Streamable;
07: import org.jgroups.util.Util;
08:
09: import java.io.*;
10:
11: /**
12: * AuthHeader is a holder object for the token that is passed from the joiner to the coordinator
13: * @author Chris Mills
14: */
15: public class AuthHeader extends Header implements Streamable {
16: private AuthToken token = null;
17:
18: public AuthHeader() {
19: }
20:
21: /**
22: * Sets the token value to that of the passed in token object
23: * @param token the new authentication token
24: */
25: public void setToken(AuthToken token) {
26: this .token = token;
27: }
28:
29: /**
30: * Used to get the token from the AuthHeader
31: * @return the token found inside the AuthHeader
32: */
33: public AuthToken getToken() {
34: return this .token;
35: }
36:
37: public void readExternal(ObjectInput in) throws IOException,
38: ClassNotFoundException {
39: this .token = (AuthToken) in.readObject();
40: }
41:
42: public void writeExternal(ObjectOutput out) throws IOException {
43: out.writeObject(this .token);
44: }
45:
46: public void writeTo(DataOutputStream out) throws IOException {
47: Util.writeAuthToken(this .token, out);
48: }
49:
50: public void readFrom(DataInputStream in) throws IOException,
51: IllegalAccessException, InstantiationException {
52: this .token = Util.readAuthToken(in);
53: }
54:
55: public long size() {
56: //need to fix this
57: return Util.sizeOf(this);
58: }
59: }
|