MCPcopy Create free account
hub / github.com/cconlon/kerberos-java-gssapi / AltCommunicate

Method AltCommunicate

examples/server.java:372–435  ·  view source on GitHub ↗
(Socket inSocket,
            InputStream clientIn, 
            OutputStream clientOut)

Source from the content-addressed store, hash-verified

370 } /* end Communicate() */
371
372 public static int AltCommunicate(Socket inSocket,
373 InputStream clientIn,
374 OutputStream clientOut)
375 {
376 long maj_status = 0;
377 long[] min_status = {0};
378 int[] conf_state = {0};
379 int[] qop_state = {0};
380 int err = 0;
381 gss_buffer_desc in_buf = new gss_buffer_desc();
382 gss_buffer_desc out_buf = new gss_buffer_desc();
383 gss_buffer_desc mic_buf = new gss_buffer_desc();
384 byte[] messageBuffer = null;
385
386 /* Receive the message token */
387 messageBuffer = Util.ReadToken(clientIn);
388
389 if (messageBuffer != null) {
390 gsswrapper.setDescArray(in_buf, messageBuffer);
391 in_buf.setLength(messageBuffer.length);
392 }
393
394 /* Unwrap token */
395 maj_status = gsswrapper.gss_unseal(min_status, context,
396 in_buf, out_buf, conf_state, qop_state);
397
398 if (maj_status != GSS_S_COMPLETE) {
399 Util.displayError("unwrapping token, gss_unseal",
400 min_status, maj_status);
401 return -1;
402 } else if (conf_state[0] == 0) {
403 System.out.println("Warning! Message not encrypted.");
404 }
405
406 System.out.println("Received message: " + out_buf.getValue());
407
408 /* Produce a signature block for the message */
409 maj_status = gsswrapper.gss_sign(min_status, context,
410 GSS_C_QOP_DEFAULT,
411 out_buf, mic_buf);
412
413 if (maj_status != GSS_S_COMPLETE) {
414 Util.displayError("producing signature block, gss_sign",
415 min_status, maj_status);
416 return -1;
417 }
418
419 /* Send signature block to client */
420 byte[] temp_token = new byte[(int)mic_buf.getLength()];
421 temp_token = gsswrapper.getDescArray(mic_buf);
422 err = Util.WriteToken(clientOut, temp_token);
423
424 if (err != 0) {
425 System.out.println("Error sending signature block to client");
426 return -1;
427 }
428
429 gsswrapper.gss_release_buffer(min_status, in_buf);

Callers 1

mainMethod · 0.95

Calls 5

ReadTokenMethod · 0.95
displayErrorMethod · 0.95
WriteTokenMethod · 0.95
setLengthMethod · 0.80
getLengthMethod · 0.80

Tested by

no test coverage detected