Search in sources :

Example 1 with GSSCaller

use of sun.security.jgss.GSSCaller in project jdk8u_jdk by JetBrains.

the class Krb5InitCredential method getTgt.

// XXX call to this.destroy() should destroy the locally cached copy
// of krb5Credentials and then call super.destroy().
private static KerberosTicket getTgt(GSSCaller caller, Krb5NameElement name, int initLifetime) throws GSSException {
    final String clientPrincipal;
    /*
         * Find the TGT for the realm that the client is in. If the client
         * name is not available, then use the default realm.
         */
    if (name != null) {
        clientPrincipal = (name.getKrb5PrincipalName()).getName();
    } else {
        clientPrincipal = null;
    }
    final AccessControlContext acc = AccessController.getContext();
    try {
        final GSSCaller realCaller = (caller == GSSCaller.CALLER_UNKNOWN) ? GSSCaller.CALLER_INITIATE : caller;
        return AccessController.doPrivileged(new PrivilegedExceptionAction<KerberosTicket>() {

            public KerberosTicket run() throws Exception {
                // the first ticket for a principal and we use list.
                return Krb5Util.getTicket(realCaller, clientPrincipal, null, acc);
            }
        });
    } catch (PrivilegedActionException e) {
        GSSException ge = new GSSException(GSSException.NO_CRED, -1, "Attempt to obtain new INITIATE credentials failed!" + " (" + e.getMessage() + ")");
        ge.initCause(e.getException());
        throw ge;
    }
}
Also used : AccessControlContext(java.security.AccessControlContext) PrivilegedActionException(java.security.PrivilegedActionException) GSSCaller(sun.security.jgss.GSSCaller) PrivilegedActionException(java.security.PrivilegedActionException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 AccessControlContext (java.security.AccessControlContext)1 PrivilegedActionException (java.security.PrivilegedActionException)1 GSSCaller (sun.security.jgss.GSSCaller)1