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

Method main

examples/client.java:57–176  ·  view source on GitHub ↗
(String argv[])

Source from the content-addressed store, hash-verified

55 public static gss_ctx_id_t_desc context = new gss_ctx_id_t_desc();
56
57 public static void main(String argv[]) throws Exception
58 {
59 /* Return/OUTPUT variables */
60 long maj_status = 0;
61 long[] min_status = {0};
62 long[] ret_flags = {0};
63 long[] time_rec = {0};
64
65 int ret = 0;
66 int port = 11115;
67 String server = "127.0.0.1";
68 String clientName = "clientname";
69 String serviceName = "service@host";
70
71 /* Customize this if a specific mechanisms should be negotiated,
72 otherwise set neg_mech_set to GSS_C_NO_OID_SET */
73 gss_OID_set_desc neg_mech_set = new gss_OID_set_desc();
74 gss_OID_desc neg_mech = new gss_OID_desc("{ 1 2 840 113554 1 2 2 }");
75 maj_status = gsswrapper.gss_add_oid_set_member(min_status,
76 neg_mech, neg_mech_set);
77
78 if (maj_status != GSS_S_COMPLETE) {
79 Util.displayError("adding oid to set", min_status, maj_status);
80 System.exit(1);
81 }
82
83 Socket clientSocket = null;
84 OutputStream serverOut = null;
85 InputStream serverIn = null;
86 String serverMsg;
87
88 /* testing gss_oid_to_str */
89 gss_buffer_desc buffer = new gss_buffer_desc();
90 maj_status = gsswrapper.gss_oid_to_str(min_status,
91 gsswrapper.getGSS_C_NT_EXPORT_NAME(), buffer);
92
93 if (maj_status != GSS_S_COMPLETE) {
94 Util.errorExit("Error calling gss_oid_to_str",
95 min_status, maj_status);
96 }
97 gsswrapper.gss_release_buffer(min_status, buffer);
98
99 /* create socket to connect to the server */
100 try {
101 clientSocket = new Socket(server, port);
102 System.out.println("Connected to " + server + " at port " + port);
103
104 /* get input and output streams */
105 serverOut = clientSocket.getOutputStream();
106 serverIn = clientSocket.getInputStream();
107
108 } catch (UnknownHostException e) {
109 System.err.println("Unknown host: " + server);
110 e.printStackTrace();
111 } catch (IOException e) {
112 System.err.println("I/O error for the connection to " + server);
113 e.printStackTrace();
114 }

Callers

nothing calls this directly

Calls 7

displayErrorMethod · 0.95
errorExitMethod · 0.95
AuthenticateMethod · 0.95
PrintContextInfoMethod · 0.95
CommunicateMethod · 0.95
AltCommunicateMethod · 0.95
MiscFunctionTestsMethod · 0.95

Tested by

no test coverage detected