1 7 8 package org.ietf.jgss; 9 10 import java.net.InetAddress ; 11 import java.util.Arrays ; 12 13 63 public class ChannelBinding { 64 65 private InetAddress initiator; 66 private InetAddress acceptor; 67 private byte[] appData; 68 69 84 public ChannelBinding(InetAddress initAddr, InetAddress acceptAddr, 85 byte[] appData) { 86 87 initiator = initAddr; 88 acceptor = acceptAddr; 89 90 if (appData != null) { 91 this.appData = new byte[appData.length]; 92 java.lang.System.arraycopy(appData, 0, this.appData, 0, 93 appData.length); 94 } 95 } 96 97 103 public ChannelBinding(byte[] appData) { 104 this(null, null, appData); 105 } 106 107 113 public InetAddress getInitiatorAddress() { 114 return initiator; 115 } 116 117 123 public InetAddress getAcceptorAddress() { 124 return acceptor; 125 } 126 127 134 public byte[] getApplicationData() { 135 136 if (appData == null) { 137 return null; 138 } 139 140 byte[] retVal = new byte[appData.length]; 141 System.arraycopy(appData, 0, retVal, 0, appData.length); 142 return retVal; 143 } 144 145 153 public boolean equals(Object obj) { 154 155 if (this == obj) 156 return true; 157 158 if (! (obj instanceof ChannelBinding )) 159 return false; 160 161 ChannelBinding cb = (ChannelBinding ) obj; 162 163 if ((initiator != null && cb.initiator == null) || 164 (initiator == null && cb.initiator != null)) 165 return false; 166 167 if (initiator != null && !initiator.equals(cb.initiator)) 168 return false; 169 170 if ((acceptor != null && cb.acceptor == null) || 171 (acceptor == null && cb.acceptor != null)) 172 return false; 173 174 if (acceptor != null && !acceptor.equals(cb.acceptor)) 175 return false; 176 177 return Arrays.equals(appData, cb.appData); 178 } 179 180 185 public int hashCode() { 186 if (initiator != null) 187 return initiator.hashCode(); 188 else if (acceptor != null) 189 return acceptor.hashCode(); 190 else if (appData != null) 191 return new String (appData).hashCode(); 192 else 193 return 1; 194 } 195 } 196 | Popular Tags |