AbstractAuthorizationEnforcer(CConfiguration cConf) { this.securityAuthorizationEnabled = AuthorizationUtil.isSecurityAuthorizationEnabled(cConf); }
/** * Get the effective master user, if it is specified in the {@link CConfiguration}, use it. Otherwise, use the * current login user. If security is not enabled, null is returned. */ @Nullable public static String getEffectiveMasterUser(CConfiguration cConf) { String masterPrincipal = cConf.get(Constants.Security.CFG_CDAP_MASTER_KRB_PRINCIPAL); try { if (isSecurityAuthorizationEnabled(cConf)) { masterPrincipal = masterPrincipal == null ? UserGroupInformation.getLoginUser().getShortUserName() : new KerberosName(masterPrincipal).getShortName(); } else { masterPrincipal = null; } } catch (IOException e) { throw new RuntimeException(String.format("Failed to translate the principal name %s to an operating system " + "user name.", masterPrincipal), e); } return masterPrincipal; } }