001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.geronimo.mail;
017:
018: import java.util.Properties;
019:
020: import org.apache.commons.logging.Log;
021: import org.apache.commons.logging.LogFactory;
022:
023: import org.apache.geronimo.gbean.GBeanInfo;
024: import org.apache.geronimo.gbean.GBeanInfoBuilder;
025:
026: /**
027: * A GBean that provides for the configuration of a JavaMail IMAP message store
028: * protocol.
029: * <p/>
030: * IMAP store properties that are common to all IMAP stores are
031: * provided via member variables of this class. Values that are set in the
032: * individual member variables will override any of the corresponding values
033: * that have been set in the properties set.
034: *
035: * @version $Rev: 594563 $ $Date: 2007-11-13 07:28:52 -0800 (Tue, 13 Nov 2007) $
036: * @see MailGBean
037: */
038: public class IMAPStoreGBean extends ProtocolGBean {
039:
040: // the IMAP configuration property names
041: static public final String IMAP_PORT = "mail.imap.port";
042: static public final String IMAP_CONNECTION_TIMEOUT = "mail.imap.connectiontimeout";
043: static public final String IMAP_TIMEOUT = "mail.imap.timeout";
044: static public final String IMAP_FACTORY_CLASS = "mail.imap.socketFactory.class";
045: static public final String IMAP_FACTORY_FALLBACK = "mail.imap.socketFactory.fallback";
046: static public final String IMAP_FACTORY_PORT = "mail.imap.socketFactory.port";
047: static public final String IMAP_LOCALHOST = "mail.imap.localhost";
048: static public final String IMAP_LOCALADDRESS = "mail.imap.localaddress";
049: static public final String IMAP_LOCALPORT = "mail.imap.localport";
050: static public final String IMAP_PARTIAL_FETCH = "mail.imap.partialfetch";
051: static public final String IMAP_FETCH_SIZE = "mail.imap.fetchsize";
052: static public final String IMAP_STATUS_TIMEOUT = "mail.imap.statuscachetimeout";
053: static public final String IMAP_APPEND_SIZE = "mail.imap.appendbuffersize";
054: static public final String IMAP_POOL_SIZE = "mail.imap.connectionpoolsize";
055: static public final String IMAP_POOL_TIMEOUT = "mail.imap.connectionpooltimeout";
056: static public final String IMAP_SEPARATE_STORE_CONNECTION = "mail.imap.separatestoreconnection";
057: static public final String IMAP_READONLY_SELECT = "mail.imap.allreadonlyselect";
058: static public final String IMAP_LOGIN_DISABLE = "mail.imap.auth.login.disable";
059: static public final String IMAP_PLAIN_DISABLE = "mail.imap.auth.plain.disable";
060: static public final String IMAP_STARTTLS_ENABLE = "mail.imap.auth.starttls.enable";
061: static public final String IMAP_SASL_ENABLE = "mail.imap.sasl.enable";
062: static public final String IMAP_SASL_MECHANISMS = "mail.imap.sasl.mechanisms";
063: static public final String IMAP_SASL_AUTHORIZATIONID = "mail.imap.sasl.authorizationid";
064:
065: // the GBEAN property names
066: static public final String GBEAN_PARTIAL_FETCH = "partialFetch";
067: static public final String GBEAN_FETCH_SIZE = "fetchSize";
068: static public final String GBEAN_STATUS_TIMEOUT = "statusCacheTimeout";
069: static public final String GBEAN_APPEND_SIZE = "appendBufferSize";
070: static public final String GBEAN_POOL_SIZE = "connectionPoolSize";
071: static public final String GBEAN_POOL_TIMEOUT = "connectionPoolTimeout";
072: static public final String GBEAN_SEPARATE_STORE_CONNECTION = "separateStoreConnection";
073: static public final String GBEAN_READONLY_SELECT = "allowReadOnlySelect";
074: static public final String GBEAN_LOGIN_DISABLE = "authLoginDisable";
075: static public final String GBEAN_PLAIN_DISABLE = "authPlainDisable";
076: static public final String GBEAN_STARTTLS_ENABLE = "startTLSEnable";
077: static public final String GBEAN_SASL_ENABLE = "saslEnable";
078: static public final String GBEAN_SASL_MECHANISMS = "saslMechanisms";
079: static public final String GBEAN_SASL_AUTHORIZATIONID = "saslAuthorizationId";
080:
081: private final Log log = LogFactory.getLog(IMAPStoreGBean.class);
082:
083: private Integer port;
084: private Boolean partialFetch;
085: private Integer fetchSize;
086: private Integer connectionTimeout;
087: private Integer timeout;
088: private Integer statusCacheTimeout;
089: private Integer appendBufferSize;
090: private Integer connectionPoolSize;
091: private Integer connectionPoolTimeout;
092: private Boolean separateStoreConnection;
093: private Boolean allowReadOnlySelect;
094: private Boolean authLoginDisable;
095: private Boolean authPlainDisable;
096: private Boolean startTLSEnable;
097: private String localaddress;
098: private Integer localport;
099: private Boolean saslEnable;
100: private String saslMechanisms;
101: private String saslAuthorizationId;
102: private String socketFactoryClass;
103: private Boolean socketFactoryFallback;
104: private Integer socketFactoryPort;
105:
106: /**
107: * Construct an instance of IMAPStoreGBean
108: * <p/>
109: * Values that are set in the individual member variables will override any of
110: * the corresponding values that have been set in the properties set.
111: *
112: * @param objectName the object name of the protocol
113: * @param properties the set of default properties for the protocol
114: * @param host the host the protocol connects to
115: * @param user the default name for the protocol
116: * @param port the IMAP server port
117: * @param partialFetch whether the IMAP partial-fetch capability should be used
118: * @param fetchSize the partial fetch size in bytes
119: * @param connectionTimeout the socket connection timeout value in milliseconds
120: * @param timeout the socket I/O timeout value in milliseconds
121: * @param statusCacheTimeout the timeout value in milliseconds for cache of STATUS command response
122: * @param appendBufferSize the maximum size of a message to buffer in memory when appending to an IMAP folder
123: * @param connectionPoolSize the maximum number of available connections in the connection pool
124: * @param connectionPoolTimeout the timeout value in milliseconds for connection pool connections
125: * @param separateStoreConnection the flag to indicate whether to use a dedicated store connection for store commands
126: * @param allowReadOnlySelect the flag to indicate whether SELECT commands are read-only
127: * @param authLoginDisable the flag that prevents use of the non-standard AUTHENTICATE LOGIN command, instead using the plain LOGIN command
128: * @param authPlainDisable the flag that prevents use of the AUTHENTICATE PLAIN command
129: * @param startTLSEnable the flag that enables the use of the STARTTLS command (if supported by the server) to switch the connection to a TLS-protected connection before issuing any login commands
130: * @param localaddress the local address (host name) to bind to when creating the IMAP socket
131: * @param localport the local port number to bind to when creating the IMAP socket
132: * @param saslEnable the flag that enables an attempt to use the javax.security.sasl package to choose an authentication mechanism for login
133: * @param saslMechanisms a space or comma separated list of SASL mechanism names to try to use
134: * @param saslAuthorizationId the authorization ID to use in the SASL authentication
135: * @param socketFactoryClass the class that will be used to create IMAP sockets
136: * @param socketFactoryFallback whether java.net.Socket class will be created if the specified
137: * socket factory class cannot be created
138: * @param socketFactoryPort whether java.net.Socket class will be created if the specified
139: * socket factory class cannot be created
140: */
141: public IMAPStoreGBean(String objectName, Properties properties,
142: String host, String user, Integer port,
143: Boolean partialFetch, Integer fetchSize,
144: Integer connectionTimeout, Integer timeout,
145: Integer statusCacheTimeout, Integer appendBufferSize,
146: Integer connectionPoolSize, Integer connectionPoolTimeout,
147: Boolean separateStoreConnection,
148: Boolean allowReadOnlySelect, Boolean authLoginDisable,
149: Boolean authPlainDisable, Boolean startTLSEnable,
150: String localaddress, Integer localport, Boolean saslEnable,
151: String saslMechanisms, String saslAuthorizationId,
152: String socketFactoryClass, Boolean socketFactoryFallback,
153: Integer socketFactoryPort) {
154: super (objectName, "imap", properties, host, user);
155:
156: setPort(port);
157: setPartialFetch(partialFetch);
158: setFetchSize(fetchSize);
159: setConnectionTimeout(connectionTimeout);
160: setTimeout(timeout);
161: setStatusCacheTimeout(statusCacheTimeout);
162: setAppendBufferSize(appendBufferSize);
163: setConnectionPoolSize(connectionPoolSize);
164: setConnectionPoolTimeout(connectionPoolTimeout);
165: setSeparateStoreConnection(separateStoreConnection);
166: setAllowReadOnlySelect(allowReadOnlySelect);
167: setAuthLoginDisable(authLoginDisable);
168: setAuthPlainDisable(authPlainDisable);
169: setStartTLSEnable(startTLSEnable);
170: setLocaladdress(localaddress);
171: setLocalport(localport);
172: setSaslEnable(saslEnable);
173: setSaslMechanisms(saslMechanisms);
174: setSaslAuthorizationId(saslAuthorizationId);
175: setSocketFactoryClass(socketFactoryClass);
176: setSocketFactoryFallback(socketFactoryFallback);
177: setSocketFactoryPort(socketFactoryPort);
178: }
179:
180: /**
181: * Returns the IMAP server port to connect to, if the connect() method
182: * doesn't explicitly specify one.
183: */
184: public Integer getPort() {
185: return port;
186: }
187:
188: /**
189: * Sets the IMAP server port to connect to, if the connect() method
190: * doesn't explicitly specify one.
191: * <p/>
192: * Defaults to 143.
193: * <p/>
194: * Values that are set here will override any of the corresponding value
195: * that has been set in the properties.
196: *
197: * @param port the IMAP server port to connect to, if the connect() method
198: * doesn't explicitly specify one
199: */
200: public void setPort(Integer port) {
201: this .port = port;
202: }
203:
204: /**
205: * Returns whether the IMAP partial-fetch capability should be used.
206: * <p/>
207: * Controls whether the IMAP partial-fetch capability should be used.
208: * Defaults to true.
209: */
210: public Boolean getPartialFetch() {
211: return partialFetch;
212: }
213:
214: /**
215: * Sets whether the IMAP partial-fetch capability should be used.
216: * <p/>
217: * Controls whether the IMAP partial-fetch capability should be used.
218: * Defaults to true.
219: * <p/>
220: * Values that are set here will override any of the corresponding value
221: * that has been set in the properties.
222: *
223: * @param partialFetch whether the IMAP partial-fetch capability should be used
224: */
225: public void setPartialFetch(Boolean partialFetch) {
226: this .partialFetch = partialFetch;
227: }
228:
229: /**
230: * Returns the partial fetch size in bytes.
231: * <p/>
232: * Defaults to 16K.
233: */
234: public Integer getFetchSize() {
235: return fetchSize;
236: }
237:
238: /**
239: * Sets the partial fetch size in bytes
240: * <p/>
241: * Defaults to 16K.
242: * <p/>
243: * Values that are set here will override any of the corresponding value
244: * that has been set in the properties.
245: *
246: * @param fetchSize the partial fetch size in bytes
247: */
248: public void setFetchSize(Integer fetchSize) {
249: this .fetchSize = fetchSize;
250: }
251:
252: /**
253: * Returns the socket connection timeout value in milliseconds.
254: */
255: public Integer getConnectionTimeout() {
256: return connectionTimeout;
257: }
258:
259: /**
260: * Sets the socket connection timeout value in milliseconds.
261: * <p/>
262: * Default is infinite timeout.
263: * <p/>
264: * Values that are set here will override any of the corresponding value
265: * that has been set in the properties.
266: *
267: * @param connectionTimeout the socket connection timeout value in milliseconds.
268: */
269: public void setConnectionTimeout(Integer connectionTimeout) {
270: this .connectionTimeout = connectionTimeout;
271: }
272:
273: /**
274: * Returns the socket I/O timeout value in milliseconds.
275: */
276: public Integer getTimeout() {
277: return timeout;
278: }
279:
280: /**
281: * Sets the socket I/O timeout value in milliseconds.
282: * <p/>
283: * Default is infinite timeout.
284: * <p/>
285: * Values that are set here will override any of the corresponding value
286: * that has been set in the properties.
287: *
288: * @param timeout the socket I/O timeout value in milliseconds
289: */
290: public void setTimeout(Integer timeout) {
291: this .timeout = timeout;
292: }
293:
294: /**
295: * Returns the timeout value in milliseconds for cache of STATUS command response.
296: * <p/>
297: * Timeout value in milliseconds for cache of STATUS command response.
298: * Default is 1000 (1 second). Zero disables cache.
299: */
300: public Integer getStatusCacheTimeout() {
301: return statusCacheTimeout;
302: }
303:
304: /**
305: * Sets the timeout value in milliseconds for cache of STATUS command response
306: * <p/>
307: * Timeout value in milliseconds for cache of STATUS command response.
308: * Default is 1000 (1 second). Zero disables cache.
309: * <p/>
310: * Values that are set here will override any of the corresponding value
311: * that has been set in the properties.
312: *
313: * @param statusCacheTimeout the timeout value in milliseconds for cache of STATUS command response
314: */
315: public void setStatusCacheTimeout(Integer statusCacheTimeout) {
316: this .statusCacheTimeout = statusCacheTimeout;
317: }
318:
319: /**
320: * Returns the maximum size of a message to buffer in memory when appending
321: * to an IMAP folder.
322: * <p/>
323: * Maximum size of a message to buffer in memory when appending to an IMAP
324: * folder. If not set, or set to -1, there is no maximum and all messages
325: * are buffered. If set to 0, no messages are buffered. If set to (e.g.)
326: * 8192, messages of 8K bytes or less are buffered, larger messages are not
327: * buffered. Buffering saves cpu time at the expense of short term memory
328: * usage. If you commonly append very large messages to IMAP mailboxes you
329: * might want to set this to a moderate value (1M or less).
330: */
331: public Integer getAppendBufferSize() {
332: return appendBufferSize;
333: }
334:
335: /**
336: * Sets the maximum size of a message to buffer in memory when appending
337: * to an IMAP folder.
338: * <p/>
339: * Maximum size of a message to buffer in memory when appending to an IMAP
340: * folder. If not set, or set to -1, there is no maximum and all messages
341: * are buffered. If set to 0, no messages are buffered. If set to (e.g.)
342: * 8192, messages of 8K bytes or less are buffered, larger messages are not
343: * buffered. Buffering saves cpu time at the expense of short term memory
344: * usage. If you commonly append very large messages to IMAP mailboxes you
345: * might want to set this to a moderate value (1M or less).
346: * <p/>
347: * Values that are set here will override any of the corresponding value
348: * that has been set in the properties.
349: *
350: * @param appendBufferSize the maximum size of a message to buffer in memory when appending
351: * to an IMAP folder
352: */
353: public void setAppendBufferSize(Integer appendBufferSize) {
354: this .appendBufferSize = appendBufferSize;
355: }
356:
357: /**
358: * Returns the maximum number of available connections in the connection pool.
359: * <p/>
360: * Default is 1.
361: */
362: public Integer getConnectionPoolSize() {
363: return connectionPoolSize;
364: }
365:
366: /**
367: * Sets the maximum number of available connections in the connection pool.
368: * <p/>
369: * Default is 1.
370: * <p/>
371: * Values that are set here will override any of the corresponding value
372: * that has been set in the properties.
373: *
374: * @param connectionPoolSize the maximum number of available connections in the connection pool
375: */
376: public void setConnectionPoolSize(Integer connectionPoolSize) {
377: this .connectionPoolSize = connectionPoolSize;
378: }
379:
380: /**
381: * Returns the timeout value in milliseconds for connection pool connections.
382: * <p/>
383: * Default is 45000 (45 seconds).
384: */
385: public Integer getConnectionPoolTimeout() {
386: return connectionPoolTimeout;
387: }
388:
389: /**
390: * Sets the timeout value in milliseconds for connection pool connections
391: * <p/>
392: * Default is 45000 (45 seconds).
393: * <p/>
394: * Values that are set here will override any of the corresponding value
395: * that has been set in the properties.
396: *
397: * @param connectionPoolTimeout the timeout value in milliseconds for connection pool connections
398: */
399: public void setConnectionPoolTimeout(Integer connectionPoolTimeout) {
400: this .connectionPoolTimeout = connectionPoolTimeout;
401: }
402:
403: /**
404: * Returns the flag to indicate whether to use a dedicated store
405: * connection for store commands.
406: * <p/>
407: * Flag to indicate whether to use a dedicated store connection
408: * for store commands. Default is false.
409: */
410: public Boolean getSeparateStoreConnection() {
411: return separateStoreConnection;
412: }
413:
414: /**
415: * Sets the flag to indicate whether to use a dedicated store
416: * connection for store commands
417: * <p/>
418: * Flag to indicate whether to use a dedicated store connection
419: * for store commands. Default is false.
420: * <p/>
421: * Values that are set here will override any of the corresponding value
422: * that has been set in the properties.
423: *
424: * @param separateStoreConnection the flag to indicate whether to use a dedicated store
425: * connection for store commands
426: */
427: public void setSeparateStoreConnection(
428: Boolean separateStoreConnection) {
429: this .separateStoreConnection = separateStoreConnection;
430: }
431:
432: /**
433: * Returns the flag to indicate whether SELECT commands are read-only.
434: * <p/>
435: * If false, attempts to open a folder read/write will fail if the SELECT
436: * command succeeds but indicates that the folder is READ-ONLY. This
437: * sometimes indicates that the folder contents can'tbe changed, but the
438: * flags are per-user and can be changed, such as might be the case for
439: * public shared folders. If true, such open attempts will succeed, allowing
440: * the flags to be changed. The getMode method on the Folder object will
441: * return Folder.READ_ONLY in this case even though the open method specified
442: * Folder.READ_WRITE. Default is false.
443: */
444: public Boolean getAllowReadOnlySelect() {
445: return allowReadOnlySelect;
446: }
447:
448: /**
449: * Sets the flag to indicate whether SELECT commands are read-only.
450: * <p/>
451: * If false, attempts to open a folder read/write will fail if the SELECT
452: * command succeeds but indicates that the folder is READ-ONLY. This
453: * sometimes indicates that the folder contents can'tbe changed, but the
454: * flags are per-user and can be changed, such as might be the case for
455: * public shared folders. If true, such open attempts will succeed, allowing
456: * the flags to be changed. The getMode method on the Folder object will
457: * return Folder.READ_ONLY in this case even though the open method specified
458: * Folder.READ_WRITE. Default is false.
459: * <p/>
460: * Values that are set here will override any of the corresponding value
461: * that has been set in the properties.
462: *
463: * @param allowReadOnlySelect the flag to indicate whether SELECT commands are read-only
464: */
465: public void setAllowReadOnlySelect(Boolean allowReadOnlySelect) {
466: this .allowReadOnlySelect = allowReadOnlySelect;
467: }
468:
469: /**
470: * Returns the flag that prevents use of the non-standard AUTHENTICATE LOGIN
471: * command, instead using the plain LOGIN command.
472: * <p/>
473: * Default is false.
474: */
475: public Boolean getAuthLoginDisable() {
476: return authLoginDisable;
477: }
478:
479: /**
480: * Sets the flag that prevents use of the non-standard AUTHENTICATE LOGIN
481: * command, instead using the plain LOGIN command.
482: * <p/>
483: * Default is false.
484: * <p/>
485: * Values that are set here will override any of the corresponding value
486: * that has been set in the properties.
487: *
488: * @param authLoginDisable the flag that prevents use of the non-standard AUTHENTICATE LOGIN
489: * command, instead using the plain LOGIN command
490: */
491: public void setAuthLoginDisable(Boolean authLoginDisable) {
492: this .authLoginDisable = authLoginDisable;
493: }
494:
495: /**
496: * Returns the flag that prevents use of the AUTHENTICATE PLAIN command.
497: * <p/>
498: * Default is false.
499: */
500: public Boolean getAuthPlainDisable() {
501: return authPlainDisable;
502: }
503:
504: /**
505: * Sets the flag that prevents use of the AUTHENTICATE PLAIN command.
506: * <p/>
507: * Default is false.
508: * <p/>
509: * Values that are set here will override any of the corresponding value
510: * that has been set in the properties.
511: *
512: * @param authPlainDisable the flag that prevents use of the AUTHENTICATE PLAIN command
513: */
514: public void setAuthPlainDisable(Boolean authPlainDisable) {
515: this .authPlainDisable = authPlainDisable;
516: }
517:
518: /**
519: * Returns the flag that enables the use of the STARTTLS command (if
520: * supported by the server) to switch the connection to a TLS-protected
521: * connection before issuing any login commands.
522: * <p/>
523: * If true, enables the use of the STARTTLS command (if supported by the
524: * server) to switch the connection to a TLS-protected connection before
525: * issuing any login commands. Note that an appropriate trust store must
526: * configured so that the client will trust the server's certificate.
527: * This feature only works on J2SE 1.4 and newer systems. Default is false.
528: */
529: public Boolean getStartTLSEnable() {
530: return startTLSEnable;
531: }
532:
533: /**
534: * Sets the flag that enables the use of the STARTTLS command (if
535: * supported by the server) to switch the connection to a TLS-protected
536: * connection before issuing any login commands.
537: * <p/>
538: * If true, enables the use of the STARTTLS command (if supported by the
539: * server) to switch the connection to a TLS-protected connection before
540: * issuing any login commands. Note that an appropriate trust store must
541: * configured so that the client will trust the server's certificate.
542: * This feature only works on J2SE 1.4 and newer systems. Default is false.
543: * <p/>
544: * Values that are set here will override any of the corresponding value
545: * that has been set in the properties.
546: *
547: * @param startTLSEnable the flag that enables the use of the STARTTLS command (if
548: * supported by the server) to switch the connection to a TLS-protected
549: * connection before issuing any login commands
550: */
551: public void setStartTLSEnable(Boolean startTLSEnable) {
552: this .startTLSEnable = startTLSEnable;
553: }
554:
555: /**
556: * Returns the local address (host name) to bind to when creating the IMAP socket.
557: */
558: public String getLocaladdress() {
559: return localaddress;
560: }
561:
562: /**
563: * Sets the local address (host name) to bind to when creating the IMAP socket.
564: * <p/>
565: * Local address (host name) to bind to when creating the IMAP socket.
566: * Defaults to the address picked by the Socket class. Should not normally
567: * need to be set, but useful with multi-homed hosts where it's important
568: * to pick a particular local address to bind to.
569: * <p/>
570: * Values that are set here will override any of the corresponding value
571: * that has been set in the properties.
572: *
573: * @param localaddress the local address (host name) to bind to when creating the IMAP socket
574: */
575: public void setLocaladdress(String localaddress) {
576: this .localaddress = localaddress;
577: }
578:
579: /**
580: * Returns the local port number to bind to when creating the IMAP socket.
581: */
582: public Integer getLocalport() {
583: return localport;
584: }
585:
586: /**
587: * Sets the local port number to bind to when creating the IMAP socket.
588: * <p/>
589: * Local port number to bind to when creating the IMAP socket. Defaults to
590: * the port number picked by the Socket class.
591: * <p/>
592: * Values that are set here will override any of the corresponding value
593: * that has been set in the properties.
594: *
595: * @param localport the local port number to bind to when creating the IMAP socket
596: */
597: public void setLocalport(Integer localport) {
598: this .localport = localport;
599: }
600:
601: /**
602: * Returns the flag that enables an attempt to use the javax.security.sasl
603: * package to choose an authentication mechanism for login.
604: * <p/>
605: * Defaults to false.
606: */
607: public Boolean getSaslEnable() {
608: return saslEnable;
609: }
610:
611: /**
612: * Sets the flag that enables an attempt to use the javax.security.sasl
613: * package to choose an authentication mechanism for login.
614: * <p/>
615: * Defaults to false.
616: * <p/>
617: * Values that are set here will override any of the corresponding value
618: * that has been set in the properties.
619: *
620: * @param saslEnable the flag that enables an attempt to use the javax.security.sasl
621: * package to choose an authentication mechanism for login
622: */
623: public void setSaslEnable(Boolean saslEnable) {
624: this .saslEnable = saslEnable;
625: }
626:
627: /**
628: * Returns a space or comma separated list of SASL mechanism names to try to use.
629: */
630: public String getSaslMechanisms() {
631: return saslMechanisms;
632: }
633:
634: /**
635: * Sets a space or comma separated list of SASL mechanism names to try to use.
636: * <p/>
637: * Values that are set here will override any of the corresponding value
638: * that has been set in the properties.
639: *
640: * @param saslMechanisms a space or comma separated list of SASL mechanism names to try to use
641: */
642: public void setSaslMechanisms(String saslMechanisms) {
643: this .saslMechanisms = saslMechanisms;
644: }
645:
646: /**
647: * Returns the authorization ID to use in the SASL authentication.
648: * <p/>
649: * If not set, the authetication ID (user name) is used.
650: */
651: public String getSaslAuthorizationId() {
652: return saslAuthorizationId;
653: }
654:
655: /**
656: * Sets the authorization ID to use in the SASL authentication.
657: * <p/>
658: * If not set, the authetication ID (user name) is used.
659: * <p/>
660: * Values that are set here will override any of the corresponding value
661: * that has been set in the properties.
662: *
663: * @param saslAuthorizationId the authorization ID to use in the SASL authentication
664: */
665: public void setSaslAuthorizationId(String saslAuthorizationId) {
666: this .saslAuthorizationId = saslAuthorizationId;
667: }
668:
669: /**
670: * Returns the class that will be used to create IMAP sockets.
671: * <p/>
672: * If set, specifies the name of a class that implements the
673: * javax.net.SocketFactory interface. This class will be used to create IMAP
674: * sockets.
675: */
676: public String getSocketFactoryClass() {
677: return socketFactoryClass;
678: }
679:
680: /**
681: * Sets the class that will be used to create SMTP sockets.
682: * <p/>
683: * If set, specifies the name of a class that implements the
684: * javax.net.SocketFactory interface. This class will be used to create SMTP
685: * sockets.
686: * <p/>
687: * Values that are set here will override any of the corresponding value
688: * that has been set in the properties.
689: *
690: * @param socketFactoryClass the class that will be used to create SMTP sockets
691: */
692: public void setSocketFactoryClass(String socketFactoryClass) {
693: this .socketFactoryClass = socketFactoryClass;
694: }
695:
696: /**
697: * Returns whether java.net.Socket class will be created if the specified
698: * socket factory class cannot be created.
699: * <p/>
700: * If set to true, failure to create a socket using the specified socket
701: * factory class will cause the socket to be created using the
702: * java.net.Socket class. Defaults to true.
703: */
704: public Boolean getSocketFactoryFallback() {
705: return socketFactoryFallback;
706: }
707:
708: /**
709: * Sets whether java.net.Socket class will be created if the specified
710: * socket factory class cannot be created.
711: * <p/>
712: * If set to true, failure to create a socket using the specified socket
713: * factory class will cause the socket to be created using the
714: * java.net.Socket class. Defaults to true.
715: * <p/>
716: * Values that are set here will override any of the corresponding value
717: * that has been set in the properties.
718: *
719: * @param socketFactoryFallback whether java.net.Socket class will be created if the specified
720: * socket factory class cannot be created
721: */
722: public void setSocketFactoryFallback(Boolean socketFactoryFallback) {
723: this .socketFactoryFallback = socketFactoryFallback;
724: }
725:
726: /**
727: * Returns the port to connect to when using the specified socket factory.
728: * <p/>
729: * Specifies the port to connect to when using the specified socket
730: * factory. If not set, the default port will be used.
731: */
732: public Integer getSocketFactoryPort() {
733: return socketFactoryPort;
734: }
735:
736: /**
737: * Sets the port to connect to when using the specified socket factory.
738: * <p/>
739: * Specifies the port to connect to when using the specified socket
740: * factory. If not set, the default port will be used.
741: * <p/>
742: * Values that are set here will override any of the corresponding value
743: * that has been set in the properties.
744: *
745: * @param socketFactoryPort the port to connect to when using the specified socket factory
746: */
747: public void setSocketFactoryPort(Integer socketFactoryPort) {
748: this .socketFactoryPort = socketFactoryPort;
749: }
750:
751: /**
752: * Add the overrides from the member variables to the properties file.
753: */
754: public void addOverrides(Properties props) {
755: super .addOverrides(props);
756:
757: if (port != null)
758: props.setProperty(IMAP_PORT, port.toString());
759: if (partialFetch != null)
760: props.setProperty(IMAP_PARTIAL_FETCH, partialFetch
761: .toString());
762: if (fetchSize != null)
763: props.setProperty(IMAP_FETCH_SIZE, fetchSize.toString());
764: if (connectionTimeout != null)
765: props.setProperty(IMAP_CONNECTION_TIMEOUT,
766: connectionTimeout.toString());
767: if (timeout != null)
768: props.setProperty(IMAP_TIMEOUT, timeout.toString());
769: if (statusCacheTimeout != null)
770: props.setProperty(IMAP_STATUS_TIMEOUT, statusCacheTimeout
771: .toString());
772: if (appendBufferSize != null)
773: props.setProperty(IMAP_APPEND_SIZE, appendBufferSize
774: .toString());
775: if (connectionPoolSize != null)
776: props.setProperty(IMAP_POOL_SIZE, connectionPoolSize
777: .toString());
778: if (connectionPoolTimeout != null)
779: props.setProperty(IMAP_POOL_TIMEOUT, connectionPoolTimeout
780: .toString());
781: if (separateStoreConnection != null)
782: props.setProperty(IMAP_SEPARATE_STORE_CONNECTION,
783: separateStoreConnection.toString());
784: if (allowReadOnlySelect != null)
785: props.setProperty(IMAP_READONLY_SELECT, allowReadOnlySelect
786: .toString());
787: if (authLoginDisable != null)
788: props.setProperty(IMAP_LOGIN_DISABLE, authLoginDisable
789: .toString());
790: if (authPlainDisable != null)
791: props.setProperty(IMAP_PLAIN_DISABLE, authPlainDisable
792: .toString());
793: if (startTLSEnable != null)
794: props.setProperty(IMAP_STARTTLS_ENABLE, startTLSEnable
795: .toString());
796: if (localaddress != null)
797: props.setProperty(IMAP_LOCALADDRESS, localaddress);
798: if (localport != null)
799: props.setProperty(IMAP_LOCALPORT, localport.toString());
800: if (saslEnable != null)
801: props.setProperty(IMAP_SASL_ENABLE, saslEnable.toString());
802: if (saslMechanisms != null)
803: props.setProperty(IMAP_SASL_MECHANISMS, saslMechanisms);
804: if (saslAuthorizationId != null)
805: props.setProperty(IMAP_SASL_AUTHORIZATIONID,
806: saslAuthorizationId);
807: if (socketFactoryClass != null)
808: props.setProperty(IMAP_FACTORY_CLASS, socketFactoryClass);
809: if (socketFactoryFallback != null)
810: props.setProperty(IMAP_FACTORY_FALLBACK,
811: socketFactoryFallback.toString());
812: if (socketFactoryPort != null)
813: props.setProperty(IMAP_FACTORY_PORT, socketFactoryPort
814: .toString());
815: }
816:
817: public void doStart() throws Exception {
818: log.debug("Started " + getObjectName());
819: }
820:
821: public void doStop() throws Exception {
822: log.debug("Stopped " + getObjectName());
823: }
824:
825: public void doFail() {
826: log.warn("Failed " + getObjectName());
827: }
828:
829: public static final GBeanInfo GBEAN_INFO;
830:
831: static {
832: GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(
833: IMAPStoreGBean.class, ProtocolGBean.GBEAN_INFO);
834:
835: infoFactory.addAttribute(GBEAN_PORT, Integer.class, true);
836: infoFactory.addAttribute(GBEAN_CONNECTION_TIMEOUT,
837: Integer.class, true);
838: infoFactory.addAttribute(GBEAN_TIMEOUT, Integer.class, true);
839: infoFactory
840: .addAttribute(GBEAN_LOCALADDRESS, String.class, true);
841: infoFactory.addAttribute(GBEAN_LOCALPORT, Integer.class, true);
842: infoFactory.addAttribute(GBEAN_FACTORY_CLASS, String.class,
843: true);
844: infoFactory.addAttribute(GBEAN_FACTORY_FALLBACK, Boolean.class,
845: true);
846: infoFactory.addAttribute(GBEAN_FACTORY_PORT, Integer.class,
847: true);
848: infoFactory.addAttribute(GBEAN_PARTIAL_FETCH, Boolean.class,
849: true);
850: infoFactory.addAttribute(GBEAN_FETCH_SIZE, Integer.class, true);
851: infoFactory.addAttribute(GBEAN_STATUS_TIMEOUT, Integer.class,
852: true);
853: infoFactory
854: .addAttribute(GBEAN_APPEND_SIZE, Integer.class, true);
855: infoFactory.addAttribute(GBEAN_POOL_SIZE, Integer.class, true);
856: infoFactory.addAttribute(GBEAN_POOL_TIMEOUT, Integer.class,
857: true);
858: infoFactory.addAttribute(GBEAN_SEPARATE_STORE_CONNECTION,
859: Boolean.class, true);
860: infoFactory.addAttribute(GBEAN_READONLY_SELECT, Boolean.class,
861: true);
862: infoFactory.addAttribute(GBEAN_LOGIN_DISABLE, Boolean.class,
863: true);
864: infoFactory.addAttribute(GBEAN_PLAIN_DISABLE, Boolean.class,
865: true);
866: infoFactory.addAttribute(GBEAN_STARTTLS_ENABLE, Boolean.class,
867: true);
868: infoFactory
869: .addAttribute(GBEAN_SASL_ENABLE, Boolean.class, true);
870: infoFactory.addAttribute(GBEAN_SASL_MECHANISMS, String.class,
871: true);
872: infoFactory.addAttribute(GBEAN_SASL_AUTHORIZATIONID,
873: String.class, true);
874:
875: infoFactory.addAttribute(GBEAN_OBJECTNAME, String.class, false);
876: infoFactory.addAttribute(GBEAN_PROTOCOL, String.class, true);
877: infoFactory.addAttribute(GBEAN_PROPERTIES, Properties.class,
878: true);
879: infoFactory.addAttribute(GBEAN_HOST, String.class, true);
880: infoFactory.addAttribute(GBEAN_USER, String.class, true);
881: infoFactory.addOperation(GBEAN_ADD_OVERRIDES,
882: new Class[] { Properties.class });
883:
884: infoFactory.setConstructor(new String[] { GBEAN_OBJECTNAME,
885: GBEAN_PROPERTIES, GBEAN_HOST, GBEAN_USER, GBEAN_PORT,
886: GBEAN_PARTIAL_FETCH, GBEAN_FETCH_SIZE,
887: GBEAN_CONNECTION_TIMEOUT, GBEAN_TIMEOUT,
888: GBEAN_STATUS_TIMEOUT, GBEAN_APPEND_SIZE,
889: GBEAN_POOL_SIZE, GBEAN_POOL_TIMEOUT,
890: GBEAN_SEPARATE_STORE_CONNECTION, GBEAN_READONLY_SELECT,
891: GBEAN_LOGIN_DISABLE, GBEAN_PLAIN_DISABLE,
892: GBEAN_STARTTLS_ENABLE, GBEAN_LOCALADDRESS,
893: GBEAN_LOCALPORT, GBEAN_SASL_ENABLE,
894: GBEAN_SASL_MECHANISMS, GBEAN_SASL_AUTHORIZATIONID,
895: GBEAN_FACTORY_CLASS, GBEAN_FACTORY_FALLBACK,
896: GBEAN_FACTORY_PORT });
897:
898: GBEAN_INFO = infoFactory.getBeanInfo();
899: }
900:
901: public static GBeanInfo getGBeanInfo() {
902: return GBEAN_INFO;
903: }
904: }
|