KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > filesys > server > auth > acl > UserAccessControlParser


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.acl;
18
19 import org.alfresco.config.ConfigElement;
20
21 /**
22  * User Access Control Parser Class
23  */

24 public class UserAccessControlParser extends AccessControlParser
25 {
26     /**
27      * Default constructor
28      */

29     public UserAccessControlParser()
30     {
31     }
32
33     /**
34      * Return the parser type
35      *
36      * @return String
37      */

38     public String JavaDoc getType()
39     {
40         return "user";
41     }
42
43     /**
44      * Validate the parameters and create a user access control
45      *
46      * @param params ConfigElement
47      * @return AccessControl
48      * @throws ACLParseException
49      */

50     public AccessControl createAccessControl(ConfigElement params) throws ACLParseException
51     {
52
53         // Get the access type
54

55         int access = parseAccessType(params);
56
57         // Get the user name to check for
58

59         String JavaDoc userName = params.getAttribute("name");
60         if (userName == null || userName.length() == 0)
61             throw new ACLParseException("User name not specified");
62
63         // Create the user access control
64

65         return new UserAccessControl(userName, getType(), access);
66     }
67 }
68
Popular Tags