mirror of
https://github.com/moparisthebest/davmail
synced 2025-01-13 06:28:19 -05:00
Caldav: Improve principal error handling
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@467 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
0410b144d9
commit
6726a464fb
@ -529,37 +529,43 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
actualPrincipal = session.getEmail();
|
actualPrincipal = session.getEmail();
|
||||||
}
|
}
|
||||||
|
|
||||||
CaldavResponse response = new CaldavResponse(HttpStatus.SC_MULTI_STATUS);
|
if (!session.getEmail().equals(principal)) {
|
||||||
response.startMultistatus();
|
String message = "Invalid principal path, try /principals/users/" + session.getEmail();
|
||||||
response.startResponse("/principals/users/" + principal);
|
DavGatewayTray.error(message);
|
||||||
response.startPropstat();
|
sendErr(HttpStatus.SC_NOT_FOUND, message);
|
||||||
|
} else {
|
||||||
|
CaldavResponse response = new CaldavResponse(HttpStatus.SC_MULTI_STATUS);
|
||||||
|
response.startMultistatus();
|
||||||
|
response.startResponse("/principals/users/" + principal);
|
||||||
|
response.startPropstat();
|
||||||
|
|
||||||
if (request.hasProperty("calendar-home-set")) {
|
if (request.hasProperty("calendar-home-set")) {
|
||||||
response.appendProperty("C:calendar-home-set", "<D:href>/users/" + actualPrincipal + "/calendar</D:href>");
|
response.appendProperty("C:calendar-home-set", "<D:href>/users/" + actualPrincipal + "/calendar</D:href>");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.hasProperty("calendar-user-address-set")) {
|
if (request.hasProperty("calendar-user-address-set")) {
|
||||||
response.appendProperty("C:calendar-user-address-set", "<D:href>mailto:" + actualPrincipal + "</D:href>");
|
response.appendProperty("C:calendar-user-address-set", "<D:href>mailto:" + actualPrincipal + "</D:href>");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.hasProperty("schedule-inbox-URL")) {
|
if (request.hasProperty("schedule-inbox-URL")) {
|
||||||
response.appendProperty("C:schedule-inbox-URL", "<D:href>/users/" + actualPrincipal + "/inbox</D:href>");
|
response.appendProperty("C:schedule-inbox-URL", "<D:href>/users/" + actualPrincipal + "/inbox</D:href>");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.hasProperty("schedule-outbox-URL")) {
|
if (request.hasProperty("schedule-outbox-URL")) {
|
||||||
response.appendProperty("C:schedule-outbox-URL", "<D:href>/users/" + actualPrincipal + "/outbox</D:href>");
|
response.appendProperty("C:schedule-outbox-URL", "<D:href>/users/" + actualPrincipal + "/outbox</D:href>");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.hasProperty("displayname")) {
|
if (request.hasProperty("displayname")) {
|
||||||
response.appendProperty("D:displayname", actualPrincipal);
|
response.appendProperty("D:displayname", actualPrincipal);
|
||||||
|
}
|
||||||
|
if (request.hasProperty("resourcetype")) {
|
||||||
|
response.appendProperty("D:resourcetype", "<D:collection/><D:principal/>");
|
||||||
|
}
|
||||||
|
response.endPropStatOK();
|
||||||
|
response.endResponse();
|
||||||
|
response.endMultistatus();
|
||||||
|
response.close();
|
||||||
}
|
}
|
||||||
if (request.hasProperty("resourcetype")) {
|
|
||||||
response.appendProperty("D:resourcetype", "<D:collection/><D:principal/>");
|
|
||||||
}
|
|
||||||
response.endPropStatOK();
|
|
||||||
response.endResponse();
|
|
||||||
response.endMultistatus();
|
|
||||||
response.close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendFreeBusy(String body) throws IOException {
|
public void sendFreeBusy(String body) throws IOException {
|
||||||
@ -832,8 +838,9 @@ public class CaldavConnection extends AbstractConnection {
|
|||||||
public void write(int b) throws IOException {
|
public void write(int b) throws IOException {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() throws IOException{
|
public void close() throws IOException {
|
||||||
sendClient("0");
|
sendClient("0");
|
||||||
sendClient("");
|
sendClient("");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user