public class ExchangeFileSystem extends MailFileSystemBase<ExchangeMessageReference,ExchangeAttachmentReference,microsoft.exchange.webservices.data.core.ExchangeService> implements HasKeystore, HasTruststore
IBasicFileSystem
of an Exchange Mail Inbox.
https://outlook.office365.com/
in Azure AD -> App Registrations -> MyApp -> API Permissions.https://login.microsoftonline.com
. Required for token retrieval.
N.B. MS Exchange is susceptible to problems with invalid XML characters, like . To work around these problems, a special streaming XMLInputFactory is configured in METAINF/services/javax.xml.stream.XMLInputFactory as nl.nn.adapterframework.xml.StaxParserFactory
ExchangeMailListener
), Gerrit van Brakellog
BCC_RECEPIENTS_KEY, BEST_REPLY_ADDRESS_KEY, CC_RECEPIENTS_KEY, DATETIME_RECEIVED_KEY, DATETIME_SENT_KEY, FROM_ADDRESS_KEY, MAIL_MESSAGE_ID, REPLY_ADDRESS_FIELDS_DEFAULT, REPLY_TO_RECEPIENTS_KEY, RETURN_PATH_HEADER, SENDER_ADDRESS_KEY, TO_RECEPIENTS_KEY
Constructor and Description |
---|
ExchangeFileSystem() |
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
configure() |
ExchangeMessageReference |
copyFile(ExchangeMessageReference f,
String destinationFolder,
boolean createFolder,
boolean resultantMustBeReturned)
Copies the file to a another folder.
|
protected microsoft.exchange.webservices.data.core.ExchangeService |
createConnection()
Create a fresh connection to the FileSystem.
|
void |
createFolder(String folderName) |
void |
deleteFile(ExchangeMessageReference f) |
boolean |
exists(ExchangeMessageReference f) |
void |
extractAttachment(ExchangeAttachmentReference ref,
SaxElementBuilder attachmentsXml) |
void |
extractEmail(ExchangeMessageReference ref,
SaxElementBuilder emailXml) |
microsoft.exchange.webservices.data.property.complex.FolderId |
findFolder(ExchangeObjectReference reference) |
microsoft.exchange.webservices.data.property.complex.FolderId |
findFolder(microsoft.exchange.webservices.data.property.complex.FolderId baseFolderId,
String folderName)
find a folder for listFiles(), getNumberOfFilesInFolder(), folderExists.
|
boolean |
folderExists(String folder) |
void |
forwardMail(ExchangeMessageReference emailMessage,
String destination) |
Map<String,Object> |
getAdditionalAttachmentProperties(ExchangeAttachmentReference ref) |
Map<String,Object> |
getAdditionalFileProperties(ExchangeMessageReference f) |
String |
getAttachmentContentType(ExchangeAttachmentReference a) |
String |
getAttachmentFileName(ExchangeAttachmentReference ref) |
String |
getAttachmentName(ExchangeAttachmentReference a) |
long |
getAttachmentSize(ExchangeAttachmentReference a) |
microsoft.exchange.webservices.data.property.complex.FolderId |
getBaseFolderId(String emailAddress,
String baseFolderName) |
String |
getCanonicalName(ExchangeMessageReference f) |
protected Date |
getDateTimeReceived(microsoft.exchange.webservices.data.core.service.item.EmailMessage emailMessage) |
protected Date |
getDateTimeSent(microsoft.exchange.webservices.data.core.service.item.EmailMessage emailMessage) |
ExchangeMessageReference |
getFileFromAttachment(ExchangeAttachmentReference ref) |
long |
getFileSize(ExchangeMessageReference f) |
protected String |
getFrom(microsoft.exchange.webservices.data.core.service.item.EmailMessage emailMessage) |
Message |
getMimeContent(ExchangeMessageReference ref) |
Date |
getModificationTime(ExchangeMessageReference f) |
String |
getName(ExchangeMessageReference f)
Get a string representation of an identification of a file.
|
int |
getNumberOfFilesInFolder(String foldername) |
String |
getParentFolder(ExchangeMessageReference f) |
String |
getPhysicalDestinationName() |
protected List<String> |
getReplyTo(microsoft.exchange.webservices.data.core.service.item.EmailMessage emailMessage) |
protected String |
getSender(microsoft.exchange.webservices.data.core.service.item.EmailMessage emailMessage) |
String |
getSubject(ExchangeMessageReference ref) |
Iterator<ExchangeAttachmentReference> |
listAttachments(ExchangeMessageReference f) |
DirectoryStream<ExchangeMessageReference> |
listFiles(String folder)
Lists all files in 'folder' or in the 'root' of the filesystem (when folder is null).
|
ExchangeMessageReference |
moveFile(ExchangeMessageReference f,
String destinationFolder,
boolean createFolder,
boolean resultantMustBeReturned)
Moves the file to a another folder.
|
void |
open() |
Message |
readAttachment(ExchangeAttachmentReference ref) |
Message |
readFile(ExchangeMessageReference f,
String charset) |
protected void |
releaseConnection(microsoft.exchange.webservices.data.core.ExchangeService service,
boolean invalidateConnectionOnRelease)
Release the connection, return it to the pool or invalidate it.
|
void |
removeFolder(String folderName,
boolean removeNonEmptyFolder) |
void |
setAuthAlias(String authAlias)
Alias used to obtain client ID and secret or username and password for authentication to Exchange mail server.
|
void |
setClientId(String clientId)
Client ID that represents a registered application in Azure AD which could be found at Azure AD -> App Registrations -> MyApp -> Overview.
|
void |
setClientSecret(String clientSecret)
Client secret that belongs to registered application in Azure AD which could be found at Azure AD -> App Registrations -> MyApp -> Certificates and Secrets
|
void |
setFilter(String filter)
If empty, all mails are retrieved.
|
void |
setMailAddress(String mailAddress)
The mail address of the mailbox connected to (also used for auto discovery)
|
void |
setMailboxObjectSeparator(String separator)
Separator character used when working with multiple mailboxes, specified before the separator in the object name
test@organisation.com|My sub folder or test@organisation.com|AAMkADljZDMxYzIzLTFlMjYtNGY4Mi1hM2Y1LTc2MjE5ZjIyZmMyNABGAAAAAAAu/9EmV5M6QokBRZwID1Q6BwDXQXY+F44hRbDfTB9v8jRfAAAEUqUVAADXQXY+F44hRbDfTB9v8jRfAAKA4F+pAAA= . |
void |
setPassword(String password)
Deprecated.
|
void |
setProxyAuthAlias(String proxyAuthAlias)
proxy authAlias
|
void |
setProxyDomain(String proxyDomain)
proxy domain
|
void |
setProxyHost(String proxyHost)
proxy host
|
void |
setProxyPassword(String proxyPassword)
proxy password
|
void |
setProxyPort(int proxyPort)
proxy port
|
void |
setProxyUsername(String proxyUsername)
proxy username
|
void |
setTenantId(String tenantId)
Tenant ID that represents the tenant in which the registered application exists within Azure AD which could be found at Azure AD -> App Registrations -> MyApp -> Overview.
|
void |
setUrl(String url)
Url of the Exchange server.
|
void |
setUsername(String username)
Deprecated.
|
void |
setValidateAllRedirectUrls(boolean validateAllRedirectUrls)
When
true , all redirect uris are accepted when connecting to the server |
ExchangeMessageReference |
toFile(String filename)
Get a file 'F' representation of an identification of a file.
|
ExchangeMessageReference |
toFile(String folder,
String filename)
Creates a reference to a file.
|
setBaseFolder, setReadMimeContents, setReplyAddressFields
closeConnection, getConnection, pendingRelease
getMaxNumberOfMessagesToList, isOpen, setMaxNumberOfMessagesToList
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getKeyManagerAlgorithm, getKeystore, getKeystoreAlias, getKeystoreAliasAuthAlias, getKeystoreAliasPassword, getKeystoreAuthAlias, getKeystorePassword, getKeystoreType, setKeyManagerAlgorithm, setKeystore, setKeystoreAlias, setKeystoreAliasAuthAlias, setKeystoreAliasPassword, setKeystoreAuthAlias, setKeystorePassword, setKeystoreType
getApplicationContext, getName
getConfigurationClassLoader
setApplicationContext
getTrustManagerAlgorithm, getTruststore, getTruststoreAuthAlias, getTruststorePassword, getTruststoreType, isAllowSelfSignedCertificates, isIgnoreCertificateExpiredException, isVerifyHostname, setAllowSelfSignedCertificates, setIgnoreCertificateExpiredException, setTrustManagerAlgorithm, setTruststore, setTruststoreAuthAlias, setTruststorePassword, setTruststoreType, setVerifyHostname
getReplyAddressFields
isOpen
getDomain
public void configure() throws ConfigurationException
configure
in interface IBasicFileSystem<ExchangeMessageReference>
ConfigurationException
public void open() throws FileSystemException
open
in interface IBasicFileSystem<ExchangeMessageReference>
open
in class ConnectedFileSystemBase<ExchangeMessageReference,microsoft.exchange.webservices.data.core.ExchangeService>
FileSystemException
public void close() throws FileSystemException
close
in interface IBasicFileSystem<ExchangeMessageReference>
close
in class ConnectedFileSystemBase<ExchangeMessageReference,microsoft.exchange.webservices.data.core.ExchangeService>
FileSystemException
public microsoft.exchange.webservices.data.property.complex.FolderId getBaseFolderId(String emailAddress, String baseFolderName) throws FileSystemException
FileSystemException
protected microsoft.exchange.webservices.data.core.ExchangeService createConnection() throws FileSystemException
ConnectedFileSystemBase
createConnection
in class ConnectedFileSystemBase<ExchangeMessageReference,microsoft.exchange.webservices.data.core.ExchangeService>
FileSystemException
public microsoft.exchange.webservices.data.property.complex.FolderId findFolder(ExchangeObjectReference reference) throws FileSystemException
FileSystemException
public microsoft.exchange.webservices.data.property.complex.FolderId findFolder(microsoft.exchange.webservices.data.property.complex.FolderId baseFolderId, String folderName) throws FileSystemException
FileSystemException
public ExchangeMessageReference toFile(String filename) throws FileSystemException
IBasicFileSystem
IBasicFileSystem.getName(Object)
.toFile
in interface IBasicFileSystem<ExchangeMessageReference>
FileSystemException
public ExchangeMessageReference toFile(String folder, String filename) throws FileSystemException
IBasicFileSystem
toFile
in interface IBasicFileSystem<ExchangeMessageReference>
FileSystemException
public boolean exists(ExchangeMessageReference f) throws FileSystemException
exists
in interface IBasicFileSystem<ExchangeMessageReference>
FileSystemException
public DirectoryStream<ExchangeMessageReference> listFiles(String folder) throws FileSystemException
IBasicFileSystem
listFiles
in interface IBasicFileSystem<ExchangeMessageReference>
FileSystemException
public int getNumberOfFilesInFolder(String foldername) throws FileSystemException
getNumberOfFilesInFolder
in interface IBasicFileSystem<ExchangeMessageReference>
getNumberOfFilesInFolder
in class FileSystemBase<ExchangeMessageReference>
FileSystemException
public boolean folderExists(String folder) throws FileSystemException
folderExists
in interface IBasicFileSystem<ExchangeMessageReference>
FileSystemException
public Message readFile(ExchangeMessageReference f, String charset) throws FileSystemException, IOException
readFile
in interface IBasicFileSystem<ExchangeMessageReference>
FileSystemException
IOException
public void deleteFile(ExchangeMessageReference f) throws FileSystemException
deleteFile
in interface IBasicFileSystem<ExchangeMessageReference>
FileSystemException
public ExchangeMessageReference moveFile(ExchangeMessageReference f, String destinationFolder, boolean createFolder, boolean resultantMustBeReturned) throws FileSystemException
IBasicFileSystem
resultantMustBeReturned
is set, then an Exception must be thrown, preferably before the file is moved;resultantMustBeReturned
is not set, then a null result returned might also mean the file was moved successfully, but with unknown destination;moveFile
in interface IBasicFileSystem<ExchangeMessageReference>
resultantMustBeReturned
- TODOFileSystemException
public ExchangeMessageReference copyFile(ExchangeMessageReference f, String destinationFolder, boolean createFolder, boolean resultantMustBeReturned) throws FileSystemException
IBasicFileSystem
resultantMustBeReturned
is set, then an Exception must be thrown, preferably before the file is copied;resultantMustBeReturned
is not set, then a null result returned might also mean the file was copied successfully, but with unknown destination;copyFile
in interface IBasicFileSystem<ExchangeMessageReference>
resultantMustBeReturned
- TODOFileSystemException
public long getFileSize(ExchangeMessageReference f) throws FileSystemException
getFileSize
in interface IBasicFileSystem<ExchangeMessageReference>
FileSystemException
public String getName(ExchangeMessageReference f)
IBasicFileSystem
IBasicFileSystem.toFile(String)
.
Can reflect name a file has in its folder, is not expected to be unique over folders.getName
in interface IBasicFileSystem<ExchangeMessageReference>
public String getParentFolder(ExchangeMessageReference f) throws FileSystemException
getParentFolder
in interface IBasicFileSystem<ExchangeMessageReference>
FileSystemException
public String getCanonicalName(ExchangeMessageReference f) throws FileSystemException
getCanonicalName
in interface IBasicFileSystem<ExchangeMessageReference>
FileSystemException
public Date getModificationTime(ExchangeMessageReference f) throws FileSystemException
getModificationTime
in interface IBasicFileSystem<ExchangeMessageReference>
FileSystemException
public Map<String,Object> getAdditionalFileProperties(ExchangeMessageReference f) throws FileSystemException
getAdditionalFileProperties
in interface IBasicFileSystem<ExchangeMessageReference>
FileSystemException
public void forwardMail(ExchangeMessageReference emailMessage, String destination) throws FileSystemException
forwardMail
in interface IMailFileSystem<ExchangeMessageReference,ExchangeAttachmentReference>
FileSystemException
public Iterator<ExchangeAttachmentReference> listAttachments(ExchangeMessageReference f) throws FileSystemException
listAttachments
in interface IWithAttachments<ExchangeMessageReference,ExchangeAttachmentReference>
FileSystemException
public String getAttachmentName(ExchangeAttachmentReference a)
getAttachmentName
in interface IWithAttachments<ExchangeMessageReference,ExchangeAttachmentReference>
public Message readAttachment(ExchangeAttachmentReference ref) throws FileSystemException, IOException
readAttachment
in interface IWithAttachments<ExchangeMessageReference,ExchangeAttachmentReference>
FileSystemException
IOException
public ExchangeMessageReference getFileFromAttachment(ExchangeAttachmentReference ref) throws FileSystemException
getFileFromAttachment
in interface IWithAttachments<ExchangeMessageReference,ExchangeAttachmentReference>
FileSystemException
public long getAttachmentSize(ExchangeAttachmentReference a) throws FileSystemException
getAttachmentSize
in interface IWithAttachments<ExchangeMessageReference,ExchangeAttachmentReference>
FileSystemException
public String getAttachmentContentType(ExchangeAttachmentReference a) throws FileSystemException
getAttachmentContentType
in interface IWithAttachments<ExchangeMessageReference,ExchangeAttachmentReference>
FileSystemException
public String getAttachmentFileName(ExchangeAttachmentReference ref) throws FileSystemException
getAttachmentFileName
in interface IWithAttachments<ExchangeMessageReference,ExchangeAttachmentReference>
FileSystemException
public Map<String,Object> getAdditionalAttachmentProperties(ExchangeAttachmentReference ref) throws FileSystemException
getAdditionalAttachmentProperties
in interface IWithAttachments<ExchangeMessageReference,ExchangeAttachmentReference>
FileSystemException
public void createFolder(String folderName) throws FileSystemException
createFolder
in interface IBasicFileSystem<ExchangeMessageReference>
FileSystemException
public void removeFolder(String folderName, boolean removeNonEmptyFolder) throws FileSystemException
removeFolder
in interface IBasicFileSystem<ExchangeMessageReference>
FileSystemException
protected String getFrom(microsoft.exchange.webservices.data.core.service.item.EmailMessage emailMessage)
protected String getSender(microsoft.exchange.webservices.data.core.service.item.EmailMessage emailMessage)
protected List<String> getReplyTo(microsoft.exchange.webservices.data.core.service.item.EmailMessage emailMessage)
protected Date getDateTimeSent(microsoft.exchange.webservices.data.core.service.item.EmailMessage emailMessage)
protected Date getDateTimeReceived(microsoft.exchange.webservices.data.core.service.item.EmailMessage emailMessage)
public String getSubject(ExchangeMessageReference ref) throws FileSystemException
getSubject
in interface IMailFileSystem<ExchangeMessageReference,ExchangeAttachmentReference>
FileSystemException
public Message getMimeContent(ExchangeMessageReference ref) throws FileSystemException
getMimeContent
in interface IMailFileSystem<ExchangeMessageReference,ExchangeAttachmentReference>
FileSystemException
public void extractEmail(ExchangeMessageReference ref, SaxElementBuilder emailXml) throws FileSystemException
extractEmail
in interface IMailFileSystem<ExchangeMessageReference,ExchangeAttachmentReference>
FileSystemException
public void extractAttachment(ExchangeAttachmentReference ref, SaxElementBuilder attachmentsXml) throws FileSystemException
extractAttachment
in interface IMailFileSystem<ExchangeMessageReference,ExchangeAttachmentReference>
FileSystemException
public String getPhysicalDestinationName()
getPhysicalDestinationName
in interface HasPhysicalDestination
getPhysicalDestinationName
in class MailFileSystemBase<ExchangeMessageReference,ExchangeAttachmentReference,microsoft.exchange.webservices.data.core.ExchangeService>
protected void releaseConnection(microsoft.exchange.webservices.data.core.ExchangeService service, boolean invalidateConnectionOnRelease)
ConnectedFileSystemBase
releaseConnection
in class ConnectedFileSystemBase<ExchangeMessageReference,microsoft.exchange.webservices.data.core.ExchangeService>
public void setMailAddress(String mailAddress)
public void setValidateAllRedirectUrls(boolean validateAllRedirectUrls)
true
, all redirect uris are accepted when connecting to the serverpublic void setUrl(String url)
public void setClientId(String clientId)
public void setClientSecret(String clientSecret)
public void setTenantId(String tenantId)
public void setAuthAlias(String authAlias)
setAuthAlias
in class MailFileSystemBase<ExchangeMessageReference,ExchangeAttachmentReference,microsoft.exchange.webservices.data.core.ExchangeService>
@Deprecated @ConfigurationWarning(value="Authentication to Exchange Web Services with username and password will be disabled 2021-Q3. Please migrate to modern authentication using clientId and clientSecret!") public void setUsername(String username)
setUsername
in class MailFileSystemBase<ExchangeMessageReference,ExchangeAttachmentReference,microsoft.exchange.webservices.data.core.ExchangeService>
@Deprecated @ConfigurationWarning(value="Authentication to Exchange Web Services with username and password will be disabled 2021-Q3. Please migrate to modern authentication using clientId and clientSecret!") public void setPassword(String password)
setPassword
in class MailFileSystemBase<ExchangeMessageReference,ExchangeAttachmentReference,microsoft.exchange.webservices.data.core.ExchangeService>
public void setFilter(String filter)
NDR
only Non-Delivery Report mails ('bounces') are retrievedpublic void setProxyHost(String proxyHost)
public void setProxyPort(int proxyPort)
public void setProxyUsername(String proxyUsername)
public void setProxyPassword(String proxyPassword)
public void setProxyAuthAlias(String proxyAuthAlias)
public void setProxyDomain(String proxyDomain)
public void setMailboxObjectSeparator(String separator)
test@organisation.com|My sub folder
or test@organisation.com|AAMkADljZDMxYzIzLTFlMjYtNGY4Mi1hM2Y1LTc2MjE5ZjIyZmMyNABGAAAAAAAu/9EmV5M6QokBRZwID1Q6BwDXQXY+F44hRbDfTB9v8jRfAAAEUqUVAADXQXY+F44hRbDfTB9v8jRfAAKA4F+pAAA=
.
Please consider when moving emails across mailboxes that there will be a null value returned instead of the newly created identifier.Copyright © 2023 Frank!Framework. All rights reserved.