jdk/src/share/classes/sun/security/x509/EDIPartyName.java
author ohair
Tue, 25 May 2010 15:58:33 -0700
changeset 5506 202f599c92aa
parent 2 90ce3da70b43
permissions -rw-r--r--
6943119: Rebrand source copyright notices Reviewed-by: darcy, 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: 2
diff changeset
     2
 * Copyright (c) 1997, 2004, 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: 2
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: 2
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: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
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.x509;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import sun.security.util.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
 * This class defines the EDIPartyName of the GeneralName choice.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * The ASN.1 syntax for this is:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * EDIPartyName ::= SEQUENCE {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 *     nameAssigner  [0]  DirectoryString OPTIONAL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 *     partyName     [1]  DirectoryString }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * @author Hemma Prafullchandra
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * @see GeneralName
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * @see GeneralNames
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * @see GeneralNameInterface
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
public class EDIPartyName implements GeneralNameInterface {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    // Private data members
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    private static final byte TAG_ASSIGNER = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    private static final byte TAG_PARTYNAME = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    private String assigner = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    private String party = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    private int myhash = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
     * Create the EDIPartyName object from the specified names.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
     * @param assignerName the name of the assigner
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
     * @param partyName the name of the EDI party.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    public EDIPartyName(String assignerName, String partyName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
        this.assigner = assignerName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        this.party = partyName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * Create the EDIPartyName object from the specified name.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     * @param partyName the name of the EDI party.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    public EDIPartyName(String partyName) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        this.party = partyName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     * Create the EDIPartyName object from the passed encoded Der value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * @param derValue the encoded DER EDIPartyName.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * @exception IOException on error.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    public EDIPartyName(DerValue derValue) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        DerInputStream in = new DerInputStream(derValue.toByteArray());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
        DerValue[] seq = in.getSequence(2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        int len = seq.length;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        if (len < 1 || len > 2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            throw new IOException("Invalid encoding of EDIPartyName");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        for (int i = 0; i < len; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
            DerValue opt = seq[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            if (opt.isContextSpecific(TAG_ASSIGNER) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
                !opt.isConstructed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                if (assigner != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
                    throw new IOException("Duplicate nameAssigner found in"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
                                          + " EDIPartyName");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
                opt = opt.data.getDerValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                assigner = opt.getAsString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
            if (opt.isContextSpecific(TAG_PARTYNAME) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                !opt.isConstructed()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                if (party != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                    throw new IOException("Duplicate partyName found in"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
                                          + " EDIPartyName");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
                opt = opt.data.getDerValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
                party = opt.getAsString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * Return the type of the GeneralName.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    public int getType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        return (GeneralNameInterface.NAME_EDI);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * Encode the EDI party name into the DerOutputStream.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
     * @param out the DER stream to encode the EDIPartyName to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
     * @exception IOException on encoding errors.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    public void encode(DerOutputStream out) throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        DerOutputStream tagged = new DerOutputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        DerOutputStream tmp = new DerOutputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        if (assigner != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            DerOutputStream tmp2 = new DerOutputStream();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            // XXX - shd check is chars fit into PrintableString
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            tmp2.putPrintableString(assigner);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
            tagged.write(DerValue.createTag(DerValue.TAG_CONTEXT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                                 false, TAG_ASSIGNER), tmp2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        if (party == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
            throw  new IOException("Cannot have null partyName");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        // XXX - shd check is chars fit into PrintableString
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        tmp.putPrintableString(party);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        tagged.write(DerValue.createTag(DerValue.TAG_CONTEXT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
                                 false, TAG_PARTYNAME), tmp);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
        out.write(DerValue.tag_Sequence, tagged);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * Return the assignerName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * @returns String assignerName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    public String getAssignerName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
        return assigner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * Return the partyName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     * @returns String partyName
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    public String getPartyName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        return party;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
     * Compare this EDIPartyName with another.  Does a byte-string
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
     * comparison without regard to type of the partyName and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * the assignerName.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     * @returns true if the two names match
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    public boolean equals(Object other) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        if (!(other instanceof EDIPartyName))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        String otherAssigner = ((EDIPartyName)other).assigner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
        if (this.assigner == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            if (otherAssigner != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            if (!(this.assigner.equals(otherAssigner)))
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
        String otherParty = ((EDIPartyName)other).party;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        if (this.party == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            if (otherParty != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            if (!(this.party.equals(otherParty)))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     * Returns the hash code value for this EDIPartyName.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * @return a hash code value.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    public int hashCode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        if (myhash == -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            myhash = 37 + party.hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            if (assigner != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
                myhash = 37 * myhash + assigner.hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
        return myhash;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * Return the printable string.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        return ("EDIPartyName: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                 ((assigner == null) ? "" :
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                   ("  nameAssigner = " + assigner + ","))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                 + "  partyName = " + party);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     * Return constraint type:<ul>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     *   <li>NAME_DIFF_TYPE = -1: input name is different type from name (i.e. does not constrain)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     *   <li>NAME_MATCH = 0: input name matches name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     *   <li>NAME_NARROWS = 1: input name narrows name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     *   <li>NAME_WIDENS = 2: input name widens name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     *   <li>NAME_SAME_TYPE = 3: input name does not match or narrow name, but is same type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * </ul>.  These results are used in checking NameConstraints during
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * certification path verification.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * @param inputName to be checked for being constrained
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * @returns constraint type above
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * @throws UnsupportedOperationException if name is same type, but comparison operations are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     *          not supported for this name type.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    public int constrains(GeneralNameInterface inputName) throws UnsupportedOperationException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        int constraintType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        if (inputName == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            constraintType = NAME_DIFF_TYPE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        else if (inputName.getType() != NAME_EDI)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            constraintType = NAME_DIFF_TYPE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            throw new UnsupportedOperationException("Narrowing, widening, and matching of names not supported for EDIPartyName");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        return constraintType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * Return subtree depth of this name for purposes of determining
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * NameConstraints minimum and maximum bounds and for calculating
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * path lengths in name subtrees.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * @returns distance of name from root
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * @throws UnsupportedOperationException if not supported for this name type
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    public int subtreeDepth() throws UnsupportedOperationException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        throw new UnsupportedOperationException("subtreeDepth() not supported for EDIPartyName");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
}