public class KerberosUtil extends Object
Modifier and Type | Field and Description |
---|---|
static Oid |
GSS_KRB5_MECH_OID |
static Oid |
GSS_SPNEGO_MECH_OID |
static Oid |
NT_GSS_KRB5_PRINCIPAL_OID |
Constructor and Description |
---|
KerberosUtil() |
Modifier and Type | Method and Description |
---|---|
static String |
getDefaultRealm() |
static String |
getDefaultRealmProtected() |
static String |
getDomainRealm(String shortprinc) |
static String |
getKrb5LoginModuleName() |
static Oid |
getOidInstance(String oidName) |
static String[] |
getPrincipalNames(String keytab,
Pattern pattern)
Get all the unique principals from keytabfile which matches a pattern.
|
static String |
getServicePrincipal(String service,
String hostname)
Create Kerberos principal for a given service and hostname,
inferring realm from the fqdn of the hostname.
|
static String |
getTokenServerName(byte[] rawToken)
Extract the TGS server principal from the given gssapi kerberos or spnego
wrapped token.
|
static boolean |
hasKerberosKeyTab(Subject subject)
Check if the subject contains Kerberos keytab related objects.
|
static boolean |
hasKerberosTicket(Subject subject)
Check if the subject contains Kerberos ticket.
|
public static final Oid GSS_SPNEGO_MECH_OID
public static final Oid GSS_KRB5_MECH_OID
public static final Oid NT_GSS_KRB5_PRINCIPAL_OID
public static String getKrb5LoginModuleName()
public static Oid getOidInstance(String oidName) throws ClassNotFoundException, GSSException, NoSuchFieldException, IllegalAccessException
public static String getDefaultRealm() throws ClassNotFoundException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException
public static String getDefaultRealmProtected()
public static final String getServicePrincipal(String service, String hostname) throws UnknownHostException
service
- Service for which you want to generate the principal.hostname
- Fully-qualified domain name.UnknownHostException
- If no IP address for the local host could be found.public static final String[] getPrincipalNames(String keytab, Pattern pattern) throws IOException
keytab
- Name of the keytab file to be read.pattern
- pattern to be matched.IOException
- if cannot get the principal namepublic static boolean hasKerberosKeyTab(Subject subject)
subject
- subject to be checkedpublic static boolean hasKerberosTicket(Subject subject)
subject
- subject to be checkedpublic static String getTokenServerName(byte[] rawToken)
rawToken
- bytes of the gss tokenIllegalArgumentException
- if token is undecodableCopyright © 2022 Apache Software Foundation. All rights reserved.