Package org.ametys.plugins.zimbra
Class ZimbraConnector
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.plugins.messagingconnector.AbstractMessagingConnector
org.ametys.plugins.zimbra.ZimbraConnector
- All Implemented Interfaces:
MessagingConnector
,LogEnabled
,Disposable
,Initializable
,Component
,Serviceable
The connector used by the messaging connector plugin when the zimbra mail
server is used. Implements the methods of the MessagingConnector interface in
order to get the informations from the mail server.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.ametys.plugins.messagingconnector.MessagingConnector
MessagingConnector.AttendeeInformation, MessagingConnector.FreeBusyStatus, MessagingConnector.ResponseType
-
Field Summary
Modifier and TypeFieldDescriptionprotected RequestConfig
The shared configuration for request (for timeout purposes)protected ConnectionKeepAliveStrategy
The keep-alive stragegy to optimize http clientsprotected PoolingHttpClientConnectionManager
Request to the remote app will be ppoled for perfs purposesprotected String
Preauth secret keyprotected static final int
The number of seconds after what kept alive connections are droptprotected JSONUtils
The JSON Utilsprotected UserManager
The user managerprotected String
Url to zimbrastatic final String
token cache idFields inherited from class org.ametys.plugins.messagingconnector.AbstractMessagingConnector
_cacheManager, _cryptoHelper, _currentUserProvider, _userPopulationDAO, _userPref
Fields inherited from interface org.ametys.plugins.messagingconnector.MessagingConnector
ROLE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
_doPreauthRequest
(UserIdentity userIdentity) Zimbra preauth request to log the current user into zimbra and retrieve the ZM_AUTH_TOKENprotected CloseableHttpClient
Get a new pooled http client.void
dispose()
void
protected List<EmailMessage>
internalGetEmails
(UserIdentity userIdentity, int maxEmails) Get emails (no caching)protected int
internalGetEmailsCount
(UserIdentity userIdentity) Get emails count (no caching)protected List<CalendarEvent>
internalGetEvents
(UserIdentity userIdentity, int maxDays, int maxEvents) Get upcoming events (no caching)protected int
internalGetEventsCount
(UserIdentity userIdentity, int maxDays) Get upcoming events count (no caching)void
redirect
(Redirector redirector, String targetApp) Preauth user and redirect to the zimbra applicationvoid
service
(ServiceManager smanager) Methods inherited from class org.ametys.plugins.messagingconnector.AbstractMessagingConnector
createEvent, deleteEvent, getAllowedPopulationIds, getAttendees, getEvents, getEventsCount, getFreeBusy, getUnreadEmailCount, getUnreadEmails, getUserCryptedPassword, getUserPassword, internalCreateEvent, internalDeleteEvent, internalGetAttendees, internalGetFreeBusy, internalIsEventExist, internalSetAttendees, internalUpdateEvent, isAllowed, isEventExist, isUserExist, setAttendees, setUserPassword, supportInvitation, supportUserCredential, updateEvent, userCredentialNeeded
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
TOKEN_CACHE
token cache id -
_DROP_KEPTALIVE_CONNECTION_AFTER
The number of seconds after what kept alive connections are dropt- See Also:
-
_usersManager
The user manager -
_jsonUtils
The JSON Utils -
_zimbraUrl
Url to zimbra -
_domainPreauthSecretKey
Preauth secret key -
_connectionManager
Request to the remote app will be ppoled for perfs purposes -
_connectionKeepAliveStrategy
The keep-alive stragegy to optimize http clients -
_connectionConfig
The shared configuration for request (for timeout purposes)
-
-
Constructor Details
-
ZimbraConnector
public ZimbraConnector()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAbstractMessagingConnector
- Throws:
ServiceException
-
initialize
- Specified by:
initialize
in interfaceInitializable
- Overrides:
initialize
in classAbstractMessagingConnector
-
dispose
- Specified by:
dispose
in interfaceDisposable
-
_getHttpClient
Get a new pooled http client. Do not forget to close it.- Returns:
- The client
-
redirect
public void redirect(Redirector redirector, String targetApp) throws ProcessingException, IOException Preauth user and redirect to the zimbra application- Parameters:
redirector
- The redirectortargetApp
- The zimbra application (ex: mail)- Throws:
ProcessingException
- if failed to redirectIOException
- if failed to redirect
-
_doPreauthRequest
Zimbra preauth request to log the current user into zimbra and retrieve the ZM_AUTH_TOKEN- Parameters:
userIdentity
- The user for which the preauth request will be done.- Returns:
- The Zimbra token which can be used in future request made through the Zimbra REST API or
null
if user is null or has no email. - Throws:
MessagingConnectorException
- if failed to get zimbra token for user
-
internalGetEvents
protected List<CalendarEvent> internalGetEvents(UserIdentity userIdentity, int maxDays, int maxEvents) throws MessagingConnectorException Description copied from class:AbstractMessagingConnector
Get upcoming events (no caching)- Specified by:
internalGetEvents
in classAbstractMessagingConnector
- Parameters:
userIdentity
- The user identitymaxDays
- The maximum number of days to search formaxEvents
- The maximum number of events to retrieve- Returns:
- The calendar events
- Throws:
MessagingConnectorException
- if failed to get events from server
-
internalGetEventsCount
protected int internalGetEventsCount(UserIdentity userIdentity, int maxDays) throws MessagingConnectorException Description copied from class:AbstractMessagingConnector
Get upcoming events count (no caching)- Specified by:
internalGetEventsCount
in classAbstractMessagingConnector
- Parameters:
userIdentity
- The user identitymaxDays
- The maximum number of days to search for- Returns:
- The number of calendar events
- Throws:
MessagingConnectorException
- if failed to get events from server
-
internalGetEmails
protected List<EmailMessage> internalGetEmails(UserIdentity userIdentity, int maxEmails) throws MessagingConnectorException Description copied from class:AbstractMessagingConnector
Get emails (no caching)- Specified by:
internalGetEmails
in classAbstractMessagingConnector
- Parameters:
userIdentity
- The user identitymaxEmails
- The maximum number of emails to retrieve- Returns:
- The emails
- Throws:
MessagingConnectorException
- if failed to get events from server
-
internalGetEmailsCount
Description copied from class:AbstractMessagingConnector
Get emails count (no caching)- Specified by:
internalGetEmailsCount
in classAbstractMessagingConnector
- Parameters:
userIdentity
- The user identity- Returns:
- The emails count
- Throws:
MessagingConnectorException
- if failed to get events from server
-