Skip to content →

[GSoC 2018] Caldav proxy ?

It is obvious that the hardest point of this project will be implementing the CalDAV protocol. There is standart for it but because it’s scalability, some products have different reponses to the protocol requests. First, im putting link there and explain after 🙂

https://github.com/ITUBIDB/cavabunga-caldav 

https://github.com/ITUBIDB/cavabunga-caldav/pull/1

Also other resources that use while implementing and a WireShark of couse 😀

https://tools.ietf.org/html/rfc4918.html

https://tools.ietf.org/html/rfc3744.html

https://tools.ietf.org/html/rfc4791.html

https://tools.ietf.org/html/rfc6638

https://tools.ietf.org/html/rfc5545.html

https://tools.ietf.org/html/rfc5546.html

The protocol depens on XML request and responses to deliver iCalendar data. It is like to be RestAPI but there is also totally different points from rest api.
Every uri section called “collection”, these colletions can have some properties. What type of collection it is, what type of content it has or what sub-collection it has. Even, main directory is a collection. That collection can have user collection, and user collection can have calendar and addressbook colletion(There is also a protocol for delivering addressbook information: CardDAV)

Rather than, GET POST PUT DELETE  protocol uses some different http methods like; PROPFIND, PROPPATCH, REPORT. And that is the pain in the as. Unfortunatelly not every framework supporting theese 3 unusual http methods. For example: Spring . So, i wrote some “spaghetti code” to work around. But im still looking for a proper way to do it.

/

/{USER NAME}/

/{USER NAME}/calendar

/{USER NAME}/addressbook

Theese are 4 different collection can be accesible with caldav client (iPhone has it own client [settings->accounts->add count->other->CalDAV account], for android there is opensource project for it davroid caldav client: https://www.davdroid.com/  )

With PROPFIND and REPORT methods, collection’s properties can be searchable. Calendar data is also a property and also searchable. Im not going to deep in CalDAV but, im gonna put here small example

 


REQUEST:

PROPFIND /testuser/calendar/ HTTP/1.1

<?xml version=’1.0′ encoding=’UTF-8′ ?><propfind xmlns=”DAV:” xmlns:CAL=”urn:ietf:params:xml:ns:caldav” xmlns:CARD=”urn:ietf:params:xml:ns:carddav”><prop><supported-report-set /><n0:getctag xmlns:n0=”http://calendarserver.org/ns/” /><sync-token /></prop></propfind>

* asks for changes in /testuser/calendar collection


RESPONSE:

HTTP/1.1 207

<?xml version=”1.0″ encoding=”UTF-8″?>
<D:multistatus xmlns:D=”DAV:”><response xmlns=”DAV:”><href>/testuser/calendar/</href><propstat><prop><n0:getctag xmlns:n0=”http://calendarserver.org/ns/”>pkywPSwk8dbf</n0:getctag></prop><status>HTTP/1.1 200 OK</status></propstat><propstat><prop><supported-report-set /><sync-token /></prop><status>HTTP/1.1 404 Not Found</status></propstat></response></D:multistatus>

* if getctag is different than before that means there are some changes in that collection (getctag comes null in first collection query)


REQUEST:

REPORT /testuser/calendar/ HTTP/1.1

<?xml version=’1.0′ encoding=’UTF-8′ ?><CAL:calendar-query xmlns=”DAV:” xmlns:CAL=”urn:ietf:params:xml:ns:caldav”><prop><getetag /></prop><CAL:filter><CAL:comp-filter name=“VCALENDAR”><CAL:comp-filter name=“VEVENT”><CAL:time-range start=“20180711T074709Z” /></CAL:comp-filter></CAL:comp-filter></CAL:filter></CAL:calendar-query>

* asks for a calendar data in the collection which has specific time limit and type


RESPONSE:

HTTP/1.1 207

<?xml version=”1.0″ encoding=”UTF-8″?>
<D:multistatus xmlns:D=”DAV:”><response xmlns=”DAV:”><href>/testuser/calendar/calendar.ics</href><propstat><prop><getetag>8NmCbJAFER90</getetag></prop><status>HTTP/1.1 200 OK</status></propstat><propstat><prop /><status>HTTP/1.1 404 Not Found</status></propstat></response></D:multistatus>

* changed data pointed out and can be get by GET request


REQUEST:

GET /testuser/calendar/calendar.ics HTTP/1.1


RESPONSE:

HTTP/1.1 200

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//www.marudot.com//iCal Event Maker
X-WR-CALNAME:PgCon
CALSCALE:GREGORIAN
BEGIN:VTIMEZONE
TZID:Europe/Moscow
TZURL:http://tzurl.org/zoneinfo-outlook/Europe/Moscow
X-LIC-LOCATION:Europe/Moscow
BEGIN:STANDARD
TZOFFSETFROM:+0300
TZOFFSETTO:+0300
TZNAME:MSK
DTSTART:19700101T000000
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DTSTAMP:20180711T065748Z
UID:20180711T065748Z-1478802882@marudot.com
DTSTART;TZID=”Europe/Moscow”:20180712T120000
DTEND;TZID=”Europe/Moscow”:20180712T120000
SUMMARY:TEST2
DESCRIPTION:TEST
END:VEVENT
END:VCALENDAR

Bingo ! iCalendar data ! ( i use an online tool for creating that ical data https://apps.marudot.com/ical/ )

These are the wireShark outputs of the communication. As i said before, some devices looking for a different requements in protocol respones. So, that couse a problem on iPhone devices. Im still working on it to determine the problem. However, davroid app work flowless on android. Here are some secreenshots:

Screenshot_20180711-105111.png görüntüleniyor

 

Published in Uncategorized

Comments

Leave a Reply