-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide an API to interact with CalDav server #1465
base: master
Are you sure you want to change the base?
Conversation
@@ -37,6 +37,10 @@ | |||
<groupId>${james.groupId}</groupId> | |||
<artifactId>apache-james-backends-rabbitmq</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>${project.groupId}</groupId> | |||
<artifactId>jmap-extensions</artifactId> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we did fight hard not to get this dependency here.
Why do we get it?
How can we remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not handled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm aware of it. I know it can be handled, but it takes some refactoring on the jmap-extensions side. I need to get the CalDAV stuff to work to understand what changes need to be made there.
tmail-backend/apps/memory/src/main/java/com/linagora/tmail/james/app/MemoryServer.java
Show resolved
Hide resolved
...end/tmail-third-party/openpaas/src/main/java/com/linagora/tmail/dav/card/CardDavHandler.java
Outdated
Show resolved
Hide resolved
5dc96d3
to
0df173e
Compare
.map(PartStat::new); | ||
} | ||
|
||
private Mono<CalendarAttendeeParticipationStatus> doGetUserParticipationStatus(List<VEvent> vEvents, String userEmail) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method likely do not need to be reactive.
} | ||
} | ||
|
||
private Mono<Calendar> getContainingVCalendar(String eventUid, URI calendarURI) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private Mono<Calendar> getContainingVCalendar(String eventUid, URI calendarURI) { | |
private Mono<Calendar> getContainingVCalendar(URI calendarURI, String eventUid) { |
.headers(headers -> headers.add(HttpHeaderNames.AUTHORIZATION, | ||
HttpUtils.createBasicAuthenticationToken( | ||
davConfiguration.adminCredential().getUserName(), | ||
davConfiguration.adminCredential().getPassword()))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reuse adminCredentialWithDelegatedFunction
return hrefs; | ||
} | ||
|
||
private static @NotNull Mono<Calendar> extractVCalendarFromResponse(DavMultistatus multistatus) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to be reactive here IMO
davConfiguration.adminCredential().getPassword()))) | ||
.request(HttpMethod.valueOf("REPORT")) | ||
.uri(calendarURI.getPath()) | ||
.send(Mono.just(Unpooled.wrappedBuffer(new GetCalendarByEventIdRequestBody(eventUid).value().getBytes()))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getBytes shall always take a charset as a parameter even if here US_ASCII seems the best possible value.
public String value() { | ||
return """ | ||
<C:calendar-query xmlns:C="urn:ietf:params:xml:ns:caldav"> | ||
<D:prop | ||
xmlns:D="DAV:"> | ||
<D:getetag/> | ||
<C:calendar-data/> | ||
</D:prop> | ||
<C:filter> | ||
<C:comp-filter name="VCALENDAR"> | ||
<C:comp-filter name="VEVENT"> | ||
<C:prop-filter name="UID"> | ||
<C:text-match collation="i;octet">%s</C:text-match> | ||
</C:prop-filter> | ||
</C:comp-filter> | ||
</C:comp-filter> | ||
</C:filter> | ||
</C:calendar-query> | ||
""".formatted(vEventUid); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is subject to XML injections... UID could be controlled by a remote sender and could be used to craft custom XML payload here.
We need to use a XML library in order to nettralize the input before sending it.
(Or do XML sanitation ourselves)
return "CalCalendarData{" + | ||
"'" + value + '\'' + | ||
'}'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not return " value"?
Otherwize please use MoreObjects.toStringHelper here and in other places.
}); | ||
} | ||
|
||
public Mono<PartStat> getUserParticipationStatus(String userId, String eventUid, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it really the role of the DAVClient to take bustiness decisions on participationStatus?
Maybe public Mono<List<VEvent>> getUserParticipationStatus(String userId, String eventUid,String userEmail)
and implement the logic List<VEvent> => PartStat
in another class?
static final String CARD_DAV_API_URI_PROPERTY = "carddav.api.uri"; | ||
static final String CARD_DAV_ADMIN_USER_PROPERTY = "carddav.admin.user"; | ||
static final String CARD_DAV_ADMIN_PASSWORD_PROPERTY = "carddav.admin.password"; | ||
static final String CARD_DAV_REST_CLIENT_TRUST_ALL_SSL_CERTS_PROPERTY = "carddav.rest.client.trust.all.ssl.certs"; | ||
static final String CARD_DAV_REST_CLIENT_RESPONSE_TIMEOUT_PROPERTY = "carddav.rest.client.response.timeout"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static final String CARD_DAV_API_URI_PROPERTY = "carddav.api.uri"; | |
static final String CARD_DAV_ADMIN_USER_PROPERTY = "carddav.admin.user"; | |
static final String CARD_DAV_ADMIN_PASSWORD_PROPERTY = "carddav.admin.password"; | |
static final String CARD_DAV_REST_CLIENT_TRUST_ALL_SSL_CERTS_PROPERTY = "carddav.rest.client.trust.all.ssl.certs"; | |
static final String CARD_DAV_REST_CLIENT_RESPONSE_TIMEOUT_PROPERTY = "carddav.rest.client.response.timeout"; | |
static final String CARD_DAV_API_URI_PROPERTY = "dav.api.uri"; | |
static final String CARD_DAV_ADMIN_USER_PROPERTY = "dav.admin.user"; | |
static final String CARD_DAV_ADMIN_PASSWORD_PROPERTY = "dav.admin.password"; | |
static final String CARD_DAV_REST_CLIENT_TRUST_ALL_SSL_CERTS_PROPERTY = "dav.rest.client.trust.all.ssl.certs"; | |
static final String CARD_DAV_REST_CLIENT_RESPONSE_TIMEOUT_PROPERTY = "dav.rest.client.response.timeout"; |
While we are at it?
Closes #1462