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
FieldsModifier and TypeFieldDescriptionprotected RequestConfigThe shared configuration for request (for timeout purposes)protected ConnectionKeepAliveStrategyThe keep-alive stragegy to optimize http clientsprotected PoolingHttpClientConnectionManagerRequest to the remote app will be ppoled for perfs purposesprotected StringPreauth secret keyprotected static final intThe number of seconds after what kept alive connections are droptprotected JSONUtilsThe JSON Utilsprotected UserManagerThe user managerprotected StringUrl to zimbrastatic final Stringtoken cache idFields inherited from class org.ametys.plugins.messagingconnector.AbstractMessagingConnector
_cacheManager, _cryptoHelper, _currentUserProvider, _userPopulationDAO, _userPrefFields inherited from interface org.ametys.plugins.messagingconnector.MessagingConnector
ROLE -
Constructor Summary
Constructors -
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 CloseableHttpClientGet a new pooled http client.voiddispose()voidprotected List<EmailMessage> internalGetEmails(UserIdentity userIdentity, int maxEmails) Get emails (no caching)protected intinternalGetEmailsCount(UserIdentity userIdentity) Get emails count (no caching)protected List<CalendarEvent> internalGetEvents(UserIdentity userIdentity, int maxDays, int maxEvents) Get upcoming events (no caching)protected intinternalGetEventsCount(UserIdentity userIdentity, int maxDays) Get upcoming events count (no caching)voidredirect(Redirector redirector, String targetApp) Preauth user and redirect to the zimbra applicationvoidservice(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, userCredentialNeededMethods 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:
servicein interfaceServiceable- Overrides:
servicein classAbstractMessagingConnector- Throws:
ServiceException
-
initialize
- Specified by:
initializein interfaceInitializable- Overrides:
initializein classAbstractMessagingConnector
-
dispose
- Specified by:
disposein 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
nullif 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:AbstractMessagingConnectorGet upcoming events (no caching)- Specified by:
internalGetEventsin 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:AbstractMessagingConnectorGet upcoming events count (no caching)- Specified by:
internalGetEventsCountin 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:AbstractMessagingConnectorGet emails (no caching)- Specified by:
internalGetEmailsin 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:AbstractMessagingConnectorGet emails count (no caching)- Specified by:
internalGetEmailsCountin classAbstractMessagingConnector- Parameters:
userIdentity- The user identity- Returns:
- The emails count
- Throws:
MessagingConnectorException- if failed to get events from server
-