Package davmail.exchange.auth
Class ExchangeFormAuthenticator
java.lang.Object
davmail.exchange.auth.ExchangeFormAuthenticator
- All Implemented Interfaces:
ExchangeAuthenticator
New Exchange form authenticator based on HttpClient 4.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final org.apache.log4j.LoggerVarious password fields found on custom Exchange authentication formsVarious OTP (one time password) fields found on custom Exchange authentication forms.Various username fields found on custom Exchange authentication forms -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAuthenticate against Exchange or O365protected PostRequestbuildLogonMethod(HttpClientAdapter httpClient, ResponseWrapper responseWrapper) Try to find the logon method path from the logon form body.protected voidcheckFormLoginQueryString(ResponseWrapper logonMethod) voidclose()Close session.protected voidformLogin(HttpClientAdapter httpClient, ResponseWrapper initRequest, String password) protected URIgetAbsoluteUri(URI uri, String path) Get the current Exchange alias name from the login nameBase Exchange URL.Return authenticated HttpClient 4 HttpClientAdapterprotected URIgetScriptBasedFormURL(URI uri, String pathQuery) getToken()Oauth token.Actual username.protected booleanisAuthenticated(ResponseWrapper getRequest) Look for session cookies.protected booleanisHttpAuthentication(HttpClientAdapter httpClient, String url) Test authentication mode: form-based or basic.protected ResponseWrapperpostLogonMethod(HttpClientAdapter httpClient, PostRequest logonMethod, String password) protected voidsetAuthFormFields(org.apache.http.client.methods.HttpRequestBase logonMethod, HttpClientAdapter httpClient, String password) voidsetPassword(String password) voidvoidsetUsername(String username) protected ResponseWrappersubmitLanguageSelectionForm(URI uri, String responseBodyAsString) protected void
-
Field Details
-
LOGGER
protected static final org.apache.log4j.Logger LOGGER -
USER_NAME_FIELDS
Various username fields found on custom Exchange authentication forms -
PASSWORD_FIELDS
Various password fields found on custom Exchange authentication forms -
TOKEN_FIELDS
Various OTP (one time password) fields found on custom Exchange authentication forms. Used to open an OTP dialog
-
-
Constructor Details
-
ExchangeFormAuthenticator
public ExchangeFormAuthenticator()
-
-
Method Details
-
setUsername
- Specified by:
setUsernamein interfaceExchangeAuthenticator
-
setPassword
- Specified by:
setPasswordin interfaceExchangeAuthenticator
-
setUrl
-
authenticate
Description copied from interface:ExchangeAuthenticatorAuthenticate against Exchange or O365- Specified by:
authenticatein interfaceExchangeAuthenticator- Throws:
DavMailException
-
isHttpAuthentication
Test authentication mode: form-based or basic.- Parameters:
httpClient- httpClientAdapter instanceurl- exchange base URL- Returns:
- true if basic authentication detected
-
isAuthenticated
Look for session cookies.- Returns:
- true if session cookies are available
-
formLogin
protected void formLogin(HttpClientAdapter httpClient, ResponseWrapper initRequest, String password) throws IOException - Throws:
IOException
-
buildLogonMethod
protected PostRequest buildLogonMethod(HttpClientAdapter httpClient, ResponseWrapper responseWrapper) Try to find the logon method path from the logon form body.- Parameters:
httpClient- httpClientAdapter instanceresponseWrapper- init request response wrapper- Returns:
- logon method
-
postLogonMethod
protected ResponseWrapper postLogonMethod(HttpClientAdapter httpClient, PostRequest logonMethod, String password) throws IOException - Throws:
IOException
-
submitLanguageSelectionForm
protected ResponseWrapper submitLanguageSelectionForm(URI uri, String responseBodyAsString) throws IOException - Throws:
IOException
-
setAuthFormFields
protected void setAuthFormFields(org.apache.http.client.methods.HttpRequestBase logonMethod, HttpClientAdapter httpClient, String password) throws IllegalArgumentException - Throws:
IllegalArgumentException
-
getAbsoluteUri
- Throws:
URISyntaxException
-
getScriptBasedFormURL
protected URI getScriptBasedFormURL(URI uri, String pathQuery) throws URISyntaxException, IOException - Throws:
URISyntaxExceptionIOException
-
checkFormLoginQueryString
protected void checkFormLoginQueryString(ResponseWrapper logonMethod) throws DavMailAuthenticationException - Throws:
DavMailAuthenticationException
-
throwAuthenticationFailed
- Throws:
DavMailAuthenticationException
-
getAliasFromLogin
Get the current Exchange alias name from the login name- Returns:
- user name
-
close
public void close()Close session. Shutdown http client connection manager -
getToken
Oauth token. Only for Office 365 authenticators- Specified by:
getTokenin interfaceExchangeAuthenticator- Returns:
- unsupported
-
getExchangeUri
Base Exchange URL. Welcome page for Exchange 2003, EWS url for Exchange 2007 and later- Specified by:
getExchangeUriin interfaceExchangeAuthenticator- Returns:
- Exchange url
-
getHttpClientAdapter
Return authenticated HttpClient 4 HttpClientAdapter- Specified by:
getHttpClientAdapterin interfaceExchangeAuthenticator- Returns:
- HttpClientAdapter instance
-
getUsername
Actual username. can be different from the input username with preauth- Returns:
- username
-