1 /* gss.c Shishi GSS-API self tests.
2 * Copyright (C) 2003 Simon Josefsson
4 * This file is part of Shishi.
6 * Shishi is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * Shishi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with Shishi; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <shishi/gssapi.h>
26 main (int argc
, char *argv
[])
32 gss_uint32 maj_stat
, min_stat
;
33 gss_buffer_desc bufdesc
, bufdesc2
;
37 if (strcmp (argv
[argc
- 1], "-v") == 0 ||
38 strcmp (argv
[argc
- 1], "--verbose") == 0)
40 else if (strcmp (argv
[argc
- 1], "-d") == 0 ||
41 strcmp (argv
[argc
- 1], "--debug") == 0)
43 else if (strcmp (argv
[argc
- 1], "-b") == 0 ||
44 strcmp (argv
[argc
- 1], "--break-on-error") == 0)
46 else if (strcmp (argv
[argc
- 1], "-h") == 0 ||
47 strcmp (argv
[argc
- 1], "-?") == 0 ||
48 strcmp (argv
[argc
- 1], "--help") == 0)
50 printf ("Usage: %s [-vdbh?] [--verbose] [--debug] "
51 "[--break-on-error] [--help]\n", argv
[0]);
56 escapeprint (NULL
, 0);
61 bufdesc
.value
= "imap@server.example.org@FOO";
62 bufdesc
.length
= strlen(bufdesc
.value
);
64 maj_stat
= gss_import_name (&min_stat
, &bufdesc
, GSS_C_NT_HOSTBASED_SERVICE
,
66 if (maj_stat
== GSS_S_COMPLETE
)
67 success("gss_import_name() OK\n");
69 fail("gss_import_name() failed (%d,%d)\n", maj_stat
, min_stat
);
71 maj_stat
= gss_display_name (&min_stat
, service
, &bufdesc2
, NULL
);
72 if (maj_stat
== GSS_S_COMPLETE
)
73 success("gss_display_name() OK\n");
75 fail("gss_display_name() failed (%d,%d)\n", maj_stat
, min_stat
);
78 printf("display_name() => %d: %s\n", bufdesc2
.length
, bufdesc2
.value
);
81 printf ("Ticket set self tests done with %d errors\n", error_count
);
83 return error_count
? 1 : 0;