Skip to content
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

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

HoussemNasri
Copy link
Member

Closes #1462

@@ -37,6 +37,10 @@
<groupId>${james.groupId}</groupId>
<artifactId>apache-james-backends-rabbitmq</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jmap-extensions</artifactId>
Copy link
Member

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not handled

Copy link
Member Author

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.

.map(PartStat::new);
}

private Mono<CalendarAttendeeParticipationStatus> doGetUserParticipationStatus(List<VEvent> vEvents, String userEmail) {
Copy link
Member

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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private Mono<Calendar> getContainingVCalendar(String eventUid, URI calendarURI) {
private Mono<Calendar> getContainingVCalendar(URI calendarURI, String eventUid) {

Comment on lines 188 to 191
.headers(headers -> headers.add(HttpHeaderNames.AUTHORIZATION,
HttpUtils.createBasicAuthenticationToken(
davConfiguration.adminCredential().getUserName(),
davConfiguration.adminCredential().getPassword())))
Copy link
Member

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) {
Copy link
Member

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())))
Copy link
Member

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.

Comment on lines +23 to +41
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);
Copy link
Member

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)

Comment on lines +34 to +36
return "CalCalendarData{" +
"'" + value + '\'' +
'}';
Copy link
Member

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,
Copy link
Member

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?

Comment on lines 36 to 40
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";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Provide an API to interact with CalDav server
2 participants