MapReduce服务 MRS-HBase数据读写示例安全认证(单集群场景):配置安全登录

时间:2023-11-01 16:19:45

配置安全登录

请根据实际情况,在“com.huawei.bigdata.hbase.examples”包的“TestMain”类中修改“userName”为实际用户名,例如developuser

private static void login() throws IOException {        if (User.isHBaseSecurityEnabled(conf)) {            userName = "developuser";                       //In Windows environment            String userdir = TestMain.class.getClassLoader().getResource("conf").getPath() + File.separator;            //In Linux environment            //String userdir = System.getProperty("user.dir") + File.separator + "conf" + File.separator;             /*             * if need to connect zk, please provide jaas info about zk. of course,             * you can do it as below:             * System.setProperty("java.security.auth.login.config", confDirPath +             * "jaas.conf"); but the demo can help you more : Note: if this process             * will connect more than one zk cluster, the demo may be not proper. you             * can contact us for more help             */            LoginUtil.setJaasConf(ZOOKEEPER_DEFAULT_LOGIN_CONTEXT_NAME, userName, userKeytabFile);            LoginUtil.login(userName, userKeytabFile, krb5File, conf);        }}
support.huaweicloud.com/devg3-mrs/mrs_07_080009.html