List of usage examples for org.apache.hadoop.security.authentication.util KerberosName getRules
public static String getRules()
From source file:org.apache.impala.authorization.User.java
License:Apache License
@VisibleForTesting public String getShortNameForTesting(String rules) { Preconditions.checkNotNull(rules);/*ww w. j a v a2 s . c o m*/ Preconditions.checkState(RuntimeEnv.INSTANCE.isTestEnv()); String currentRules = KerberosName.getRules(); KerberosName.setRules(rules); String shortName = null; try { shortName = getShortName(); } catch (InternalException e) { e.printStackTrace(); } // reset the rules KerberosName.setRules(currentRules); return shortName; }
From source file:org.apache.ranger.audit.provider.MiscUtil.java
License:Apache License
public static String getKerberosNamesRules() { return KerberosName.getRules(); }
From source file:org.apache.ranger.audit.provider.MiscUtil.java
License:Apache License
/** * /*from w w w .j a va 2s . co m*/ * @param principal * This could be in the format abc/host@domain.com * @return */ static public String getShortNameFromPrincipalName(String principal) { if (principal == null) { return null; } try { // Assuming it is kerberos name for now KerberosName kerbrosName = new KerberosName(principal); String userName = kerbrosName.getShortName(); userName = StringUtils.substringBefore(userName, "/"); userName = StringUtils.substringBefore(userName, "@"); return userName; } catch (Throwable t) { logger.error("Error converting kerberos name. principal=" + principal + ", KerberosName.rules=" + KerberosName.getRules()); } return principal; }
From source file:org.apache.ranger.authorization.storm.StormRangerPlugin.java
License:Apache License
@Override synchronized public void init() { if (!initialized) { // mandatory call to base plugin super.init(); // One time call to register the audit hander with the policy engine. super.setResultProcessor(new RangerDefaultAuditHandler()); // this needed to set things right in the nimbus process if (KerberosName.getRules() == null) { KerberosName.setRules("DEFAULT"); }/*ww w. jav a2 s .c om*/ initialized = true; LOG.info("StormRangerPlugin initialized!"); } }
From source file:org.apache.sentry.binding.solr.authz.SentrySolrPluginImpl.java
License:Apache License
/** * Workaround until SOLR-10814 is fixed. This method allows extracting short user-name from * Solr provided {@linkplain Principal} instance. * * @param ctx The Solr provided authorization context * @return The short name of the authenticated user for this request *///w w w.ja va 2s. co m public static String getShortUserName(Principal princ) { if (princ instanceof BasicUserPrincipal) { return princ.getName(); } KerberosName name = new KerberosName(princ.getName()); try { return name.getShortName(); } catch (IOException e) { LOG.error("Error converting kerberos name. principal = {}, KerberosName.rules = {}", princ, KerberosName.getRules()); throw new SolrException(ErrorCode.SERVER_ERROR, "Unexpected error converting a kerberos name", e); } }