KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > filesys > server > auth > DefaultAuthenticator


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.filesys.server.auth;
18
19 import org.alfresco.config.ConfigElement;
20 import org.alfresco.filesys.server.SrvSession;
21 import org.alfresco.filesys.server.config.InvalidConfigurationException;
22 import org.alfresco.filesys.server.config.ServerConfiguration;
23 import org.alfresco.filesys.server.core.SharedDevice;
24
25 /**
26  * <p>
27  * Default authenticator class.
28  * <p>
29  * The default authenticator implementation enables user level security mode and allows any user to
30  * connect to the server.
31  */

32 public class DefaultAuthenticator extends SrvAuthenticator
33 {
34
35     // Server configuration
36

37     private ServerConfiguration m_config;
38
39     /**
40      * Class constructor
41      */

42     public DefaultAuthenticator()
43     {
44         setAccessMode(USER_MODE);
45         setEncryptedPasswords(true);
46     }
47
48     /**
49      * Allow any user to access the server
50      *
51      * @param client Client details.
52      * @param share Shared device the user is connecting to.
53      * @param pwd Share level password.
54      * @param sess Server session
55      * @return int
56      */

57     public int authenticateShareConnect(ClientInfo client, SharedDevice share, String JavaDoc pwd, SrvSession sess)
58     {
59         return Writeable;
60     }
61
62     /**
63      * Allow any user to access the server.
64      *
65      * @param client Client details.
66      * @param sess Server session
67      * @param alg Encryption algorithm
68      * @return int
69      */

70     public int authenticateUser(ClientInfo client, SrvSession sess, int alg)
71     {
72         return AUTH_ALLOW;
73     }
74
75     /**
76      * The default authenticator does not use encrypted passwords.
77      *
78      * @param sess SrvSession
79      * @return byte[]
80      */

81     public byte[] getChallengeKey(SrvSession sess)
82     {
83         return null;
84     }
85
86     /**
87      * Search for the requried user account details in the defined user list
88      *
89      * @param user String
90      * @return UserAccount
91      */

92     public UserAccount getUserDetails(String JavaDoc user)
93     {
94
95         // Get the user account list from the configuration
96

97         UserAccountList userList = m_config.getUserAccounts();
98         if (userList == null || userList.numberOfUsers() == 0)
99             return null;
100
101         // Search for the required user account record
102

103         return userList.findUser(user);
104     }
105
106     /**
107      * Initialzie the authenticator
108      *
109      * @param config ServerConfiguration
110      * @param params ConfigElement
111      * @exception InvalidConfigurationException
112      */

113     public void initialize(ServerConfiguration config, ConfigElement params) throws InvalidConfigurationException
114     {
115
116         // Save the server configuration so we can access the defined user list
117

118         m_config = config;
119     }
120 }
Popular Tags