jdk/src/share/classes/sun/security/krb5/PrincipalName.java
author smarks
Wed, 12 Jan 2011 13:52:09 -0800
changeset 7977 f47f211cd627
parent 7183 d8ccc1c73358
child 9035 1255eb81cc2f
permissions -rw-r--r--
7008713: diamond conversion of kerberos5 and security tools Reviewed-by: weijun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5455
diff changeset
     2
 * Copyright (c) 2000, 2010, 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: 5455
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: 5455
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: 5455
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5455
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 5455
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
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 *  (C) Copyright IBM Corp. 1999 All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *  Copyright 1997 The Open Group Research Institute.  All rights reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
package sun.security.krb5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import sun.security.krb5.internal.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import sun.security.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.net.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.math.BigInteger;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import sun.security.krb5.internal.ccache.CCacheOutputStream;
3949
00603a93b589 6862679: ESC: AD Authentication with user with umlauts fails
weijun
parents: 2918
diff changeset
    41
import sun.security.krb5.internal.util.KerberosString;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * This class encapsulates a Kerberos principal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
public class PrincipalName
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    implements Cloneable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    //name types
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
     * Name type not known
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    public static final int KRB_NT_UNKNOWN =   0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     * Just the name of the principal as in DCE, or for users
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    public static final int KRB_NT_PRINCIPAL = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * Service and other unique instance (krbtgt)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    public static final int KRB_NT_SRV_INST =  2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * Service with host name as instance (telnet, rcommands)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    public static final int KRB_NT_SRV_HST =   3;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * Service with host as remaining components
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    public static final int KRB_NT_SRV_XHST =  4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * Unique ID
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    public static final int KRB_NT_UID = 5;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
     * TGS Name
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    public static final String TGS_DEFAULT_SRV_NAME = "krbtgt";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    public static final int TGS_DEFAULT_NT = KRB_NT_SRV_INST;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    public static final char NAME_COMPONENT_SEPARATOR = '/';
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    public static final char NAME_REALM_SEPARATOR = '@';
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    public static final char REALM_COMPONENT_SEPARATOR = '.';
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    public static final String NAME_COMPONENT_SEPARATOR_STR = "/";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    public static final String NAME_REALM_SEPARATOR_STR = "@";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    public static final String REALM_COMPONENT_SEPARATOR_STR = ".";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    private int nameType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    private String[] nameStrings;  // Principal names don't mutate often
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    private Realm nameRealm;  // optional; a null realm means use default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    // Note: the nameRealm is not included in the default ASN.1 encoding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
5455
19d2395cfe3e 6856069: PrincipalName.clone() does not invoke super.clone()
weijun
parents: 3949
diff changeset
   104
    // cached salt, might be changed by KDC info, not used in clone
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    private String salt = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    protected PrincipalName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    public PrincipalName(String[] nameParts, int type)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        throws IllegalArgumentException, IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        if (nameParts == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            throw new IllegalArgumentException("Null input not allowed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        nameStrings = new String[nameParts.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        System.arraycopy(nameParts, 0, nameStrings, 0, nameParts.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        nameType = type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        nameRealm = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    public PrincipalName(String[] nameParts) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
        this(nameParts, KRB_NT_UNKNOWN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    public Object clone() {
5455
19d2395cfe3e 6856069: PrincipalName.clone() does not invoke super.clone()
weijun
parents: 3949
diff changeset
   126
        try {
19d2395cfe3e 6856069: PrincipalName.clone() does not invoke super.clone()
weijun
parents: 3949
diff changeset
   127
            PrincipalName pName = (PrincipalName) super.clone();
19d2395cfe3e 6856069: PrincipalName.clone() does not invoke super.clone()
weijun
parents: 3949
diff changeset
   128
            // Re-assign mutable fields
19d2395cfe3e 6856069: PrincipalName.clone() does not invoke super.clone()
weijun
parents: 3949
diff changeset
   129
            if (nameStrings != null) {
19d2395cfe3e 6856069: PrincipalName.clone() does not invoke super.clone()
weijun
parents: 3949
diff changeset
   130
                pName.nameStrings = nameStrings.clone();
19d2395cfe3e 6856069: PrincipalName.clone() does not invoke super.clone()
weijun
parents: 3949
diff changeset
   131
            }
19d2395cfe3e 6856069: PrincipalName.clone() does not invoke super.clone()
weijun
parents: 3949
diff changeset
   132
            if (nameRealm != null) {
19d2395cfe3e 6856069: PrincipalName.clone() does not invoke super.clone()
weijun
parents: 3949
diff changeset
   133
                pName.nameRealm = (Realm)nameRealm.clone();
19d2395cfe3e 6856069: PrincipalName.clone() does not invoke super.clone()
weijun
parents: 3949
diff changeset
   134
            }
19d2395cfe3e 6856069: PrincipalName.clone() does not invoke super.clone()
weijun
parents: 3949
diff changeset
   135
            return pName;
19d2395cfe3e 6856069: PrincipalName.clone() does not invoke super.clone()
weijun
parents: 3949
diff changeset
   136
        } catch (CloneNotSupportedException ex) {
19d2395cfe3e 6856069: PrincipalName.clone() does not invoke super.clone()
weijun
parents: 3949
diff changeset
   137
            throw new AssertionError("Should never happen");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * Added to workaround a bug where the equals method that takes a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * PrincipalName is not being called but Object.equals(Object) is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * being called.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    public boolean equals(Object o) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        if (o instanceof PrincipalName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            return equals((PrincipalName)o);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    public boolean equals(PrincipalName other) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        if (!equalsWithoutRealm(other)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        if ((nameRealm != null && other.nameRealm == null) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            (nameRealm == null && other.nameRealm != null)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        if (nameRealm != null && other.nameRealm != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            if (!nameRealm.equals(other.nameRealm)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    boolean equalsWithoutRealm(PrincipalName other) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        if (nameType != KRB_NT_UNKNOWN &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            other.nameType != KRB_NT_UNKNOWN &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            nameType != other.nameType)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        if ((nameStrings != null && other.nameStrings == null) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            (nameStrings == null && other.nameStrings != null))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        if (nameStrings != null && other.nameStrings != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            if (nameStrings.length != other.nameStrings.length)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            for (int i = 0; i < nameStrings.length; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                if (!nameStrings[i].equals(other.nameStrings[i]))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                    return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * Returns the ASN.1 encoding of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * <xmp>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     * PrincipalName    ::= SEQUENCE {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
     *          name-type       [0] Int32,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     *          name-string     [1] SEQUENCE OF KerberosString
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * KerberosString   ::= GeneralString (IA5String)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * </xmp>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * This definition reflects the Network Working Group RFC 4120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     * specification available at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * <a href="http://www.ietf.org/rfc/rfc4120.txt">
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * http://www.ietf.org/rfc/rfc4120.txt</a>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * @param encoding a Der-encoded data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * @exception Asn1Exception if an error occurs while decoding
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * an ASN1 encoded data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * @exception Asn1Exception if there is an ASN1 encoding error
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * @exception IOException if an I/O error occurs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * @exception IllegalArgumentException if encoding is null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * reading encoded data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    public PrincipalName(DerValue encoding)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        throws Asn1Exception, IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        nameRealm = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        DerValue der;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        if (encoding == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            throw new IllegalArgumentException("Null input not allowed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        if (encoding.getTag() != DerValue.tag_Sequence) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            throw new Asn1Exception(Krb5.ASN1_BAD_ID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        der = encoding.getData().getDerValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        if ((der.getTag() & 0x1F) == 0x00) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            BigInteger bint = der.getData().getBigInteger();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            nameType = bint.intValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            throw new Asn1Exception(Krb5.ASN1_BAD_ID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        der = encoding.getData().getDerValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        if ((der.getTag() & 0x01F) == 0x01) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
            DerValue subDer = der.getData().getDerValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
            if (subDer.getTag() != DerValue.tag_SequenceOf) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                throw new Asn1Exception(Krb5.ASN1_BAD_ID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
            }
7977
f47f211cd627 7008713: diamond conversion of kerberos5 and security tools
smarks
parents: 7183
diff changeset
   247
            Vector<String> v = new Vector<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
            DerValue subSubDer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
            while(subDer.getData().available() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
                subSubDer = subDer.getData().getDerValue();
3949
00603a93b589 6862679: ESC: AD Authentication with user with umlauts fails
weijun
parents: 2918
diff changeset
   251
                v.addElement(new KerberosString(subSubDer).toString());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            if (v.size() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
                nameStrings = new String[v.size()];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
                v.copyInto(nameStrings);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
                nameStrings = new String[] {""};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        } else  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            throw new Asn1Exception(Krb5.ASN1_BAD_ID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     * Parse (unmarshal) a <code>PrincipalName</code> from a DER
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * input stream.  This form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * parsing might be used when expanding a value which is part of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * a constructed sequence and uses explicitly tagged type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * @exception Asn1Exception on error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * @param data the Der input stream value, which contains one or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * more marshaled value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * @param explicitTag tag number.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * @param optional indicate if this data field is optional
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     * @return an instance of <code>PrincipalName</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    public static PrincipalName parse(DerInputStream data,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
                                      byte explicitTag, boolean
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
                                      optional)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        throws Asn1Exception, IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        if ((optional) && (((byte)data.peekByte() & (byte)0x1F) !=
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
                           explicitTag))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        DerValue der = data.getDerValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
        if (explicitTag != (der.getTag() & (byte)0x1F))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            throw new Asn1Exception(Krb5.ASN1_BAD_ID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
            DerValue subDer = der.getData().getDerValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
            return new PrincipalName(subDer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    // This is protected because the definition of a principal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    // string is fixed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    // XXX Error checkin consistent with MIT krb5_parse_name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    // Code repetition, realm parsed again by class Realm
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    protected static String[] parseName(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
7977
f47f211cd627 7008713: diamond conversion of kerberos5 and security tools
smarks
parents: 7183
diff changeset
   302
        Vector<String> tempStrings = new Vector<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        String temp = name;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        int i = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        int componentStart = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        String component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        while (i < temp.length()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
            if (temp.charAt(i) == NAME_COMPONENT_SEPARATOR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
                /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                 * If this separator is escaped then don't treat it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                 * as a separator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
                 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                if (i > 0 && temp.charAt(i - 1) == '\\') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
                    temp = temp.substring(0, i - 1) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
                        temp.substring(i, temp.length());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
                    continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
                else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
                    if (componentStart < i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
                        component = temp.substring(componentStart, i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
                        tempStrings.addElement(component);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                    componentStart = i + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
            } else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
                if (temp.charAt(i) == NAME_REALM_SEPARATOR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
                    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
                     * If this separator is escaped then don't treat it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                     * as a separator
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
                     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                    if (i > 0 && temp.charAt(i - 1) == '\\') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
                        temp = temp.substring(0, i - 1) +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
                            temp.substring(i, temp.length());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                        continue;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
                        if (componentStart < i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                            component = temp.substring(componentStart, i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                            tempStrings.addElement(component);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                        componentStart = i + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
            i++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        if (i == temp.length())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        if (componentStart < i) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
            component = temp.substring(componentStart, i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
            tempStrings.addElement(component);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        String[] result = new String[tempStrings.size()];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        tempStrings.copyInto(result);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
    public PrincipalName(String name, int type)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        throws RealmException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        if (name == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
            throw new IllegalArgumentException("Null name not allowed");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        String[] nameParts = parseName(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        Realm tempRealm = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        String realmString = Realm.parseRealmAtSeparator(name);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        if (realmString == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
                Config config = Config.getInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
                realmString = config.getDefaultRealm();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
            } catch (KrbException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                RealmException re =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
                    new RealmException(e.getMessage());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
                re.initCause(e);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
                throw re;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        if (realmString != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
            tempRealm = new Realm(realmString);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        switch (type) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        case KRB_NT_SRV_HST:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
            if (nameParts.length >= 2) {
2918
395b9ffa7cc6 6682516: SPNEGO_HTTP_AUTH/WWW_KRB and SPNEGO_HTTP_AUTH/WWW_SPNEGO failed on all non-windows platforms
weijun
parents: 2
diff changeset
   386
                String hostName = nameParts[1];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                try {
2918
395b9ffa7cc6 6682516: SPNEGO_HTTP_AUTH/WWW_KRB and SPNEGO_HTTP_AUTH/WWW_SPNEGO failed on all non-windows platforms
weijun
parents: 2
diff changeset
   388
                    // RFC4120 does not recommend canonicalizing a hostname.
395b9ffa7cc6 6682516: SPNEGO_HTTP_AUTH/WWW_KRB and SPNEGO_HTTP_AUTH/WWW_SPNEGO failed on all non-windows platforms
weijun
parents: 2
diff changeset
   389
                    // However, for compatibility reason, we will try
395b9ffa7cc6 6682516: SPNEGO_HTTP_AUTH/WWW_KRB and SPNEGO_HTTP_AUTH/WWW_SPNEGO failed on all non-windows platforms
weijun
parents: 2
diff changeset
   390
                    // canonicalize it and see if the output looks better.
395b9ffa7cc6 6682516: SPNEGO_HTTP_AUTH/WWW_KRB and SPNEGO_HTTP_AUTH/WWW_SPNEGO failed on all non-windows platforms
weijun
parents: 2
diff changeset
   391
395b9ffa7cc6 6682516: SPNEGO_HTTP_AUTH/WWW_KRB and SPNEGO_HTTP_AUTH/WWW_SPNEGO failed on all non-windows platforms
weijun
parents: 2
diff changeset
   392
                    String canonicalized = (InetAddress.getByName(hostName)).
395b9ffa7cc6 6682516: SPNEGO_HTTP_AUTH/WWW_KRB and SPNEGO_HTTP_AUTH/WWW_SPNEGO failed on all non-windows platforms
weijun
parents: 2
diff changeset
   393
                            getCanonicalHostName();
395b9ffa7cc6 6682516: SPNEGO_HTTP_AUTH/WWW_KRB and SPNEGO_HTTP_AUTH/WWW_SPNEGO failed on all non-windows platforms
weijun
parents: 2
diff changeset
   394
395b9ffa7cc6 6682516: SPNEGO_HTTP_AUTH/WWW_KRB and SPNEGO_HTTP_AUTH/WWW_SPNEGO failed on all non-windows platforms
weijun
parents: 2
diff changeset
   395
                    // Looks if canonicalized is a longer format of hostName,
395b9ffa7cc6 6682516: SPNEGO_HTTP_AUTH/WWW_KRB and SPNEGO_HTTP_AUTH/WWW_SPNEGO failed on all non-windows platforms
weijun
parents: 2
diff changeset
   396
                    // we accept cases like
395b9ffa7cc6 6682516: SPNEGO_HTTP_AUTH/WWW_KRB and SPNEGO_HTTP_AUTH/WWW_SPNEGO failed on all non-windows platforms
weijun
parents: 2
diff changeset
   397
                    //     bunny -> bunny.rabbit.hole
395b9ffa7cc6 6682516: SPNEGO_HTTP_AUTH/WWW_KRB and SPNEGO_HTTP_AUTH/WWW_SPNEGO failed on all non-windows platforms
weijun
parents: 2
diff changeset
   398
                    if (canonicalized.toLowerCase()
395b9ffa7cc6 6682516: SPNEGO_HTTP_AUTH/WWW_KRB and SPNEGO_HTTP_AUTH/WWW_SPNEGO failed on all non-windows platforms
weijun
parents: 2
diff changeset
   399
                            .startsWith(hostName.toLowerCase()+".")) {
395b9ffa7cc6 6682516: SPNEGO_HTTP_AUTH/WWW_KRB and SPNEGO_HTTP_AUTH/WWW_SPNEGO failed on all non-windows platforms
weijun
parents: 2
diff changeset
   400
                        hostName = canonicalized;
395b9ffa7cc6 6682516: SPNEGO_HTTP_AUTH/WWW_KRB and SPNEGO_HTTP_AUTH/WWW_SPNEGO failed on all non-windows platforms
weijun
parents: 2
diff changeset
   401
                    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                } catch (UnknownHostException e) {
2918
395b9ffa7cc6 6682516: SPNEGO_HTTP_AUTH/WWW_KRB and SPNEGO_HTTP_AUTH/WWW_SPNEGO failed on all non-windows platforms
weijun
parents: 2
diff changeset
   403
                    // no canonicalization, use old
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
                }
2918
395b9ffa7cc6 6682516: SPNEGO_HTTP_AUTH/WWW_KRB and SPNEGO_HTTP_AUTH/WWW_SPNEGO failed on all non-windows platforms
weijun
parents: 2
diff changeset
   405
                nameParts[1] = hostName.toLowerCase();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
            nameStrings = nameParts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
            nameType = type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
                // We will try to get realm name from the mapping in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
                // the configuration. If it is not specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
                // we will use the default realm. This nametype does
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
                // not allow a realm to be specified. The name string must of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
                // the form service@host and this is internally changed into
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
                // service/host by Kerberos
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
            String mapRealm =  mapHostToRealm(nameParts[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            if (mapRealm != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                nameRealm = new Realm(mapRealm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
                nameRealm = tempRealm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        case KRB_NT_UNKNOWN:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        case KRB_NT_PRINCIPAL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
        case KRB_NT_SRV_INST:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
        case KRB_NT_SRV_XHST:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        case KRB_NT_UID:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
            nameStrings = nameParts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
            nameType = type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
            nameRealm = tempRealm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
            throw new IllegalArgumentException("Illegal name type");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    public PrincipalName(String name) throws RealmException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
        this(name, KRB_NT_UNKNOWN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    public PrincipalName(String name, String realm) throws RealmException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        this(name, KRB_NT_UNKNOWN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        nameRealm = new Realm(realm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    public String getRealmAsString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        return getRealmString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    public String getPrincipalNameAsString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        StringBuffer temp = new StringBuffer(nameStrings[0]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        for (int i = 1; i < nameStrings.length; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
            temp.append(nameStrings[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        return temp.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        return toString().hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    public String getName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
        return toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
    public int getNameType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        return nameType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    public String[] getNameStrings() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
        return nameStrings;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    public byte[][] toByteArray() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        byte[][] result = new byte[nameStrings.length][];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
        for (int i = 0; i < nameStrings.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
            result[i] = new byte[nameStrings[i].length()];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
            result[i] = nameStrings[i].getBytes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
    public String getRealmString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        if (nameRealm != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
            return nameRealm.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    public Realm getRealm() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
        return nameRealm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
    public void setRealm(Realm new_nameRealm) throws RealmException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
        nameRealm = new_nameRealm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    public void setRealm(String realmsString) throws RealmException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        nameRealm = new Realm(realmsString);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
    public String getSalt() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        if (salt == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
            StringBuffer salt = new StringBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
            if (nameRealm != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
                salt.append(nameRealm.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
            for (int i = 0; i < nameStrings.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
                salt.append(nameStrings[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
            return salt.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
        return salt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        StringBuffer str = new StringBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        for (int i = 0; i < nameStrings.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
            if (i > 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
                str.append("/");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
            str.append(nameStrings[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        if (nameRealm != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
            str.append("@");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
            str.append(nameRealm.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
        return str.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
    public String getNameString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        StringBuffer str = new StringBuffer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        for (int i = 0; i < nameStrings.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
            if (i > 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
                str.append("/");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
            str.append(nameStrings[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        return str.toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     * Encodes a <code>PrincipalName</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     * @return the byte array of the encoded PrncipalName object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     * @exception Asn1Exception if an error occurs while decoding an ASN1 encoded data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     * @exception IOException if an I/O error occurs while reading encoded data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    public byte[] asn1Encode() throws Asn1Exception, IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
        DerOutputStream bytes = new DerOutputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
        DerOutputStream temp = new DerOutputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
        BigInteger bint = BigInteger.valueOf(this.nameType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
        temp.putInteger(bint);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x00), temp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
        temp = new DerOutputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
        DerValue der[] = new DerValue[nameStrings.length];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
        for (int i = 0; i < nameStrings.length; i++) {
3949
00603a93b589 6862679: ESC: AD Authentication with user with umlauts fails
weijun
parents: 2918
diff changeset
   555
            der[i] = new KerberosString(nameStrings[i]).toDerValue();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
        temp.putSequence(der);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
        bytes.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0x01), temp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
        temp = new DerOutputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
        temp.write(DerValue.tag_Sequence, bytes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
        return temp.toByteArray();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     * Checks if two <code>PrincipalName</code> objects have identical values in their corresponding data fields.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     * @param pname the other <code>PrincipalName</code> object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     * @return true if two have identical values, otherwise, return false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
    // It is used in <code>sun.security.krb5.internal.ccache</code> package.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
    public boolean match(PrincipalName pname) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
        boolean matched = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
        //name type is just a hint, no two names can be the same ignoring name type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
        // if (this.nameType != pname.nameType) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
        //      matched = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
        // }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
        if ((this.nameRealm != null) && (pname.nameRealm != null)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
            if (!(this.nameRealm.toString().equalsIgnoreCase(pname.nameRealm.toString()))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
                matched = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
        if (this.nameStrings.length != pname.nameStrings.length) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
            matched = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
            for (int i = 0; i < this.nameStrings.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
                if (!(this.nameStrings[i].equalsIgnoreCase(pname.nameStrings[i]))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
                    matched = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
        return matched;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     * Writes data field values of <code>PrincipalName</code> in FCC format to an output stream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * @param cos a <code>CCacheOutputStream</code> for writing data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     * @exception IOException if an I/O exception occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     * @see sun.security.krb5.internal.ccache.CCacheOutputStream
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    public void writePrincipal(CCacheOutputStream cos) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
        cos.write32(nameType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
        cos.write32(nameStrings.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
        if (nameRealm != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
            byte[] realmBytes = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
            realmBytes = nameRealm.toString().getBytes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
            cos.write32(realmBytes.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
            cos.write(realmBytes, 0, realmBytes.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
        byte[] bytes = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        for (int i = 0; i < nameStrings.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
            bytes = nameStrings[i].getBytes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
            cos.write32(bytes.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
            cos.write(bytes, 0, bytes.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
     * Creates a KRB_NT_SRV_INST name from the supplied
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     * name components and realm.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     * @param primary the primary component of the name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     * @param instance the instance component of the name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
     * @param realm the realm
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     * @throws KrbException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    protected PrincipalName(String primary, String instance, String realm,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
                            int type)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
        throws KrbException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
        if (type != KRB_NT_SRV_INST) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
            throw new KrbException(Krb5.KRB_ERR_GENERIC, "Bad name type");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
        String[] nParts = new String[2];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
        nParts[0] = primary;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
        nParts[1] = instance;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
        this.nameStrings = nParts;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        this.nameRealm = new Realm(realm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        this.nameType = type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     * Returns the instance component of a name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     * In a multi-component name such as a KRB_NT_SRV_INST
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
     * name, the second component is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
     * Null is returned if there are not two or more
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
     * components in the name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     * @returns instance component of a multi-component name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
    public String getInstanceComponent()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
        if (nameStrings != null && nameStrings.length >= 2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
                return new String(nameStrings[1]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
    static String mapHostToRealm(String name) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
        String result = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
            String subname = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
            Config c = Config.getInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
            if ((result = c.getDefault(name, "domain_realm")) != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
                return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
                for (int i = 1; i < name.length(); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
                    if ((name.charAt(i) == '.') && (i != name.length() - 1)) { //mapping could be .ibm.com = AUSTIN.IBM.COM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
                        subname = name.substring(i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
                        result = c.getDefault(subname, "domain_realm");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
                        if (result != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
                        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
                            subname = name.substring(i + 1);      //or mapping could be ibm.com = AUSTIN.IBM.COM
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
                            result = c.getDefault(subname, "domain_realm");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
                            if (result != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
                                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
                            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
        } catch (KrbException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
        return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
}