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;
022import org.apache.hadoop.conf.Configuration;
023import org.apache.hadoop.hbase.TableName;
024import org.apache.hadoop.hbase.client.RegionInfo;
025import org.apache.hadoop.hbase.security.User;
026import org.apache.hadoop.hbase.security.access.Permission.Action;
027import org.apache.yetus.audience.InterfaceAudience;
028
029/**
030 * NoopAccessChecker is returned when hbase.security.authorization is not enabled. Always allow
031 * authorization if any user require any permission.
032 */
033@InterfaceAudience.Private
034public final class NoopAccessChecker extends AccessChecker {
035
036  public NoopAccessChecker(Configuration conf) throws RuntimeException {
037    super(conf);
038  }
039
040  @Override
041  public void requireAccess(User user, String request, TableName tableName, Action... permissions) {
042  }
043
044  @Override
045  public void requirePermission(User user, String request, String filterUser, Action perm) {
046    requireGlobalPermission(user, request, perm, null, null, filterUser);
047  }
048
049  @Override
050  public void requireGlobalPermission(User user, String request, Action perm, TableName tableName,
051    Map<byte[], ? extends Collection<byte[]>> familyMap, String filterUser) {
052  }
053
054  @Override
055  public void requireGlobalPermission(User user, String request, Action perm, String namespace) {
056  }
057
058  @Override
059  public void requireNamespacePermission(User user, String request, String namespace,
060    String filterUser, Action... permissions) {
061  }
062
063  @Override
064  public void requireNamespacePermission(User user, String request, String namespace,
065    TableName tableName, Map<byte[], ? extends Collection<byte[]>> familyMap,
066    Action... permissions) {
067  }
068
069  @Override
070  public void requirePermission(User user, String request, TableName tableName, byte[] family,
071    byte[] qualifier, String filterUser, Action... permissions) {
072  }
073
074  @Override
075  public void requireTablePermission(User user, String request, TableName tableName, byte[] family,
076    byte[] qualifier, Action... permissions) {
077  }
078
079  @Override
080  public void performOnSuperuser(String request, User caller, String userToBeChecked) {
081  }
082
083  @Override
084  public void checkLockPermissions(User user, String namespace, TableName tableName,
085    RegionInfo[] regionInfos, String reason) {
086  }
087
088  @Override
089  public boolean hasUserPermission(User user, String request, Permission permission) {
090    return true;
091  }
092
093  @Override
094  public AuthResult permissionGranted(String request, User user, Action permRequest,
095    TableName tableName, Map<byte[], ? extends Collection<?>> families) {
096    return AuthResult.allow(request, "All users allowed because authorization is disabled", user,
097      permRequest, tableName, families);
098  }
099}