1 package org.jacorb.security.sas; 2 3 22 23 import java.io.InputStream ; 24 import java.io.OutputStream ; 25 import java.security.Provider ; 26 27 import org.ietf.jgss.ChannelBinding ; 28 import org.ietf.jgss.GSSCredential ; 29 import org.ietf.jgss.GSSException ; 30 import org.ietf.jgss.MessageProp ; 31 import org.ietf.jgss.Oid ; 32 33 import sun.security.jgss.spi.GSSContextSpi; 34 import sun.security.jgss.spi.GSSCredentialSpi; 35 import sun.security.jgss.spi.GSSNameSpi; 36 37 43 44 public final class GSSUPContextSpi 45 implements GSSContextSpi 46 { 47 private Provider provider = null; 48 private Oid mechOid = null; 49 private int lifetime; 50 private boolean mutualAuth = false; 51 private boolean relayDet = false; 52 private boolean sequenceDet = false; 53 private boolean credDeleg = false; 54 private boolean anonymity = false; 55 private boolean conf = false; 56 private boolean integ = false; 57 private boolean established = false; 58 private ChannelBinding channelBinding = null; 59 60 private GSSNameSpi targetName; 61 private GSSCredentialSpi sourceCred; 62 63 public GSSUPContextSpi(Provider provider, 64 Oid mechOid, 65 GSSNameSpi nameSpi, 66 GSSCredentialSpi credSpi, 67 int lifetime) 68 { 69 this.provider = provider; 70 this.mechOid = mechOid; 71 this.targetName = nameSpi; 72 this.sourceCred = credSpi; 73 this.lifetime = lifetime; 74 } 75 76 public Provider getProvider() 77 { 78 return provider; 79 } 80 81 public void requestLifetime(int lifetime) 82 throws GSSException 83 { 84 this.lifetime = lifetime; 85 } 86 87 public void requestMutualAuth(boolean tf) throws GSSException 88 { 89 mutualAuth = tf; 90 } 91 92 public void requestReplayDet(boolean tf) throws GSSException 93 { 94 relayDet = tf; 95 } 96 97 public void requestSequenceDet(boolean tf) throws GSSException 98 { 99 sequenceDet = false; 100 } 101 102 public void requestCredDeleg(boolean tf) throws GSSException 103 { 104 credDeleg = tf; 105 } 106 107 public void requestAnonymity(boolean tf) throws GSSException 108 { 109 anonymity = tf; 110 } 111 112 public void requestConf(boolean tf) throws GSSException 113 { 114 conf = tf; 115 } 116 117 public void requestInteg(boolean tf) throws GSSException 118 { 119 integ = tf; 120 } 121 122 public void setChannelBinding(ChannelBinding cb) throws GSSException 123 { 124 channelBinding = cb; 125 } 126 127 public boolean getCredDelegState() 128 { 129 return credDeleg; 130 } 131 132 public boolean getMutualAuthState() 133 { 134 return mutualAuth; 135 } 136 137 public boolean getReplayDetState() 138 { 139 return relayDet; 140 } 141 142 public boolean getSequenceDetState() 143 { 144 return sequenceDet; 145 } 146 147 public boolean getAnonymityState() 148 { 149 return anonymity; 150 } 151 152 public boolean isTransferable() throws GSSException 153 { 154 return true; 155 } 156 157 public boolean isProtReady() 158 { 159 return false; 160 } 161 162 public boolean getConfState() 163 { 164 return conf; 165 } 166 167 public boolean getIntegState() 168 { 169 return integ; 170 } 171 172 public int getLifetime() 173 { 174 return lifetime; 175 } 176 177 public boolean isEstablished() 178 { 179 return established; 180 } 181 182 public GSSNameSpi getSrcName() throws GSSException 183 { 184 return sourceCred.getName(); 185 } 186 187 public GSSNameSpi getTargName() throws GSSException 188 { 189 return targetName; 190 } 191 192 public Oid getMech() throws GSSException 193 { 194 return mechOid; 195 } 196 197 public GSSCredentialSpi getDelegCred() throws GSSException 198 { 199 return null; 200 } 201 202 public byte[] initSecContext(InputStream inStream, int inLen) 203 throws GSSException 204 { 205 established = true; 206 return sourceCred.getName().toString().getBytes(); 207 } 208 209 public byte[] acceptSecContext(InputStream inStream, int inLen) 210 throws GSSException 211 { 212 established = true; 213 try 214 { 215 byte[] inBytes = new byte[inStream.available()]; 216 inStream.read(inBytes); 217 GSSNameSpi sourceName = 218 new GSSUPNameSpi(provider, mechOid, inBytes, null); 219 sourceCred = 220 new GSSUPCredentialSpi(provider, 221 mechOid, 222 sourceName, 223 GSSCredential.DEFAULT_LIFETIME, 224 GSSCredential.DEFAULT_LIFETIME, 225 GSSCredential.ACCEPT_ONLY); 226 } 227 catch (Exception e) 228 { 229 } 231 return null; 232 } 233 234 public int getWrapSizeLimit(int i1, boolean b1, int i2) throws GSSException 235 { 236 return 0; 237 } 238 239 public void wrap(InputStream inStream, OutputStream outStream, MessageProp mp) throws GSSException 240 { 241 } 242 243 public byte[] wrap(byte[] b, int i1, int i2, MessageProp mp) throws GSSException 244 { 245 return null; 246 } 247 248 public int wrap(byte[] b1, int i1, int i2, byte[] b2, int i3, MessageProp mp) throws GSSException 249 { 250 return 0; 251 } 252 253 public void wrap(byte[] b, int i1, int i2, OutputStream outStream, MessageProp mp) throws GSSException 254 { 255 } 256 257 public void unwrap(InputStream inStream, OutputStream outStream, MessageProp mp) throws GSSException 258 { 259 } 260 261 public byte[] unwrap(byte[] b, int i1, int i2, MessageProp mp) throws GSSException 262 { 263 return null; 264 } 265 266 public int unwrap(byte[] b1, int i1, int i2, byte[] b2, int i3, MessageProp mp) throws GSSException 267 { 268 return 0; 269 } 270 271 public int unwrap(InputStream inStream, byte[] b, int i1, MessageProp mp) throws GSSException 272 { 273 return 0; 274 } 275 276 public void getMIC(InputStream inStream, OutputStream outStream, MessageProp mp) throws GSSException 277 { 278 } 279 280 public byte[] getMIC(byte[] b1, int i1, int i2, MessageProp mp) throws GSSException 281 { 282 return null; 283 } 284 285 public void verifyMIC(InputStream inStream1, InputStream inStream2, MessageProp mp) throws GSSException 286 { 287 } 288 289 public void verifyMIC(byte[] b1, int i1, int i2, byte[] b2, int i3, int i4, MessageProp mp) throws GSSException 290 { 291 } 292 293 public byte[] export() throws GSSException 294 { 295 return null; 296 } 297 298 public void dispose() throws GSSException 299 { 300 channelBinding = null; 301 provider = null; 302 mechOid = null; 303 } 304 } 305 | Popular Tags |