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

Class GssUtil

examples/GssUtil.java:47–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45import java.net.*;
46
47public class GssUtil {
48
49 private static boolean DEBUG = false;
50
51 /*
52 * Write a token byte[] to OutputStream.
53 * Return: 0 on success, -1 on failure
54 */
55 public static int WriteToken(OutputStream outStream, byte[] outputToken)
56 {
57 if (DEBUG)
58 System.out.println("Entered WriteToken...");
59
60 try {
61
62 /* First send the size of our byte array */
63 byte[] size = Util.intToByteArray(outputToken.length);
64
65 if (DEBUG)
66 System.out.println("... sending byte array size: " +
67 Util.byteArrayToInt(size));
68 outStream.write(size);
69
70 /* Now send our actual byte array */
71 if (DEBUG) {
72 System.out.println("... sending byte array: ");
73 printByteArray(outputToken);
74 System.out.println("... outputToken.length = " +
75 outputToken.length);
76 }
77 outStream.write(outputToken);
78
79 return 0;
80
81 } catch (IOException e) {
82
83 e.printStackTrace();
84 return -1;
85
86 }
87 }
88
89 /*
90 * Read a token byte[] from InputStream.
91 * Return byte[] on success, null on failure
92 */
93 public static byte[] ReadToken(InputStream inStream)
94 {
95 if (DEBUG)
96 System.out.println("Entered ReadToken...");
97
98 byte[] inputTokenBuffer = null;
99
100 try {
101
102 int data;
103 ByteArrayOutputStream out = new ByteArrayOutputStream();
104

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected