Example usage for javax.security.auth.kerberos KerberosPrincipal getRealm

List of usage examples for javax.security.auth.kerberos KerberosPrincipal getRealm

Introduction

In this page you can find the example usage for javax.security.auth.kerberos KerberosPrincipal getRealm.

Prototype

public String getRealm() 

Source Link

Document

Returns the realm component of this Kerberos principal.

Usage

From source file:com.buaa.cfs.utils.SecurityUtil.java

/**
 * TGS must have the server principal of the form "krbtgt/FOO@FOO".
 *
 * @param principal// w w  w.  j  a v a 2  s  . co  m
 *
 * @return true or false
 */
static boolean isTGSPrincipal(KerberosPrincipal principal) {
    if (principal == null)
        return false;
    if (principal.getName().equals("krbtgt/" + principal.getRealm() + "@" + principal.getRealm())) {
        return true;
    }
    return false;
}

From source file:org.apache.hadoop.security.UserGroupInformation.java

/**
 * Get the Kerberos TGT//from   w  ww .java 2 s .c o  m
 * @return the user's TGT or null if none was found
 */
private synchronized KerberosTicket getTGT() {
    Set<KerberosTicket> tickets = subject.getPrivateCredentials(KerberosTicket.class);
    for (KerberosTicket ticket : tickets) {
        KerberosPrincipal server = ticket.getServer();
        if (server.getName().equals("krbtgt/" + server.getRealm() + "@" + server.getRealm())) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Found tgt " + ticket);
            }
            return ticket;
        }
    }
    return null;
}

From source file:org.apache.nifi.security.krb.AbstractKerberosUser.java

/**
 * TGS must have the server principal of the form "krbtgt/FOO@FOO".
 *
 * @param principal the principal to check
 * @return true if the principal is the TGS, false otherwise
 *//*from   w w w .  j  a  va  2  s .  com*/
private boolean isTGSPrincipal(final KerberosPrincipal principal) {
    if (principal == null) {
        return false;
    }

    if (principal.getName().equals("krbtgt/" + principal.getRealm() + "@" + principal.getRealm())) {
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Found TGT principal: " + principal.getName());
        }
        return true;
    }

    return false;
}