183 ucx_map_cstr_put(context->keys, key->name, key); |
183 ucx_map_cstr_put(context->keys, key->name, key); |
184 } |
184 } |
185 |
185 |
186 DavKey* dav_context_get_key(DavContext *context, char *name) { |
186 DavKey* dav_context_get_key(DavContext *context, char *name) { |
187 if(name) { |
187 if(name) { |
188 return ucx_map_cstr_get(context->keys, name); |
188 DavKey *key = ucx_map_cstr_get(context->keys, name); |
|
189 if(key && key->type == DAV_KEY_PASSWORD && !key->data) { |
|
190 char *pw = NULL; |
|
191 if(context->key_input && (pw = context->key_input(context, key))) { |
|
192 // generate key |
|
193 util_generate_key(key, pw); |
|
194 } else { |
|
195 // cannot generate key from password |
|
196 key = NULL; |
|
197 } |
|
198 if(pw) { |
|
199 free(pw); |
|
200 } |
|
201 } |
|
202 return key; |
189 } else { |
203 } else { |
190 return NULL; |
204 return NULL; |
191 } |
205 } |
192 } |
206 } |
193 |
207 |