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

Method AltCommunicate

examples/client.java:489–573  ·  view source on GitHub ↗
(Socket clientSocket, 
            InputStream serverIn, OutputStream serverOut)

Source from the content-addressed store, hash-verified

487 } /* end Communicate() */
488
489 public static int AltCommunicate(Socket clientSocket,
490 InputStream serverIn, OutputStream serverOut)
491 {
492 long maj_status = 0;
493 long[] min_status = {0};
494 int[] qop_state = {0};
495 int[] state = {0};
496 int err = 0;
497 gss_buffer_desc in_buf = new gss_buffer_desc("Hello Server!");
498 gss_buffer_desc out_buf = new gss_buffer_desc();
499 byte[] sigBlockBuffer = null;
500
501 gss_buffer_desc context_token = new gss_buffer_desc();
502
503 /* Test context export/import functions */
504 maj_status = gsswrapper.gss_export_sec_context(min_status,
505 context, context_token);
506 if (maj_status != GSS_S_COMPLETE) {
507 Util.displayError("exporting security context",
508 min_status, maj_status);
509 return -1;
510 } else {
511 System.out.println("Successfully exported security context");
512 }
513
514 maj_status = gsswrapper.gss_import_sec_context(min_status,
515 context_token, context);
516 if (maj_status != GSS_S_COMPLETE) {
517 Util.displayError("importing security context",
518 min_status, maj_status);
519 return -1;
520 } else {
521 System.out.println("Successfully imported security context");
522 }
523 gsswrapper.gss_release_buffer(min_status, context_token);
524
525 /* Sign and encrypt plain message */
526 maj_status = gsswrapper.gss_seal(min_status, context, 1,
527 GSS_C_QOP_DEFAULT, in_buf,
528 state, out_buf);
529
530 if (maj_status != GSS_S_COMPLETE) {
531 Util.displayError("wrapping message, gss_seal",
532 min_status, maj_status);
533 return -1;
534 } else if (state[0] == 0) {
535 System.out.println("Warning! Message not encrypted.");
536 }
537
538 /* Send wrapped message to server */
539 byte[] temp_token = new byte[(int)out_buf.getLength()];
540 temp_token = gsswrapper.getDescArray(out_buf);
541 err = Util.WriteToken(serverOut, temp_token);
542 if (err != 0) {
543 System.out.println("Error sending wrapped message to " +
544 "server, WriteToken");
545 return -1;
546 }

Callers 1

mainMethod · 0.95

Calls 5

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

Tested by

no test coverage detected