PageRenderTime 20ms CodeModel.GetById 11ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/tags/release-0.1-rc2/hive/external/ql/src/java/org/apache/hadoop/hive/ql/security/authorization/PrivilegeRegistry.java

#
Java | 58 lines | 27 code | 10 blank | 21 comment | 0 complexity | 2fc30723e8e13b1e1a1c7cb602094358 MD5 | raw file
 1/**
 2 * Licensed to the Apache Software Foundation (ASF) under one
 3 * or more contributor license agreements.  See the NOTICE file
 4 * distributed with this work for additional information
 5 * regarding copyright ownership.  The ASF licenses this file
 6 * to you under the Apache License, Version 2.0 (the
 7 * "License"); you may not use this file except in compliance
 8 * with the License.  You may obtain a copy of the License at
 9 *
10 *     http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19package org.apache.hadoop.hive.ql.security.authorization;
20
21import java.util.HashMap;
22
23import org.apache.hadoop.hive.ql.security.authorization.Privilege.PrivilegeType;
24
25/**
26 * PrivilegeRegistry is used to do privilege lookups. Given a privilege name, it
27 * will return the Privilege object.
28 */
29public class PrivilegeRegistry {
30
31  protected static HashMap<PrivilegeType, Privilege> Registry = new HashMap<PrivilegeType, Privilege>();
32
33  static {
34    Registry.put(Privilege.ALL.getPriv(), Privilege.ALL);
35    Registry.put(Privilege.ALTER_DATA.getPriv(), Privilege.ALTER_DATA);
36    Registry.put(Privilege.ALTER_METADATA.getPriv(), Privilege.ALTER_METADATA);
37    Registry.put(Privilege.CREATE.getPriv(), Privilege.CREATE);
38    Registry.put(Privilege.DROP.getPriv(), Privilege.DROP);
39    Registry.put(Privilege.INDEX.getPriv(), Privilege.INDEX);
40    Registry.put(Privilege.LOCK.getPriv(), Privilege.LOCK);
41    Registry.put(Privilege.SELECT.getPriv(), Privilege.SELECT);
42    Registry.put(Privilege.SHOW_DATABASE.getPriv(),
43        Privilege.SHOW_DATABASE);
44  }
45
46  public static Privilege getPrivilege(PrivilegeType privilegeType) {
47    return Registry.get(privilegeType);
48  }
49
50  public static Privilege getPrivilege(int privilegeToken) {
51    return Registry.get(Privilege.getPrivTypeByToken(privilegeToken));
52  }
53
54  public static Privilege getPrivilege(String privilegeName) {
55    return Registry.get(Privilege.getPrivTypeByName(privilegeName));
56  }
57
58}