public final class LdapUtils extends Object
Modifier and Type | Method and Description |
---|---|
static List<String> |
createCandidatePrincipals(HiveConf conf,
String user)
Creates a list of principals to be used for user authentication.
|
static String |
extractBaseDn(String dn)
Extracts a base DN from the provided distinguished name.
|
static String |
extractFirstRdn(String dn)
Extracts the first Relative Distinguished Name (RDN).
|
static String |
extractUserName(String userDn)
Extracts username from user DN.
|
static String |
getShortName(String rdn)
Gets value part of the first attribute in the provided RDN.
|
static boolean |
hasDomain(String userName)
Check for a domain part in the provided username.
|
static boolean |
isDn(String name)
Detects DN names.
|
static List<String> |
parseDnPatterns(HiveConf conf,
HiveConf.ConfVars var)
Reads and parses DN patterns from Hive configuration.
|
static List<String> |
patternsToBaseDns(Collection<String> patterns)
Converts a collection of Distinguished Name patterns to a collection of base DNs.
|
public static String extractBaseDn(String dn)
dn
- distinguished namepublic static String extractFirstRdn(String dn)
dn
- distinguished namepublic static String extractUserName(String userDn)
LdapUtils.extractUserName("UserName") = "UserName" LdapUtils.extractUserName("UserName@mycorp.com") = "UserName" LdapUtils.extractUserName("cn=UserName,dc=mycompany,dc=com") = "UserName"
userDn
- public static String getShortName(String rdn)
rdn
- Relative Distinguished Namepublic static boolean hasDomain(String userName)
LdapUtils.hasDomain("user1@mycorp.com") = true LdapUtils.hasDomain("user1") = false
userName
- usernameuserName
contains @<domain>
partpublic static boolean isDn(String name)
LdapUtils.isDn("cn=UserName,dc=mycompany,dc=com") = true LdapUtils.isDn("user1") = false
name
- name to be checkedpublic static List<String> parseDnPatterns(HiveConf conf, HiveConf.ConfVars var)
conf
- Hive configurationvar
- variable to be readHiveConf.ConfVars.HIVE_SERVER2_PLAIN_LDAP_BASEDN
,
HiveConf.ConfVars.HIVE_SERVER2_PLAIN_LDAP_GUIDKEY
,
HiveConf.ConfVars.HIVE_SERVER2_PLAIN_LDAP_GROUPDNPATTERN
,
HiveConf.ConfVars.HIVE_SERVER2_PLAIN_LDAP_USERDNPATTERN
public static List<String> patternsToBaseDns(Collection<String> patterns)
patterns
- Distinguished Name patternsHiveConf.ConfVars.HIVE_SERVER2_PLAIN_LDAP_GROUPDNPATTERN
,
HiveConf.ConfVars.HIVE_SERVER2_PLAIN_LDAP_USERDNPATTERN
Copyright © 2022 The Apache Software Foundation. All rights reserved.