jdk/src/share/classes/org/ietf/jgss/GSSName.java
author malenkov
Tue, 29 Oct 2013 17:01:06 +0400
changeset 21278 ef8a3a2a72f2
parent 5506 202f599c92aa
child 23010 6dadb192ad81
permissions -rw-r--r--
8022746: List of spelling errors in API doc Reviewed-by: alexsch, smarks
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: 4533
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: 4533
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: 4533
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: 4533
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4533
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4533
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 org.ietf.jgss;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import sun.security.jgss.spi.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.Enumeration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * This interface encapsulates a single GSS-API principal entity. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * application obtains an implementation of this interface
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * through one of the <code>createName</code> methods that exist in the {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * GSSManager GSSManager} class. Conceptually a GSSName contains many
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * representations of the entity or many primitive name elements, one for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * each supported underlying mechanism. In GSS terminology, a GSSName that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * contains an element from just one mechanism is called a Mechanism Name
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * (MN)<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * Since different authentication mechanisms may employ different
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * namespaces for identifying their principals, GSS-API's naming support is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * necessarily complex in multi-mechanism environments (or even in some
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * single-mechanism environments where the underlying mechanism supports
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * multiple namespaces). Different name formats and their definitions are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * identified with {@link Oid Oid's} and some standard types
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 5506
diff changeset
    48
 * are defined in this interface. The format of the names can be derived
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * based on the unique <code>Oid</code> of its name type.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * Included below are code examples utilizing the <code>GSSName</code> interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * The code below creates a <code>GSSName</code>, converts it to an MN, performs a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * comparison, obtains a printable representation of the name, exports it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * to a byte array and then re-imports to obtain a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * new <code>GSSName</code>.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *      GSSManager manager = GSSManager.getInstance();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *      // create a host based service name
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 *      GSSName name = manager.createName("service@host",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 *                   GSSName.NT_HOSTBASED_SERVICE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 *      Oid krb5 = new Oid("1.2.840.113554.1.2.2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 *      GSSName mechName = name.canonicalize(krb5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 *      // the above two steps are equivalent to the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 *      GSSName mechName = manager.createName("service@host",
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 *                      GSSName.NT_HOSTBASED_SERVICE, krb5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 *      // perform name comparison
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 *      if (name.equals(mechName))
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 *              print("Names are equals.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 *      // obtain textual representation of name and its printable
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 *      // name type
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 *      print(mechName.toString() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 *                      mechName.getStringNameType().toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 *      // export and re-import the name
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 *      byte [] exportName = mechName.export();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 *      // create a new name object from the exported buffer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 *      GSSName newName = manager.createName(exportName,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 *                      GSSName.NT_EXPORT_NAME);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 * @see #export()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * @see #equals(GSSName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * @see GSSManager#createName(String, Oid)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * @see GSSManager#createName(String, Oid, Oid)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * @see GSSManager#createName(byte[], Oid)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * @author Mayank Upadhyay
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
public interface GSSName {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * Oid indicating a host-based service name form.  It is used to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     * represent services associated with host computers.  This name form
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
     * is constructed using two elements, "service" and "hostname", as
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
     * follows: service@hostname.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * It represents the following Oid value:<br>
4533
eb8cec364323 6895424: RFC 5653
weijun
parents: 2
diff changeset
   106
     *  <code>{ iso(1) member-body(2) United
eb8cec364323 6895424: RFC 5653
weijun
parents: 2
diff changeset
   107
     * States(840) mit(113554) infosys(1) gssapi(2) generic(1) service_name(4)
eb8cec364323 6895424: RFC 5653
weijun
parents: 2
diff changeset
   108
     * }</code>
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    public static final Oid NT_HOSTBASED_SERVICE
4533
eb8cec364323 6895424: RFC 5653
weijun
parents: 2
diff changeset
   111
        = Oid.getInstance("1.2.840.113554.1.2.1.4");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * Name type to indicate a named user on a local system.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * It represents the following Oid value:<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     *  <code>{ iso(1) member-body(2) United
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * States(840) mit(113554) infosys(1) gssapi(2) generic(1) user_name(1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * }</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    public static final Oid NT_USER_NAME
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        = Oid.getInstance("1.2.840.113554.1.2.1.1");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * Name type to indicate a numeric user identifier corresponding to a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * user on a local system. (e.g. Uid).<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
     *  It represents the following Oid value:<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * <code>{ iso(1) member-body(2) United States(840) mit(113554)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * infosys(1) gssapi(2) generic(1) machine_uid_name(2) }</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    public static final Oid NT_MACHINE_UID_NAME
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        = Oid.getInstance("1.2.840.113554.1.2.1.2");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * Name type to indicate a string of digits representing the numeric
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * user identifier of a user on a local system.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * It represents the following Oid value:<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     * <code>{ iso(1) member-body(2) United
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * States(840) mit(113554) infosys(1) gssapi(2) generic(1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * string_uid_name(3) }</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    public static final Oid NT_STRING_UID_NAME
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        = Oid.getInstance("1.2.840.113554.1.2.1.3");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     * Name type for representing an anonymous entity.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
     * It represents the following Oid value:<br>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * <code>{ 1(iso), 3(org), 6(dod), 1(internet),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * 5(security), 6(nametypes), 3(gss-anonymous-name) }</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    public static final Oid NT_ANONYMOUS
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        = Oid.getInstance("1.3.6.1.5.6.3");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
     * Name type used to indicate an exported name produced by the export
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * method.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * It represents the following Oid value:<br> <code>{ 1(iso),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * 3(org), 6(dod), 1(internet), 5(security), 6(nametypes),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     * 4(gss-api-exported-name) }</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    public static final Oid NT_EXPORT_NAME
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        = Oid.getInstance("1.3.6.1.5.6.4");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
     * Compares two <code>GSSName</code> objects to determine if they refer to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
     * same entity.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
     * @param another the <code>GSSName</code> to compare this name with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
     * @return true if the two names contain at least one primitive element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
     * in common. If either of the names represents an anonymous entity, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
     * method will return false.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
     * @throws GSSException when the names cannot be compared, containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
     *         {@link GSSException#BAD_NAMETYPE GSSException.BAD_NAMETYPE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     *         {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    public boolean equals(GSSName another) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
     * Compares this <code>GSSName</code> object to another Object that might be a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * <code>GSSName</code>. The behaviour is exactly the same as in {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * #equals(GSSName) equals} except that no GSSException is thrown;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     * instead, false will be returned in the situation where an error
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
     * occurs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * @return true if the object to compare to is also a <code>GSSName</code> and the two
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     * names refer to the same entity.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * @param another the object to compare this name to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     * @see #equals(GSSName)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    public boolean equals(Object another);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
     * Returns a hashcode value for this GSSName.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
     * @return a hashCode value
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    public int hashCode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
     * Creates a name that is canonicalized for some
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * mechanism.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * @return a <code>GSSName</code> that contains just one primitive
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * element representing this name in a canonicalized form for the desired
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * mechanism.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * @param mech the oid for the mechanism for which the canonical form of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     * the name is requested.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     *         {@link GSSException#BAD_MECH GSSException.BAD_MECH},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     *         {@link GSSException#BAD_NAMETYPE GSSException.BAD_NAMETYPE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     *         {@link GSSException#BAD_NAME GSSException.BAD_NAME},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     *         {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    public GSSName canonicalize(Oid mech) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * Returns a canonical contiguous byte representation of a mechanism name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * (MN), suitable for direct, byte by byte comparison by authorization
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * functions.  If the name is not an MN, implementations may throw a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * GSSException with the NAME_NOT_MN status code.  If an implementation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * chooses not to throw an exception, it should use some system specific
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * default mechanism to canonicalize the name and then export
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * it. Structurally, an exported name object consists of a header
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * containing an OID identifying the mechanism that authenticated the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * name, and a trailer containing the name itself, where the syntax of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * the trailer is defined by the individual mechanism specification. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * format of the header of the output buffer is specified in RFC 2743.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * The exported name is useful when used in large access control lists
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * where the overhead of creating a <code>GSSName</code> object on each
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * name and invoking the equals method on each name from the ACL may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * prohibitive.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * Exported names may be re-imported by using the byte array factory
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * method {@link GSSManager#createName(byte[], Oid)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * GSSManager.createName} and specifying the NT_EXPORT_NAME as the name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     * type object identifier. The resulting <code>GSSName</code> name will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * also be a MN.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * @return a byte[] containing the exported name. RFC 2743 defines the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * "Mechanism-Independent Exported Name Object Format" for these bytes.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     *         {@link GSSException#BAD_NAME GSSException.BAD_NAME},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     *         {@link GSSException#BAD_NAMETYPE GSSException.BAD_NAMETYPE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     *         {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    public byte[] export() throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * Returns a textual representation of the <code>GSSName</code> object.  To retrieve
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * the printed name format, which determines the syntax of the returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * string, use the {@link #getStringNameType() getStringNameType}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * @return a String representing this name in printable form.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
    public String toString();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     * Returns the name type of the printable
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     * representation of this name that can be obtained from the <code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     * toString</code> method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     * @return an Oid representing the namespace of the name returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     * from the toString method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
     *         {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    public Oid getStringNameType() throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * Tests if this name object represents an anonymous entity.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * @return true if this is an anonymous name, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    public boolean isAnonymous();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * Tests if this name object represents a Mechanism Name (MN). An MN is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * a GSSName the contains exactly one mechanism's primitive name
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * element.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * @return true if this is an MN, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    public boolean isMN();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
}