28 #include <afs/kautils.h>
29 #include <afs/com_err.h>
31 struct ubik_client *conn,
int service,
32 struct ktc_encryptionKey *key, Date
start,
33 Date end,
struct ktc_token *token,
34 afs_int32 * pwexpires);
36 struct ktc_token *token,
37 struct ubik_client **conn);
39 struct ktc_encryptionKey *key,
40 afs_int32 lifetime, afs_int32 *pwexpires);
42 Date lifetime, afs_int32 flags);
45 struct ktc_encryptionKey *key);
46 int ktc_GetToken(
struct ktc_principal *server,
struct ktc_token *token,
47 int tokenLen,
struct ktc_principal *client);
62 emsg =
"password was incorrect";
65 emsg =
"Authentication Server was unavailable";
68 #ifdef R__AFSOLDCOMERR
69 emsg = error_message(rc);
71 emsg = afs_error_message(rc);
94 int life,
char **emsg)
101 if (!usr || strlen(usr) <= 0) {
103 *emsg =
"Input user name undefined - check your inputs!";
108 if (!pwd || (pwlen <= 0 && strlen(pwd) <= 0)) {
110 *emsg =
"Password buffer undefined - check your inputs!";
118 }
else if (life == 0) {
125 if ((rc = ka_Init(0))) {
133 struct ktc_encryptionKey key;
136 memcpy(key.data, pwd, pwlen);
139 int len = strlen(pwd);
140 if (pwd[len-1] ==
'\n')
142 char *pw =
new char[len + 1];
143 memcpy(pw, pwd, len);
152 char cellname[MAXKTCREALMLEN];
153 if (ka_ExpandCell(cell, cellname, 0) != 0) {
155 *emsg =
"Could not expand cell name";
161 struct ubik_client *conn = 0;
164 *emsg =
"Could not get a connection to server";
174 KA_TICKET_GRANTING_SERVICE,
175 &key, now, now + life, tkn, &pwexpires))) {
179 ubik_ClientDestroy(conn);
184 if ((rc =
ka_GetAuthToken((
char *)usr,
"",
"", &key, life, &pwexpires))) {
188 ubik_ClientDestroy(conn);
192 KA_USERAUTH_VERSION + KA_USERAUTH_DOSETPAG))) {
196 ubik_ClientDestroy(conn);
201 ubik_ClientDestroy(conn);
222 return ((
int) tkn->endTime - time(0));
afs_int32 ka_AuthServerConn(char *cell, int service, struct ktc_token *token, struct ubik_client **conn)
void ka_StringToKey(char *str, char *cell, struct ktc_encryptionKey *key)
int VerifyAFSToken(void *token)
Verify validity an AFS token.
char * GetAFSErrorString(afs_int32 rc)
Decode the error code returning a pointer to a human readable string.
void * GetAFSToken(const char *usr, const char *pwd, int pwlen, int life, char **emsg)
Get AFS token for the local cell for 'usr'.
#define DFLTTOKENLIFETIME
afs_int32 ka_Authenticate(char *name, char *instance, char *cell, struct ubik_client *conn, int service, struct ktc_encryptionKey *key, Date start, Date end, struct ktc_token *token, afs_int32 *pwexpires)
afs_int32 ka_GetAFSTicket(char *name, char *instance, char *realm, Date lifetime, afs_int32 flags)
void DeleteAFSToken(void *token)
Delete an AFS token returned by a successful call to GetAFSToken.
int ktc_GetToken(struct ktc_principal *server, struct ktc_token *token, int tokenLen, struct ktc_principal *client)
afs_int32 ka_GetAuthToken(char *name, char *instance, char *cell, struct ktc_encryptionKey *key, afs_int32 lifetime, afs_int32 *pwexpires)
char * AFSLocalCell()
Returns a pointer to a string with the local cell.
struct ktc_token AFStoken_t