KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ivata > groupware > business > mail > session > MailAuthenticator


1 /*
2  * Copyright (c) 2001 - 2005 ivata limited.
3  * All rights reserved.
4  * -----------------------------------------------------------------------------
5  * ivata groupware may be redistributed under the GNU General Public
6  * License as published by the Free Software Foundation;
7  * version 2 of the License.
8  *
9  * These programs are free software; you can redistribute them and/or
10  * modify them under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; version 2 of the License.
12  *
13  * These programs are distributed in the hope that they will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  * See the GNU General Public License in the file LICENSE.txt for more
18  * details.
19  *
20  * If you would like a copy of the GNU General Public License write to
21  *
22  * Free Software Foundation, Inc.
23  * 59 Temple Place - Suite 330
24  * Boston, MA 02111-1307, USA.
25  *
26  *
27  * To arrange commercial support and licensing, contact ivata at
28  * http://www.ivata.com/contact.jsp
29  * -----------------------------------------------------------------------------
30  * $Log: MailAuthenticator.java,v $
31  * Revision 1.2 2005/04/09 17:20:01 colinmacleod
32  * Changed copyright text to GPL v2 explicitly.
33  *
34  * Revision 1.1.1.1 2005/03/10 17:51:16 colinmacleod
35  * Restructured ivata op around Hibernate/PicoContainer.
36  * Renamed ivata groupware.
37  *
38  * Revision 1.4 2004/07/13 19:48:12 colinmacleod
39  * Moved project to POJOs from EJBs.
40  * Applied PicoContainer to services layer (replacing session EJBs).
41  * Applied Hibernate to persistence layer (replacing entity EJBs).
42  *
43  * Revision 1.3 2004/03/21 21:16:39 colinmacleod
44  * Shortened name to ivata op.
45  *
46  * Revision 1.2 2004/02/01 22:07:32 colinmacleod
47  * Added full names to author tags
48  *
49  * Revision 1.1.1.1 2004/01/27 20:59:58 colinmacleod
50  * Moved ivata openportal to SourceForge..
51  *
52  * Revision 1.2 2003/10/15 14:11:33 colin
53  * fixing for XDoclet
54  *
55  * Revision 1.1 2003/02/24 19:09:24 colin
56  * moved to business
57  *
58  * Revision 1.3 2003/02/04 17:39:22 colin
59  * copyright notice
60  *
61  * Revision 1.2 2002/09/09 11:00:38 colin
62  * made session classes serializable :-)
63  *
64  * Revision 1.3 2002/09/09 08:44:52 colin
65  * made new mail session class to abstract the non-serializable JavaMail session
66  *
67  * Revision 1.1 2002/09/09 08:25:50 colin
68  * moved authenticator to session subpackage
69  *
70  * Revision 1.2 2002/08/30 14:20:36 peter
71  * fixed the previous state
72  *
73  * Revision 1.1 2002/08/30 09:18:22 colin
74  * added to repository late - sorry peter
75  *
76  * Revision 1.1 2002/07/15 07:51:04 colin
77  * added new Mail EJB and local interface to settings
78  *
79  * Revision 1.2 2002/07/01 10:24:07 colin
80  * improved documentation and added imports
81  * -----------------------------------------------------------------------------
82  */

83 package com.ivata.groupware.business.mail.session;
84
85 import java.io.IOException JavaDoc;
86 import java.io.ObjectInputStream JavaDoc;
87 import java.io.ObjectOutputStream JavaDoc;
88 import java.io.Serializable JavaDoc;
89
90 import javax.mail.Authenticator JavaDoc;
91 import javax.mail.PasswordAuthentication JavaDoc;
92
93
94 /**
95  * <p>Handles email authentication within the {@link
96  * com.ivata.groupware.web.tag.LoginTag LoginTag}.</p>
97  *
98  * @since 2001-09-08
99  * @author Colin MacLeod
100  * <a HREF='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
101  * @version $Revision: 1.2 $
102  */

103 public class MailAuthenticator extends Authenticator JavaDoc implements Serializable JavaDoc {
104     /**
105      * <p>This username will be used to log into the mail account.</p>
106      */

107     String JavaDoc userName;
108
109     /**
110      * <p>Password used to check user against mail account.</p>
111      */

112     String JavaDoc password;
113
114     /**
115      * <p>Construct an Authenticator with the given username and
116      * password.</p>
117      *
118      * @param userName username used to create a password authentication
119      * in
120      * <code>getPasswordAuthentication</code>
121      * @param password username used to create a password
122      * authentication in <code>getPasswordAuthentication</code>
123      * @see #getPasswordAuthentication( )
124      *
125      */

126     public MailAuthenticator(String JavaDoc userName, String JavaDoc password) {
127         this.userName = userName;
128         this.password = password;
129     }
130
131     /**
132      * <p>Return a PasswordAuthentication for the username and password
133      * given in
134      * the constructor.</p>
135      *
136      * @return PasswordAuthentication instantiated using the username and
137      * password given in the constructor
138      *
139      */

140     public PasswordAuthentication JavaDoc getPasswordAuthentication() {
141         return new PasswordAuthentication JavaDoc(userName, password);
142     }
143
144     /**
145      * <p>Serialize the object to the output stream provided.</p>
146      * @exception IOException thrown by
147      * <code>ObjectOutputStream.defaultWriteObject( )</code>
148      * @param oos the output stream to serialize the object to
149      *
150      */

151     private void writeObject(final ObjectOutputStream JavaDoc oos) throws IOException JavaDoc {
152         oos.defaultWriteObject();
153     }
154
155     /**
156      * <p>Serialize the object from the input stream provided.</p>
157      * @exception ClassNotFoundException thrown by
158      * <code>ObjectInputStream.defaultReadObject( )</code>.
159      * @exception IOException thrown by
160      * <code>ObjectInputStream.defaultReadObject( )</code>.
161      * @param ois the input stream to serialize the object from
162      *
163      */

164     private void readObject(final ObjectInputStream JavaDoc ois)
165         throws ClassNotFoundException JavaDoc, IOException JavaDoc {
166         ois.defaultReadObject();
167     }
168 }
169
Popular Tags