001/*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.apache.hadoop.hbase.security.access;
019
020import java.util.Collection;
021import java.util.Map;
022
023import org.apache.hadoop.conf.Configuration;
024import org.apache.hadoop.hbase.TableName;
025import org.apache.hadoop.hbase.client.RegionInfo;
026import org.apache.hadoop.hbase.security.User;
027import org.apache.hadoop.hbase.security.access.Permission.Action;
028import org.apache.yetus.audience.InterfaceAudience;
029
030/**
031 * NoopAccessChecker is returned when hbase.security.authorization is not enabled.
032 * Always allow authorization if any user require any permission.
033 */
034@InterfaceAudience.Private
035public final class NoopAccessChecker extends AccessChecker {
036
037  public NoopAccessChecker(Configuration conf) throws RuntimeException {
038    super(conf);
039  }
040
041  @Override
042  public void requireAccess(User user, String request, TableName tableName, Action... permissions) {
043  }
044
045  @Override
046  public void requirePermission(User user, String request, String filterUser, Action perm) {
047    requireGlobalPermission(user, request, perm, null, null, filterUser);
048  }
049
050  @Override
051  public void requireGlobalPermission(User user, String request, Action perm, TableName tableName,
052      Map<byte[], ? extends Collection<byte[]>> familyMap, String filterUser) {
053  }
054
055  @Override
056  public void requireGlobalPermission(User user, String request, Action perm, String namespace) {
057  }
058
059  @Override
060  public void requireNamespacePermission(User user, String request, String namespace,
061      String filterUser, Action... permissions) {
062  }
063
064  @Override
065  public void requireNamespacePermission(User user, String request, String namespace,
066      TableName tableName, Map<byte[], ? extends Collection<byte[]>> familyMap,
067      Action... permissions) {
068  }
069
070  @Override
071  public void requirePermission(User user, String request, TableName tableName, byte[] family,
072      byte[] qualifier, String filterUser, Action... permissions) {
073  }
074
075  @Override
076  public void requireTablePermission(User user, String request, TableName tableName, byte[] family,
077      byte[] qualifier, Action... permissions) {
078  }
079
080  @Override
081  public void performOnSuperuser(String request, User caller, String userToBeChecked) {
082  }
083
084  @Override
085  public void checkLockPermissions(User user, String namespace, TableName tableName,
086      RegionInfo[] regionInfos, String reason) {
087  }
088
089  @Override
090  public boolean hasUserPermission(User user, String request, Permission permission) {
091    return true;
092  }
093
094  @Override
095  public AuthResult permissionGranted(String request, User user, Action permRequest,
096      TableName tableName, Map<byte[], ? extends Collection<?>> families) {
097    return AuthResult.allow(request, "All users allowed because authorization is disabled", user,
098      permRequest, tableName, families);
099  }
100}