Ticket #117: libsyncml_session_support_cred.diff
| File libsyncml_session_support_cred.diff, 3.8 kB (added by Ganadist, 1 year ago) |
|---|
-
./parser/sml_xml_assm.c
old new 742 747 if (!_smlXmlAssemblerEndNode(assm, error)) 743 748 goto error_free_writer; 744 749 } 750 751 if (session->cred) { 752 if (!smlCredAssemble(session->cred, assm, error)) { 753 goto error_free_writer; 754 } 755 } 745 756 746 757 if (!_smlXmlAssemblerEndNode(assm, error)) 747 758 goto error_free_writer; -
./sml_session.c
old new 1114 1114 session->end = FALSE; 1115 1115 session->sessionType = sessionType; 1116 1116 session->lastCommandID = 0; 1117 session->cred = NULL; 1117 1118 1118 1119 if (sessionType == SML_SESSION_TYPE_CLIENT) 1119 1120 session->sending = TRUE; … … 1199 1200 1200 1201 if (session->parentCommand) 1201 1202 smlCommandUnref(session->parentCommand); 1203 if (session->cred) 1204 smlCredFree(session->cred); 1202 1205 1203 1206 g_free(session); 1204 1207 } … … 1597 1600 return FALSE; 1598 1601 } 1599 1602 1603 SmlBool smlSessionRegisterCred(SmlSession *session, SmlAuthType type, const char *user, const char *password, SmlError **error) 1604 { 1605 smlTrace(TRACE_ENTRY, "%s(%p, %u, %p, %p)", __func__, session, type, user, password, error); 1606 SmlCred *cred = smlTryMalloc0(sizeof(SmlCred), error); 1607 gchar *data = NULL, *encoded = NULL; 1608 if (!cred) 1609 goto error; 1610 /* 1611 * FIXME 1612 * Currently, libsyncml supports basic authentication only. 1613 */ 1614 cred->format = SML_FORMAT_TYPE_BASE64; 1615 cred->type = type; 1616 1617 data = g_strconcat(user, ":", password, NULL); 1618 if (!data) { 1619 smlErrorSet(error, SML_ERROR_NO_MEMORY, "No memory left"); 1620 goto error_free_cred; 1621 } 1622 switch (type) { 1623 case SML_AUTH_TYPE_BASIC: 1624 if (smlBase64Encode(data, &encoded, error)) { 1625 cred->data = encoded; 1626 g_free(data); 1627 if (session->cred) 1628 smlCredFree(session->cred); 1629 session->cred = cred; 1630 smlTrace(TRACE_EXIT, "%s", __func__); 1631 return TRUE; 1632 } 1633 break; 1634 default: 1635 break; 1636 } 1637 1638 smlErrorSet(error, SML_ERROR_NOT_SUPPORTED, "Basic authentication type support only"); 1639 free(data); 1640 error_free_cred: 1641 smlCredFree(cred); 1642 error: 1643 smlTrace(TRACE_EXIT_ERROR, "%s: %s", __func__, smlErrorPrint(error)); 1644 return FALSE; 1645 } 1600 1646 /*@}*/ 1601 1647 1602 1648 /*@}*/ -
./sml_session.h
old new 79 79 80 80 SmlBool smlSessionCheck(SmlSession *session); 81 81 void smlSessionDispatch(SmlSession *session); 82 SmlBool smlSessionRegisterCred(SmlSession *session, SmlAuthType type, const char *user, const char *password, SmlError **error); 82 83 83 84 #endif //_SML_SESSION_H_ -
./sml_session_internals.h
old new 82 82 void *frag_userdata; 83 83 84 84 SmlBool active; 85 SmlCred *cred; 85 86 }; 86 87 87 88 struct SmlPendingStatus {
