public class CaldavConnection extends AbstractConnection
Modifier and Type | Class and Description |
---|---|
protected static class |
CaldavConnection.CaldavRequest |
protected class |
CaldavConnection.CaldavResponse
Caldav response wrapper, content sent in chunked mode to avoid timeout
|
protected class |
CaldavConnection.ChunkedResponse
Http chunked response.
|
AbstractConnection.LineReaderInputStream, AbstractConnection.State
Thread.UncaughtExceptionHandler
Modifier and Type | Field and Description |
---|---|
protected boolean |
closed |
static BitSet |
ical_allowed_abs_path
custom url encode path set for iCal 5
|
protected static int |
MAX_KEEP_ALIVE_TIME
Maximum keep alive time in seconds
|
protected org.apache.log4j.Logger |
wireLogger |
client, in, os, password, session, state, userName
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Constructor and Description |
---|
CaldavConnection(Socket clientSocket)
Initialize the streams and start the thread.
|
Modifier and Type | Method and Description |
---|---|
protected void |
appendEventsResponses(CaldavConnection.CaldavResponse response,
CaldavConnection.CaldavRequest request,
List<ExchangeSession.Event> events) |
void |
appendFolderOrItem(CaldavConnection.CaldavResponse response,
CaldavConnection.CaldavRequest request,
ExchangeSession.Folder folder,
String subFolder)
Append folder object to Caldav response.
|
void |
appendInbox(CaldavConnection.CaldavResponse response,
CaldavConnection.CaldavRequest request,
String subFolder)
Append calendar inbox object to Caldav response.
|
protected void |
appendItemResponse(CaldavConnection.CaldavResponse response,
CaldavConnection.CaldavRequest request,
ExchangeSession.Item item) |
void |
appendOutbox(CaldavConnection.CaldavResponse response,
CaldavConnection.CaldavRequest request,
String subFolder)
Append calendar outbox object to Caldav response.
|
protected HashMap<String,String> |
buildEtagHeader(CaldavConnection.CaldavRequest request,
ExchangeSession.ItemResult itemResult) |
protected HashMap<String,String> |
buildEtagHeader(String etag) |
protected String |
buildEventPath(CaldavConnection.CaldavRequest request,
String itemName) |
protected void |
decodeCredentials(String authorization)
Decode HTTP credentials
|
protected String |
getContent(String contentLength) |
protected String |
getEventFileNameFromPath(String path) |
protected void |
handleFolderOrItem(CaldavConnection.CaldavRequest request) |
protected void |
handlePrincipals(CaldavConnection.CaldavRequest request) |
void |
handleRequest(String command,
String path,
Map<String,String> headers,
String body)
Handle caldav request.
|
protected Map<String,String> |
parseHeaders() |
void |
patchCalendar(CaldavConnection.CaldavRequest request)
Fake PROPPATCH response for request.
|
void |
reportItems(CaldavConnection.CaldavRequest request)
Report items listed in request.
|
void |
run() |
void |
sendChunkedHttpResponse(int status,
String contentType)
Send Http response with given status in chunked mode.
|
void |
sendDirectory(CaldavConnection.CaldavRequest request)
Send caldav response for /directory/ request.
|
void |
sendErr(Exception e)
Send Http error response for exception
|
void |
sendErr(int status,
String message)
Send Http error status and message.
|
void |
sendFolderOrItem(CaldavConnection.CaldavRequest request)
Send calendar response for request.
|
void |
sendFreeBusy(String body)
Send free busy response for body request.
|
void |
sendGetRoot()
Send simple html response to GET /.
|
void |
sendHttpResponse(int status)
Send Http response with given status.
|
void |
sendHttpResponse(int status,
Map<String,String> headers)
Send Http response with given status and headers.
|
void |
sendHttpResponse(int status,
Map<String,String> headers,
String contentType,
byte[] content,
boolean keepAlive)
Send Http response with given status, headers, content type and content.
|
void |
sendHttpResponse(int status,
Map<String,String> headers,
String contentType,
String content,
boolean keepAlive)
Send Http response with given status, headers, content type and content.
|
void |
sendInbox(CaldavConnection.CaldavRequest request)
Send inbox response for request.
|
void |
sendNotFound(CaldavConnection.CaldavRequest request)
Send 404 not found for unknown request.
|
void |
sendOptions()
Send OPTIONS response.
|
void |
sendOutbox(CaldavConnection.CaldavRequest request)
Send outbox response for request.
|
void |
sendPrincipal(CaldavConnection.CaldavRequest request,
String prefix,
String principal)
Send Caldav principal response.
|
void |
sendPrincipalsFolder(CaldavConnection.CaldavRequest request)
Send principals folder.
|
void |
sendRoot(CaldavConnection.CaldavRequest request)
Send caldav response for / request.
|
void |
sendUnauthorized()
Send 401 Unauthorized response.
|
void |
sendUserRoot(CaldavConnection.CaldavRequest request)
Send user response for request.
|
void |
sendWellKnown()
Send caldav response for /.well-known/ request.
|
protected void |
setSocketTimeout(String keepAliveValue) |
close, logConnection, readClient, sendClient, sendClient, sendClient, sendClient
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
protected static final int MAX_KEEP_ALIVE_TIME
protected final org.apache.log4j.Logger wireLogger
protected boolean closed
public static final BitSet ical_allowed_abs_path
public CaldavConnection(Socket clientSocket)
clientSocket
- Caldav client socketprotected Map<String,String> parseHeaders() throws IOException
IOException
protected String getContent(String contentLength) throws IOException
IOException
protected void setSocketTimeout(String keepAliveValue) throws IOException
IOException
public void handleRequest(String command, String path, Map<String,String> headers, String body) throws IOException
command
- Http commandpath
- request pathheaders
- Http headers mapbody
- request bodyIOException
- on errorprotected void handlePrincipals(CaldavConnection.CaldavRequest request) throws IOException
IOException
protected void handleFolderOrItem(CaldavConnection.CaldavRequest request) throws IOException
IOException
protected HashMap<String,String> buildEtagHeader(CaldavConnection.CaldavRequest request, ExchangeSession.ItemResult itemResult)
protected void appendEventsResponses(CaldavConnection.CaldavResponse response, CaldavConnection.CaldavRequest request, List<ExchangeSession.Event> events) throws IOException
IOException
protected String buildEventPath(CaldavConnection.CaldavRequest request, String itemName)
protected void appendItemResponse(CaldavConnection.CaldavResponse response, CaldavConnection.CaldavRequest request, ExchangeSession.Item item) throws IOException
IOException
public void appendFolderOrItem(CaldavConnection.CaldavResponse response, CaldavConnection.CaldavRequest request, ExchangeSession.Folder folder, String subFolder) throws IOException
response
- Caldav responserequest
- Caldav requestfolder
- folder objectsubFolder
- calendar folder path relative to request pathIOException
- on errorpublic void appendInbox(CaldavConnection.CaldavResponse response, CaldavConnection.CaldavRequest request, String subFolder) throws IOException
response
- Caldav responserequest
- Caldav requestsubFolder
- inbox folder path relative to request pathIOException
- on errorpublic void appendOutbox(CaldavConnection.CaldavResponse response, CaldavConnection.CaldavRequest request, String subFolder) throws IOException
response
- Caldav responserequest
- Caldav requestsubFolder
- outbox folder path relative to request pathIOException
- on errorpublic void sendGetRoot() throws IOException
IOException
- on errorpublic void sendInbox(CaldavConnection.CaldavRequest request) throws IOException
request
- Caldav requestIOException
- on errorpublic void sendOutbox(CaldavConnection.CaldavRequest request) throws IOException
request
- Caldav requestIOException
- on errorpublic void sendFolderOrItem(CaldavConnection.CaldavRequest request) throws IOException
request
- Caldav requestIOException
- on errorpublic void patchCalendar(CaldavConnection.CaldavRequest request) throws IOException
request
- Caldav requestIOException
- on errorpublic void reportItems(CaldavConnection.CaldavRequest request) throws IOException
request
- Caldav requestIOException
- on errorpublic void sendPrincipalsFolder(CaldavConnection.CaldavRequest request) throws IOException
request
- Caldav requestIOException
- on errorpublic void sendUserRoot(CaldavConnection.CaldavRequest request) throws IOException
request
- Caldav requestIOException
- on errorpublic void sendRoot(CaldavConnection.CaldavRequest request) throws IOException
request
- Caldav requestIOException
- on errorpublic void sendDirectory(CaldavConnection.CaldavRequest request) throws IOException
request
- Caldav requestIOException
- on errorpublic void sendWellKnown() throws IOException
IOException
- on errorpublic void sendPrincipal(CaldavConnection.CaldavRequest request, String prefix, String principal) throws IOException
request
- Caldav requestprefix
- principal prefix (users or public)principal
- principal name (email address for users)IOException
- on errorpublic void sendFreeBusy(String body) throws IOException
body
- request bodyIOException
- on errorpublic void sendErr(Exception e) throws IOException
e
- exceptionIOException
- on errorpublic void sendNotFound(CaldavConnection.CaldavRequest request) throws IOException
request
- Caldav requestIOException
- on errorpublic void sendErr(int status, String message) throws IOException
status
- Http statusmessage
- error messageeIOException
- on errorpublic void sendOptions() throws IOException
IOException
- on errorpublic void sendUnauthorized() throws IOException
IOException
- on errorpublic void sendHttpResponse(int status) throws IOException
status
- Http statusIOException
- on errorpublic void sendHttpResponse(int status, Map<String,String> headers) throws IOException
status
- Http statusheaders
- Http headersIOException
- on errorpublic void sendChunkedHttpResponse(int status, String contentType) throws IOException
status
- Http statuscontentType
- MIME content typeIOException
- on errorpublic void sendHttpResponse(int status, Map<String,String> headers, String contentType, String content, boolean keepAlive) throws IOException
status
- Http statusheaders
- Http headerscontentType
- MIME content typecontent
- response body as stringkeepAlive
- keep connection openIOException
- on errorpublic void sendHttpResponse(int status, Map<String,String> headers, String contentType, byte[] content, boolean keepAlive) throws IOException
status
- Http statusheaders
- Http headerscontentType
- MIME content typecontent
- response body as byte arraykeepAlive
- keep connection openIOException
- on errorprotected void decodeCredentials(String authorization) throws IOException
authorization
- http authorization header valueIOException
- if invalid credentialsCopyright © 2001–2024 MickaĆ«l Guessant. All rights reserved.