Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Privilege.java
Go to the documentation of this file.
1 // Copyright 2013 Cloudera Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 package com.cloudera.impala.authorization;
16 
17 import java.util.EnumSet;
18 
19 import org.apache.sentry.core.model.db.DBModelAction;
20 
21 /*
22  * Maps an Impala Privilege to one or more Hive Access "Actions".
23  */
24 public enum Privilege {
25  ALL(DBModelAction.ALL, false),
26  ALTER(DBModelAction.ALL, false),
27  DROP(DBModelAction.ALL, false),
28  CREATE(DBModelAction.ALL, false),
29  INSERT(DBModelAction.INSERT, false),
30  SELECT(DBModelAction.SELECT, false),
31  // Privileges required to view metadata on a server object.
32  VIEW_METADATA(EnumSet.of(DBModelAction.INSERT, DBModelAction.SELECT), true),
33  // Special privilege that is used to determine if the user has any valid privileges
34  // on a target object.
35  ANY(EnumSet.allOf(DBModelAction.class), true),
36  ;
37 
38  private final EnumSet<DBModelAction> actions;
39 
40  // Determines whether to check if the user has ANY the privileges defined in the
41  // actions list or whether to check if the user has ALL of the privileges in the
42  // actions list.
43  private final boolean anyOf_;
44 
45  private Privilege(EnumSet<DBModelAction> actions, boolean anyOf) {
46  this.actions = actions;
47  this.anyOf_ = anyOf;
48  }
49 
50  private Privilege(DBModelAction action, boolean anyOf) {
51  this(EnumSet.of(action), anyOf);
52  }
53 
54  /*
55  * Returns the set of Hive Access Actions mapping to this Privilege.
56  */
57  public EnumSet<DBModelAction> getHiveActions() {
58  return actions;
59  }
60 
61  /*
62  * Determines whether to check if the user has ANY the privileges defined in the
63  * actions list or whether to check if the user has ALL of the privileges in the
64  * actions list.
65  */
66  public boolean getAnyOf() { return anyOf_; }
67 }
Privilege(DBModelAction action, boolean anyOf)
Definition: Privilege.java:50
final EnumSet< DBModelAction > actions
Definition: Privilege.java:38
EnumSet< DBModelAction > getHiveActions()
Definition: Privilege.java:57
Privilege(EnumSet< DBModelAction > actions, boolean anyOf)
Definition: Privilege.java:45