1 /*
2 * ========================================================================
3 *
4 * Licensed to the Apache Software Foundation (ASF) under one or more
5 * contributor license agreements. See the NOTICE file distributed with
6 * this work for additional information regarding copyright ownership.
7 * The ASF licenses this file to You under the Apache License, Version 2.0
8 * (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 * ========================================================================
20 */
21 package org.apache.cactus.client.authentication;
22
23 /**
24 * This class was designed with the simple assumption that ALL authentication
25 * implementations will have a String <code>Name</code> and a String
26 * <code>Password</code>. Two abstract functions <code>validateName</code> and
27 * <code>validatePassword</code> provide for concrete implementations to
28 * perform character validation. All the work is then done in the
29 * <code>configure</code> abstract function. In the
30 * <code>BasicAuthentication</code> class, for example, the configuring is done
31 * by adding the request property "Authorization" with a value
32 * "Basic <base64encode of 'userid:password'>".
33 *
34 * @since 1.3
35 *
36 * @version $Id: AbstractAuthentication.java 238991 2004-05-22 11:34:50Z vmassol $
37 */
38 public abstract class AbstractAuthentication implements Authentication
39 {
40 /**
41 * User name part of the Credential.
42 */
43 private String name;
44
45 /**
46 * Password part of the Credential.
47 */
48 private String password;
49
50 /**
51 * @param theName user name of the Credential
52 * @param thePassword user password of the Credential
53 */
54 public AbstractAuthentication(String theName, String thePassword)
55 {
56 setName(theName);
57 setPassword(thePassword);
58 }
59
60 /**
61 * Sets the user name.
62 *
63 * @param theName user name of the Credential
64 */
65 public final void setName(String theName)
66 {
67 this.name = theName;
68 }
69
70 /**
71 * @return the user name of the Credential
72 */
73 public final String getName()
74 {
75 return this.name;
76 }
77
78 /**
79 * Sets the user password of the Credential.
80 *
81 * @param thePassword the user password of the Credential
82 */
83 public final void setPassword(String thePassword)
84 {
85 this.password = thePassword;
86 }
87
88 /**
89 * @return the user password of the Credential
90 */
91 public final String getPassword()
92 {
93 return this.password;
94 }
95 }