Search in sources :

Example 1 with SpNegoCredElement

use of sun.security.jgss.spnego.SpNegoCredElement in project jdk8u_jdk by JetBrains.

the class GSSUtil method populateCredentials.

/**
     * Populates the set credentials with elements from gssCredentials. At
     * the same time, it converts any subclasses of KerberosTicket
     * into KerberosTicket instances and any subclasses of KerberosKey into
     * KerberosKey instances. (It is not desirable to expose the customer
     * to sun.security.jgss.krb5.Krb5InitCredential which extends
     * KerberosTicket and sun.security.jgss.krb5.Kbr5AcceptCredential which
     * extends KerberosKey.)
     */
private static void populateCredentials(Set<Object> credentials, Set<?> gssCredentials) {
    Object cred;
    Iterator<?> elements = gssCredentials.iterator();
    while (elements.hasNext()) {
        cred = elements.next();
        // Retrieve the internal cred out of SpNegoCredElement
        if (cred instanceof SpNegoCredElement) {
            cred = ((SpNegoCredElement) cred).getInternalCred();
        }
        if (cred instanceof KerberosTicket) {
            if (!cred.getClass().getName().equals("javax.security.auth.kerberos.KerberosTicket")) {
                KerberosTicket tempTkt = (KerberosTicket) cred;
                cred = new KerberosTicket(tempTkt.getEncoded(), tempTkt.getClient(), tempTkt.getServer(), tempTkt.getSessionKey().getEncoded(), tempTkt.getSessionKeyType(), tempTkt.getFlags(), tempTkt.getAuthTime(), tempTkt.getStartTime(), tempTkt.getEndTime(), tempTkt.getRenewTill(), tempTkt.getClientAddresses());
            }
            credentials.add(cred);
        } else if (cred instanceof KerberosKey) {
            if (!cred.getClass().getName().equals("javax.security.auth.kerberos.KerberosKey")) {
                KerberosKey tempKey = (KerberosKey) cred;
                cred = new KerberosKey(tempKey.getPrincipal(), tempKey.getEncoded(), tempKey.getKeyType(), tempKey.getVersionNumber());
            }
            credentials.add(cred);
        } else {
            // Ignore non-KerberosTicket and non-KerberosKey elements
            debug("Skipped cred element: " + cred);
        }
    }
}
Also used : KerberosKey(javax.security.auth.kerberos.KerberosKey) KerberosTicket(javax.security.auth.kerberos.KerberosTicket) SpNegoCredElement(sun.security.jgss.spnego.SpNegoCredElement)

Aggregations

KerberosKey (javax.security.auth.kerberos.KerberosKey)1 KerberosTicket (javax.security.auth.kerberos.KerberosTicket)1 SpNegoCredElement (sun.security.jgss.spnego.SpNegoCredElement)1