mirror of
https://github.com/moparisthebest/davmail
synced 2025-01-05 18:58:02 -05:00
Implement ISA server PINsafeISAFilter support (captcha image)
git-svn-id: http://svn.code.sf.net/p/davmail/code/trunk@1882 3d1905a2-6b24-0410-a738-b14d5a86fcbd
This commit is contained in:
parent
f2a09a4498
commit
24b842bafe
@ -38,12 +38,14 @@ import org.htmlcleaner.ContentToken;
|
||||
import org.htmlcleaner.HtmlCleaner;
|
||||
import org.htmlcleaner.TagNode;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import javax.mail.internet.MimeMultipart;
|
||||
import javax.mail.internet.MimePart;
|
||||
import javax.mail.util.SharedByteArrayInputStream;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.net.NoRouteToHostException;
|
||||
import java.net.UnknownHostException;
|
||||
@ -400,6 +402,24 @@ public abstract class ExchangeSession {
|
||||
} else if (TOKEN_FIELDS.contains(name)) {
|
||||
// one time password, ask user
|
||||
((PostMethod) logonMethod).addParameter(name, DavGatewayOTPPrompt.getOneTimePassword());
|
||||
} else if ("otc".equals(name)) {
|
||||
// captcha image, get image and ask user
|
||||
String pinsafeUser = getAliasFromLogin();
|
||||
if (pinsafeUser == null) {
|
||||
pinsafeUser = userName;
|
||||
}
|
||||
GetMethod getMethod = new GetMethod("/PINsafeISAFilter.dll?username="+pinsafeUser);
|
||||
try {
|
||||
int status = httpClient.executeMethod(getMethod);
|
||||
if (status != HttpStatus.SC_OK) {
|
||||
throw DavGatewayHttpClientFacade.buildHttpException(getMethod);
|
||||
}
|
||||
BufferedImage captchaImage = ImageIO.read(getMethod.getResponseBodyAsStream());
|
||||
((PostMethod) logonMethod).addParameter(name, DavGatewayOTPPrompt.getCaptchaValue(captchaImage));
|
||||
|
||||
} finally {
|
||||
getMethod.releaseConnection();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -21,6 +21,8 @@ package davmail.http;
|
||||
import davmail.BundleMessage;
|
||||
import davmail.ui.PasswordPromptDialog;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* Ask user one time password.
|
||||
*/
|
||||
@ -37,4 +39,15 @@ public final class DavGatewayOTPPrompt {
|
||||
PasswordPromptDialog passwordPromptDialog = new PasswordPromptDialog(BundleMessage.format("UI_OTP_PASSWORD_PROMPT"));
|
||||
return String.valueOf(passwordPromptDialog.getPassword());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ask user captcha value
|
||||
*
|
||||
* @param captchaImage captcha image
|
||||
* @return user provided one time password
|
||||
*/
|
||||
public static String getCaptchaValue(Image captchaImage) {
|
||||
PasswordPromptDialog passwordPromptDialog = new PasswordPromptDialog(BundleMessage.format("UI_CAPTCHA_PROMPT"), captchaImage);
|
||||
return String.valueOf(passwordPromptDialog.getPassword());
|
||||
}
|
||||
}
|
||||
|
@ -52,6 +52,16 @@ public class PasswordPromptDialog extends JDialog {
|
||||
* @param prompt password prompt from PKCS11 module
|
||||
*/
|
||||
public PasswordPromptDialog(String prompt) {
|
||||
this(prompt, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get smartcard password.
|
||||
*
|
||||
* @param prompt password prompt from PKCS11 module
|
||||
* @param captchaImage ISA filter pinsafe image
|
||||
*/
|
||||
public PasswordPromptDialog(String prompt, Image captchaImage) {
|
||||
setAlwaysOnTop(true);
|
||||
|
||||
setTitle(BundleMessage.format("UI_PASSWORD_PROMPT"));
|
||||
@ -78,8 +88,13 @@ public class PasswordPromptDialog extends JDialog {
|
||||
});
|
||||
JPanel passwordPanel = new JPanel();
|
||||
passwordPanel.setLayout(new BoxLayout(passwordPanel, BoxLayout.Y_AXIS));
|
||||
if (captchaImage != null) {
|
||||
JLabel captchaLabel = new JLabel(new ImageIcon(captchaImage));
|
||||
captchaLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
|
||||
passwordPanel.add(captchaLabel);
|
||||
}
|
||||
passwordPanel.add(passwordField);
|
||||
//questionPanel.add(passwordField);
|
||||
|
||||
add(questionPanel, BorderLayout.NORTH);
|
||||
add(passwordPanel, BorderLayout.CENTER);
|
||||
add(getButtonPanel(), BorderLayout.SOUTH);
|
||||
|
@ -243,6 +243,7 @@ LOG_FOLDER_NOT_FOUND=Folder {0} not found
|
||||
LOG_FOLDER_ACCESS_FORBIDDEN=Folder access to {0} forbidden
|
||||
LOG_FOLDER_ACCESS_ERROR=Folder access to {0} error: {1}
|
||||
UI_OTP_PASSWORD_PROMPT=One Time (token) Password:
|
||||
UI_CAPTCHA_PROMPT=Enter image value:
|
||||
UI_TAB_LOGGING=Logging
|
||||
UI_OTHER=Other
|
||||
UI_CALDAV_ALARM_SOUND=Caldav alarm sound:
|
||||
|
@ -234,6 +234,7 @@ LOG_FOLDER_ACCESS_FORBIDDEN=Acc
|
||||
LOG_FOLDER_NOT_FOUND=Dossier {0} introuvable
|
||||
LOG_FOLDER_ACCESS_ERROR=Erreur lors de l''accès au dossier {0} : {1}
|
||||
UI_OTP_PASSWORD_PROMPT=Mot de passe du jeton :
|
||||
UI_CAPTCHA_PROMPT=Valeur de l''image :
|
||||
EXCEPTION_SESSION_EXPIRED=Session Exchange expirée
|
||||
UI_CLIENT_KEY_STORE_TYPE=Type de stockage :
|
||||
UI_CLIENT_KEY_STORE_TYPE_HELP=Choisir le type de stockage du certificat client, PKCS11 pour une carte à puce
|
||||
|
Loading…
Reference in New Issue
Block a user