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