mirror of
https://github.com/moparisthebest/davmail
synced 2024-12-13 03:02:22 -05:00
IMAP: throw error on 440 Login Timeout to avoid message corruption
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1538 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
12e047b6e2
commit
90d6648413
35
src/java/davmail/exception/LoginTimeoutException.java
Normal file
35
src/java/davmail/exception/LoginTimeoutException.java
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* DavMail POP/IMAP/SMTP/CalDav/LDAP Exchange Gateway
|
||||
* Copyright (C) 2009 Mickael Guessant
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
package davmail.exception;
|
||||
|
||||
import org.apache.commons.httpclient.HttpException;
|
||||
|
||||
/**
|
||||
* HttpException with 440 login timeout status.
|
||||
*/
|
||||
public class LoginTimeoutException extends HttpException {
|
||||
/**
|
||||
* HttpException with 550 login timeout status.
|
||||
*
|
||||
* @param message exception message
|
||||
*/
|
||||
public LoginTimeoutException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
@ -2435,6 +2435,10 @@ public class DavExchangeSession extends ExchangeSession {
|
||||
contentInputStream.close();
|
||||
}
|
||||
|
||||
} catch (LoginTimeoutException e) {
|
||||
// throw error on expired session
|
||||
LOGGER.warn(e.getMessage());
|
||||
throw e;
|
||||
} catch (IOException e) {
|
||||
LOGGER.warn("Broken message at: " + message.messageUrl + " permanentUrl: " + message.permanentUrl + ", trying to rebuild from properties");
|
||||
|
||||
|
@ -631,10 +631,6 @@ public final class DavGatewayHttpClientFacade {
|
||||
*/
|
||||
public static HttpException buildHttpException(HttpMethod method) {
|
||||
int status = method.getStatusCode();
|
||||
// 440 means forbidden on Exchange
|
||||
if (status == 440) {
|
||||
status = HttpStatus.SC_FORBIDDEN;
|
||||
}
|
||||
StringBuilder message = new StringBuilder();
|
||||
message.append(status).append(' ').append(method.getStatusText());
|
||||
try {
|
||||
@ -645,7 +641,10 @@ public final class DavGatewayHttpClientFacade {
|
||||
} catch (URIException e) {
|
||||
message.append(method.getPath());
|
||||
}
|
||||
if (status == HttpStatus.SC_FORBIDDEN) {
|
||||
// 440 means forbidden on Exchange
|
||||
if (status == 440) {
|
||||
return new LoginTimeoutException(message.toString());
|
||||
} else if (status == HttpStatus.SC_FORBIDDEN) {
|
||||
return new HttpForbiddenException(message.toString());
|
||||
} else if (status == HttpStatus.SC_NOT_FOUND) {
|
||||
return new HttpNotFoundException(message.toString());
|
||||
|
Loading…
Reference in New Issue
Block a user