1
0
mirror of https://github.com/moparisthebest/davmail synced 2024-12-13 19:22:22 -05:00

Various fixes from audit

git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@394 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
mguessan 2009-02-24 11:53:02 +00:00
parent a75fda975e
commit e45328fe43
7 changed files with 23 additions and 54 deletions

View File

@ -16,11 +16,6 @@ public class AbstractConnection extends Thread {
protected enum State {INITIAL, LOGIN, USER, PASSWORD, AUTHENTICATED, STARTMAIL, RECIPIENT, MAILDATA} protected enum State {INITIAL, LOGIN, USER, PASSWORD, AUTHENTICATED, STARTMAIL, RECIPIENT, MAILDATA}
/**
* read password state
*/
public static final int PASSWORD = 1;
protected final Socket client; protected final Socket client;
protected BufferedReader in; protected BufferedReader in;

View File

@ -28,7 +28,7 @@ import java.util.*;
* Handle a caldav connection. * Handle a caldav connection.
*/ */
public class CaldavConnection extends AbstractConnection { public class CaldavConnection extends AbstractConnection {
protected Logger wireLogger = Logger.getLogger(this.getClass()); protected final Logger wireLogger = Logger.getLogger(this.getClass());
protected boolean closed = false; protected boolean closed = false;
@ -343,7 +343,7 @@ public class CaldavConnection extends AbstractConnection {
buffer.append("</D:response>"); buffer.append("</D:response>");
} }
public void appendInbox(StringBuilder buffer, String principal, CaldavRequest request) throws IOException { public void appendInbox(StringBuilder buffer, String principal, CaldavRequest request) {
buffer.append("<D:response>"); buffer.append("<D:response>");
buffer.append("<D:href>/users/").append(principal).append("/inbox</D:href>"); buffer.append("<D:href>/users/").append(principal).append("/inbox</D:href>");
buffer.append("<D:propstat>"); buffer.append("<D:propstat>");
@ -367,7 +367,7 @@ public class CaldavConnection extends AbstractConnection {
buffer.append("</D:response>"); buffer.append("</D:response>");
} }
public void appendOutbox(StringBuilder buffer, String principal, CaldavRequest request) throws IOException { public void appendOutbox(StringBuilder buffer, String principal, CaldavRequest request) {
buffer.append("<D:response>"); buffer.append("<D:response>");
buffer.append("<D:href>/users/").append(principal).append("/outbox</D:href>"); buffer.append("<D:href>/users/").append(principal).append("/outbox</D:href>");
buffer.append("<D:propstat>"); buffer.append("<D:propstat>");
@ -773,7 +773,7 @@ public class CaldavConnection extends AbstractConnection {
} }
protected static class CaldavRequest { protected static class CaldavRequest {
protected HashSet<String> properties = new HashSet<String>(); protected final HashSet<String> properties = new HashSet<String>();
protected HashSet<String> hrefs; protected HashSet<String> hrefs;
protected boolean isMultiGet; protected boolean isMultiGet;

View File

@ -13,10 +13,10 @@ import org.apache.log4j.Logger;
import org.apache.webdav.lib.Property; import org.apache.webdav.lib.Property;
import org.apache.webdav.lib.ResponseEntity; import org.apache.webdav.lib.ResponseEntity;
import org.apache.webdav.lib.WebdavResource; import org.apache.webdav.lib.WebdavResource;
import org.apache.webdav.lib.methods.CopyMethod;
import org.apache.webdav.lib.methods.MoveMethod; import org.apache.webdav.lib.methods.MoveMethod;
import org.apache.webdav.lib.methods.PropPatchMethod; import org.apache.webdav.lib.methods.PropPatchMethod;
import org.apache.webdav.lib.methods.SearchMethod; import org.apache.webdav.lib.methods.SearchMethod;
import org.apache.webdav.lib.methods.CopyMethod;
import org.htmlcleaner.CommentToken; import org.htmlcleaner.CommentToken;
import org.htmlcleaner.HtmlCleaner; import org.htmlcleaner.HtmlCleaner;
import org.htmlcleaner.TagNode; import org.htmlcleaner.TagNode;
@ -36,17 +36,6 @@ public class ExchangeSession {
public static final SimpleTimeZone GMT_TIMEZONE = new SimpleTimeZone(0, "GMT"); public static final SimpleTimeZone GMT_TIMEZONE = new SimpleTimeZone(0, "GMT");
/**
* exchange message properties needed to rebuild mime message
*/
protected static final Vector<String> MESSAGE_REQUEST_PROPERTIES = new Vector<String>();
static {
MESSAGE_REQUEST_PROPERTIES.add("DAV:uid");
// size
MESSAGE_REQUEST_PROPERTIES.add("http://schemas.microsoft.com/mapi/proptag/x0e080003");
}
protected static final Vector<String> EVENT_REQUEST_PROPERTIES = new Vector<String>(); protected static final Vector<String> EVENT_REQUEST_PROPERTIES = new Vector<String>();
static { static {
@ -561,21 +550,6 @@ public class ExchangeSession {
return message; return message;
} }
public Message getMessage(String messageUrl) throws IOException {
Enumeration messageEnum = wdr.propfindMethod(messageUrl, 0, MESSAGE_REQUEST_PROPERTIES);
if ((wdr.getStatusCode() != HttpURLConnection.HTTP_OK)
|| !messageEnum.hasMoreElements()) {
throw new IOException("Unable to get message: " + wdr.getStatusCode()
+ " " + wdr.getStatusMessage());
}
ResponseEntity entity = (ResponseEntity) messageEnum.nextElement();
return buildMessage(entity);
}
protected void addProperties(PropPatchMethod patchMethod, Map<String, String> properties) { protected void addProperties(PropPatchMethod patchMethod, Map<String, String> properties) {
for (Map.Entry<String, String> entry : properties.entrySet()) { for (Map.Entry<String, String> entry : properties.entrySet()) {
if ("read".equals(entry.getKey())) { if ("read".equals(entry.getKey())) {
@ -1122,7 +1096,7 @@ public class ExchangeSession {
} }
public class MessageList extends ArrayList<Message> { public class MessageList extends ArrayList<Message> {
HashMap<Long, Message> uidMessageMap = new HashMap<Long, Message>(); final HashMap<Long, Message> uidMessageMap = new HashMap<Long, Message>();
@Override @Override
public boolean add(Message message) { public boolean add(Message message) {
@ -1382,7 +1356,7 @@ public class ExchangeSession {
return result.toString(); return result.toString();
} }
protected void splitExDate(ICSBufferedWriter result, String line) throws IOException { protected void splitExDate(ICSBufferedWriter result, String line) {
int cur = line.lastIndexOf(':') + 1; int cur = line.lastIndexOf(':') + 1;
String start = line.substring(0, cur); String start = line.substring(0, cur);
@ -1445,7 +1419,7 @@ public class ExchangeSession {
return internalCreateOrUpdateEvent(messageUrl, "urn:content-classes:appointment", icsBody, etag, noneMatch); return internalCreateOrUpdateEvent(messageUrl, "urn:content-classes:appointment", icsBody, etag, noneMatch);
} }
protected String getICSMethod(String icsBody) throws IOException { protected String getICSMethod(String icsBody) {
int methodIndex = icsBody.indexOf("METHOD:"); int methodIndex = icsBody.indexOf("METHOD:");
if (methodIndex < 0) { if (methodIndex < 0) {
return "REQUEST"; return "REQUEST";
@ -1644,9 +1618,8 @@ public class ExchangeSession {
* Get current Exchange alias name from login name * Get current Exchange alias name from login name
* *
* @return user name * @return user name
* @throws java.io.IOException on error
*/ */
protected String getAliasFromLogin() throws IOException { protected String getAliasFromLogin() {
// Exchange 2007 : userName is login without domain // Exchange 2007 : userName is login without domain
String userName = poolKey.userName; String userName = poolKey.userName;
int index = userName.indexOf('\\'); int index = userName.indexOf('\\');
@ -1710,9 +1683,8 @@ public class ExchangeSession {
* Get current user email * Get current user email
* *
* @return user email * @return user email
* @throws java.io.IOException on error
*/ */
public String getEmail() throws IOException { public String getEmail() {
return email; return email;
} }

View File

@ -10,7 +10,7 @@ import java.io.IOException;
*/ */
public class ICSBufferedReader extends BufferedReader { public class ICSBufferedReader extends BufferedReader {
protected String nextLine; protected String nextLine;
protected StringBuilder currentLine = new StringBuilder(75); protected final StringBuilder currentLine = new StringBuilder(75);
public ICSBufferedReader(Reader in, int sz) throws IOException { public ICSBufferedReader(Reader in, int sz) throws IOException {
super(in, sz); super(in, sz);

View File

@ -5,7 +5,7 @@ package davmail.exchange;
* split lines longer than 75 characters * split lines longer than 75 characters
*/ */
public class ICSBufferedWriter { public class ICSBufferedWriter {
StringBuilder buffer = new StringBuilder(); final StringBuilder buffer = new StringBuilder();
public void writeLine(String line) { public void writeLine(String line) {
if (line.length() > 75) { if (line.length() > 75) {

View File

@ -146,7 +146,7 @@ public class LdapConnection extends AbstractConnection {
/** /**
* For some unknow reaseon parseIntWithTag is private ! * For some unknow reaseon parseIntWithTag is private !
*/ */
static Method parseIntWithTag; static final Method parseIntWithTag;
static { static {
try { try {
@ -154,6 +154,7 @@ public class LdapConnection extends AbstractConnection {
parseIntWithTag.setAccessible(true); parseIntWithTag.setAccessible(true);
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
DavGatewayTray.error("Unable to get BerDecoder.parseIntWithTag method"); DavGatewayTray.error("Unable to get BerDecoder.parseIntWithTag method");
throw new RuntimeException(e);
} }
} }
@ -435,7 +436,7 @@ public class LdapConnection extends AbstractConnection {
if (reqBer.peekByte() == LDAP_FILTER_PRESENT) { if (reqBer.peekByte() == LDAP_FILTER_PRESENT) {
String attributeName = reqBer.parseStringWithTag(LDAP_FILTER_PRESENT, isLdapV3(), null).toLowerCase(); String attributeName = reqBer.parseStringWithTag(LDAP_FILTER_PRESENT, isLdapV3(), null).toLowerCase();
if ("objectclass".equals(attributeName)) { if ("objectclass".equals(attributeName)) {
criteria.put(attributeName, new SimpleFilter("*")); criteria.put(attributeName, new SimpleFilter());
} else { } else {
DavGatewayTray.warn("Unsupported filter"); DavGatewayTray.warn("Unsupported filter");
} }
@ -641,11 +642,12 @@ public class LdapConnection extends AbstractConnection {
} }
class SimpleFilter { class SimpleFilter {
String value; static final String STAR = "*";
int operator; final String value;
final int operator;
SimpleFilter(String value) { SimpleFilter() {
this.value = value; this.value = SimpleFilter.STAR;
this.operator = LDAP_FILTER_SUBSTRINGS; this.operator = LDAP_FILTER_SUBSTRINGS;
} }

View File

@ -10,9 +10,9 @@ import java.lang.reflect.Proxy;
*/ */
public class OSXAdapter implements InvocationHandler { public class OSXAdapter implements InvocationHandler {
protected Object targetObject; protected final Object targetObject;
protected Method targetMethod; protected final Method targetMethod;
protected String proxySignature; protected final String proxySignature;
static Object macOSXApplication; static Object macOSXApplication;