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

Method Authenticate

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

Source from the content-addressed store, hash-verified

193 }
194
195 public static int Authenticate(Socket inSocket,
196 InputStream clientIn,
197 OutputStream clientOut)
198 {
199 int err = 0;
200 long maj_status = 0;
201 long[] min_status = {0};
202 gss_ctx_id_t_desc context_tmp = GSS_C_NO_CONTEXT;
203
204 byte[] inputTokenBuffer = null;
205 gss_buffer_desc inputToken = new gss_buffer_desc();
206
207 System.out.println("Authenticating...");
208
209 /* The main authentication loop. We need to loop reading "input
210 * tokens" from the client, calling gss_accept_sec_context on the
211 * "input tokens" and send the resulting "output tokens" back to
212 * the client until we get GSS_S_COMPLETE or an error */
213
214 maj_status = GSS_S_CONTINUE_NEEDED;
215 while ( (err == 0) &&
216 (maj_status != GSS_S_COMPLETE)) {
217
218 /* Clean up old input buffer */
219 if (inputTokenBuffer != null)
220 inputTokenBuffer = null;
221
222 inputTokenBuffer = Util.ReadToken(clientIn);
223
224 if (inputTokenBuffer != null) {
225 /* Set up input buffers for the next run through the loop */
226 gsswrapper.setDescArray(inputToken, inputTokenBuffer);
227 inputToken.setLength(inputTokenBuffer.length);
228
229 System.out.println("inputToken.value = "
230 + inputToken.getValue());
231 System.out.println("inputToken.length = "
232 + inputToken.getLength());
233 } else {
234 System.out.println("Got bad token from client, " +
235 "check client for error description.");
236 return -1;
237 }
238
239 if (inputTokenBuffer != null) {
240 gss_buffer_desc outputToken = new gss_buffer_desc();
241 outputToken.setValue(null);
242 outputToken.setLength(0);
243
244 /* gss_accept_sec_context takes the client request and
245 * generates an appropriate reply. Passing
246 * GSS_C_NO_CREDENTIAL for the service principal causes
247 * the server to accept any service princiapl in the
248 * server's keytab. */
249
250 System.out.println("Calling gss_accept_sec_context...");
251 long[] req_flags = {0};
252 long[] time_rec = {0};

Callers 1

mainMethod · 0.95

Calls 5

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

Tested by

no test coverage detected