1: #include <stdio.h>
2: #include <sys/types.h>
3: #include <netns/ns.h>
4: #include "BasicAuthentication2_defs.h"
5: #include <xnscourier/except.h>
6:
7: main(argc, argv)
8: int argc;
9: char *argv[];
10: {
11: CheckSimpleCredentialsResults result;
12: struct xn_addr *destaddr;
13: CourierConnection *conn;
14: extern struct xn_addr *getXNSaddr();
15: Credentials credentials;
16: Verifier verifier;
17: Clearinghouse_Name name;
18: char *pwd;
19: char *xnshost;
20: extern char *getpass();
21:
22: /* defaults */
23: /* default to CornellS1 2-273, 2-852-151-014 */
24: xnshost = "8E1#00.00.AA.00.5E.E6";
25: /* default to our organization/domain */
26: name.organization = "Cornell-Univ";
27: name.domain = "Computer Science";
28: /* default to me */
29: name.object = "JQ Johnson";
30:
31: switch (argc) {
32: case 3: xnshost = argv[2];
33: case 2: name.object = argv[1];
34: case 1: if ((destaddr = getXNSaddr(xnshost)) == NULL)
35: fprintf(stderr,"Invalid machine name.\n");
36: else
37: break; /* got a valid host name */
38: default:
39: fprintf(stderr,"Usage: %s user [machine]\n",argv[0]);
40: exit(1);
41: }
42: fprintf(stderr,"User: %s:%s:%s\n",
43: name.object, name.domain, name.organization);
44: pwd = getpass("Password: ");
45:
46: if ((conn = CourierOpen(destaddr)) == NULL) {
47: fprintf(stderr,"Can't open connection to %s\n",xnshost);
48: exit(1);
49: }
50:
51: MakeSimpleCredentialsAndVerifier(&name,pwd,&credentials,&verifier);
52:
53: DURING
54: result = CheckSimpleCredentials(conn,NULL,credentials,verifier);
55: HANDLER {
56: switch (Exception.Code) {
57: case CallError:
58: fprintf(stderr,"Call error, number %d, argument %d\n",
59: CourierErrArgs(CallErrorArgs,problem),
60: CourierErrArgs(CallErrorArgs,whichArg));
61: break;
62: case AuthenticationError:
63: fprintf(stderr,"Auth error, problem %d\n",
64: CourierErrArgs(AuthenticationErrorArgs,problem) );
65: break;
66: case REJECT_ERROR:
67: fprintf(stderr,"REJECT: type = %d\n",
68: CourierErrArgs(rejectionDetails, designator));
69: break;
70: default:
71: fprintf(stderr,"Some random error, code %d\n",
72: Exception.Code);
73: break;
74: }
75: exit(1);
76: } END_HANDLER;
77:
78: /* CourierClose(conn); */
79: printf("Returned %d\n", result.ok);
80: }
Defined functions
main
defined in line
7;
never used