Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifdef HAVE_CONFIG_H
00024 # include "config.h"
00025 #endif
00026
00027
00028 #include <stdlib.h>
00029
00030
00031 #include <string.h>
00032
00033
00034 #include "login.h"
00035
00036 struct _Gsasl_login_client_state
00037 {
00038 int step;
00039 };
00040
00041 int
00042 _gsasl_login_client_start (Gsasl_session * sctx, void **mech_data)
00043 {
00044 struct _Gsasl_login_client_state *state;
00045
00046 state = malloc (sizeof (*state));
00047 if (state == NULL)
00048 return GSASL_MALLOC_ERROR;
00049
00050 state->step = 0;
00051
00052 *mech_data = state;
00053
00054 return GSASL_OK;
00055 }
00056
00057 int
00058 _gsasl_login_client_step (Gsasl_session * sctx,
00059 void *mech_data,
00060 const char *input, size_t input_len,
00061 char **output, size_t * output_len)
00062 {
00063 struct _Gsasl_login_client_state *state = mech_data;
00064 const char *p;
00065 int res;
00066
00067 switch (state->step)
00068 {
00069 case 0:
00070 p = gsasl_property_get (sctx, GSASL_AUTHID);
00071 if (!p)
00072 return GSASL_NO_AUTHID;
00073
00074 *output = strdup (p);
00075 *output_len = strlen (p);
00076
00077 state->step++;
00078 res = GSASL_NEEDS_MORE;
00079 break;
00080
00081 case 1:
00082 p = gsasl_property_get (sctx, GSASL_PASSWORD);
00083 if (!p)
00084 return GSASL_NO_PASSWORD;
00085
00086 *output = strdup (p);
00087 *output_len = strlen (*output);
00088
00089 state->step++;
00090 res = GSASL_OK;
00091 break;
00092
00093 default:
00094 res = GSASL_MECHANISM_CALLED_TOO_MANY_TIMES;
00095 break;
00096 }
00097
00098 return res;
00099 }
00100
00101 void
00102 _gsasl_login_client_finish (Gsasl_session * sctx, void *mech_data)
00103 {
00104 struct _Gsasl_login_client_state *state = mech_data;
00105
00106 if (!state)
00107 return;
00108
00109 free (state);
00110 }