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

Method Communicate

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

Source from the content-addressed store, hash-verified

304 } /* end Authorize() */
305
306 public static int Communicate(Socket inSocket,
307 InputStream clientIn,
308 OutputStream clientOut)
309 {
310 long maj_status = 0;
311 long[] min_status = {0};
312 int[] conf_state = {0};
313 long[] qop_state = {0};
314 int err = 0;
315 gss_buffer_desc in_buf = new gss_buffer_desc();
316 gss_buffer_desc out_buf = new gss_buffer_desc();
317 gss_buffer_desc mic_buf = new gss_buffer_desc();
318 byte[] messageBuffer = null;
319
320
321 /* Receive the message token */
322 messageBuffer = Util.ReadToken(clientIn);
323
324 if (messageBuffer != null) {
325 gsswrapper.setDescArray(in_buf, messageBuffer);
326 in_buf.setLength(messageBuffer.length);
327 }
328
329 /* Unwrap token */
330 maj_status = gsswrapper.gss_unwrap(min_status, context,
331 in_buf, out_buf, conf_state, qop_state);
332
333 if (maj_status != GSS_S_COMPLETE) {
334 Util.displayError("unwrapping token, gss_unwrap",
335 min_status, maj_status);
336 return -1;
337 } else if (conf_state[0] == 0) {
338 System.out.println("Warning! Message not encrypted.");
339 }
340
341 System.out.println("Received message: " + out_buf.getValue());
342
343 /* Produce a signature block for the message */
344 maj_status = gsswrapper.gss_get_mic(min_status, context,
345 GSS_C_QOP_DEFAULT,
346 out_buf, mic_buf);
347
348 if (maj_status != GSS_S_COMPLETE) {
349 Util.displayError("producing signature block, gss_get_mic",
350 min_status, maj_status);
351 return -1;
352 }
353
354 /* Send signature block to client */
355 byte[] temp_token = new byte[(int)mic_buf.getLength()];
356 temp_token = gsswrapper.getDescArray(mic_buf);
357 err = Util.WriteToken(clientOut, temp_token);
358
359 if (err != 0) {
360 System.out.println("Error sending signature block to client");
361 return -1;
362 }
363

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