001/** 002 * Licensed to the Apache Software Foundation (ASF) under one or more contributor license 003 * agreements. See the NOTICE file distributed with this work for additional information regarding 004 * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the 005 * "License"); you may not use this file except in compliance with the License. You may obtain a 006 * copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable 007 * law or agreed to in writing, software distributed under the License is distributed on an "AS IS" 008 * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License 009 * for the specific language governing permissions and limitations under the License. 010 */ 011package org.apache.hadoop.hbase.security.visibility; 012 013import java.io.IOException; 014 015import org.apache.hadoop.conf.Configuration; 016import org.apache.hadoop.hbase.coprocessor.CoprocessorHost; 017import org.apache.hadoop.hbase.security.User; 018 019/** 020 * Utility methods for testing visibility labels. 021 */ 022public class VisibilityTestUtil { 023 024 public static void enableVisiblityLabels(Configuration conf) throws IOException { 025 conf.setInt("hfile.format.version", 3); 026 conf.setBoolean(User.HBASE_SECURITY_AUTHORIZATION_CONF_KEY, true); 027 appendCoprocessor(conf, CoprocessorHost.MASTER_COPROCESSOR_CONF_KEY, 028 VisibilityController.class.getName()); 029 appendCoprocessor(conf, CoprocessorHost.REGION_COPROCESSOR_CONF_KEY, 030 VisibilityController.class.getName()); 031 } 032 033 private static void appendCoprocessor(Configuration conf, String property, String value) { 034 if (conf.get(property) == null) { 035 conf.set(property, VisibilityController.class.getName()); 036 } else { 037 conf.set(property, conf.get(property) + "," + VisibilityController.class.getName()); 038 } 039 } 040 041}