src/java.security.jgss/share/classes/org/ietf/jgss/GSSContext.java
author weijun
Thu, 04 Jul 2019 07:25:47 +0800
changeset 55599 e6c430d4d217
parent 50307 ba1b490901d4
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: 28059
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: 4336
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: 4336
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: 4336
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4336
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4336
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 java.io.InputStream;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.io.OutputStream;
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 interface encapsulates the GSS-API security context and provides
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * the security services that are available over the context.  Security
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * contexts are established between peers using locally acquired
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * credentials.  Multiple contexts may exist simultaneously between a pair
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * of peers, using the same or different set of credentials.  GSS-API
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 * functions in a manner independent of the underlying transport protocol
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
 * and depends on its calling application to transport the tokens that are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * generated by the security context between the peers.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * If the caller instantiates the context using the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * <code>GSSManager</code> instance, then the Kerberos v5 GSS-API mechanism
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * is guaranteed to be available for context establishment. This mechanism
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * is identified by the Oid "1.2.840.113554.1.2.2" and is defined in RFC
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * 1964.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * Before the context establishment phase is initiated, the context
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * initiator may request specific characteristics desired of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * established context. Not all underlying mechanisms support all
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * characteristics that a caller might desire. After the context is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 * established, the caller can check the actual characteristics and services
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * offered by that context by means of various query methods. When using
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * the Kerberos v5 GSS-API mechanism offered by the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * <code>GSSManager</code> instance, all optional services will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * available locally. They are mutual authentication, credential
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * delegation, confidentiality and integrity protection, and per-message
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 * replay detection and sequencing. Note that in the GSS-API, message integrity
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * is a prerequisite for message confidentiality.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
 * The context establishment occurs in a loop where the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * initiator calls {@link #initSecContext(byte[], int, int) initSecContext}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 * and the acceptor calls {@link #acceptSecContext(byte[], int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
 * acceptSecContext} until the context is established. While in this loop
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
 * the <code>initSecContext</code> and <code>acceptSecContext</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
 * methods produce tokens that the application sends over to the peer. The
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * peer passes any such token as input to its <code>acceptSecContext</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * or <code>initSecContext</code> as the case may be.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * During the context establishment phase, the {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * #isProtReady() isProtReady} method may be called to determine if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * context can be used for the per-message operations of {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * #wrap(byte[], int, int, MessageProp) wrap} and {@link #getMIC(byte[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
 * int, int, MessageProp) getMIC}.  This allows applications to use
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * per-message operations on contexts which aren't yet fully
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * established.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * After the context has been established or the <code>isProtReady</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * method returns <code>true</code>, the query routines can be invoked to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * determine the actual characteristics and services of the established
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * context.  The application can also start using the per-message methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
 * of {@link #wrap(byte[], int, int, MessageProp) wrap} and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * {@link #getMIC(byte[], int, int, MessageProp) getMIC} to obtain
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * cryptographic operations on application supplied data.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * When the context is no longer needed, the application should call
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * {@link #dispose() dispose} to release any system resources the context
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * may be using.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
 * A security context typically maintains sequencing and replay detection
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
 * information about the tokens it processes. Therefore, the sequence in
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
 * which any tokens are presented to this context for processing can be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
 * important. Also note that none of the methods in this interface are
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
 * synchronized. Therefore, it is not advisable to share a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
 * <code>GSSContext</code> among several threads unless some application
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
 * level synchronization is in place.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 * Finally, different mechanism providers might place different security
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * restrictions on using GSS-API contexts. These will be documented by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * mechanism provider. The application will need to ensure that it has the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 * appropriate permissions if such checks are made in the mechanism layer.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 *
50307
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   102
 * The stream-based methods of {@code GSSContext} have been deprecated in
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   103
 * Java SE 11. These methods have also been removed from
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   104
 * <a href="http://tools.ietf.org/html/rfc8353">
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   105
 * RFC 8353: Generic Security Service API Version 2: Java Bindings Update</a>
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   106
 * for the following reasons (see section 11): "The overloaded methods of
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   107
 * GSSContext that use input and output streams as the means to convey
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   108
 * authentication and per-message GSS-API tokens as described in Section 5.15
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   109
 * of RFC 5653 are removed in this update as the wire protocol
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   110
 * should be defined by an application and not a library. It's also impossible
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   111
 * to implement these methods correctly when the token has no self-framing
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   112
 * (where the end cannot be determined), or the library has no knowledge of
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   113
 * the token format (for example, as a bridge talking to another GSS library)".
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   114
 * These methods include {@link #initSecContext(InputStream, OutputStream)},
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   115
 * {@link #acceptSecContext(InputStream, OutputStream)},
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   116
 * {@link #wrap(InputStream, OutputStream, MessageProp)},
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   117
 * {@link #unwrap(InputStream, OutputStream, MessageProp)},
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   118
 * {@link #getMIC(InputStream, OutputStream, MessageProp)},
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   119
 * and {@link #verifyMIC(InputStream, InputStream, MessageProp)}.<p>
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   120
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
 * The example code presented below demonstrates the usage of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
 * <code>GSSContext</code> interface for the initiating peer.  Different
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 * operations on the <code>GSSContext</code> object are presented,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
 * including: object instantiation, setting of desired flags, context
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
 * establishment, query of actual context flags, per-message operations on
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 28059
diff changeset
   126
 * application data, and finally context deletion.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
 * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
 *    // Create a context using default credentials
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
 *    // and the implementation specific default mechanism
55599
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   131
 *    GSSManager manager = ...
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   132
 *    GSSName targetName = ...
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
 *    GSSContext context = manager.createContext(targetName, null, null,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
 *                                           GSSContext.INDEFINITE_LIFETIME);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
 *    // set desired context options prior to context establishment
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
 *    context.requestConf(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
 *    context.requestMutualAuth(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
 *    context.requestReplayDet(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
 *    context.requestSequenceDet(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
 *    // establish a context between peers
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
 *
55599
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   144
 *    byte[] inToken = new byte[0];
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   145
 *    byte[] outToken;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
 *    // Loop while there still is a token to be processed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
 *    while (!context.isEstablished()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
 *
55599
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   151
 *        outToken = context.initSecContext(inToken, 0, inToken.length);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
 *        // send the output token if generated
55599
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   154
 *        if (outToken != null) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
 *            sendToken(outToken);
55599
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   156
 *        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
 *        if (!context.isEstablished()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
 *            inToken = readToken();
55599
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   160
 *        }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
 *    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
 *     // display context information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
 *     System.out.println("Remaining lifetime in seconds = "
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
 *                                          + context.getLifetime());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
 *     System.out.println("Context mechanism = " + context.getMech());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
 *     System.out.println("Initiator = " + context.getSrcName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
 *     System.out.println("Acceptor = " + context.getTargName());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
 *
55599
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   170
 *     if (context.getConfState()) {
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   171
 *         System.out.println("Confidentiality (i.e., privacy) is available");
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   172
 *     }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
 *
55599
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   174
 *     if (context.getIntegState()) {
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   175
 *         System.out.println("Integrity is available");
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   176
 *     }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
 *     // perform wrap on an application supplied message, appMsg,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
 *     // using QOP = 0, and requesting privacy service
55599
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   180
 *     byte[] appMsg = ...
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
 *     MessageProp mProp = new MessageProp(0, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
 *
55599
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   184
 *     outToken = context.wrap(appMsg, 0, appMsg.length, mProp);
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   185
 *
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   186
 *     sendToken(outToken);
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   187
 *
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   188
 *     // perform unwrap on an incoming application message, and check
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   189
 *     // its privacy state and supplementary information
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   190
 *     inToken = readToken();
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   191
 *
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   192
 *     mProp = new MessageProp(0, true);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
 *
55599
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   194
 *     appMsg = context.unwrap(inToken, 0, inToken.length, mProp);
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   195
 *
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   196
 *     System.out.println("Was it encrypted? " + mProp.getPrivacy());
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   197
 *     System.out.println("Duplicate Token? " + mProp.isDuplicateToken());
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   198
 *     System.out.println("Old Token? " + mProp.isOldToken());
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   199
 *     System.out.println("Unsequenced Token? " + mProp.isUnseqToken());
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   200
 *     System.out.println("Gap Token? " + mProp.isGapToken());
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   201
 *
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   202
 *     // the application determines if the privacy state and supplementary
e6c430d4d217 8226963: More clarification on possible sequencing error in GSSContext::unwrap
weijun
parents: 50307
diff changeset
   203
 *     // information are acceptable
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
 *     // release the local-end of the context
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
 *     context.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
 * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
 * @author Mayank Upadhyay
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
 * @since 1.4
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
public interface GSSContext {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * A lifetime constant representing the default context lifetime.  This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * value is set to 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    public static final int DEFAULT_LIFETIME = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * A lifetime constant representing indefinite context lifetime.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * This value must is set to the maximum integer value in Java -
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * {@link java.lang.Integer#MAX_VALUE Integer.MAX_VALUE}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    public static final int INDEFINITE_LIFETIME = Integer.MAX_VALUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     * Called by the context initiator to start the context creation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
     * phase and process any tokens generated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
     * by the peer's <code>acceptSecContext</code> method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * This method may return an output token which the application will need
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * to send to the peer for processing by its <code>acceptSecContext</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * method. The application can call {@link #isEstablished()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     * isEstablished} to determine if the context establishment phase is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
     * complete on this side of the context.  A return value of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
     * <code>false</code> from <code>isEstablished</code> indicates that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
     * more tokens are expected to be supplied to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
     * <code>initSecContext</code>.  Upon completion of the context
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * establishment, the available context options may be queried through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     * the get methods.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
     * Note that it is possible that the <code>initSecContext</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
     * return a token for the peer, and <code>isEstablished</code> return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * <code>true</code> also. This indicates that the token needs to be sent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * to the peer, but the local end of the context is now fully
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * established.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * Some mechanism providers might require that the caller be granted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * permission to initiate a security context. A failed permission check
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * might cause a {@link java.lang.SecurityException SecurityException}
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 28059
diff changeset
   252
     * to be thrown from this method.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * @return a byte[] containing the token to be sent to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
     * peer. <code>null</code> indicates that no token is generated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     * @param inputBuf token generated by the peer. This parameter is ignored
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     * on the first call since no token has been received from the peer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     * @param offset the offset within the inputBuf where the token begins.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * @param len the length of the token.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     *   {@link GSSException#DEFECTIVE_TOKEN GSSException.DEFECTIVE_TOKEN},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     *   {@link GSSException#BAD_MIC GSSException.BAD_MIC},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     *   {@link GSSException#NO_CRED GSSException.NO_CRED},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     *   {@link GSSException#CREDENTIALS_EXPIRED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     *                                  GSSException.CREDENTIALS_EXPIRED},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
     *   {@link GSSException#BAD_BINDINGS GSSException.BAD_BINDINGS},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     *   {@link GSSException#OLD_TOKEN GSSException.OLD_TOKEN},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     *   {@link GSSException#DUPLICATE_TOKEN GSSException.DUPLICATE_TOKEN},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
     *   {@link GSSException#BAD_NAMETYPE GSSException.BAD_NAMETYPE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     *   {@link GSSException#BAD_MECH GSSException.BAD_MECH},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     *   {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    public byte[] initSecContext(byte inputBuf[], int offset, int len)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
     * Called by the context initiator to start the context creation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
     * phase and process any tokens generated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
     * by the peer's <code>acceptSecContext</code> method using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
     * streams. This method may write an output token to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * <code>OutpuStream</code>, which the application will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * need to send to the peer for processing by its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * <code>acceptSecContext</code> call. Typically, the application would
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * ensure this by calling the  {@link java.io.OutputStream#flush() flush}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * method on an <code>OutputStream</code> that encapsulates the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * connection between the two peers. The application can
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * determine if a token is written to the OutputStream from the return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * value of this method. A return value of <code>0</code> indicates that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * no token was written. The application can call
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     * {@link #isEstablished() isEstablished} to determine if the context
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     * establishment phase is complete on this side of the context. A
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     * return  value of <code>false</code> from <code>isEstablished</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     * indicates that more tokens are expected to be supplied to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     * <code>initSecContext</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     * Upon completion of the context establishment, the available context
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * options may be queried through the get methods.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * Note that it is possible that the <code>initSecContext</code> method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
     * return a token for the peer, and <code>isEstablished</code> return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
     * <code>true</code> also. This indicates that the token needs to be sent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
     * to the peer, but the local end of the context is now fully
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     * established.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     * The GSS-API authentication tokens contain a definitive start and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * end. This method will attempt to read one of these tokens per
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     * invocation, and may block on the stream if only part of the token is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     * available.  In all other respects this method is equivalent to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
     * byte array based {@link #initSecContext(byte[], int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
     * initSecContext}.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
     * Some mechanism providers might require that the caller be granted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
     * permission to initiate a security context. A failed permission check
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
     * might cause a {@link java.lang.SecurityException SecurityException}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
     * to be thrown from this method.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
     * The following example code demonstrates how this method might be
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 28059
diff changeset
   319
     * used:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
     *     InputStream is ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
     *     OutputStream os ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     *     GSSContext context ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     *     // Loop while there is still a token to be processed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
     *     while (!context.isEstablished()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
     *         context.initSecContext(is, os);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
     *         // send output token if generated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
     *         os.flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
     *     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
     * @return the number of bytes written to the OutputStream as part of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
     * token to be sent to the peer. A value of 0 indicates that no token
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
     * needs to be sent.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
     * @param inStream an InputStream that contains the token generated by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
     * the peer. This parameter is ignored on the first call since no token
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
     * has been or will be received from the peer at that point.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * @param outStream an OutputStream where the output token will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * written. During the final stage of context establishment, there may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * no bytes written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     *   {@link GSSException#DEFECTIVE_TOKEN GSSException.DEFECTIVE_TOKEN},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     *   {@link GSSException#BAD_MIC GSSException.BAD_MIC},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     *   {@link GSSException#NO_CRED GSSException.NO_CRED},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     *   {@link GSSException#CREDENTIALS_EXPIRED GSSException.CREDENTIALS_EXPIRED},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     *   {@link GSSException#BAD_BINDINGS GSSException.BAD_BINDINGS},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
     *   {@link GSSException#OLD_TOKEN GSSException.OLD_TOKEN},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
     *   {@link GSSException#DUPLICATE_TOKEN GSSException.DUPLICATE_TOKEN},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     *   {@link GSSException#BAD_NAMETYPE GSSException.BAD_NAMETYPE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     *   {@link GSSException#BAD_MECH GSSException.BAD_MECH},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     *   {@link GSSException#FAILURE GSSException.FAILURE}
50307
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   359
     * @deprecated The stream-based methods have been removed from RFC 8353.
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   360
     * Use {@link #initSecContext(byte[], int, int)} instead.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     */
50307
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   362
    @Deprecated(since="11")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    public int initSecContext(InputStream inStream,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                              OutputStream outStream) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * Called by the context acceptor upon receiving a token from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * peer. This method may return an output token which the application
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * will need to send to the peer for further processing by its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     * <code>initSecContext</code> call.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
     * The application can call {@link #isEstablished() isEstablished} to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
     * determine if the context establishment phase is complete for this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
     * peer.  A return value of <code>false</code> from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
     * <code>isEstablished</code> indicates that more tokens are expected to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * be supplied to this method.    Upon completion of the context
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * establishment, the available context options may be queried through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * the get methods.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
     * Note that it is possible that <code>acceptSecContext</code> return a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
     * token for the peer, and <code>isEstablished</code> return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
     * <code>true</code> also.  This indicates that the token needs to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
     * sent to the peer, but the local end of the context is now fully
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
     * established.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * Some mechanism providers might require that the caller be granted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * permission to accept a security context. A failed permission check
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * might cause a {@link java.lang.SecurityException SecurityException}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     * to be thrown from this method.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
     * The following example code demonstrates how this method might be
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 28059
diff changeset
   392
     * used:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
     *     byte[] inToken;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
     *     byte[] outToken;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
     *     GSSContext context ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     *     // Loop while there is still a token to be processed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     *     while (!context.isEstablished()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
     *         inToken = readToken();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
     *         outToken = context.acceptSecContext(inToken, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     *                                             inToken.length);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     *         // send output token if generated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     *         if (outToken != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     *             sendToken(outToken);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     *     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     * @return a byte[] containing the token to be sent to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     * peer. <code>null</code> indicates that no token is generated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     * @param inToken token generated by the peer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * @param offset the offset within the inToken where the token begins.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * @param len the length of the token.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     *   {@link GSSException#DEFECTIVE_TOKEN GSSException.DEFECTIVE_TOKEN},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     *   {@link GSSException#BAD_MIC GSSException.BAD_MIC},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     *   {@link GSSException#NO_CRED GSSException.NO_CRED},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     *   {@link GSSException#CREDENTIALS_EXPIRED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     *                               GSSException.CREDENTIALS_EXPIRED},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     *   {@link GSSException#BAD_BINDINGS GSSException.BAD_BINDINGS},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
     *   {@link GSSException#OLD_TOKEN GSSException.OLD_TOKEN},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
     *   {@link GSSException#DUPLICATE_TOKEN GSSException.DUPLICATE_TOKEN},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
     *   {@link GSSException#BAD_MECH GSSException.BAD_MECH},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
     *   {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    public byte[] acceptSecContext(byte inToken[], int offset, int len)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
     * Called by the context acceptor to process a token from the peer using
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
     * streams.   It may write an output token to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
     * <code>OutputStream</code>, which the application
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
     * will need to send to the peer for processing by its
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
     * <code>initSecContext</code> method.  Typically, the application would
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
     * ensure this by calling the  {@link java.io.OutputStream#flush() flush}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
     * method on an <code>OutputStream</code> that encapsulates the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
     * connection between the two peers. The application can call
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
     * {@link #isEstablished() isEstablished} to determine if the context
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
     * establishment phase is complete on this side of the context. A
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
     * return  value of <code>false</code> from <code>isEstablished</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
     * indicates that more tokens are expected to be supplied to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
     * <code>acceptSecContext</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * Upon completion of the context establishment, the available context
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * options may be queried through the get methods.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
     * Note that it is possible that <code>acceptSecContext</code> return a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
     * token for the peer, and <code>isEstablished</code> return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     * <code>true</code> also.  This indicates that the token needs to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * sent to the peer, but the local end of the context is now fully
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     * established.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * The GSS-API authentication tokens contain a definitive start and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     * end. This method will attempt to read one of these tokens per
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     * invocation, and may block on the stream if only part of the token is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
     * available. In all other respects this method is equivalent to the byte
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     * array based {@link #acceptSecContext(byte[], int, int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     * acceptSecContext}.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
     * Some mechanism providers might require that the caller be granted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
     * permission to accept a security context. A failed permission check
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * might cause a {@link java.lang.SecurityException SecurityException}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     * to be thrown from this method.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
     * The following example code demonstrates how this method might be
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 28059
diff changeset
   469
     * used:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
     *     InputStream is ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     *     OutputStream os ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     *     GSSContext context ...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     *     // Loop while there is still a token to be processed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
     *     while (!context.isEstablished()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     *         context.acceptSecContext(is, os);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     *         // send output token if generated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     *         os.flush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     *     }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
     * @param inStream an InputStream that contains the token generated by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
     * the peer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
     * @param outStream an OutputStream where the output token will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
     * written. During the final stage of context establishment, there may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * no bytes written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     *   {@link GSSException#DEFECTIVE_TOKEN GSSException.DEFECTIVE_TOKEN},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     *   {@link GSSException#BAD_MIC GSSException.BAD_MIC},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
     *   {@link GSSException#NO_CRED GSSException.NO_CRED},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
     *   {@link GSSException#CREDENTIALS_EXPIRED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
     *                           GSSException.CREDENTIALS_EXPIRED},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
     *   {@link GSSException#BAD_BINDINGS GSSException.BAD_BINDINGS},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     *   {@link GSSException#OLD_TOKEN GSSException.OLD_TOKEN},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     *   {@link GSSException#DUPLICATE_TOKEN GSSException.DUPLICATE_TOKEN},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     *   {@link GSSException#BAD_MECH GSSException.BAD_MECH},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     *   {@link GSSException#FAILURE GSSException.FAILURE}
50307
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   505
     *
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   506
     * @deprecated The stream-based methods have been removed from RFC 8353.
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   507
     * Use {@link #acceptSecContext(byte[], int, int)} instead.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    /* Missing return value in RFC. int should have been returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * -----------------------------------------------------------
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     * The application can determine if a token is written to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
     * OutputStream from the return value of this method. A return value of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
     * <code>0</code> indicates that no token was written.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
     * @return <strong>the number of bytes written to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * OutputStream as part of the token to be sent to the peer. A value of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     * 0 indicates that no token  needs to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
     * sent.</strong>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
     */
50307
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   521
    @Deprecated(since="11")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    public void acceptSecContext(InputStream inStream,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
                                 OutputStream outStream) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
     * Used during context establishment to determine the state of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
     * context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
     * @return <code>true</code> if this is a fully established context on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
     * the caller's side and no more tokens are needed from the peer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
    public boolean isEstablished();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     * Releases any system resources and cryptographic information stored in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
     * the context object and invalidates the context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     *   {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    public void dispose() throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     * Used to determine limits on the size of the message
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * that can be passed to <code>wrap</code>. Returns the maximum
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     * message size that, if presented to the <code>wrap</code> method with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     * the same <code>confReq</code> and <code>qop</code> parameters, will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     * result in an output token containing no more
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     * than <code>maxTokenSize</code> bytes.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     * This call is intended for use by applications that communicate over
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * protocols that impose a maximum message size.  It enables the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     * application to fragment messages prior to applying protection.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     * GSS-API implementations are recommended but not required to detect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     * invalid QOP values when <code>getWrapSizeLimit</code> is called.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     * This routine guarantees only a maximum message size, not the
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 28059
diff changeset
   560
     * availability of specific QOP values for message protection.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
     * @param qop the level of protection wrap will be asked to provide.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
     * @param confReq <code>true</code> if wrap will be asked to provide
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
     * privacy, <code>false</code>  otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
     * @param maxTokenSize the desired maximum size of the token emitted by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
     * wrap.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
     * @return the maximum size of the input token for the given output
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     * token size
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
     *   {@link GSSException#CONTEXT_EXPIRED GSSException.CONTEXT_EXPIRED},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
     *   {@link GSSException#BAD_QOP GSSException.BAD_QOP},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
     *   {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    public int getWrapSizeLimit(int qop, boolean confReq,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
                                int maxTokenSize) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
     * Applies per-message security services over the established security
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
     * context. The method will return a token with the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
     * application supplied data and a cryptographic MIC over it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
     * The data may be encrypted if confidentiality (privacy) was
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
     * requested.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
     * The MessageProp object is instantiated by the application and used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
     * to specify a QOP value which selects cryptographic algorithms, and a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     * privacy service to optionally encrypt the message.  The underlying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     * mechanism that is used in the call may not be able to provide the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
     * privacy service.  It sets the actual privacy service that it does
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
     * provide in this MessageProp object which the caller should then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
     * query upon return.  If the mechanism is not able to provide the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     * requested QOP, it throws a GSSException with the BAD_QOP code.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     * Since some application-level protocols may wish to use tokens
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     * emitted by wrap to provide "secure framing", implementations should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     * support the wrapping of zero-length messages.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     * The application will be responsible for sending the token to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     * peer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     * @param inBuf application data to be protected.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     * @param offset the offset within the inBuf where the data begins.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     * @param len the length of the data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
     * @param msgProp instance of MessageProp that is used by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
     * application to set the desired QOP and privacy state. Set the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     * desired QOP to 0 to request the default QOP. Upon return from this
28059
e576535359cc 8067377: My hobby: caning, then then canning, the the can-can
martin
parents: 26629
diff changeset
   608
     * method, this object will contain the actual privacy state that
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     * was applied to the message by the underlying mechanism.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     * @return a byte[] containing the token to be sent to the peer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
     * @throws GSSException containing the following major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
     *   {@link GSSException#CONTEXT_EXPIRED GSSException.CONTEXT_EXPIRED},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
     *   {@link GSSException#BAD_QOP GSSException.BAD_QOP},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     *   {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
    public byte[] wrap(byte inBuf[], int offset, int len,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
                       MessageProp msgProp) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
     * Applies per-message security services over the established security
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
     * context using streams. The method will return a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
     * token with the application supplied data and a cryptographic MIC over it.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
     * The data may be encrypted if confidentiality
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
     * (privacy) was requested. This method is equivalent to the byte array
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
     * based {@link #wrap(byte[], int, int, MessageProp) wrap} method.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
     * The application will be responsible for sending the token to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
     * peer.  Typically, the application would
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
     * ensure this by calling the  {@link java.io.OutputStream#flush() flush}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
     * method on an <code>OutputStream</code> that encapsulates the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
     * connection between the two peers.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
     * The MessageProp object is instantiated by the application and used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
     * to specify a QOP value which selects cryptographic algorithms, and a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
     * privacy service to optionally encrypt the message.  The underlying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
     * mechanism that is used in the call may not be able to provide the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
     * privacy service.  It sets the actual privacy service that it does
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
     * provide in this MessageProp object which the caller should then
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
     * query upon return.  If the mechanism is not able to provide the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
     * requested QOP, it throws a GSSException with the BAD_QOP code.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
     * Since some application-level protocols may wish to use tokens
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     * emitted by wrap to provide "secure framing", implementations should
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 28059
diff changeset
   645
     * support the wrapping of zero-length messages.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
     * @param inStream an InputStream containing the application data to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
     * protected. All of the data that is available in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
     * inStream is used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     * @param outStream an OutputStream to write the protected message
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
     * to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
     * @param msgProp instance of MessageProp that is used by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
     * application to set the desired QOP and privacy state. Set the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
     * desired QOP to 0 to request the default QOP. Upon return from this
28059
e576535359cc 8067377: My hobby: caning, then then canning, the the can-can
martin
parents: 26629
diff changeset
   655
     * method, this object will contain the actual privacy state that
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
     * was applied to the message by the underlying mechanism.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
     *   {@link GSSException#CONTEXT_EXPIRED GSSException.CONTEXT_EXPIRED},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
     *   {@link GSSException#BAD_QOP GSSException.BAD_QOP},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
     *   {@link GSSException#FAILURE GSSException.FAILURE}
50307
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   663
     *
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   664
     * @deprecated The stream-based methods have been removed from RFC 8353.
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   665
     * Use {@link #wrap(byte[], int, int, MessageProp)} instead.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
     */
50307
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   667
    @Deprecated(since="11")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
    public void wrap(InputStream inStream, OutputStream outStream,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
                     MessageProp msgProp) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
     * Used to process tokens generated by the <code>wrap</code> method on
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
     * the other side of the context. The method will return the message
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
     * supplied by the peer application to its wrap call, while at the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
     * time verifying the embedded MIC for that message.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
     * The MessageProp object is instantiated by the application and is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
     * used by the underlying mechanism to return information to the caller
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
     * such as the QOP, whether confidentiality was applied to the message,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
     * and other supplementary message state information.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
     * Since some application-level protocols may wish to use tokens
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
     * emitted by wrap to provide "secure framing", implementations should
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 28059
diff changeset
   684
     * support the wrapping and unwrapping of zero-length messages.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     * @param inBuf a byte array containing the wrap token received from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     * peer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     * @param offset the offset where the token begins.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     * @param len the length of the token
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     * @param msgProp upon return from the method, this object will contain
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
     * the applied QOP, the privacy state of the message, and supplementary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     * information stating if the token was a duplicate, old, out of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
     * sequence or arriving after a gap.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
     * @return a byte[] containing the message unwrapped from the input
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
     * token.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     *   {@link GSSException#DEFECTIVE_TOKEN GSSException.DEFECTIVE_TOKEN},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
     *   {@link GSSException#BAD_MIC GSSException.BAD_MIC},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     *   {@link GSSException#CONTEXT_EXPIRED GSSException.CONTEXT_EXPIRED},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     *   {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
    public byte [] unwrap(byte[] inBuf, int offset, int len,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
                          MessageProp msgProp) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
     * Uses streams to process tokens generated by the <code>wrap</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
     * method on the other side of the context. The method will return the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
     * message supplied by the peer application to its wrap call, while at
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
     * the same time verifying the embedded MIC for that message.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
     * The MessageProp object is instantiated by the application and is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
     * used by the underlying mechanism to return information to the caller
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
     * such as the QOP, whether confidentiality was applied to the message,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
     * and other supplementary message state information.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
     * Since some application-level protocols may wish to use tokens
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
     * emitted by wrap to provide "secure framing", implementations should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     * support the wrapping and unwrapping of zero-length messages.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     * The format of the input token that this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
     * reads is defined in the specification for the underlying mechanism that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
     * will be used. This method will attempt to read one of these tokens per
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     * invocation. If the mechanism token contains a definitive start and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
     * end this method may block on the <code>InputStream</code> if only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
     * part of the token is available. If the start and end of the token
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
     * are not definitive then the method will attempt to treat all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
     * available bytes as part of the token.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     *
4336
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 2
diff changeset
   731
     * Other than the possible blocking behavior described above, this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
     * method is equivalent to the byte array based {@link #unwrap(byte[],
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 28059
diff changeset
   733
     * int, int, MessageProp) unwrap} method.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
     * @param inStream an InputStream that contains the wrap token generated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
     * by the peer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
     * @param outStream an OutputStream to write the application message
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
     * to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
     * @param msgProp upon return from the method, this object will contain
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
     * the applied QOP, the privacy state of the message, and supplementary
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
     * information stating if the token was a duplicate, old, out of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
     * sequence or arriving after a gap.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
     *   {@link GSSException#DEFECTIVE_TOKEN GSSException.DEFECTIVE_TOKEN},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
     *   {@link GSSException#BAD_MIC GSSException.BAD_MIC},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
     *   {@link GSSException#CONTEXT_EXPIRED GSSException.CONTEXT_EXPIRED},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
     *   {@link GSSException#FAILURE GSSException.FAILURE}
50307
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   750
     *
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   751
     * @deprecated The stream-based methods have been removed from RFC 8353.
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   752
     * Use {@link #unwrap(byte[], int, int, MessageProp)} instead.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
     */
50307
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   754
    @Deprecated(since="11")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
    public void unwrap(InputStream inStream, OutputStream outStream,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
                       MessageProp msgProp) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
     * Returns a token containing a cryptographic Message Integrity Code
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
     * (MIC) for the supplied message,  for transfer to the peer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
     * application.  Unlike wrap, which encapsulates the user message in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
     * returned token, only the message MIC is returned in the output
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
     * token.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
     * Note that privacy can only be applied through the wrap call.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
     * Since some application-level protocols may wish to use tokens emitted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
     * by getMIC to provide "secure framing", implementations should support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
     * derivation of MICs from zero-length messages.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
     * @param inMsg the message to generate the MIC over.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
     * @param offset offset within the inMsg where the message begins.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
     * @param len the length of the message
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
     * @param msgProp an instance of <code>MessageProp</code> that is used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
     * by the application to set the desired QOP.  Set the desired QOP to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
     * <code>0</code> in <code>msgProp</code> to request the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
     * QOP. Alternatively pass in <code>null</code> for <code>msgProp</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
     * to request the default QOP.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
     * @return a byte[] containing the token to be sent to the peer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
     *   {@link GSSException#CONTEXT_EXPIRED GSSException.CONTEXT_EXPIRED},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
     *   {@link GSSException#BAD_QOP GSSException.BAD_QOP},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
     *   {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
    public byte[] getMIC(byte []inMsg, int offset, int len,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
                         MessageProp msgProp) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
     * Uses streams to produce a token containing a cryptographic MIC for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
     * the supplied message, for transfer to the peer application.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
     * Unlike wrap, which encapsulates the user message in the returned
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
     * token, only the message MIC is produced in the output token. This
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
     * method is equivalent to the byte array based {@link #getMIC(byte[],
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
     * int, int, MessageProp) getMIC} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
     * Note that privacy can only be applied through the wrap call.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
     * Since some application-level protocols may wish to use tokens emitted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
     * by getMIC to provide "secure framing", implementations should support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
     * derivation of MICs from zero-length messages.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
     * @param inStream an InputStream containing the message to generate the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
     * MIC over. All of the data that is available in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
     * inStream is used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
     * @param outStream an OutputStream to write the output token to.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
     * @param msgProp an instance of <code>MessageProp</code> that is used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
     * by the application to set the desired QOP.  Set the desired QOP to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
     * <code>0</code> in <code>msgProp</code> to request the default
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
     * QOP. Alternatively pass in <code>null</code> for <code>msgProp</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
     * to request the default QOP.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
     *   {@link GSSException#CONTEXT_EXPIRED GSSException.CONTEXT_EXPIRED},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
     *   {@link GSSException#BAD_QOP GSSException.BAD_QOP},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
     *   {@link GSSException#FAILURE GSSException.FAILURE}
50307
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   819
     *
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   820
     * @deprecated The stream-based methods have been removed from RFC 8353.
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   821
     * Use {@link #getMIC(byte[], int, int, MessageProp)} instead.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
     */
50307
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   823
    @Deprecated(since="11")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
    public void getMIC(InputStream inStream, OutputStream outStream,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
                       MessageProp msgProp) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
     * Verifies the cryptographic MIC, contained in the token parameter,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
     * over the supplied message.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
     * The MessageProp object is instantiated by the application and is used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
     * by the underlying mechanism to return information to the caller such
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
     * as the QOP indicating the strength of protection that was applied to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
     * the message and other supplementary message state information.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
     * Since some application-level protocols may wish to use tokens emitted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
     * by getMIC to provide "secure framing", implementations should support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
     * the calculation and verification of MICs over zero-length messages.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
     * @param inToken the token generated by peer's getMIC method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
     * @param tokOffset the offset within the inToken where the token
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
     * begins.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
     * @param tokLen the length of the token.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
     * @param inMsg the application message to verify the cryptographic MIC
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
     * over.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
     * @param msgOffset the offset in inMsg where the message begins.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
     * @param msgLen the length of the message.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
     * @param msgProp upon return from the method, this object will contain
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
     * the applied QOP and supplementary information stating if the token
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
     * was a duplicate, old, out of sequence or arriving after a gap.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
     *   {@link GSSException#DEFECTIVE_TOKEN GSSException.DEFECTIVE_TOKEN}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
     *   {@link GSSException#BAD_MIC GSSException.BAD_MIC}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
     *   {@link GSSException#CONTEXT_EXPIRED GSSException.CONTEXT_EXPIRED}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
     *   {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
    public void verifyMIC(byte[] inToken, int tokOffset, int tokLen,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
                          byte[] inMsg, int msgOffset, int msgLen,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
                          MessageProp msgProp) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
     * Uses streams to verify the cryptographic MIC, contained in the token
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
     * parameter, over the supplied message.  This method is equivalent to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
     * the byte array based {@link #verifyMIC(byte[], int, int, byte[], int,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
     * int, MessageProp) verifyMIC} method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
     * The MessageProp object is instantiated by the application and is used
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
     * by the underlying mechanism to return information to the caller such
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
     * as the QOP indicating the strength of protection that was applied to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
     * the message and other supplementary message state information.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
     * Since some application-level protocols may wish to use tokens emitted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
     * by getMIC to provide "secure framing", implementations should support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
     * the calculation and verification of MICs over zero-length messages.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
     * The format of the input token that this method
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
     * reads is defined in the specification for the underlying mechanism that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
     * will be used. This method will attempt to read one of these tokens per
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
     * invocation. If the mechanism token contains a definitive start and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
     * end this method may block on the <code>InputStream</code> if only
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
     * part of the token is available. If the start and end of the token
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
     * are not definitive then the method will attempt to treat all
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
     * available bytes as part of the token.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
     *
4336
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 2
diff changeset
   887
     * Other than the possible blocking behavior described above, this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
     * method is equivalent to the byte array based {@link #verifyMIC(byte[],
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 28059
diff changeset
   889
     * int, int, byte[], int, int, MessageProp) verifyMIC} method.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
     * @param tokStream an InputStream containing the token generated by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
     * peer's getMIC method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
     * @param msgStream an InputStream containing the application message to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
     * verify the cryptographic MIC over. All of the data
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
     * that is available in msgStream is used.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
     * @param msgProp upon return from the method, this object will contain
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
     * the applied QOP and supplementary information stating if the token
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
     * was a duplicate, old, out of sequence or arriving after a gap.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
     *   {@link GSSException#DEFECTIVE_TOKEN GSSException.DEFECTIVE_TOKEN}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
     *   {@link GSSException#BAD_MIC GSSException.BAD_MIC}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
     *   {@link GSSException#CONTEXT_EXPIRED GSSException.CONTEXT_EXPIRED}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
     *   {@link GSSException#FAILURE GSSException.FAILURE}
50307
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   906
     *
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   907
     * @deprecated The stream-based methods have been removed from RFC 8353.
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   908
     * Use {@link #verifyMIC(byte[], int, int, byte[], int, int, MessageProp)}
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   909
     * instead.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
     */
50307
ba1b490901d4 8072996: Deprecate stream-based GSSContext methods
weijun
parents: 47216
diff changeset
   911
    @Deprecated(since="11")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
    public void verifyMIC(InputStream tokStream, InputStream msgStream,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
                          MessageProp msgProp) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
     * Exports this context so that another process may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
     * import it.. Provided to support the sharing of work between
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
     * multiple processes. This routine will typically be used by the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
     * context-acceptor, in an application where a single process receives
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
     * incoming connection requests and accepts security contexts over
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
     * them, then passes the established context to one or more other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
     * processes for message exchange.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
     * This method deactivates the security context and creates an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
     * interprocess token which, when passed to {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
     * GSSManager#createContext(byte[]) GSSManager.createContext} in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
     * another process, will re-activate the context in the second process.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
     * Only a single instantiation of a given context may be active at any
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
     * one time; a subsequent attempt by a context exporter to access the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
     * exported security context will fail.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
     * The implementation may constrain the set of processes by which the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
     * interprocess token may be imported, either as a function of local
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
     * security policy, or as a result of implementation decisions.  For
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
     * example, some implementations may constrain contexts to be passed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
     * only between processes that run under the same account, or which are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
     * part of the same process group.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
     * The interprocess token may contain security-sensitive information
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
     * (for example cryptographic keys).  While mechanisms are encouraged
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
     * to either avoid placing such sensitive information within
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
     * interprocess tokens, or to encrypt the token before returning it to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
     * the application, in a typical GSS-API implementation this may not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
     * possible.  Thus the application must take care to protect the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
     * interprocess token, and ensure that any process to which the token
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
     * is transferred is trustworthy. <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
     * Implementations are not required to support the inter-process
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
     * transfer of security contexts.  Calling the {@link #isTransferable()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
     * isTransferable} method will indicate if the context object is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
     * transferable.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
     * Calling this method on a context that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
     * is not exportable will result in this exception being thrown with
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
     * the error code {@link GSSException#UNAVAILABLE
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
     * GSSException.UNAVAILABLE}.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
     * @return a byte[] containing the exported context
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
     * @see GSSManager#createContext(byte[])
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
     *   {@link GSSException#UNAVAILABLE GSSException.UNAVAILABLE},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
     *   {@link GSSException#CONTEXT_EXPIRED GSSException.CONTEXT_EXPIRED},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
     *   {@link GSSException#NO_CONTEXT GSSException.NO_CONTEXT},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
     *   {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
    public byte [] export() throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
     * Requests that mutual authentication be done during
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
     * context establishment. This request can only be made on the context
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
     * initiator's side and it has to be done prior to the first call to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
     * <code>initSecContext</code>.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
     * Not all mechanisms support mutual authentication and some mechanisms
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
     * might require mutual authentication even if the application
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
     * doesn't. Therefore, the application should check to see if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
     * request was honored with the {@link #getMutualAuthState()
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 28059
diff changeset
   980
     * getMutualAuthState} method.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
     * @param state a boolean value indicating whether mutual
4336
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 2
diff changeset
   983
     * authentication should be used or not.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
     * @see #getMutualAuthState()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
     *   {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
    public void requestMutualAuth(boolean state) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
     * Requests that replay detection be enabled for the
4336
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 2
diff changeset
   994
     * per-message security services after context establishment. This
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
     * request can only be made on the context initiator's side and it has
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
     * to be done prior to the first call to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
     * <code>initSecContext</code>. During context establishment replay
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
     * detection is not an option and is a function of the underlying
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
     * mechanism's capabilities.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
     * Not all mechanisms support replay detection and some mechanisms
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
     * might require replay detection even if the application
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
     * doesn't. Therefore, the application should check to see if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
     * request was honored with the {@link #getReplayDetState()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
     * getReplayDetState} method. If replay detection is enabled then the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
     * {@link MessageProp#isDuplicateToken() MessageProp.isDuplicateToken} and {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
     * MessageProp#isOldToken() MessageProp.isOldToken} methods will return
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
     * valid results for the <code>MessageProp</code> object that is passed
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
     * in to the <code>unwrap</code> method or the <code>verifyMIC</code>
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 28059
diff changeset
  1010
     * method.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
     * @param state a boolean value indicating whether replay detection
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
     * should be enabled over the established context or not.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
     * @see #getReplayDetState()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
     *   {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
    public void requestReplayDet(boolean state) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1021
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1022
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
     * Requests that sequence checking be enabled for the
4336
4c792c19266e 6853328: Support OK-AS-DELEGATE flag
weijun
parents: 2
diff changeset
  1024
     * per-message security services after context establishment. This
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
     * request can only be made on the context initiator's side and it has
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
     * to be done prior to the first call to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
     * <code>initSecContext</code>. During context establishment sequence
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
     * checking is not an option and is a function of the underlying
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1029
     * mechanism's capabilities.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1030
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1031
     * Not all mechanisms support sequence checking and some mechanisms
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1032
     * might require sequence checking even if the application
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1033
     * doesn't. Therefore, the application should check to see if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1034
     * request was honored with the {@link #getSequenceDetState()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1035
     * getSequenceDetState} method. If sequence checking is enabled then the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1036
     * {@link MessageProp#isDuplicateToken() MessageProp.isDuplicateToken},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1037
     * {@link MessageProp#isOldToken() MessageProp.isOldToken},
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1038
     * {@link MessageProp#isUnseqToken() MessageProp.isUnseqToken}, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1039
     * {@link MessageProp#isGapToken() MessageProp.isGapToken} methods will return
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1040
     * valid results for the <code>MessageProp</code> object that is passed
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1041
     * in to the <code>unwrap</code> method or the <code>verifyMIC</code>
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 28059
diff changeset
  1042
     * method.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1043
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1044
     * @param state a boolean value indicating whether sequence checking
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1045
     * should be enabled over the established context or not.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1046
     * @see #getSequenceDetState()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1047
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1048
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1049
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1050
     *   {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1051
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1052
    public void requestSequenceDet(boolean state) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1053
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1054
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1055
     * Requests that the initiator's credentials be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1056
     * delegated to the acceptor during context establishment. This
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1057
     * request can only be made on the context initiator's side and it has
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1058
     * to be done prior to the first call to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1059
     * <code>initSecContext</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1060
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1061
     * Not all mechanisms support credential delegation. Therefore, an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1062
     * application that desires delegation should check to see if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1063
     * request was honored with the {@link #getCredDelegState()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1064
     * getCredDelegState} method. If the application indicates that
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1065
     * delegation must not be used, then the mechanism will honor the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1066
     * request and delegation will not occur. This is an exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1067
     * to the general rule that a mechanism may enable a service even if it
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 28059
diff changeset
  1068
     * is not requested.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1069
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1070
     * @param state a boolean value indicating whether the credentials
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1071
     * should be delegated or not.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1072
     * @see #getCredDelegState()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1073
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1074
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1075
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1076
     *   {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1077
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1078
    public void requestCredDeleg(boolean state) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1079
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1080
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1081
     * Requests that the initiator's identity not be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1082
     * disclosed to the acceptor. This request can only be made on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1083
     * context initiator's side and it has to be done prior to the first
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1084
     * call to <code>initSecContext</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1085
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1086
     * Not all mechanisms support anonymity for the initiator. Therefore, the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1087
     * application should check to see if the request was honored with the
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 28059
diff changeset
  1088
     * {@link #getAnonymityState() getAnonymityState} method.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1089
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1090
     * @param state a boolean value indicating if the initiator should
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1091
     * be authenticated to the acceptor as an anonymous principal.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1092
     * @see #getAnonymityState
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1093
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1094
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1095
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1096
     *   {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1097
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1098
    public void requestAnonymity(boolean state) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1099
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1100
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1101
     * Requests that data confidentiality be enabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1102
     * for the <code>wrap</code> method. This request can only be made on
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1103
     * the context initiator's side and it has to be done prior to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1104
     * first call to <code>initSecContext</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1105
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1106
     * Not all mechanisms support confidentiality and other mechanisms
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1107
     * might enable it even if the application doesn't request
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1108
     * it. The application may check to see if the request was honored with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1109
     * the {@link #getConfState() getConfState} method. If confidentiality
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1110
     * is enabled, only then will the mechanism honor a request for privacy
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1111
     * in the {@link MessageProp#MessageProp(int, boolean) MessageProp}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1112
     * object that is passed in to the <code>wrap</code> method.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1113
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1114
     * Enabling confidentiality will also automatically enable
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 28059
diff changeset
  1115
     * integrity.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1116
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1117
     * @param state a boolean value indicating whether confidentiality
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1118
     * should be enabled or not.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1119
     * @see #getConfState()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1120
     * @see #getIntegState()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1121
     * @see #requestInteg(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1122
     * @see MessageProp
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1123
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1124
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1125
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1126
     *   {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1127
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1128
    public void requestConf(boolean state) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1129
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1130
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1131
     * Requests that data integrity be enabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1132
     * for the <code>wrap</code> and <code>getMIC</code>methods. This
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1133
     * request can only be made on the context initiator's side and it has
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1134
     * to be done prior to the first call to <code>initSecContext</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1135
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1136
     * Not all mechanisms support integrity and other mechanisms
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1137
     * might enable it even if the application doesn't request
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1138
     * it. The application may check to see if the request was honored with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1139
     * the {@link #getIntegState() getIntegState} method.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1140
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1141
     * Disabling integrity will also automatically disable
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 28059
diff changeset
  1142
     * confidentiality.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1143
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1144
     * @param state a boolean value indicating whether integrity
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1145
     * should be enabled or not.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1146
     * @see #getIntegState()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1147
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1148
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1149
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1150
     *   {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1151
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1152
    public void requestInteg(boolean state) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1153
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1154
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1155
     * Requests a lifetime in seconds for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1156
     * context. This method can only be called on the context initiator's
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1157
     * side  and it has to be done prior to the first call to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1158
     * <code>initSecContext</code>.<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1159
     *
21278
ef8a3a2a72f2 8022746: List of spelling errors in API doc
malenkov
parents: 5506
diff changeset
  1160
     * The actual lifetime of the context will depend on the capabilities of
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1161
     * the underlying mechanism and the application should call the {@link
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 28059
diff changeset
  1162
     * #getLifetime() getLifetime} method to determine this.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1163
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1164
     * @param lifetime the desired context lifetime in seconds. Use
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1165
     * <code>INDEFINITE_LIFETIME</code> to request an indefinite lifetime
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1166
     * and <code>DEFAULT_LIFETIME</code> to request a default lifetime.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1167
     * @see #getLifetime()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1168
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1169
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1170
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1171
     *   {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1172
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1173
    public void requestLifetime(int lifetime) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1174
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1175
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1176
     * Sets the channel bindings to be used during context
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1177
     * establishment. This method can be called on both
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1178
     * the context initiator's and the context acceptor's side, but it must
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1179
     * be called before context establishment begins. This means that an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1180
     * initiator must call it before the first call to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1181
     * <code>initSecContext</code> and the acceptor must call it before the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1182
     * first call to <code>acceptSecContext</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1183
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1184
     * @param cb the channel bindings to use.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1185
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1186
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1187
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1188
     *   {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1189
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1190
    public void setChannelBinding(ChannelBinding cb) throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1191
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1192
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1193
     * Determines if credential delegation is enabled on
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1194
     * this context. It can be called by both the context initiator and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1195
     * context acceptor. For a definitive answer this method must be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1196
     * called only after context establishment is complete. Note that if an
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1197
     * initiator requests that delegation not be allowed the {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1198
     * #requestCredDeleg(boolean) requestCredDeleg} method will honor that
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1199
     * request and this method will return <code>false</code> on the
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 28059
diff changeset
  1200
     * initiator's side from that point onwards.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1201
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1202
     * @return true if delegation is enabled, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1203
     * @see #requestCredDeleg(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1204
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1205
    public boolean getCredDelegState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1206
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1207
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1208
     * Determines if mutual authentication is enabled on
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1209
     * this context. It can be called by both the context initiator and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1210
     * context acceptor. For a definitive answer this method must be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1211
     * called only after context establishment is complete. An initiator
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1212
     * that requests mutual authentication can call this method after
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1213
     * context completion and dispose the context if its request was not
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 28059
diff changeset
  1214
     * honored.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1215
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1216
     * @return true if mutual authentication is enabled, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1217
     * @see #requestMutualAuth(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1218
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1219
    public boolean getMutualAuthState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1220
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1221
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1222
     * Determines if replay detection is enabled for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1223
     * per-message security services from this context. It can be called by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1224
     * both the context initiator and the context acceptor. For a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1225
     * definitive answer this method must be called only after context
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1226
     * establishment is complete. An initiator that requests replay
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1227
     * detection can call this method after context completion and
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 28059
diff changeset
  1228
     * dispose the context if its request was not honored.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1229
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1230
     * @return true if replay detection is enabled, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1231
     * @see #requestReplayDet(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1232
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1233
    public boolean getReplayDetState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1234
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1235
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1236
     * Determines if sequence checking is enabled for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1237
     * per-message security services from this context. It can be called by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1238
     * both the context initiator and the context acceptor. For a
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1239
     * definitive answer this method must be called only after context
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1240
     * establishment is complete. An initiator that requests sequence
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1241
     * checking can call this method after context completion and
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 28059
diff changeset
  1242
     * dispose the context if its request was not honored.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1243
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1244
     * @return true if sequence checking is enabled, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1245
     * @see #requestSequenceDet(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1246
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1247
    public boolean getSequenceDetState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1248
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1249
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1250
     * Determines if the context initiator is
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1251
     * anonymously authenticated to the context acceptor. It can be called by
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1252
     * both the context initiator and the context acceptor, and at any
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1253
     * time. <strong>On the initiator side, a call to this method determines
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1254
     * if the identity of the initiator has been disclosed in any of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1255
     * context establishment tokens that might have been generated thus far
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1256
     * by <code>initSecContext</code>. An initiator that absolutely must be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1257
     * authenticated anonymously should call this method after each call to
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1258
     * <code>initSecContext</code> to determine if the generated token
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1259
     * should be sent to the peer or the context aborted.</strong> On the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1260
     * acceptor side, a call to this method determines if any of the tokens
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1261
     * processed by <code>acceptSecContext</code> thus far have divulged
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 28059
diff changeset
  1262
     * the identity of the initiator.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1263
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1264
     * @return true if the context initiator is still anonymous, false
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1265
     * otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1266
     * @see #requestAnonymity(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1267
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1268
    public boolean getAnonymityState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1269
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1270
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1271
     * Determines if the context is transferable to other processes
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1272
     * through the use of the {@link #export() export} method.  This call
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1273
     * is only valid on fully established contexts.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1274
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1275
     * @return true if this context can be exported, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1276
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1277
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1278
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1279
     *   {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1280
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1281
    public boolean isTransferable() throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1282
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1283
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1284
     * Determines if the context is ready for per message operations to be
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1285
     * used over it.  Some mechanisms may allow the usage of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1286
     * per-message operations before the context is fully established.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1287
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1288
     * @return true if methods like <code>wrap</code>, <code>unwrap</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1289
     * <code>getMIC</code>, and <code>verifyMIC</code> can be used with
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1290
     * this context at the current stage of context establishment, false
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1291
     * otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1292
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1293
    public boolean isProtReady();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1294
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1295
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1296
     * Determines if data confidentiality is available
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1297
     * over the context. This method can be called by both the context
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1298
     * initiator and the context acceptor, but only after one of {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1299
     * #isProtReady() isProtReady} or {@link #isEstablished()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1300
     * isEstablished} return <code>true</code>. If this method returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1301
     * <code>true</code>, so will {@link #getIntegState()
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 28059
diff changeset
  1302
     * getIntegState}
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1303
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1304
     * @return true if confidentiality services are available, false
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1305
     * otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1306
     * @see #requestConf(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1307
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1308
    public boolean getConfState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1309
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1310
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1311
     * Determines if data integrity is available
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1312
     * over the context. This method can be called by both the context
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1313
     * initiator and the context acceptor, but only after one of {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1314
     * #isProtReady() isProtReady} or {@link #isEstablished()
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1315
     * isEstablished} return <code>true</code>. This method will always
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1316
     * return <code>true</code> if {@link #getConfState() getConfState}
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 28059
diff changeset
  1317
     * returns true.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1318
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1319
     * @return true if integrity services are available, false otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1320
     * @see #requestInteg(boolean)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1321
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1322
    public boolean getIntegState();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1323
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1324
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1325
     * Determines what the remaining lifetime for this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1326
     * context is. It can be called by both the context initiator and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1327
     * context acceptor, but for a definitive answer it should be called
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1328
     * only after {@link #isEstablished() isEstablished} returns
29820
7a3f0268f55b 8076223: Rest of tidy warning in javax.security / java.security
avstepan
parents: 28059
diff changeset
  1329
     * true.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1330
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1331
     * @return the remaining lifetime in seconds
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1332
     * @see #requestLifetime(int)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1333
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1334
    public int getLifetime();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1335
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1336
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1337
     * Returns the name of the context initiator. This call is valid only
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1338
     * after one of {@link #isProtReady() isProtReady} or {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1339
     * #isEstablished() isEstablished} return <code>true</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1340
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1341
     * @return a GSSName that is an MN containing the name of the context
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1342
     * initiator.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1343
     * @see GSSName
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1344
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1345
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1346
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1347
     *   {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1348
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1349
    public GSSName getSrcName() throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1350
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1351
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1352
     * Returns the name of the context acceptor. This call is valid only
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1353
     * after one of {@link #isProtReady() isProtReady} or {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1354
     * #isEstablished() isEstablished} return <code>true</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1355
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1356
     * @return a GSSName that is an MN containing the name of the context
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1357
     * acceptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1358
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1359
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1360
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1361
     *   {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1362
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1363
    public GSSName getTargName() throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1364
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1365
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1366
     * Determines what mechanism is being used for this
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1367
     * context. This method may be called before the context is fully
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1368
     * established, but the mechanism returned may change on successive
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1369
     * calls in the negotiated mechanism case.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1370
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1371
     * @return the Oid of the mechanism being used
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1372
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1373
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1374
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1375
     *   {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1376
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1377
    public Oid getMech() throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1378
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1379
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1380
     * Obtains the credentials delegated by the context
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1381
     * initiator to the context acceptor. It should be called only on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1382
     * context acceptor's side, and once the context is fully
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1383
     * established. The caller can use the method {@link
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1384
     * #getCredDelegState() getCredDelegState} to determine if there are
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1385
     * any delegated credentials.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1386
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1387
     * @return a GSSCredential containing the initiator's delegated
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1388
     * credentials, or <code>null</code> is no credentials
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1389
     * were delegated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1390
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1391
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1392
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1393
     *   {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1394
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1395
    public GSSCredential getDelegCred() throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1396
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1397
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1398
     * Determines if this is the context initiator. This
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1399
     * can be called on both the context initiator's and context acceptor's
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1400
     * side.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1401
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1402
     * @return true if this is the context initiator, false if it is the
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1403
     * context acceptor.
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1404
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1405
     * @throws GSSException containing the following
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1406
     * major error codes:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1407
     *   {@link GSSException#FAILURE GSSException.FAILURE}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1408
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1409
    public boolean isInitiator() throws GSSException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1410
}