mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-14 11:42:23 -05:00
Doc: Improve javadoc
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@680 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
a961f7431b
commit
1dd75c84b3
@ -1416,6 +1416,7 @@ public class ExchangeSession {
|
|||||||
/**
|
/**
|
||||||
* Load ICS content from Exchange server.
|
* Load ICS content from Exchange server.
|
||||||
* User Translate: f header to get MIME event content and get ICS attachment from it
|
* User Translate: f header to get MIME event content and get ICS attachment from it
|
||||||
|
*
|
||||||
* @return ICS (iCalendar) event
|
* @return ICS (iCalendar) event
|
||||||
* @throws IOException on error
|
* @throws IOException on error
|
||||||
*/
|
*/
|
||||||
@ -1461,6 +1462,7 @@ public class ExchangeSession {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get event name (file name part in URL).
|
* Get event name (file name part in URL).
|
||||||
|
*
|
||||||
* @return event name
|
* @return event name
|
||||||
*/
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@ -1474,6 +1476,7 @@ public class ExchangeSession {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get event etag (last change tag).
|
* Get event etag (last change tag).
|
||||||
|
*
|
||||||
* @return event etag
|
* @return event etag
|
||||||
*/
|
*/
|
||||||
public String getEtag() {
|
public String getEtag() {
|
||||||
@ -1483,6 +1486,7 @@ public class ExchangeSession {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Search calendar messages in provided folder.
|
* Search calendar messages in provided folder.
|
||||||
|
*
|
||||||
* @param folderPath Exchange folder path
|
* @param folderPath Exchange folder path
|
||||||
* @return list of calendar messages as Event objects
|
* @return list of calendar messages as Event objects
|
||||||
* @throws IOException on error
|
* @throws IOException on error
|
||||||
@ -1498,6 +1502,7 @@ public class ExchangeSession {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Search calendar events in provided folder.
|
* Search calendar events in provided folder.
|
||||||
|
*
|
||||||
* @param folderPath Exchange folder path
|
* @param folderPath Exchange folder path
|
||||||
* @return list of calendar events
|
* @return list of calendar events
|
||||||
* @throws IOException on error
|
* @throws IOException on error
|
||||||
@ -1526,6 +1531,7 @@ public class ExchangeSession {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Search calendar events or messages in provided folder matching the search query.
|
* Search calendar events or messages in provided folder matching the search query.
|
||||||
|
*
|
||||||
* @param folderPath Exchange folder path
|
* @param folderPath Exchange folder path
|
||||||
* @param searchQuery Exchange search query
|
* @param searchQuery Exchange search query
|
||||||
* @return list of calendar messages as Event objects
|
* @return list of calendar messages as Event objects
|
||||||
@ -1542,6 +1548,7 @@ public class ExchangeSession {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get event named eventName in folder
|
* Get event named eventName in folder
|
||||||
|
*
|
||||||
* @param folderPath Exchange folder path
|
* @param folderPath Exchange folder path
|
||||||
* @param eventName event name
|
* @param eventName event name
|
||||||
* @return event object
|
* @return event object
|
||||||
@ -1558,6 +1565,7 @@ public class ExchangeSession {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete event named eventName in folder
|
* Delete event named eventName in folder
|
||||||
|
*
|
||||||
* @param folderPath Exchange folder path
|
* @param folderPath Exchange folder path
|
||||||
* @param eventName event name
|
* @param eventName event name
|
||||||
* @return HTTP status
|
* @return HTTP status
|
||||||
@ -1791,6 +1799,7 @@ public class ExchangeSession {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Build and send the MIME message for the provided ICS event.
|
* Build and send the MIME message for the provided ICS event.
|
||||||
|
*
|
||||||
* @param icsBody event in iCalendar format
|
* @param icsBody event in iCalendar format
|
||||||
* @return HTTP status
|
* @return HTTP status
|
||||||
* @throws IOException on error
|
* @throws IOException on error
|
||||||
@ -1812,6 +1821,7 @@ public class ExchangeSession {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create or update event on the Exchange server
|
* Create or update event on the Exchange server
|
||||||
|
*
|
||||||
* @param folderPath Exchange folder path
|
* @param folderPath Exchange folder path
|
||||||
* @param eventName event name
|
* @param eventName event name
|
||||||
* @param icsBody event body in iCalendar format
|
* @param icsBody event body in iCalendar format
|
||||||
@ -2099,6 +2109,7 @@ public class ExchangeSession {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get user alias from mailbox display name over Webdav.
|
* Get user alias from mailbox display name over Webdav.
|
||||||
|
*
|
||||||
* @return user alias
|
* @return user alias
|
||||||
*/
|
*/
|
||||||
public String getAliasFromMailboxDisplayName() {
|
public String getAliasFromMailboxDisplayName() {
|
||||||
@ -2539,6 +2550,7 @@ public class ExchangeSession {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Append freebusy information to buffer.
|
* Append freebusy information to buffer.
|
||||||
|
*
|
||||||
* @param buffer String buffer
|
* @param buffer String buffer
|
||||||
*/
|
*/
|
||||||
public void appendTo(StringBuilder buffer) {
|
public void appendTo(StringBuilder buffer) {
|
||||||
@ -2548,6 +2560,11 @@ public class ExchangeSession {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return internal HttpClient instance
|
||||||
|
* @return http client
|
||||||
|
*/
|
||||||
public HttpClient getHttpClient() {
|
public HttpClient getHttpClient() {
|
||||||
return httpClient;
|
return httpClient;
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
package davmail.http;
|
package davmail.http;
|
||||||
|
|
||||||
import davmail.Settings;
|
|
||||||
import davmail.BundleMessage;
|
import davmail.BundleMessage;
|
||||||
|
import davmail.Settings;
|
||||||
import davmail.exception.DavMailException;
|
import davmail.exception.DavMailException;
|
||||||
import davmail.ui.tray.DavGatewayTray;
|
import davmail.ui.tray.DavGatewayTray;
|
||||||
import org.apache.commons.httpclient.*;
|
import org.apache.commons.httpclient.*;
|
||||||
@ -28,17 +28,16 @@ import org.apache.commons.httpclient.auth.AuthScope;
|
|||||||
import org.apache.commons.httpclient.methods.DeleteMethod;
|
import org.apache.commons.httpclient.methods.DeleteMethod;
|
||||||
import org.apache.commons.httpclient.methods.GetMethod;
|
import org.apache.commons.httpclient.methods.GetMethod;
|
||||||
import org.apache.commons.httpclient.methods.StringRequestEntity;
|
import org.apache.commons.httpclient.methods.StringRequestEntity;
|
||||||
import org.apache.commons.httpclient.params.HttpMethodParams;
|
|
||||||
import org.apache.commons.httpclient.params.HttpClientParams;
|
import org.apache.commons.httpclient.params.HttpClientParams;
|
||||||
|
import org.apache.commons.httpclient.params.HttpMethodParams;
|
||||||
import org.apache.jackrabbit.webdav.DavException;
|
import org.apache.jackrabbit.webdav.DavException;
|
||||||
import org.apache.jackrabbit.webdav.MultiStatusResponse;
|
import org.apache.jackrabbit.webdav.MultiStatusResponse;
|
||||||
import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
|
|
||||||
import org.apache.jackrabbit.webdav.client.methods.DavMethodBase;
|
import org.apache.jackrabbit.webdav.client.methods.DavMethodBase;
|
||||||
import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
|
import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
|
||||||
|
import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create HttpClient instance according to DavGateway Settings
|
* Create HttpClient instance according to DavGateway Settings
|
||||||
@ -75,6 +74,15 @@ public final class DavGatewayHttpClientFacade {
|
|||||||
return httpClient;
|
return httpClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build an HttpClient instance for the provided url and credentials.
|
||||||
|
*
|
||||||
|
* @param url http(s) url
|
||||||
|
* @param userName user name
|
||||||
|
* @param password user password
|
||||||
|
* @return HttpClient instance
|
||||||
|
* @throws DavMailException on error
|
||||||
|
*/
|
||||||
public static HttpClient getInstance(String url, String userName, String password) throws DavMailException {
|
public static HttpClient getInstance(String url, String userName, String password) throws DavMailException {
|
||||||
HttpClient httpClient = new HttpClient();
|
HttpClient httpClient = new HttpClient();
|
||||||
httpClient.getParams().setParameter(HttpMethodParams.USER_AGENT, IE_USER_AGENT);
|
httpClient.getParams().setParameter(HttpMethodParams.USER_AGENT, IE_USER_AGENT);
|
||||||
@ -163,6 +171,12 @@ public final class DavGatewayHttpClientFacade {
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if status is a redirect (various 30x values).
|
||||||
|
*
|
||||||
|
* @param status Http status
|
||||||
|
* @return true if status is a redirect
|
||||||
|
*/
|
||||||
public static boolean isRedirect(int status) {
|
public static boolean isRedirect(int status) {
|
||||||
return status == HttpStatus.SC_MOVED_PERMANENTLY
|
return status == HttpStatus.SC_MOVED_PERMANENTLY
|
||||||
|| status == HttpStatus.SC_MOVED_TEMPORARILY
|
|| status == HttpStatus.SC_MOVED_TEMPORARILY
|
||||||
@ -185,6 +199,14 @@ public final class DavGatewayHttpClientFacade {
|
|||||||
return executeFollowRedirects(httpClient, method);
|
return executeFollowRedirects(httpClient, method);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute method with httpClient, follow 30x redirects.
|
||||||
|
*
|
||||||
|
* @param httpClient Http client instance
|
||||||
|
* @param method Http method
|
||||||
|
* @return last http method after redirects
|
||||||
|
* @throws IOException on error
|
||||||
|
*/
|
||||||
public static HttpMethod executeFollowRedirects(HttpClient httpClient, HttpMethod method) throws IOException {
|
public static HttpMethod executeFollowRedirects(HttpClient httpClient, HttpMethod method) throws IOException {
|
||||||
HttpMethod currentMethod = method;
|
HttpMethod currentMethod = method;
|
||||||
try {
|
try {
|
||||||
@ -259,6 +281,14 @@ public final class DavGatewayHttpClientFacade {
|
|||||||
return executeMethod(httpClient, propFindMethod);
|
return executeMethod(httpClient, propFindMethod);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute a delete method on the given path with httpClient.
|
||||||
|
*
|
||||||
|
* @param httpClient Http client instance
|
||||||
|
* @param path Path to be deleted
|
||||||
|
* @return Http status
|
||||||
|
* @throws IOException on error
|
||||||
|
*/
|
||||||
public static int executeDeleteMethod(HttpClient httpClient, String path) throws IOException {
|
public static int executeDeleteMethod(HttpClient httpClient, String path) throws IOException {
|
||||||
DeleteMethod deleteMethod = new DeleteMethod(path);
|
DeleteMethod deleteMethod = new DeleteMethod(path);
|
||||||
|
|
||||||
@ -296,6 +326,14 @@ public final class DavGatewayHttpClientFacade {
|
|||||||
return responses;
|
return responses;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute method with httpClient.
|
||||||
|
*
|
||||||
|
* @param httpClient Http client instance
|
||||||
|
* @param method Http method
|
||||||
|
* @return Http status
|
||||||
|
* @throws IOException on error
|
||||||
|
*/
|
||||||
public static int executeHttpMethod(HttpClient httpClient, HttpMethod method) throws IOException {
|
public static int executeHttpMethod(HttpClient httpClient, HttpMethod method) throws IOException {
|
||||||
int status = 0;
|
int status = 0;
|
||||||
try {
|
try {
|
||||||
@ -322,6 +360,9 @@ public final class DavGatewayHttpClientFacade {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stop HttpConnectionManager.
|
||||||
|
*/
|
||||||
public static void stop() {
|
public static void stop() {
|
||||||
if (multiThreadedHttpConnectionManager != null) {
|
if (multiThreadedHttpConnectionManager != null) {
|
||||||
if (httpConnectionManagerThread != null) {
|
if (httpConnectionManagerThread != null) {
|
||||||
@ -332,6 +373,9 @@ public final class DavGatewayHttpClientFacade {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create and start a new HttpConnectionManager, close idle connections every minute.
|
||||||
|
*/
|
||||||
public static void start() {
|
public static void start() {
|
||||||
if (multiThreadedHttpConnectionManager == null) {
|
if (multiThreadedHttpConnectionManager == null) {
|
||||||
multiThreadedHttpConnectionManager = new MultiThreadedHttpConnectionManager();
|
multiThreadedHttpConnectionManager = new MultiThreadedHttpConnectionManager();
|
||||||
|
@ -42,6 +42,12 @@ import java.io.InputStreamReader;
|
|||||||
public class DavGatewayX509TrustManager implements X509TrustManager {
|
public class DavGatewayX509TrustManager implements X509TrustManager {
|
||||||
private final X509TrustManager standardTrustManager;
|
private final X509TrustManager standardTrustManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new custom X509 trust manager.
|
||||||
|
*
|
||||||
|
* @throws NoSuchAlgorithmException on error
|
||||||
|
* @throws KeyStoreException on error
|
||||||
|
*/
|
||||||
public DavGatewayX509TrustManager() throws NoSuchAlgorithmException, KeyStoreException {
|
public DavGatewayX509TrustManager() throws NoSuchAlgorithmException, KeyStoreException {
|
||||||
TrustManagerFactory factory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
TrustManagerFactory factory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||||
factory.init((KeyStore) null);
|
factory.init((KeyStore) null);
|
||||||
@ -130,6 +136,12 @@ public class DavGatewayX509TrustManager implements X509TrustManager {
|
|||||||
return yes.equals(answer);
|
return yes.equals(answer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get rdn value from principal dn.
|
||||||
|
*
|
||||||
|
* @param principal security principal
|
||||||
|
* @return rdn
|
||||||
|
*/
|
||||||
public static String getRDN(Principal principal) {
|
public static String getRDN(Principal principal) {
|
||||||
String dn = principal.getName();
|
String dn = principal.getName();
|
||||||
int start = dn.indexOf('=');
|
int start = dn.indexOf('=');
|
||||||
@ -141,6 +153,12 @@ public class DavGatewayX509TrustManager implements X509TrustManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a formatted certificate serial string.
|
||||||
|
*
|
||||||
|
* @param certificate X509 certificate
|
||||||
|
* @return formatted serial
|
||||||
|
*/
|
||||||
public static String getFormattedSerial(X509Certificate certificate) {
|
public static String getFormattedSerial(X509Certificate certificate) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
String serial = certificate.getSerialNumber().toString(16);
|
String serial = certificate.getSerialNumber().toString(16);
|
||||||
@ -153,6 +171,12 @@ public class DavGatewayX509TrustManager implements X509TrustManager {
|
|||||||
return builder.toString().toUpperCase();
|
return builder.toString().toUpperCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a formatted hash string.
|
||||||
|
*
|
||||||
|
* @param certificate X509 certificate
|
||||||
|
* @return formatted hash
|
||||||
|
*/
|
||||||
public static String getFormattedHash(X509Certificate certificate) {
|
public static String getFormattedHash(X509Certificate certificate) {
|
||||||
String sha1Hash;
|
String sha1Hash;
|
||||||
try {
|
try {
|
||||||
@ -167,7 +191,13 @@ public class DavGatewayX509TrustManager implements X509TrustManager {
|
|||||||
return sha1Hash;
|
return sha1Hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String formatHash(byte[] buffer) {
|
/**
|
||||||
|
* Format byte buffer to a hexadecimal hash string.
|
||||||
|
*
|
||||||
|
* @param buffer byte array
|
||||||
|
* @return hexadecimal hash string
|
||||||
|
*/
|
||||||
|
protected static String formatHash(byte[] buffer) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
for (int i = 0; i < buffer.length; i++) {
|
for (int i = 0; i < buffer.length; i++) {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
|
@ -28,6 +28,9 @@ import java.net.Socket;
|
|||||||
* Pop3 server
|
* Pop3 server
|
||||||
*/
|
*/
|
||||||
public class ImapServer extends AbstractServer {
|
public class ImapServer extends AbstractServer {
|
||||||
|
/**
|
||||||
|
* Default IMAP port
|
||||||
|
*/
|
||||||
public static final int DEFAULT_PORT = 143;
|
public static final int DEFAULT_PORT = 143;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -295,7 +295,11 @@ public class LdapConnection extends AbstractConnection {
|
|||||||
*/
|
*/
|
||||||
int ldapVersion = LDAP_VERSION3;
|
int ldapVersion = LDAP_VERSION3;
|
||||||
|
|
||||||
// Initialize the streams and start the thread
|
/**
|
||||||
|
* Initialize the streams and start the thread.
|
||||||
|
*
|
||||||
|
* @param clientSocket LDAP client socket
|
||||||
|
*/
|
||||||
public LdapConnection(Socket clientSocket) {
|
public LdapConnection(Socket clientSocket) {
|
||||||
super(LdapConnection.class.getSimpleName(), clientSocket);
|
super(LdapConnection.class.getSimpleName(), clientSocket);
|
||||||
try {
|
try {
|
||||||
|
@ -27,6 +27,9 @@ import java.net.Socket;
|
|||||||
* LDAP server, handle LDAP directory requests.
|
* LDAP server, handle LDAP directory requests.
|
||||||
*/
|
*/
|
||||||
public class LdapServer extends AbstractServer {
|
public class LdapServer extends AbstractServer {
|
||||||
|
/**
|
||||||
|
* Default LDAP port
|
||||||
|
*/
|
||||||
public static final int DEFAULT_PORT = 389;
|
public static final int DEFAULT_PORT = 389;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,6 +28,9 @@ import java.net.Socket;
|
|||||||
* Pop3 server
|
* Pop3 server
|
||||||
*/
|
*/
|
||||||
public class PopServer extends AbstractServer {
|
public class PopServer extends AbstractServer {
|
||||||
|
/**
|
||||||
|
* Default POP port
|
||||||
|
*/
|
||||||
public static final int DEFAULT_PORT = 110;
|
public static final int DEFAULT_PORT = 110;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,7 +39,11 @@ import java.util.ArrayList;
|
|||||||
*/
|
*/
|
||||||
public class SmtpConnection extends AbstractConnection {
|
public class SmtpConnection extends AbstractConnection {
|
||||||
|
|
||||||
// Initialize the streams and start the thread
|
/**
|
||||||
|
* Initialize the streams and start the thread.
|
||||||
|
*
|
||||||
|
* @param clientSocket SMTP client socket
|
||||||
|
*/
|
||||||
public SmtpConnection(Socket clientSocket) {
|
public SmtpConnection(Socket clientSocket) {
|
||||||
super(SmtpConnection.class.getSimpleName(), clientSocket, null);
|
super(SmtpConnection.class.getSimpleName(), clientSocket, null);
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,13 @@ import davmail.AbstractServer;
|
|||||||
|
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SMTP server, handle message send requests.
|
||||||
|
*/
|
||||||
public class SmtpServer extends AbstractServer {
|
public class SmtpServer extends AbstractServer {
|
||||||
|
/**
|
||||||
|
* Default SMTP Caldav port
|
||||||
|
*/
|
||||||
public static final int DEFAULT_PORT = 25;
|
public static final int DEFAULT_PORT = 25;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user