src/java.security.jgss/share/classes/sun/security/jgss/krb5/Krb5Util.java
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 58611 53ddf218eddd
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
55613
a55b46a208d1 8227305: Krb5Util::getTicketFromSubjectAndTgs is useless
weijun
parents: 51398
diff changeset
     2
 * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2942
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2942
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2942
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2942
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2942
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.security.jgss.krb5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import javax.security.auth.kerberos.KerberosTicket;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.security.auth.kerberos.KerberosPrincipal;
9499
f3115698a012 6894072: always refresh keytab
weijun
parents: 5506
diff changeset
    30
import javax.security.auth.kerberos.KeyTab;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import javax.security.auth.Subject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import javax.security.auth.login.LoginException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.security.AccessControlContext;
51398
3c389a284345 8209416: Refactoring GetPropertyAction calls in security libs
weijun
parents: 47216
diff changeset
    34
3c389a284345 8209416: Refactoring GetPropertyAction calls in security libs
weijun
parents: 47216
diff changeset
    35
import sun.security.action.GetBooleanAction;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import sun.security.jgss.GSSUtil;
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents: 2
diff changeset
    37
import sun.security.jgss.GSSCaller;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import sun.security.krb5.Credentials;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import sun.security.krb5.EncryptionKey;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import sun.security.krb5.KrbException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import java.io.IOException;
10044
413c0f8ca341 7048466: Move sun.misc.JavaxSecurityAuthKerberosAccess to sun.security.krb5 package
weijun
parents: 9499
diff changeset
    43
import sun.security.krb5.KerberosSecrets;
9499
f3115698a012 6894072: always refresh keytab
weijun
parents: 5506
diff changeset
    44
import sun.security.krb5.PrincipalName;
51398
3c389a284345 8209416: Refactoring GetPropertyAction calls in security libs
weijun
parents: 47216
diff changeset
    45
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * Utilities for obtaining and converting Kerberos tickets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
public class Krb5Util {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
51398
3c389a284345 8209416: Refactoring GetPropertyAction calls in security libs
weijun
parents: 47216
diff changeset
    51
    static final boolean DEBUG = GetBooleanAction
3c389a284345 8209416: Refactoring GetPropertyAction calls in security libs
weijun
parents: 47216
diff changeset
    52
            .privilegedGetProperty("sun.security.krb5.debug");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
     * Default constructor
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    private Krb5Util() {  // Cannot create one of these
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * Retrieves the ticket corresponding to the client/server principal
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * pair from the Subject in the specified AccessControlContext.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     */
58611
53ddf218eddd 8220302: Better Kerberos ccache handling
weijun
parents: 57487
diff changeset
    64
    static KerberosTicket getServiceTicket(GSSCaller caller,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
        String clientPrincipal, String serverPrincipal,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
        AccessControlContext acc) throws LoginException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        // Try to get ticket from acc's Subject
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        Subject accSubj = Subject.getSubject(acc);
9499
f3115698a012 6894072: always refresh keytab
weijun
parents: 5506
diff changeset
    70
        KerberosTicket ticket =
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
            SubjectComber.find(accSubj, serverPrincipal, clientPrincipal,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
                  KerberosTicket.class);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
58611
53ddf218eddd 8220302: Better Kerberos ccache handling
weijun
parents: 57487
diff changeset
    74
        return ticket;
53ddf218eddd 8220302: Better Kerberos ccache handling
weijun
parents: 57487
diff changeset
    75
    }
53ddf218eddd 8220302: Better Kerberos ccache handling
weijun
parents: 57487
diff changeset
    76
53ddf218eddd 8220302: Better Kerberos ccache handling
weijun
parents: 57487
diff changeset
    77
    /**
53ddf218eddd 8220302: Better Kerberos ccache handling
weijun
parents: 57487
diff changeset
    78
     * Retrieves the initial TGT corresponding to the client principal
53ddf218eddd 8220302: Better Kerberos ccache handling
weijun
parents: 57487
diff changeset
    79
     * from the Subject in the specified AccessControlContext.
53ddf218eddd 8220302: Better Kerberos ccache handling
weijun
parents: 57487
diff changeset
    80
     * If the ticket can not be found in the Subject, and if
53ddf218eddd 8220302: Better Kerberos ccache handling
weijun
parents: 57487
diff changeset
    81
     * useSubjectCredsOnly is false, then obtain ticket from
53ddf218eddd 8220302: Better Kerberos ccache handling
weijun
parents: 57487
diff changeset
    82
     * a LoginContext.
53ddf218eddd 8220302: Better Kerberos ccache handling
weijun
parents: 57487
diff changeset
    83
     */
53ddf218eddd 8220302: Better Kerberos ccache handling
weijun
parents: 57487
diff changeset
    84
    static KerberosTicket getInitialTicket(GSSCaller caller,
53ddf218eddd 8220302: Better Kerberos ccache handling
weijun
parents: 57487
diff changeset
    85
            String clientPrincipal,
53ddf218eddd 8220302: Better Kerberos ccache handling
weijun
parents: 57487
diff changeset
    86
            AccessControlContext acc) throws LoginException {
53ddf218eddd 8220302: Better Kerberos ccache handling
weijun
parents: 57487
diff changeset
    87
53ddf218eddd 8220302: Better Kerberos ccache handling
weijun
parents: 57487
diff changeset
    88
        // Try to get ticket from acc's Subject
53ddf218eddd 8220302: Better Kerberos ccache handling
weijun
parents: 57487
diff changeset
    89
        Subject accSubj = Subject.getSubject(acc);
53ddf218eddd 8220302: Better Kerberos ccache handling
weijun
parents: 57487
diff changeset
    90
        KerberosTicket ticket =
53ddf218eddd 8220302: Better Kerberos ccache handling
weijun
parents: 57487
diff changeset
    91
                SubjectComber.find(accSubj, null, clientPrincipal,
53ddf218eddd 8220302: Better Kerberos ccache handling
weijun
parents: 57487
diff changeset
    92
                        KerberosTicket.class);
53ddf218eddd 8220302: Better Kerberos ccache handling
weijun
parents: 57487
diff changeset
    93
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        // Try to get ticket from Subject obtained from GSSUtil
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        if (ticket == null && !GSSUtil.useSubjectCredsOnly(caller)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            Subject subject = GSSUtil.login(caller, GSSUtil.GSS_KRB5_MECH_OID);
9499
f3115698a012 6894072: always refresh keytab
weijun
parents: 5506
diff changeset
    97
            ticket = SubjectComber.find(subject,
58611
53ddf218eddd 8220302: Better Kerberos ccache handling
weijun
parents: 57487
diff changeset
    98
                    null, clientPrincipal, KerberosTicket.class);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        return ticket;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     * Retrieves the caller's Subject, or Subject obtained by logging in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * via the specified caller.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * Caller must have permission to:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     *    - access the Subject
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     *    - create LoginContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     *    - read the auth.login.defaultCallbackHandler security property
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * NOTE: This method is used by JSSE Kerberos Cipher Suites
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     */
2942
37d9baeb7518 6578647: Undefined requesting URL in java.net.Authenticator.getPasswordAuthentication()
weijun
parents: 2
diff changeset
   114
    public static Subject getSubject(GSSCaller caller,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        AccessControlContext acc) throws LoginException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        // Try to get the Subject from acc
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        Subject subject = Subject.getSubject(acc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        // Try to get Subject obtained from GSSUtil
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        if (subject == null && !GSSUtil.useSubjectCredsOnly(caller)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            subject = GSSUtil.login(caller, GSSUtil.GSS_KRB5_MECH_OID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        return subject;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    /**
9499
f3115698a012 6894072: always refresh keytab
weijun
parents: 5506
diff changeset
   128
     * Retrieves the ServiceCreds for the specified server principal from
f3115698a012 6894072: always refresh keytab
weijun
parents: 5506
diff changeset
   129
     * the Subject in the specified AccessControlContext. If not found, and if
f3115698a012 6894072: always refresh keytab
weijun
parents: 5506
diff changeset
   130
     * useSubjectCredsOnly is false, then obtain from a LoginContext.
f3115698a012 6894072: always refresh keytab
weijun
parents: 5506
diff changeset
   131
     *
f3115698a012 6894072: always refresh keytab
weijun
parents: 5506
diff changeset
   132
     * NOTE: This method is also used by JSSE Kerberos Cipher Suites
f3115698a012 6894072: always refresh keytab
weijun
parents: 5506
diff changeset
   133
     */
f3115698a012 6894072: always refresh keytab
weijun
parents: 5506
diff changeset
   134
    public static ServiceCreds getServiceCreds(GSSCaller caller,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        String serverPrincipal, AccessControlContext acc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                throws LoginException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        Subject accSubj = Subject.getSubject(acc);
9499
f3115698a012 6894072: always refresh keytab
weijun
parents: 5506
diff changeset
   139
        ServiceCreds sc = null;
f3115698a012 6894072: always refresh keytab
weijun
parents: 5506
diff changeset
   140
        if (accSubj != null) {
f3115698a012 6894072: always refresh keytab
weijun
parents: 5506
diff changeset
   141
            sc = ServiceCreds.getInstance(accSubj, serverPrincipal);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
        }
9499
f3115698a012 6894072: always refresh keytab
weijun
parents: 5506
diff changeset
   143
        if (sc == null && !GSSUtil.useSubjectCredsOnly(caller)) {
f3115698a012 6894072: always refresh keytab
weijun
parents: 5506
diff changeset
   144
            Subject subject = GSSUtil.login(caller, GSSUtil.GSS_KRB5_MECH_OID);
f3115698a012 6894072: always refresh keytab
weijun
parents: 5506
diff changeset
   145
            sc = ServiceCreds.getInstance(subject, serverPrincipal);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        }
9499
f3115698a012 6894072: always refresh keytab
weijun
parents: 5506
diff changeset
   147
        return sc;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    public static KerberosTicket credsToTicket(Credentials serviceCreds) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
        EncryptionKey sessionKey =  serviceCreds.getSessionKey();
57487
643978a35f6e 8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents: 55613
diff changeset
   152
        KerberosTicket kt = new KerberosTicket(
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            serviceCreds.getEncoded(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            new KerberosPrincipal(serviceCreds.getClient().getName()),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            new KerberosPrincipal(serviceCreds.getServer().getName(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                                KerberosPrincipal.KRB_NT_SRV_INST),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            sessionKey.getBytes(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            sessionKey.getEType(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            serviceCreds.getFlags(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
            serviceCreds.getAuthTime(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            serviceCreds.getStartTime(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
            serviceCreds.getEndTime(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
            serviceCreds.getRenewTill(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
            serviceCreds.getClientAddresses());
57487
643978a35f6e 8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents: 55613
diff changeset
   165
        PrincipalName clientAlias = serviceCreds.getClientAlias();
643978a35f6e 8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents: 55613
diff changeset
   166
        PrincipalName serverAlias = serviceCreds.getServerAlias();
643978a35f6e 8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents: 55613
diff changeset
   167
        if (clientAlias != null) {
643978a35f6e 8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents: 55613
diff changeset
   168
            KerberosSecrets.getJavaxSecurityAuthKerberosAccess()
643978a35f6e 8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents: 55613
diff changeset
   169
                    .kerberosTicketSetClientAlias(kt, new KerberosPrincipal(
643978a35f6e 8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents: 55613
diff changeset
   170
                            clientAlias.getName(), clientAlias.getNameType()));
643978a35f6e 8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents: 55613
diff changeset
   171
        }
643978a35f6e 8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents: 55613
diff changeset
   172
        if (serverAlias != null) {
643978a35f6e 8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents: 55613
diff changeset
   173
            KerberosSecrets.getJavaxSecurityAuthKerberosAccess()
643978a35f6e 8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents: 55613
diff changeset
   174
                    .kerberosTicketSetServerAlias(kt, new KerberosPrincipal(
643978a35f6e 8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents: 55613
diff changeset
   175
                            serverAlias.getName(), serverAlias.getNameType()));
643978a35f6e 8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents: 55613
diff changeset
   176
        }
643978a35f6e 8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents: 55613
diff changeset
   177
        return kt;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    public static Credentials ticketToCreds(KerberosTicket kerbTicket)
14413
e954df027393 6355584: Introduce constrained Kerberos delegation
weijun
parents: 10336
diff changeset
   181
            throws KrbException, IOException {
57487
643978a35f6e 8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents: 55613
diff changeset
   182
        KerberosPrincipal clientAlias = KerberosSecrets
643978a35f6e 8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents: 55613
diff changeset
   183
                .getJavaxSecurityAuthKerberosAccess()
643978a35f6e 8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents: 55613
diff changeset
   184
                .kerberosTicketGetClientAlias(kerbTicket);
643978a35f6e 8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents: 55613
diff changeset
   185
        KerberosPrincipal serverAlias = KerberosSecrets
643978a35f6e 8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents: 55613
diff changeset
   186
                .getJavaxSecurityAuthKerberosAccess()
643978a35f6e 8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents: 55613
diff changeset
   187
                .kerberosTicketGetServerAlias(kerbTicket);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        return new Credentials(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            kerbTicket.getEncoded(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            kerbTicket.getClient().getName(),
57487
643978a35f6e 8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents: 55613
diff changeset
   191
            (clientAlias != null ? clientAlias.getName() : null),
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            kerbTicket.getServer().getName(),
57487
643978a35f6e 8227437: S4U2proxy cannot continue because server's TGT cannot be found
mbalao
parents: 55613
diff changeset
   193
            (serverAlias != null ? serverAlias.getName() : null),
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            kerbTicket.getSessionKey().getEncoded(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            kerbTicket.getSessionKeyType(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            kerbTicket.getFlags(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            kerbTicket.getAuthTime(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            kerbTicket.getStartTime(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            kerbTicket.getEndTime(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            kerbTicket.getRenewTill(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            kerbTicket.getClientAddresses());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    }
9499
f3115698a012 6894072: always refresh keytab
weijun
parents: 5506
diff changeset
   203
f3115698a012 6894072: always refresh keytab
weijun
parents: 5506
diff changeset
   204
    /**
15649
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents: 15006
diff changeset
   205
     * A helper method to get a sun..KeyTab from a javax..KeyTab
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents: 15006
diff changeset
   206
     * @param ktab the javax..KeyTab object
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents: 15006
diff changeset
   207
     * @return the sun..KeyTab object
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents: 15006
diff changeset
   208
     */
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents: 15006
diff changeset
   209
    public static sun.security.krb5.internal.ktab.KeyTab
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents: 15006
diff changeset
   210
            snapshotFromJavaxKeyTab(KeyTab ktab) {
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents: 15006
diff changeset
   211
        return KerberosSecrets.getJavaxSecurityAuthKerberosAccess()
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents: 15006
diff changeset
   212
                .keyTabTakeSnapshot(ktab);
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents: 15006
diff changeset
   213
    }
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents: 15006
diff changeset
   214
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents: 15006
diff changeset
   215
    /**
9499
f3115698a012 6894072: always refresh keytab
weijun
parents: 5506
diff changeset
   216
     * A helper method to get EncryptionKeys from a javax..KeyTab
15649
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents: 15006
diff changeset
   217
     * @param ktab the javax..KeyTab object
9499
f3115698a012 6894072: always refresh keytab
weijun
parents: 5506
diff changeset
   218
     * @param cname the PrincipalName
f3115698a012 6894072: always refresh keytab
weijun
parents: 5506
diff changeset
   219
     * @return the EKeys, never null, might be empty
f3115698a012 6894072: always refresh keytab
weijun
parents: 5506
diff changeset
   220
     */
f3115698a012 6894072: always refresh keytab
weijun
parents: 5506
diff changeset
   221
    public static EncryptionKey[] keysFromJavaxKeyTab(
f3115698a012 6894072: always refresh keytab
weijun
parents: 5506
diff changeset
   222
            KeyTab ktab, PrincipalName cname) {
15649
f6bd3d34f844 8001104: Unbound SASL service: the GSSAPI/krb5 mech
weijun
parents: 15006
diff changeset
   223
        return snapshotFromJavaxKeyTab(ktab).readServiceKeys(cname);
9499
f3115698a012 6894072: always refresh keytab
weijun
parents: 5506
diff changeset
   224
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
}