3 ** Copyright 1998 - 2005 Double Precision, Inc. See COPYING for
4 ** distribution information.
7 #include "courier_auth_config.h"
9 #include "random128/random128.h"
10 #include "courierauthsasl.h"
20 extern char *strdupdefdomain(const char *userid
, const char *s1
,
21 const char *s2
, const char *s3
);
23 int authsasl_login(const char *method
, const char *initresponse
,
24 char *(*getresp
)(const char *, void *),
36 uid
=malloc(strlen(initresponse
)+1);
40 return (AUTHSASL_ERROR
);
42 strcpy(uid
, initresponse
);
46 p
=authsasl_tobase64("Username:", -1);
50 return (AUTHSASL_ERROR
);
52 uid
=getresp(p
, callback_arg
);
57 return (AUTHSASL_ERROR
);
63 return (AUTHSASL_ABORTED
);
67 p
=authsasl_tobase64("Password:", -1);
72 return (AUTHSASL_ERROR
);
75 pw
=getresp(p
, callback_arg
);
81 return (AUTHSASL_ERROR
);
88 return (AUTHSASL_ABORTED
);
91 if ((n
=authsasl_frombase64(uid
)) < 0 ||
92 (uid
[n
]=0, n
=authsasl_frombase64(pw
)) < 0)
96 return (AUTHSASL_ABORTED
);
100 if ( (*authtype
=malloc(sizeof(AUTHTYPE_LOGIN
))) == 0)
105 return (AUTHSASL_ERROR
);
108 strcpy( *authtype
, AUTHTYPE_LOGIN
);
110 if ( (*authdata
=strdupdefdomain(uid
,"\n",pw
,"\n")) == 0)
116 return (AUTHSASL_ERROR
);
122 return (AUTHSASL_OK
);