01: /*
02: * Copyright 2001-2005 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.apache.commons.mail;
17:
18: import javax.mail.Authenticator;
19: import javax.mail.PasswordAuthentication;
20:
21: /**
22: * This is a very simple authentication object that can be used for any
23: * transport needing basic userName and password type authentication.
24: *
25: * @since 1.0
26: * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
27: * @version $Id: DefaultAuthenticator.java 225600 2005-07-27 20:16:23Z rdonkin $
28: */
29: public class DefaultAuthenticator extends Authenticator {
30: /** Stores the login information for authentication */
31: private PasswordAuthentication authentication;
32:
33: /**
34: * Default constructor
35: *
36: * @param userName user name to use when authentication is requested
37: * @param password password to use when authentication is requested
38: * @since 1.0
39: */
40: public DefaultAuthenticator(String userName, String password) {
41: this .authentication = new PasswordAuthentication(userName,
42: password);
43: }
44:
45: /**
46: * Gets the authentication object that will be used to login to the mail
47: * server.
48: *
49: * @return A <code>PasswordAuthentication</code> object containing the
50: * login information.
51: * @since 1.0
52: */
53: protected PasswordAuthentication getPasswordAuthentication() {
54: return this.authentication;
55: }
56: }
|