Source Code Cross Referenced for ScriptMailServer.java in  » Groupware » ivatagroupware » com » ivata » groupware » business » mail » server » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Groupware » ivatagroupware » com.ivata.groupware.business.mail.server 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 2001 - 2005 ivata limited.
003:         * All rights reserved.
004:         * -----------------------------------------------------------------------------
005:         * ivata groupware may be redistributed under the GNU General Public
006:         * License as published by the Free Software Foundation;
007:         * version 2 of the License.
008:         *
009:         * These programs are free software; you can redistribute them and/or
010:         * modify them under the terms of the GNU General Public License
011:         * as published by the Free Software Foundation; version 2 of the License.
012:         *
013:         * These programs are distributed in the hope that they will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
016:         *
017:         * See the GNU General Public License in the file LICENSE.txt for more
018:         * details.
019:         *
020:         * If you would like a copy of the GNU General Public License write to
021:         *
022:         * Free Software Foundation, Inc.
023:         * 59 Temple Place - Suite 330
024:         * Boston, MA 02111-1307, USA.
025:         *
026:         *
027:         * To arrange commercial support and licensing, contact ivata at
028:         *                  http://www.ivata.com/contact.jsp
029:         * -----------------------------------------------------------------------------
030:         * $Log: ScriptMailServer.java,v $
031:         * Revision 1.6  2005/10/03 10:21:15  colinmacleod
032:         * Fixed some style and javadoc issues.
033:         *
034:         * Revision 1.5  2005/10/02 14:08:59  colinmacleod
035:         * Added/improved log4j logging.
036:         *
037:         * Revision 1.4  2005/09/14 16:16:52  colinmacleod
038:         * Removed unused local and class variables.
039:         * Added serialVersionUID.
040:         *
041:         * Revision 1.3  2005/04/10 18:47:43  colinmacleod
042:         * Changed i tag to em and b tag to strong.
043:         *
044:         * Revision 1.2  2005/04/09 17:20:01  colinmacleod
045:         * Changed copyright text to GPL v2 explicitly.
046:         *
047:         * Revision 1.1.1.1  2005/03/10 17:51:20  colinmacleod
048:         * Restructured ivata op around Hibernate/PicoContainer.
049:         * Renamed ivata groupware.
050:         *
051:         * Revision 1.8  2004/11/12 18:16:08  colinmacleod
052:         * Ordered imports.
053:         *
054:         * Revision 1.7  2004/11/12 15:57:25  colinmacleod
055:         * Removed dependencies on SSLEXT.
056:         * Moved Persistence classes to ivata masks.
057:         *
058:         * Revision 1.6  2004/11/03 16:18:09  colinmacleod
059:         * Changed return type of getUserAliases to List.
060:         *
061:         * Revision 1.5  2004/07/18 21:59:15  colinmacleod
062:         * Removed Person from User - now you need to use addressbook/persistence manager to find the person (makes the app run faster.)
063:         *
064:         * Revision 1.4  2004/07/13 19:48:12  colinmacleod
065:         * Moved project to POJOs from EJBs.
066:         * Applied PicoContainer to services layer (replacing session EJBs).
067:         * Applied Hibernate to persistence layer (replacing entity EJBs).
068:         *
069:         * Revision 1.3  2004/03/21 21:16:39  colinmacleod
070:         * Shortened name to ivata op.
071:         *
072:         * Revision 1.2  2004/02/01 22:07:32  colinmacleod
073:         * Added full names to author tags
074:         *
075:         * Revision 1.1.1.1  2004/01/27 20:59:57  colinmacleod
076:         * Moved ivata openportal to SourceForge..
077:         *
078:         * Revision 1.5  2004/01/12 14:02:23  jano
079:         * fixing bugs
080:         *
081:         * Revision 1.4  2003/10/28 13:27:51  jano
082:         * Committed webmail,
083:         * still fixing compile and building openGroupware project
084:         *
085:         * Revision 1.3  2003/10/23 21:31:05  colin
086:         * Fixed singletons; removed double-checked locking.
087:         *
088:         * Revision 1.2  2003/10/15 14:11:33  colin
089:         * fixing for XDoclet
090:         *
091:         * Revision 1.2  2003/02/27 17:24:25  peter
092:         * getFolderModified - script return value trimmed
093:         *
094:         * Revision 1.1  2003/02/24 19:09:24  colin
095:         * moved to business
096:         * Revision 1.9  2003/02/04 17:39:22  colin
097:         * copyright notice
098:         * Revision 1.8  2002/11/19 14:38:29  colin
099:         * ed getFolderModified
100:         * Revision 1.7  2002/11/05 16:13:29  jano
101:         * we need to read setting in echa exec method,
102:         * Revision 1.6  2002/10/24 15:50:08  jano
103:         * filing bug with spaces in exec and SUDO
104:         * Revision 1.5  2002/10/23 09:18:08  jano
105:         * there is a new method for generating SystemUserName
106:         * Revision 1.4  2002/09/09 11:03:08  colin
107:         * made session classes serializable
108:         * Revision 1.3  2002/09/09 08:44:52  colin
109:         * made new mail session class to abstract the non-serializable
110:         * * JavaMail session
111:         * Revision 1.2  2002/08/30 14:20:36  peter
112:         * fixed the previous state
113:         * Revision 1.2  2002/08/11 11:42:03  colin
114:         * made initialization use path directly rather than the
115:         * settings
116:         * Revision 1.1  2002/07/26 13:10:18  colin
117:         * first version of mail server support
118:         * user rights currently not implemented
119:         * -----------------------------------------------------------------------------
120:         */
121:        package com.ivata.groupware.business.mail.server;
122:
123:        import org.apache.log4j.Logger;
124:
125:        import java.util.Collection;
126:        import java.util.Iterator;
127:        import java.util.List;
128:
129:        import com.ivata.groupware.admin.script.ScriptExecutor;
130:        import com.ivata.groupware.admin.security.server.SecuritySession;
131:        import com.ivata.groupware.admin.setting.Settings;
132:        import com.ivata.groupware.business.addressbook.AddressBook;
133:        import com.ivata.mask.util.CollectionHandling;
134:        import com.ivata.mask.util.SystemException;
135:
136:        /**
137:         * <p>This implementation of the mail server uses scripts
138:         * to perform each of the actions.</p>
139:         *
140:         * <p>The scripts must have the same name as each of the
141:         * methods and use the same parameters. The location of the
142:         * scripts within the system is set using the system setting
143:         * 'pathScriptMailServer'.</p>
144:         *
145:         * <p>For each script, a return value of <code>0</code> is taken
146:         * as success. Any other value results in a {@link
147:         * GroupwareException GroupwareException} being thrown, with
148:         * the contents of the standard error stream as its message.</p>
149:         *
150:         * @since 2002-07-20
151:         * @author Colin MacLeod
152:         * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
153:         * @version $Revision: 1.6 $
154:         */
155:        public class ScriptMailServer extends JavaMailServer implements 
156:                MailServer {
157:            /**
158:             * Logger for this class.
159:             */
160:            private static final Logger logger = Logger
161:                    .getLogger(ScriptMailServer.class);
162:
163:            /**
164:             * Serialization version (for <code>Serializable</code> interface).
165:             */
166:            private static final long serialVersionUID = 1L;
167:            String[] environmentVariables = null;
168:            private ScriptExecutor scriptExecutor;
169:            /**
170:             * <p>Stores the sole instance of this class.</p>
171:             */
172:            String scriptPath;
173:
174:            /**
175:             * This prefix is appended to user names to get the underlying system
176:             * equivalent.
177:             */
178:            private String userNamePrefix;
179:            AddressBook addressBook;
180:
181:            /**
182:             * <p>Create a script mail server.</p>
183:             */
184:            public ScriptMailServer(final ScriptExecutor scriptExecutor,
185:                    final String userNamePrefix, final AddressBook addressBook,
186:                    final Settings settings) {
187:                super (addressBook, settings);
188:                this .scriptExecutor = scriptExecutor;
189:                this .userNamePrefix = userNamePrefix;
190:                this .addressBook = addressBook;
191:            }
192:
193:            /**
194:             * <p>Add a new user to the system. </p>
195:             *
196:             * <p>This method calls the <code>addUser</code> script.</p>
197:             *
198:             * @param userName it's userName in System
199:             * @param fileAs it's file as of user
200:             * @throws GroupwareException containing the content of the standard
201:             * error stream, if the script returns non-zero.
202:             */
203:            public void addUser(final SecuritySession securitySession,
204:                    final String userName, final String fileAs)
205:                    throws SystemException {
206:                if (logger.isDebugEnabled()) {
207:                    logger.debug("addUser(SecuritySession securitySession = "
208:                            + securitySession + ", String userName = "
209:                            + userName + ", String fileAs = " + fileAs
210:                            + ") - start");
211:                }
212:
213:                String[] argv = new String[2];
214:
215:                argv[0] = getSystemUserName(securitySession, userName);
216:                argv[1] = fileAs;
217:
218:                scriptExecutor.exec("addUser", argv);
219:                argv = new String[3];
220:
221:                argv[0] = getSystemUserName(securitySession, userName);
222:                argv[1] = getSystemUserName(securitySession, securitySession
223:                        .getUser().getName());
224:                argv[2] = getSystemUserName(securitySession, securitySession
225:                        .getPassword());
226:                scriptExecutor.exec("makeMaildir", argv);
227:
228:                if (logger.isDebugEnabled()) {
229:                    logger
230:                            .debug("addUser(SecuritySession, String, String) - end");
231:                }
232:            }
233:
234:            /**
235:             * <p>Gets the contents of mailing list with the name provided.</p>
236:             *
237:             * <p>This method calls the script called <code>getList</code>.</p>
238:             *
239:             * @param name the name of the list to be retrieved.
240:             * @return a <code>Collection</code> containing
241:             * <code>UserLocal</code>
242:             * instances of each of the users in the list.
243:             * @throws GroupwareException containing the content of the standard
244:             * error stream, if the script returns non-zero.
245:             */
246:            public final Collection getList(
247:                    final SecuritySession securitySession, final String name)
248:                    throws SystemException {
249:                if (logger.isDebugEnabled()) {
250:                    logger.debug("getList(SecuritySession securitySession = "
251:                            + securitySession + ", String name = " + name
252:                            + ") - start");
253:                }
254:
255:                String[] argv = new String[1];
256:
257:                argv[0] = name;
258:
259:                Collection returnCollection = CollectionHandling
260:                        .convertFromLines(scriptExecutor.exec("getList", argv));
261:                if (logger.isDebugEnabled()) {
262:                    logger
263:                            .debug("getList(SecuritySession, String) - end - return value = "
264:                                    + returnCollection);
265:                }
266:                return returnCollection;
267:            }
268:
269:            /**
270:             * <p>This method add prefix to username.</p>
271:             *
272:             * @param userName
273:             * @return prefix_userName
274:             */
275:            public final String getSystemUserName(
276:                    final SecuritySession securitySession, final String userName) {
277:                if (logger.isDebugEnabled()) {
278:                    logger
279:                            .debug("getSystemUserName(SecuritySession securitySession = "
280:                                    + securitySession
281:                                    + ", String userName = "
282:                                    + userName + ") - start");
283:                }
284:
285:                //server.getJndiPrefix();
286:                //ApplicationServer.get .getInstance().getJndiPrefix();
287:                if (userNamePrefix.length() > 0) {
288:                    String returnString = userNamePrefix + "_" + userName;
289:                    if (logger.isDebugEnabled()) {
290:                        logger
291:                                .debug("getSystemUserName(SecuritySession, String) - end - return value = "
292:                                        + returnString);
293:                    }
294:                    return returnString;
295:                } else {
296:                    if (logger.isDebugEnabled()) {
297:                        logger
298:                                .debug("getSystemUserName(SecuritySession, String) - end - return value = "
299:                                        + userName);
300:                    }
301:                    return userName;
302:                }
303:            }
304:
305:            /**
306:             * <p>Gets all of the email aliases for the user provided.</p>
307:             *
308:             * <p>This method calls the script <code>getUserAliases</code>.</p>
309:             *
310:             * @param userName the user for whom to get the email aliases.
311:             * @return a <code>Collection</code> containing
312:             * <code>String</code> values for each of the aliases.
313:             * @throws GroupwareException containing the content of the standard
314:             * error stream, if the script returns non-zero.
315:             */
316:            public List getUserAliases(final SecuritySession securitySession,
317:                    final String userName) throws SystemException {
318:                if (logger.isDebugEnabled()) {
319:                    logger
320:                            .debug("getUserAliases(SecuritySession securitySession = "
321:                                    + securitySession
322:                                    + ", String userName = "
323:                                    + userName + ") - start");
324:                }
325:
326:                String[] argv = new String[1];
327:
328:                argv[0] = getSystemUserName(securitySession, userName);
329:
330:                List returnList = CollectionHandling
331:                        .convertFromLines(scriptExecutor.exec("getUserAliases",
332:                                argv));
333:                if (logger.isDebugEnabled()) {
334:                    logger
335:                            .debug("getUserAliases(SecuritySession, String) - end - return value = "
336:                                    + returnList);
337:                }
338:                return returnList;
339:            }
340:
341:            /**
342:             * <p>Get the email addresss this user's mail is forwarded to.</p>
343:             *
344:             * <p>This method calls the script <code>getUserForwarding</code>.</p>
345:             *
346:             * @param userName the user for whom to activate/deactive email
347:             * forwarding.
348:             * @return email address all email for this user is forwarded to, or
349:             * <code>null</code> if there is no forwarding for this user.
350:             * @throws GroupwareException containing the content of the standard
351:             * error stream, if the script returns non-zero.
352:             */
353:            public final String getUserForwarding(
354:                    final SecuritySession securitySession, final String userName)
355:                    throws SystemException {
356:                if (logger.isDebugEnabled()) {
357:                    logger
358:                            .debug("getUserForwarding(SecuritySession securitySession = "
359:                                    + securitySession
360:                                    + ", String userName = "
361:                                    + userName + ") - start");
362:                }
363:
364:                String[] argv = new String[1];
365:
366:                argv[0] = getSystemUserName(securitySession, userName);
367:
368:                String returnString = scriptExecutor.exec("getUserForwarding",
369:                        argv);
370:                if (logger.isDebugEnabled()) {
371:                    logger
372:                            .debug("getUserForwarding(SecuritySession, String) - end - return value = "
373:                                    + returnString);
374:                }
375:                return returnString;
376:            }
377:
378:            /**
379:             * <p>This method is converting SystemUserName to userName, it's oposite method to getSystemUserName.</p>
380:             * @param systemUserName
381:             * @return
382:             */
383:            public final String getUserNameFromSystemUserName(
384:                    final SecuritySession securitySession,
385:                    final String systemUserName) {
386:                if (logger.isDebugEnabled()) {
387:                    logger
388:                            .debug("getUserNameFromSystemUserName(SecuritySession securitySession = "
389:                                    + securitySession
390:                                    + ", String systemUserName = "
391:                                    + systemUserName + ") - start");
392:                }
393:
394:                if ((userNamePrefix.length() > 0)
395:                        && systemUserName.startsWith(userNamePrefix)) {
396:                    String returnString = systemUserName
397:                            .substring(userNamePrefix.length() + 1);
398:                    if (logger.isDebugEnabled()) {
399:                        logger
400:                                .debug("getUserNameFromSystemUserName(SecuritySession, String) - end - return value = "
401:                                        + returnString);
402:                    }
403:                    return returnString;
404:                } else {
405:                    if (logger.isDebugEnabled()) {
406:                        logger
407:                                .debug("getUserNameFromSystemUserName(SecuritySession, String) - end - return value = "
408:                                        + systemUserName);
409:                    }
410:                    return systemUserName;
411:                }
412:            }
413:
414:            /**
415:             * <p>Gets the current vacation method for the user provided. </p>
416:             *
417:             * <p>This method calls the script
418:             * <code>getVacationMessage</code>.</p>
419:             *
420:             * @param userName the user for whom to set the vacation message.
421:             * @return the current vacation message for this user, or
422:             * <code>null</code> if
423:             * the user does not have a vacation message.
424:             * @throws GroupwareException containing the content of the standard
425:             * error stream, if the script returns non-zero.
426:             */
427:            public final String getVacationMessage(
428:                    final SecuritySession securitySession, final String userName)
429:                    throws SystemException {
430:                if (logger.isDebugEnabled()) {
431:                    logger
432:                            .debug("getVacationMessage(SecuritySession securitySession = "
433:                                    + securitySession
434:                                    + ", String userName = "
435:                                    + userName + ") - start");
436:                }
437:
438:                String[] argv = new String[1];
439:
440:                argv[0] = getSystemUserName(securitySession, userName);
441:
442:                String vacationMessage = scriptExecutor.exec(
443:                        "getVacationMessage", argv);
444:
445:                // TODO: we're assuming that an empty message = no message
446:                String returnString = vacationMessage.equals("") ? null
447:                        : vacationMessage;
448:                if (logger.isDebugEnabled()) {
449:                    logger
450:                            .debug("getVacationMessage(SecuritySession, String) - end - return value = "
451:                                    + returnString);
452:                }
453:                return returnString;
454:            }
455:
456:            /**
457:             * <p>Removes an existing mailing list from the system.</p>
458:             *
459:             * <p>The <code>removeList</code> script is called with
460:             * <code>name</code> as its only parameter.</p>
461:             *
462:             * @param name the name of the list to remove.
463:             * @throws GroupwareException containing the content of the standard
464:             * error stream, if the script returns non-zero.
465:             */
466:            public void removeList(final SecuritySession securitySession,
467:                    final String name) throws SystemException {
468:                if (logger.isDebugEnabled()) {
469:                    logger
470:                            .debug("removeList(SecuritySession securitySession = "
471:                                    + securitySession
472:                                    + ", String name = "
473:                                    + name + ") - start");
474:                }
475:
476:                String[] argv = new String[1];
477:
478:                argv[0] = name;
479:                scriptExecutor.exec("removeList", argv);
480:
481:                if (logger.isDebugEnabled()) {
482:                    logger.debug("removeList(SecuritySession, String) - end");
483:                }
484:            }
485:
486:            /**
487:             * <p>Remove a user from the email system. <strong>Note:</strong> this user is
488:             * not removed
489:             * from the address book, only the email server. Comments by this user
490:             * will still appear in the system, though the user will no longer
491:             * have an email account.</p>
492:             *
493:             * <p>This is good for employees who have left the company. We still
494:             * want to see their contributions, but they no longer have access to
495:             * the system themselves.</p>
496:             *
497:             * <p>This method calls the <code>removeUser</code> script.</p>
498:             *
499:             * @param userName the user to remove from the email system.
500:             * @throws GroupwareException containing the content of the standard
501:             * error stream, if the script returns non-zero.
502:             */
503:            public void removeUser(final SecuritySession securitySession,
504:                    final String userName) throws SystemException {
505:                if (logger.isDebugEnabled()) {
506:                    logger
507:                            .debug("removeUser(SecuritySession securitySession = "
508:                                    + securitySession
509:                                    + ", String userName = "
510:                                    + userName + ") - start");
511:                }
512:
513:                String[] argv = new String[1];
514:
515:                argv[0] = getSystemUserName(securitySession, userName);
516:                scriptExecutor.exec("removeUser", argv);
517:
518:                if (logger.isDebugEnabled()) {
519:                    logger.debug("removeUser(SecuritySession, String) - end");
520:                }
521:            }
522:
523:            /**
524:             * <p>Adds or amends a mailing list with the name and users
525:             * provided.</p>
526:             *
527:             * <p>This method calls the <code>setList</code> script with the name
528:             * as the first parameter and the user names of each of the users as
529:             * following parameters.</p>
530:             *
531:             * @param name the name of the list to be added.
532:             * @param users <code>Collection</code> containing
533:             * <code>UserLocal</code> instances of each of the users in the list.
534:             * Note that if you are changing an existing list, this array should
535:             * contain all of the users, not just the new ones.
536:             * @throws GroupwareException containing the content of the standard
537:             * error stream, if the script returns non-zero.
538:             */
539:            public final void setList(final SecuritySession securitySession,
540:                    final String name, final Collection users)
541:                    throws SystemException {
542:                if (logger.isDebugEnabled()) {
543:                    logger.debug("setList(SecuritySession securitySession = "
544:                            + securitySession + ", String name = " + name
545:                            + ", Collection users = " + users + ") - start");
546:                }
547:
548:                String[] argv = new String[users.size() + 1];
549:                argv[0] = name;
550:                int index = 1;
551:
552:                for (Iterator i = users.iterator(); i.hasNext(); ++index) {
553:                    argv[index] = (String) i.next();
554:                }
555:
556:                scriptExecutor.exec("setList", argv);
557:
558:                if (logger.isDebugEnabled()) {
559:                    logger
560:                            .debug("setList(SecuritySession, String, Collection) - end");
561:                }
562:            }
563:
564:            /**
565:             * <p>Set a user's password in the system. This method calls the
566:             * <code>setPassword</code> script with <code>userName</code> and
567:             * <code>password</code> as parameters.</p>
568:             *
569:             * @param userName the user for whom to set the password.
570:             * @param password new value of the password.
571:             * @throws GroupwareException containing the content of the standard
572:             * error stream, if the script returns non-zero.
573:             */
574:            public final void setPassword(
575:                    final SecuritySession securitySession,
576:                    final String userName, final String password)
577:                    throws SystemException {
578:                if (logger.isDebugEnabled()) {
579:                    logger
580:                            .debug("setPassword(SecuritySession securitySession = "
581:                                    + securitySession
582:                                    + ", String userName = "
583:                                    + userName
584:                                    + ", String password = "
585:                                    + password + ") - start");
586:                }
587:
588:                String[] argv = new String[3];
589:
590:                argv[0] = getSystemUserName(securitySession, userName);
591:                argv[1] = password;
592:                // this parameter should be no-zero to indicate conversion of error
593:                // messages to localized keys
594:                argv[2] = "1";
595:                scriptExecutor.exec("setPassword", argv);
596:
597:                if (logger.isDebugEnabled()) {
598:                    logger
599:                            .debug("setPassword(SecuritySession, String, String) - end");
600:                }
601:            }
602:
603:            /**
604:             * <p>Gets all of the email aliases for the user provided.</p>
605:             *
606:             * <p>This method calls the script <code>setUserAliases</code>.</p>
607:             *
608:             * @param userName the user for whom to get the email aliases.
609:             * @param aliases a <code>Collection</code> containing
610:             * <code>String</code> values for each of the aliases.
611:             * @throws GroupwareException containing the content of the standard
612:             * error stream, if the script returns non-zero.
613:             */
614:            public final void setUserAliases(
615:                    final SecuritySession securitySession,
616:                    final String userName, final Collection aliases)
617:                    throws SystemException {
618:                if (logger.isDebugEnabled()) {
619:                    logger
620:                            .debug("setUserAliases(SecuritySession securitySession = "
621:                                    + securitySession
622:                                    + ", String userName = "
623:                                    + userName
624:                                    + ", Collection aliases = "
625:                                    + aliases + ") - start");
626:                }
627:
628:                String[] argv = new String[aliases.size() + 1];
629:
630:                argv[0] = getSystemUserName(securitySession, userName);
631:
632:                int index = 1;
633:
634:                for (Iterator i = aliases.iterator(); i.hasNext(); ++index) {
635:                    argv[index] = (String) i.next();
636:                }
637:
638:                scriptExecutor.exec("setUserAliases", argv);
639:
640:                if (logger.isDebugEnabled()) {
641:                    logger
642:                            .debug("setUserAliases(SecuritySession, String, Collection) - end");
643:                }
644:            }
645:
646:            /**
647:             * <p>Set an email addresss to forward this user's mail to. If
648:             * <code>address</code> is set to <code>null</code> then any previous
649:             * email
650:             * forwarding is removed.
651:             *
652:             * @param userName the user for whom to activate/deactive email
653:             * forwarding.
654:             * @param address email address to forward all email for this user to.
655:             * If this
656:             * address is set to <code>null</code> then any previous forwarding is
657:             * removed.
658:             * @throws GroupwareException containing the content of the standard
659:             * error
660:             * stream, if the script returns non-zero.
661:             *
662:             *
663:             */
664:            public final void setUserForwarding(
665:                    final SecuritySession securitySession,
666:                    final String userName, final String address)
667:                    throws SystemException {
668:                if (logger.isDebugEnabled()) {
669:                    logger
670:                            .debug("setUserForwarding(SecuritySession securitySession = "
671:                                    + securitySession
672:                                    + ", String userName = "
673:                                    + userName
674:                                    + ", String address = "
675:                                    + address + ") - start");
676:                }
677:
678:                String[] argv = new String[2];
679:
680:                argv[0] = getSystemUserName(securitySession, userName);
681:                argv[1] = address;
682:                scriptExecutor.exec("setUserForwarding", argv);
683:
684:                if (logger.isDebugEnabled()) {
685:                    logger
686:                            .debug("setUserForwarding(SecuritySession, String, String) - end");
687:                }
688:            }
689:
690:            /**
691:             * <p>Sets the vacation method for the user provided. This message
692:             * will be sent
693:             * to all mails received at this address until it has been cleared, by
694:             * calling
695:             * this method again with a <code>null</code> value for the
696:             * <code>message</code>
697:             * parameter.</p>
698:             *
699:             * <p>This method calls the <code>setVacationMessage</code> script
700:             * with <code>user name</code> and <code>message</code> as parameters.
701:             * If the <code>message</code> parameter is <code>null</code>, then
702:             * the
703:             * script is called with just the
704:             * <code>user name</code> parameter.</p>
705:             *
706:             * @param userName the user for whom to set the vacation message.
707:             * @param messageParam the new vacation message for this user. Set to
708:             * <code>null</code> to remove any existing vacation message.
709:             * @throws GroupwareException containing the content of the standard
710:             * error stream, if the script returns non-zero.
711:             */
712:            public final void setVacationMessage(
713:                    final SecuritySession securitySession,
714:                    final String userName, final String messageParam)
715:                    throws SystemException {
716:                if (logger.isDebugEnabled()) {
717:                    logger
718:                            .debug("setVacationMessage(SecuritySession securitySession = "
719:                                    + securitySession
720:                                    + ", String userName = "
721:                                    + userName
722:                                    + ", String messageParam = "
723:                                    + messageParam + ") - start");
724:                }
725:
726:                String[] argv = new String[2];
727:                String message = messageParam;
728:
729:                // TODO: possibly handle vacation message removal differently here
730:                // (null = remove vacation message - we just set it to the empty string)
731:                if (message == null) {
732:                    message = "";
733:                }
734:
735:                argv[0] = getSystemUserName(securitySession, userName);
736:                argv[1] = message;
737:                scriptExecutor.exec("setVacationMessage", argv);
738:
739:                if (logger.isDebugEnabled()) {
740:                    logger
741:                            .debug("setVacationMessage(SecuritySession, String, String) - end");
742:                }
743:            }
744:
745:            /**
746:             * <copyDoc>Refer to {@link }.</copyDoc>
747:             *
748:             * @param userNameParam
749:             * @return
750:             * @see com.ivata.groupware.admin.security.server.SecurityServer#isUser(java.lang.String)
751:             */
752:            public boolean isUser(final SecuritySession securitySession,
753:                    final String userNameParam) throws SystemException {
754:                if (logger.isDebugEnabled()) {
755:                    logger.debug("isUser(SecuritySession securitySession = "
756:                            + securitySession + ", String userNameParam = "
757:                            + userNameParam + ") - start");
758:                }
759:
760:                String[] argv = new String[1];
761:
762:                argv[0] = getSystemUserName(securitySession, userNameParam);
763:
764:                String isUser = scriptExecutor.exec("isUser", argv).trim();
765:                boolean returnboolean = "true".equals(isUser);
766:                if (logger.isDebugEnabled()) {
767:                    logger
768:                            .debug("isUser(SecuritySession, String) - end - return value = "
769:                                    + returnboolean);
770:                }
771:                return returnboolean;
772:            }
773:
774:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.