1 45 package org.openejb.client; 46 47 import java.io.IOException ; 48 import java.io.ObjectInput ; 49 import java.io.ObjectOutput ; 50 51 56 public class AuthenticationResponse implements Response { 57 58 private transient int responseCode = -1; 59 private transient ClientMetaData identity; 60 private transient ServerMetaData server; 61 62 public AuthenticationResponse(){ 63 } 64 65 public AuthenticationResponse(int code){ 66 responseCode = code; 67 } 68 69 public int getResponseCode(){ 70 return responseCode; 71 } 72 73 public ClientMetaData getIdentity(){ 74 return identity; 75 } 76 77 public ServerMetaData getServer(){ 78 return server; 79 } 80 81 public void setResponseCode(int responseCode){ 82 this.responseCode = responseCode; 83 } 84 85 public void setIdentity(ClientMetaData identity){ 86 this.identity = identity; 87 } 88 89 public void setServer(ServerMetaData server){ 90 this.server = server; 91 } 92 93 105 public void readExternal(ObjectInput in) throws IOException , ClassNotFoundException { 106 responseCode = in.readByte(); 107 switch (responseCode) { 108 case AUTH_GRANTED: 109 identity = new ClientMetaData(); 110 identity.readExternal(in); 111 break; 112 case AUTH_REDIRECT: 113 identity = new ClientMetaData(); 114 identity.readExternal(in); 115 server = new ServerMetaData(); 116 server.readExternal( in ); 117 break; 118 case AUTH_DENIED: 119 break; 120 } 121 } 122 123 138 public void writeExternal(ObjectOutput out) throws IOException { 139 out.writeByte((byte)responseCode); 140 switch (responseCode) { 141 case AUTH_GRANTED: 142 identity.writeExternal(out); 143 break; 144 case AUTH_REDIRECT: 145 identity.writeExternal(out); 146 server.writeExternal( out ); 147 break; 148 case AUTH_DENIED: 149 break; 150 } 151 } 152 153 154 155 } 156 157 158 | Popular Tags |