1 /* $Id: authsasllogin.c,v 1.3 2005/07/02 15:40:28 mrsam Exp $ */
4 ** Copyright 1998 - 2005 Double Precision, Inc. See COPYING for
5 ** distribution information.
8 #include "courier_auth_config.h"
10 #include "random128/random128.h"
11 #include "courierauthsasl.h"
21 extern char *strdupdefdomain(const char *userid
, const char *s1
,
22 const char *s2
, const char *s3
);
24 int authsasl_login(const char *method
, const char *initresponse
,
25 char *(*getresp
)(const char *, void *),
37 uid
=malloc(strlen(initresponse
)+1);
41 return (AUTHSASL_ERROR
);
43 strcpy(uid
, initresponse
);
47 p
=authsasl_tobase64("Username:", -1);
51 return (AUTHSASL_ERROR
);
53 uid
=getresp(p
, callback_arg
);
58 return (AUTHSASL_ERROR
);
64 return (AUTHSASL_ABORTED
);
68 p
=authsasl_tobase64("Password:", -1);
73 return (AUTHSASL_ERROR
);
76 pw
=getresp(p
, callback_arg
);
82 return (AUTHSASL_ERROR
);
89 return (AUTHSASL_ABORTED
);
92 if ((n
=authsasl_frombase64(uid
)) < 0 ||
93 (uid
[n
]=0, n
=authsasl_frombase64(pw
)) < 0)
97 return (AUTHSASL_ABORTED
);
101 if ( (*authtype
=malloc(sizeof(AUTHTYPE_LOGIN
))) == 0)
106 return (AUTHSASL_ERROR
);
109 strcpy( *authtype
, AUTHTYPE_LOGIN
);
111 if ( (*authdata
=strdupdefdomain(uid
,"\n",pw
,"\n")) == 0)
117 return (AUTHSASL_ERROR
);
120 return (AUTHSASL_OK
);