APIdia Launch Partner
Top Description Fields Constructors Methods
sun.security.jgss

public Class GSSContextImpl

extends Object
implements GSSContext
Class Inheritance
All Implemented Interfaces
org.ietf.jgss.GSSContext
Imports
org.ietf.jgss.*, sun.security.jgss.spi.*, sun.security.util.ObjectIdentifier, java.io.InputStream, .OutputStream, .ByteArrayInputStream, .ByteArrayOutputStream, .IOException, java.lang.reflect.Field, .Modifier

This class represents the JGSS security context and its associated operations. JGSS security contexts are established between peers using locally established credentials. Multiple contexts may exist simultaneously between a pair of peers, using the same or different set of credentials. The JGSS is independent of the underlying transport protocols and depends on its callers to transport the tokens between peers.

The context object can be thought of as having 3 implicit states: before it is established, during its context establishment, and after a fully established context exists.

Before the context establishment phase is initiated, the context initiator may request specific characteristics desired of the established context. These can be set using the set methods. After the context is established, the caller can check the actual characteristic and services offered by the context using the query methods.

The context establishment phase begins with the first call to the initSecContext method by the context initiator. During this phase the initSecContext and acceptSecContext methods will produce GSS-API authentication tokens which the calling application needs to send to its peer. The initSecContext and acceptSecContext methods may return a CONTINUE_NEEDED code which indicates that a token is needed from its peer in order to continue the context establishment phase. A return code of COMPLETE signals that the local end of the context is established. This may still require that a token be sent to the peer, depending if one is produced by GSS-API. The isEstablished method can also be used to determine if the local end of the context has been fully established. During the context establishment phase, the isProtReady method may be called to determine if the context can be used for the per-message operations. This allows implementation to use per-message operations on contexts which aren't fully established.

After the context has been established or the isProtReady method returns "true", the query routines can be invoked to determine the actual characteristics and services of the established context. The application can also start using the per-message methods of wrap and getMIC to obtain cryptographic operations on application supplied data.

When the context is no longer needed, the application should call dispose to release any system resources the context may be using.

RFC 2078
This class corresponds to the context level calls together with the per message calls of RFC 2078. The gss_init_sec_context and gss_accept_sec_context calls have been made simpler by only taking required parameters. The context can have its properties set before the first call to initSecContext. The supplementary status codes for the per-message operations are returned in an instance of the MessageProp class, which is used as an argument in these calls.

Field Summary

Modifier and TypeField and Description
private ChannelBinding
private int
private static final int
private GSSManagerImpl
private static final int
private boolean
private GSSContextSpi
private Oid
private GSSCredentialImpl
private ObjectIdentifier
private static final int
private static final int
private boolean
private boolean
private boolean
private boolean
private boolean
private int
private boolean
private boolean
private boolean
private GSSNameImpl
private GSSNameImpl

Constructor Summary

AccessConstructor and Description
public
protected
public
GSSContextImpl(GSSManagerImpl gssManager, GSSName peer, Oid mech, GSSCredential myCred, int lifetime)

Creates a GSSContextImp on the context initiator's side.

public
GSSContextImpl(GSSManagerImpl gssManager, GSSCredential myCred)

Creates a GSSContextImpl on the context acceptor's side.

public
GSSContextImpl(GSSManagerImpl gssManager, byte[] interProcessToken)

Creates a GSSContextImpl out of a previously exported GSSContext.

Method Summary

Modifier and TypeMethod and Description
public byte[]
acceptSecContext(byte[] inTok, int offset, int len)

Implements org.ietf.jgss.GSSContext.acceptSecContext.

Called by the context acceptor upon receiving a token from the peer.

public void
acceptSecContext(InputStream inStream, OutputStream outStream)

Implements org.ietf.jgss.GSSContext.acceptSecContext.

Deprecated since 11.

Called by the context acceptor to process a token from the peer using streams.

public void
dispose()

Implements org.ietf.jgss.GSSContext.dispose.

Releases any system resources and cryptographic information stored in the context object and invalidates the context.

public byte[]
export()

Implements org.ietf.jgss.GSSContext.export.

Exports this context so that another process may import it.

public boolean
getAnonymityState()

Implements org.ietf.jgss.GSSContext.getAnonymityState.

Determines if the context initiator is anonymously authenticated to the context acceptor.

public boolean
getConfState()

Implements org.ietf.jgss.GSSContext.getConfState.

Determines if data confidentiality is available over the context.

public boolean
getCredDelegState()

Implements org.ietf.jgss.GSSContext.getCredDelegState.

Determines if credential delegation is enabled on this context.

public GSSCredential
getDelegCred()

Implements org.ietf.jgss.GSSContext.getDelegCred.

Obtains the credentials delegated by the context initiator to the context acceptor.

public boolean
public boolean
getIntegState()

Implements org.ietf.jgss.GSSContext.getIntegState.

Determines if data integrity is available over the context.

public int
getLifetime()

Implements org.ietf.jgss.GSSContext.getLifetime.

Determines what the remaining lifetime for this context is.

public Oid
getMech()

Implements org.ietf.jgss.GSSContext.getMech.

Determines what mechanism is being used for this context.

public byte[]
getMIC(byte[] inMsg, int offset, int len, MessageProp msgProp)

Implements org.ietf.jgss.GSSContext.getMIC.

Returns a token containing a cryptographic Message Integrity Code (MIC) for the supplied message, for transfer to the peer application.

public void
getMIC(InputStream inStream, OutputStream outStream, MessageProp msgProp)

Implements org.ietf.jgss.GSSContext.getMIC.

Deprecated since 11.

Uses streams to produce a token containing a cryptographic MIC for the supplied message, for transfer to the peer application.

public boolean
getMutualAuthState()

Implements org.ietf.jgss.GSSContext.getMutualAuthState.

Determines if mutual authentication is enabled on this context.

public boolean
getReplayDetState()

Implements org.ietf.jgss.GSSContext.getReplayDetState.

Determines if replay detection is enabled for the per-message security services from this context.

public boolean
getSequenceDetState()

Implements org.ietf.jgss.GSSContext.getSequenceDetState.

Determines if sequence checking is enabled for the per-message security services from this context.

public GSSName
getSrcName()

Implements org.ietf.jgss.GSSContext.getSrcName.

Returns the name of the context initiator.

public GSSName
getTargName()

Implements org.ietf.jgss.GSSContext.getTargName.

Returns the name of the context acceptor.

public int
getWrapSizeLimit(int qop, boolean confReq, int maxTokenSize)

Implements org.ietf.jgss.GSSContext.getWrapSizeLimit.

Used to determine limits on the size of the message that can be passed to wrap.

public byte[]
initSecContext(byte[] inputBuf, int offset, int len)

Implements org.ietf.jgss.GSSContext.initSecContext.

Called by the context initiator to start the context creation phase and process any tokens generated by the peer's acceptSecContext method.

public int
initSecContext(InputStream inStream, OutputStream outStream)

Implements org.ietf.jgss.GSSContext.initSecContext.

Deprecated since 11.

Called by the context initiator to start the context creation phase and process any tokens generated by the peer's acceptSecContext method using streams.

public Object
public boolean
isEstablished()

Implements org.ietf.jgss.GSSContext.isEstablished.

Used during context establishment to determine the state of the context.

public boolean
isInitiator()

Implements org.ietf.jgss.GSSContext.isInitiator.

Determines if this is the context initiator.

public boolean
isProtReady()

Implements org.ietf.jgss.GSSContext.isProtReady.

Determines if the context is ready for per message operations to be used over it.

public boolean
isTransferable()

Implements org.ietf.jgss.GSSContext.isTransferable.

Determines if the context is transferable to other processes through the use of the export method.

public void
requestAnonymity(boolean state)

Implements org.ietf.jgss.GSSContext.requestAnonymity.

Requests that the initiator's identity not be disclosed to the acceptor.

public void
requestConf(boolean state)

Implements org.ietf.jgss.GSSContext.requestConf.

Requests that data confidentiality be enabled for the wrap method.

public void
requestCredDeleg(boolean state)

Implements org.ietf.jgss.GSSContext.requestCredDeleg.

Requests that the initiator's credentials be delegated to the acceptor during context establishment.

public void
requestDelegPolicy(boolean state)

public void
requestInteg(boolean state)

Implements org.ietf.jgss.GSSContext.requestInteg.

Requests that data integrity be enabled for the wrap and getMICmethods.

public void
requestLifetime(int lifetime)

Implements org.ietf.jgss.GSSContext.requestLifetime.

Requests a lifetime in seconds for the context.

public void
requestMutualAuth(boolean state)

Implements org.ietf.jgss.GSSContext.requestMutualAuth.

Requests that mutual authentication be done during context establishment.

public void
requestReplayDet(boolean state)

Implements org.ietf.jgss.GSSContext.requestReplayDet.

Requests that replay detection be enabled for the per-message security services after context establishment.

public void
requestSequenceDet(boolean state)

Implements org.ietf.jgss.GSSContext.requestSequenceDet.

Requests that sequence checking be enabled for the per-message security services after context establishment.

public void
setChannelBinding(ChannelBinding channelBindings)

Implements org.ietf.jgss.GSSContext.setChannelBinding.

Sets the channel bindings to be used during context establishment.

public byte[]
unwrap(byte[] inBuf, int offset, int len, MessageProp msgProp)

Implements org.ietf.jgss.GSSContext.unwrap.

Used to process tokens generated by the wrap method on the other side of the context.

public void
unwrap(InputStream inStream, OutputStream outStream, MessageProp msgProp)

Implements org.ietf.jgss.GSSContext.unwrap.

Deprecated since 11.

Uses streams to process tokens generated by the wrap method on the other side of the context.

public void
verifyMIC(byte[] inTok, int tokOffset, int tokLen, byte[] inMsg, int msgOffset, int msgLen, MessageProp msgProp)

Implements org.ietf.jgss.GSSContext.verifyMIC.

Verifies the cryptographic MIC, contained in the token parameter, over the supplied message.

public void
verifyMIC(InputStream tokStream, InputStream msgStream, MessageProp msgProp)

Implements org.ietf.jgss.GSSContext.verifyMIC.

Deprecated since 11.

Uses streams to verify the cryptographic MIC, contained in the token parameter, over the supplied message.

public byte[]
wrap(byte[] inBuf, int offset, int len, MessageProp msgProp)

Implements org.ietf.jgss.GSSContext.wrap.

Applies per-message security services over the established security context.

public void
wrap(InputStream inStream, OutputStream outStream, MessageProp msgProp)

Implements org.ietf.jgss.GSSContext.wrap.

Deprecated since 11.

Applies per-message security services over the established security context using streams.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

channelBindingsback to summary
private ChannelBinding channelBindings
currentStateback to summary
private int currentState
DELETEDback to summary
private static final int DELETED
gssManagerback to summary
private GSSManagerImpl gssManager
IN_PROGRESSback to summary
private static final int IN_PROGRESS
initiatorback to summary
private boolean initiator
mechCtxtback to summary
private GSSContextSpi mechCtxt
mechOidback to summary
private Oid mechOid
myCredback to summary
private GSSCredentialImpl myCred
objIdback to summary
private ObjectIdentifier objId
PRE_INITback to summary
private static final int PRE_INIT
READYback to summary
private static final int READY
reqAnonStateback to summary
private boolean reqAnonState
reqConfStateback to summary
private boolean reqConfState
reqCredDelegStateback to summary
private boolean reqCredDelegState
reqDelegPolicyStateback to summary
private boolean reqDelegPolicyState
reqIntegStateback to summary
private boolean reqIntegState
reqLifetimeback to summary
private int reqLifetime
reqMutualAuthStateback to summary
private boolean reqMutualAuthState
reqReplayDetStateback to summary
private boolean reqReplayDetState
reqSequenceDetStateback to summary
private boolean reqSequenceDetState
srcNameback to summary
private GSSNameImpl srcName
targNameback to summary
private GSSNameImpl targName

Constructor Detail

GSSContextImplback to summary
public GSSContextImpl()
GSSContextImplback to summary
protected GSSContextImpl(GSSContextImpl src)
GSSContextImplback to summary
public GSSContextImpl(GSSManagerImpl gssManager, GSSName peer, Oid mech, GSSCredential myCred, int lifetime) throws GSSException

Creates a GSSContextImp on the context initiator's side.

GSSContextImplback to summary
public GSSContextImpl(GSSManagerImpl gssManager, GSSCredential myCred) throws GSSException

Creates a GSSContextImpl on the context acceptor's side.

GSSContextImplback to summary
public GSSContextImpl(GSSManagerImpl gssManager, byte[] interProcessToken) throws GSSException

Creates a GSSContextImpl out of a previously exported GSSContext.

See Also
isTransferable

Method Detail

acceptSecContextback to summary
public byte[] acceptSecContext(byte[] inTok, int offset, int len) throws GSSException

Implements org.ietf.jgss.GSSContext.acceptSecContext.

Doc from org.ietf.jgss.GSSContext.acceptSecContext.

Called by the context acceptor upon receiving a token from the peer. This method may return an output token which the application will need to send to the peer for further processing by its initSecContext call.

The application can call isEstablished to determine if the context establishment phase is complete for this peer. A return value of false from isEstablished indicates that more tokens are expected to be supplied to this method. Upon completion of the context establishment, the available context options may be queried through the get methods.

Note that it is possible that acceptSecContext return a token for the peer, and isEstablished return true also. This indicates that the token needs to be sent to the peer, but the local end of the context is now fully established.

The following example code demonstrates how this method might be used:

    byte[] inToken;
    byte[] outToken;
    GSSContext context ...

    // Loop while there is still a token to be processed

    while (!context.isEstablished()) {
        inToken = readToken();
        outToken = context.acceptSecContext(inToken, 0,
                                            inToken.length);
        // send output token if generated
        if (outToken != null)
            sendToken(outToken);
    }
Exceptions
GSSException:
containing the following major error codes: GSSException.DEFECTIVE_TOKEN, GSSException.BAD_MIC, GSSException.NO_CRED, GSSException.CREDENTIALS_EXPIRED, GSSException.BAD_BINDINGS, GSSException.OLD_TOKEN, GSSException.DUPLICATE_TOKEN, GSSException.BAD_MECH, GSSException.FAILURE
acceptSecContextback to summary
public void acceptSecContext(InputStream inStream, OutputStream outStream) throws GSSException

Implements org.ietf.jgss.GSSContext.acceptSecContext.

Doc from org.ietf.jgss.GSSContext.acceptSecContext.

Deprecated

since 11.

Called by the context acceptor to process a token from the peer using streams. It may write an output token to the OutputStream, which the application will need to send to the peer for processing by its initSecContext method. Typically, the application would ensure this by calling the flush method on an OutputStream that encapsulates the connection between the two peers. The application can call isEstablished to determine if the context establishment phase is complete on this side of the context. A return value of false from isEstablished indicates that more tokens are expected to be supplied to acceptSecContext. Upon completion of the context establishment, the available context options may be queried through the get methods.

Note that it is possible that acceptSecContext return a token for the peer, and isEstablished return true also. This indicates that the token needs to be sent to the peer, but the local end of the context is now fully established.

The GSS-API authentication tokens contain a definitive start and end. This method will attempt to read one of these tokens per invocation, and may block on the stream if only part of the token is available. In all other respects this method is equivalent to the byte array based acceptSecContext.

The following example code demonstrates how this method might be used:

    InputStream is ...
    OutputStream os ...
    GSSContext context ...

    // Loop while there is still a token to be processed

    while (!context.isEstablished()) {

        context.acceptSecContext(is, os);

        // send output token if generated
        os.flush();
    }
Annotations
@Deprecated
since:11
Exceptions
GSSException:
containing the following major error codes: GSSException.DEFECTIVE_TOKEN, GSSException.BAD_MIC, GSSException.NO_CRED, GSSException.CREDENTIALS_EXPIRED, GSSException.BAD_BINDINGS, GSSException.OLD_TOKEN, GSSException.DUPLICATE_TOKEN, GSSException.BAD_MECH, GSSException.FAILURE
disposeback to summary
public void dispose() throws GSSException

Implements org.ietf.jgss.GSSContext.dispose.

Doc from org.ietf.jgss.GSSContext.dispose.

Releases any system resources and cryptographic information stored in the context object and invalidates the context.

Exceptions
GSSException:
containing the following major error codes: GSSException.FAILURE
exportback to summary
public byte[] export() throws GSSException

Implements org.ietf.jgss.GSSContext.export.

Doc from org.ietf.jgss.GSSContext.export.

Exports this context so that another process may import it. Provided to support the sharing of work between multiple processes. This routine will typically be used by the context-acceptor, in an application where a single process receives incoming connection requests and accepts security contexts over them, then passes the established context to one or more other processes for message exchange.

This method deactivates the security context and creates an interprocess token which, when passed to GSSManager.createContext in another process, will re-activate the context in the second process. Only a single instantiation of a given context may be active at any one time; a subsequent attempt by a context exporter to access the exported security context will fail.

The implementation may constrain the set of processes by which the interprocess token may be imported, either as a function of local security policy, or as a result of implementation decisions. For example, some implementations may constrain contexts to be passed only between processes that run under the same account, or which are part of the same process group.

The interprocess token may contain security-sensitive information (for example cryptographic keys). While mechanisms are encouraged to either avoid placing such sensitive information within interprocess tokens, or to encrypt the token before returning it to the application, in a typical GSS-API implementation this may not be possible. Thus, the application must take care to protect the interprocess token, and ensure that any process to which the token is transferred is trustworthy.

Implementations are not required to support the inter-process transfer of security contexts. Calling the isTransferable method will indicate if the context object is transferable.

Calling this method on a context that is not exportable will result in this exception being thrown with the error code GSSException.UNAVAILABLE.

Exceptions
GSSException:
containing the following major error codes: GSSException.UNAVAILABLE, GSSException.CONTEXT_EXPIRED, GSSException.NO_CONTEXT, GSSException.FAILURE
getAnonymityStateback to summary
public boolean getAnonymityState()

Implements org.ietf.jgss.GSSContext.getAnonymityState.

Doc from org.ietf.jgss.GSSContext.getAnonymityState.

Determines if the context initiator is anonymously authenticated to the context acceptor. It can be called by both the context initiator and the context acceptor, and at any time. On the initiator side, a call to this method determines if the identity of the initiator has been disclosed in any of the context establishment tokens that might have been generated thus far by initSecContext. An initiator that absolutely must be authenticated anonymously should call this method after each call to initSecContext to determine if the generated token should be sent to the peer or the context aborted. On the acceptor side, a call to this method determines if any of the tokens processed by acceptSecContext thus far have divulged the identity of the initiator.

getConfStateback to summary
public boolean getConfState()

Implements org.ietf.jgss.GSSContext.getConfState.

Doc from org.ietf.jgss.GSSContext.getConfState.

Determines if data confidentiality is available over the context. This method can be called by both the context initiator and the context acceptor, but only after one of isProtReady or isEstablished return true. If this method returns true, so will getIntegState

getCredDelegStateback to summary
public boolean getCredDelegState()

Implements org.ietf.jgss.GSSContext.getCredDelegState.

Doc from org.ietf.jgss.GSSContext.getCredDelegState.

Determines if credential delegation is enabled on this context. It can be called by both the context initiator and the context acceptor. For a definitive answer this method must be called only after context establishment is complete. Note that if an initiator requests that delegation not be allowed the requestCredDeleg method will honor that request and this method will return false on the initiator's side from that point onwards.

getDelegCredback to summary
public GSSCredential getDelegCred() throws GSSException

Implements org.ietf.jgss.GSSContext.getDelegCred.

Doc from org.ietf.jgss.GSSContext.getDelegCred.

Obtains the credentials delegated by the context initiator to the context acceptor. It should be called only on the context acceptor's side, and once the context is fully established. The caller can use the method getCredDelegState to determine if there are any delegated credentials.

Exceptions
GSSException:
containing the following major error codes: GSSException.FAILURE
getDelegPolicyStateback to summary
public boolean getDelegPolicyState()
getIntegStateback to summary
public boolean getIntegState()

Implements org.ietf.jgss.GSSContext.getIntegState.

Doc from org.ietf.jgss.GSSContext.getIntegState.

Determines if data integrity is available over the context. This method can be called by both the context initiator and the context acceptor, but only after one of isProtReady or isEstablished return true. This method will always return true if getConfState returns true.

getLifetimeback to summary
public int getLifetime()

Implements org.ietf.jgss.GSSContext.getLifetime.

Doc from org.ietf.jgss.GSSContext.getLifetime.

Determines what the remaining lifetime for this context is. It can be called by both the context initiator and the context acceptor, but for a definitive answer it should be called only after isEstablished returns true.

getMechback to summary
public Oid getMech() throws GSSException

Implements org.ietf.jgss.GSSContext.getMech.

Doc from org.ietf.jgss.GSSContext.getMech.

Determines what mechanism is being used for this context. This method may be called before the context is fully established, but the mechanism returned may change on successive calls in the negotiated mechanism case.

Exceptions
GSSException:
containing the following major error codes: GSSException.FAILURE
getMICback to summary
public byte[] getMIC(byte[] inMsg, int offset, int len, MessageProp msgProp) throws GSSException

Implements org.ietf.jgss.GSSContext.getMIC.

Doc from org.ietf.jgss.GSSContext.getMIC.

Returns a token containing a cryptographic Message Integrity Code (MIC) for the supplied message, for transfer to the peer application. Unlike wrap, which encapsulates the user message in the returned token, only the message MIC is returned in the output token.

Note that privacy can only be applied through the wrap call.

Since some application-level protocols may wish to use tokens emitted by getMIC to provide "secure framing", implementations should support derivation of MICs from zero-length messages.

Exceptions
GSSException:
containing the following major error codes: GSSException.CONTEXT_EXPIRED, GSSException.BAD_QOP, GSSException.FAILURE
getMICback to summary
public void getMIC(InputStream inStream, OutputStream outStream, MessageProp msgProp) throws GSSException

Implements org.ietf.jgss.GSSContext.getMIC.

Doc from org.ietf.jgss.GSSContext.getMIC.

Deprecated

since 11.

Uses streams to produce a token containing a cryptographic MIC for the supplied message, for transfer to the peer application. Unlike wrap, which encapsulates the user message in the returned token, only the message MIC is produced in the output token. This method is equivalent to the byte array based getMIC method. Note that privacy can only be applied through the wrap call.

Since some application-level protocols may wish to use tokens emitted by getMIC to provide "secure framing", implementations should support derivation of MICs from zero-length messages.

Annotations
@Deprecated
since:11
Exceptions
GSSException:
containing the following major error codes: GSSException.CONTEXT_EXPIRED, GSSException.BAD_QOP, GSSException.FAILURE
getMutualAuthStateback to summary
public boolean getMutualAuthState()

Implements org.ietf.jgss.GSSContext.getMutualAuthState.

Doc from org.ietf.jgss.GSSContext.getMutualAuthState.

Determines if mutual authentication is enabled on this context. It can be called by both the context initiator and the context acceptor. For a definitive answer this method must be called only after context establishment is complete. An initiator that requests mutual authentication can call this method after context completion and dispose the context if its request was not honored.

getReplayDetStateback to summary
public boolean getReplayDetState()

Implements org.ietf.jgss.GSSContext.getReplayDetState.

Doc from org.ietf.jgss.GSSContext.getReplayDetState.

Determines if replay detection is enabled for the per-message security services from this context. It can be called by both the context initiator and the context acceptor. For a definitive answer this method must be called only after context establishment is complete. An initiator that requests replay detection can call this method after context completion and dispose the context if its request was not honored.

getSequenceDetStateback to summary
public boolean getSequenceDetState()

Implements org.ietf.jgss.GSSContext.getSequenceDetState.

Doc from org.ietf.jgss.GSSContext.getSequenceDetState.

Determines if sequence checking is enabled for the per-message security services from this context. It can be called by both the context initiator and the context acceptor. For a definitive answer this method must be called only after context establishment is complete. An initiator that requests sequence checking can call this method after context completion and dispose the context if its request was not honored.

getSrcNameback to summary
public GSSName getSrcName() throws GSSException

Implements org.ietf.jgss.GSSContext.getSrcName.

Doc from org.ietf.jgss.GSSContext.getSrcName.

Returns the name of the context initiator. This call is valid only after one of isProtReady or isEstablished return true.

Exceptions
GSSException:
containing the following major error codes: GSSException.FAILURE
getTargNameback to summary
public GSSName getTargName() throws GSSException

Implements org.ietf.jgss.GSSContext.getTargName.

Doc from org.ietf.jgss.GSSContext.getTargName.

Returns the name of the context acceptor. This call is valid only after one of isProtReady or isEstablished return true.

Exceptions
GSSException:
containing the following major error codes: GSSException.FAILURE
getWrapSizeLimitback to summary
public int getWrapSizeLimit(int qop, boolean confReq, int maxTokenSize) throws GSSException

Implements org.ietf.jgss.GSSContext.getWrapSizeLimit.

Doc from org.ietf.jgss.GSSContext.getWrapSizeLimit.

Used to determine limits on the size of the message that can be passed to wrap. Returns the maximum message size that, if presented to the wrap method with the same confReq and qop parameters, will result in an output token containing no more than maxTokenSize bytes.

This call is intended for use by applications that communicate over protocols that impose a maximum message size. It enables the application to fragment messages prior to applying protection.

GSS-API implementations are recommended but not required to detect invalid QOP values when getWrapSizeLimit is called. This routine guarantees only a maximum message size, not the availability of specific QOP values for message protection.

Exceptions
GSSException:
containing the following major error codes: GSSException.CONTEXT_EXPIRED, GSSException.BAD_QOP, GSSException.FAILURE
initSecContextback to summary
public byte[] initSecContext(byte[] inputBuf, int offset, int len) throws GSSException

Implements org.ietf.jgss.GSSContext.initSecContext.

Doc from org.ietf.jgss.GSSContext.initSecContext.

Called by the context initiator to start the context creation phase and process any tokens generated by the peer's acceptSecContext method. This method may return an output token which the application will need to send to the peer for processing by its acceptSecContext method. The application can call isEstablished to determine if the context establishment phase is complete on this side of the context. A return value of false from isEstablished indicates that more tokens are expected to be supplied to initSecContext. Upon completion of the context establishment, the available context options may be queried through the get methods.

Note that it is possible that the initSecContext method return a token for the peer, and isEstablished return true also. This indicates that the token needs to be sent to the peer, but the local end of the context is now fully established.

Exceptions
GSSException:
containing the following major error codes: GSSException.DEFECTIVE_TOKEN, GSSException.BAD_MIC, GSSException.NO_CRED, GSSException.CREDENTIALS_EXPIRED, GSSException.BAD_BINDINGS, GSSException.OLD_TOKEN, GSSException.DUPLICATE_TOKEN, GSSException.BAD_NAMETYPE, GSSException.BAD_MECH, GSSException.FAILURE
initSecContextback to summary
public int initSecContext(InputStream inStream, OutputStream outStream) throws GSSException

Implements org.ietf.jgss.GSSContext.initSecContext.

Doc from org.ietf.jgss.GSSContext.initSecContext.

Deprecated

since 11.

Called by the context initiator to start the context creation phase and process any tokens generated by the peer's acceptSecContext method using streams. This method may write an output token to the OutpuStream, which the application will need to send to the peer for processing by its acceptSecContext call. Typically, the application would ensure this by calling the flush method on an OutputStream that encapsulates the connection between the two peers. The application can determine if a token is written to the OutputStream from the return value of this method. A return value of 0 indicates that no token was written. The application can call isEstablished to determine if the context establishment phase is complete on this side of the context. A return value of false from isEstablished indicates that more tokens are expected to be supplied to initSecContext. Upon completion of the context establishment, the available context options may be queried through the get methods.

Note that it is possible that the initSecContext method return a token for the peer, and isEstablished return true also. This indicates that the token needs to be sent to the peer, but the local end of the context is now fully established.

The GSS-API authentication tokens contain a definitive start and end. This method will attempt to read one of these tokens per invocation, and may block on the stream if only part of the token is available. In all other respects this method is equivalent to the byte array based initSecContext.

The following example code demonstrates how this method might be used:

    InputStream is ...
    OutputStream os ...
    GSSContext context ...

    // Loop while there is still a token to be processed

    while (!context.isEstablished()) {

        context.initSecContext(is, os);

        // send output token if generated
        os.flush();
    }
Annotations
@Deprecated
since:11
Exceptions
GSSException:
containing the following major error codes: GSSException.DEFECTIVE_TOKEN, GSSException.BAD_MIC, GSSException.NO_CRED, GSSException.CREDENTIALS_EXPIRED, GSSException.BAD_BINDINGS, GSSException.OLD_TOKEN, GSSException.DUPLICATE_TOKEN, GSSException.BAD_NAMETYPE, GSSException.BAD_MECH, GSSException.FAILURE
inquireSecContextback to summary
public Object inquireSecContext(String type) throws GSSException
isEstablishedback to summary
public boolean isEstablished()

Implements org.ietf.jgss.GSSContext.isEstablished.

Doc from org.ietf.jgss.GSSContext.isEstablished.

Used during context establishment to determine the state of the context.

isInitiatorback to summary
public boolean isInitiator() throws GSSException

Implements org.ietf.jgss.GSSContext.isInitiator.

Doc from org.ietf.jgss.GSSContext.isInitiator.

Determines if this is the context initiator. This can be called on both the context initiator's and context acceptor's side.

Exceptions
GSSException:
containing the following major error codes: GSSException.FAILURE
isProtReadyback to summary
public boolean isProtReady()

Implements org.ietf.jgss.GSSContext.isProtReady.

Doc from org.ietf.jgss.GSSContext.isProtReady.

Determines if the context is ready for per message operations to be used over it. Some mechanisms may allow the usage of the per-message operations before the context is fully established.

isTransferableback to summary
public boolean isTransferable() throws GSSException

Implements org.ietf.jgss.GSSContext.isTransferable.

Doc from org.ietf.jgss.GSSContext.isTransferable.

Determines if the context is transferable to other processes through the use of the export method. This call is only valid on fully established contexts.

Exceptions
GSSException:
containing the following major error codes: GSSException.FAILURE
requestAnonymityback to summary
public void requestAnonymity(boolean state) throws GSSException

Implements org.ietf.jgss.GSSContext.requestAnonymity.

Doc from org.ietf.jgss.GSSContext.requestAnonymity.

Requests that the initiator's identity not be disclosed to the acceptor. This request can only be made on the context initiator's side, and it has to be done prior to the first call to initSecContext. Not all mechanisms support anonymity for the initiator. Therefore, the application should check to see if the request was honored with the getAnonymityState method.

Exceptions
GSSException:
containing the following major error codes: GSSException.FAILURE
requestConfback to summary
public void requestConf(boolean state) throws GSSException

Implements org.ietf.jgss.GSSContext.requestConf.

Doc from org.ietf.jgss.GSSContext.requestConf.

Requests that data confidentiality be enabled for the wrap method. This request can only be made on the context initiator's side, and it has to be done prior to the first call to initSecContext. Not all mechanisms support confidentiality and other mechanisms might enable it even if the application doesn't request it. The application may check to see if the request was honored with the getConfState method. If confidentiality is enabled, only then will the mechanism honor a request for privacy in the MessageProp object that is passed in to the wrap method.

Enabling confidentiality will also automatically enable integrity.

Exceptions
GSSException:
containing the following major error codes: GSSException.FAILURE
requestCredDelegback to summary
public void requestCredDeleg(boolean state) throws GSSException

Implements org.ietf.jgss.GSSContext.requestCredDeleg.

Doc from org.ietf.jgss.GSSContext.requestCredDeleg.

Requests that the initiator's credentials be delegated to the acceptor during context establishment. This request can only be made on the context initiator's side, and it has to be done prior to the first call to initSecContext. Not all mechanisms support credential delegation. Therefore, an application that desires delegation should check to see if the request was honored with the getCredDelegState method. If the application indicates that delegation must not be used, then the mechanism will honor the request and delegation will not occur. This is an exception to the general rule that a mechanism may enable a service even if it is not requested.

Exceptions
GSSException:
containing the following major error codes: GSSException.FAILURE
requestDelegPolicyback to summary
public void requestDelegPolicy(boolean state) throws GSSException
requestIntegback to summary
public void requestInteg(boolean state) throws GSSException

Implements org.ietf.jgss.GSSContext.requestInteg.

Doc from org.ietf.jgss.GSSContext.requestInteg.

Requests that data integrity be enabled for the wrap and getMICmethods. This request can only be made on the context initiator's side, and it has to be done prior to the first call to initSecContext. Not all mechanisms support integrity and other mechanisms might enable it even if the application doesn't request it. The application may check to see if the request was honored with the getIntegState method.

Disabling integrity will also automatically disable confidentiality.

Exceptions
GSSException:
containing the following major error codes: GSSException.FAILURE
requestLifetimeback to summary
public void requestLifetime(int lifetime) throws GSSException

Implements org.ietf.jgss.GSSContext.requestLifetime.

Doc from org.ietf.jgss.GSSContext.requestLifetime.

Requests a lifetime in seconds for the context. This method can only be called on the context initiator's side, and it has to be done prior to the first call to initSecContext.

The actual lifetime of the context will depend on the capabilities of the underlying mechanism and the application should call the getLifetime method to determine this.

Exceptions
GSSException:
containing the following major error codes: GSSException.FAILURE
requestMutualAuthback to summary
public void requestMutualAuth(boolean state) throws GSSException

Implements org.ietf.jgss.GSSContext.requestMutualAuth.

Doc from org.ietf.jgss.GSSContext.requestMutualAuth.

Requests that mutual authentication be done during context establishment. This request can only be made on the context initiator's side, and it has to be done prior to the first call to initSecContext.

Not all mechanisms support mutual authentication and some mechanisms might require mutual authentication even if the application doesn't. Therefore, the application should check to see if the request was honored with the getMutualAuthState method.

Exceptions
GSSException:
containing the following major error codes: GSSException.FAILURE
requestReplayDetback to summary
public void requestReplayDet(boolean state) throws GSSException

Implements org.ietf.jgss.GSSContext.requestReplayDet.

Doc from org.ietf.jgss.GSSContext.requestReplayDet.

Requests that replay detection be enabled for the per-message security services after context establishment. This request can only be made on the context initiator's side, and it has to be done prior to the first call to initSecContext. During context establishment replay detection is not an option and is a function of the underlying mechanism's capabilities.

Not all mechanisms support replay detection and some mechanisms might require replay detection even if the application doesn't. Therefore, the application should check to see if the request was honored with the getReplayDetState method. If replay detection is enabled then the MessageProp.isDuplicateToken and MessageProp.isOldToken methods will return valid results for the MessageProp object that is passed in to the unwrap method or the verifyMIC method.

Exceptions
GSSException:
containing the following major error codes: GSSException.FAILURE
requestSequenceDetback to summary
public void requestSequenceDet(boolean state) throws GSSException

Implements org.ietf.jgss.GSSContext.requestSequenceDet.

Doc from org.ietf.jgss.GSSContext.requestSequenceDet.

Requests that sequence checking be enabled for the per-message security services after context establishment. This request can only be made on the context initiator's side, and it has to be done prior to the first call to initSecContext. During context establishment sequence checking is not an option and is a function of the underlying mechanism's capabilities.

Not all mechanisms support sequence checking and some mechanisms might require sequence checking even if the application doesn't. Therefore, the application should check to see if the request was honored with the getSequenceDetState method. If sequence checking is enabled then the MessageProp.isDuplicateToken, MessageProp.isOldToken, MessageProp.isUnseqToken, and MessageProp.isGapToken methods will return valid results for the MessageProp object that is passed in to the unwrap method or the verifyMIC method.

Exceptions
GSSException:
containing the following major error codes: GSSException.FAILURE
setChannelBindingback to summary
public void setChannelBinding(ChannelBinding channelBindings) throws GSSException

Implements org.ietf.jgss.GSSContext.setChannelBinding.

Doc from org.ietf.jgss.GSSContext.setChannelBinding.

Sets the channel bindings to be used during context establishment. This method can be called on both the context initiator's and the context acceptor's side, but it must be called before context establishment begins. This means that an initiator must call it before the first call to initSecContext and the acceptor must call it before the first call to acceptSecContext.

Exceptions
GSSException:
containing the following major error codes: GSSException.FAILURE
unwrapback to summary
public byte[] unwrap(byte[] inBuf, int offset, int len, MessageProp msgProp) throws GSSException

Implements org.ietf.jgss.GSSContext.unwrap.

Doc from org.ietf.jgss.GSSContext.unwrap.

Used to process tokens generated by the wrap method on the other side of the context. The method will return the message supplied by the peer application to its wrap call, while at the same time verifying the embedded MIC for that message.

The MessageProp object is instantiated by the application and is used by the underlying mechanism to return information to the caller such as the QOP, whether confidentiality was applied to the message, and other supplementary message state information.

Since some application-level protocols may wish to use tokens emitted by wrap to provide "secure framing", implementations should support the wrapping and unwrapping of zero-length messages.

Exceptions
GSSException:
containing the following major error codes: GSSException.DEFECTIVE_TOKEN, GSSException.BAD_MIC, GSSException.CONTEXT_EXPIRED, GSSException.FAILURE
unwrapback to summary
public void unwrap(InputStream inStream, OutputStream outStream, MessageProp msgProp) throws GSSException

Implements org.ietf.jgss.GSSContext.unwrap.

Doc from org.ietf.jgss.GSSContext.unwrap.

Deprecated

since 11.

Uses streams to process tokens generated by the wrap method on the other side of the context. The method will return the message supplied by the peer application to its wrap call, while at the same time verifying the embedded MIC for that message.

The MessageProp object is instantiated by the application and is used by the underlying mechanism to return information to the caller such as the QOP, whether confidentiality was applied to the message, and other supplementary message state information.

Since some application-level protocols may wish to use tokens emitted by wrap to provide "secure framing", implementations should support the wrapping and unwrapping of zero-length messages.

The format of the input token that this method reads is defined in the specification for the underlying mechanism that will be used. This method will attempt to read one of these tokens per invocation. If the mechanism token contains a definitive start and end this method may block on the InputStream if only part of the token is available. If the start and end of the token are not definitive then the method will attempt to treat all available bytes as part of the token.

Other than the possible blocking behavior described above, this method is equivalent to the byte array based unwrap method.

Annotations
@Deprecated
since:11
Exceptions
GSSException:
containing the following major error codes: GSSException.DEFECTIVE_TOKEN, GSSException.BAD_MIC, GSSException.CONTEXT_EXPIRED, GSSException.FAILURE
verifyMICback to summary
public void verifyMIC(byte[] inTok, int tokOffset, int tokLen, byte[] inMsg, int msgOffset, int msgLen, MessageProp msgProp) throws GSSException

Implements org.ietf.jgss.GSSContext.verifyMIC.

Doc from org.ietf.jgss.GSSContext.verifyMIC.

Verifies the cryptographic MIC, contained in the token parameter, over the supplied message.

The MessageProp object is instantiated by the application and is used by the underlying mechanism to return information to the caller such as the QOP indicating the strength of protection that was applied to the message and other supplementary message state information.

Since some application-level protocols may wish to use tokens emitted by getMIC to provide "secure framing", implementations should support the calculation and verification of MICs over zero-length messages.

Exceptions
GSSException:
containing the following major error codes: GSSException.DEFECTIVE_TOKEN GSSException.BAD_MIC GSSException.CONTEXT_EXPIRED GSSException.FAILURE
verifyMICback to summary
public void verifyMIC(InputStream tokStream, InputStream msgStream, MessageProp msgProp) throws GSSException

Implements org.ietf.jgss.GSSContext.verifyMIC.

Doc from org.ietf.jgss.GSSContext.verifyMIC.

Deprecated

since 11.

Uses streams to verify the cryptographic MIC, contained in the token parameter, over the supplied message. This method is equivalent to the byte array based verifyMIC method. The MessageProp object is instantiated by the application and is used by the underlying mechanism to return information to the caller such as the QOP indicating the strength of protection that was applied to the message and other supplementary message state information.

Since some application-level protocols may wish to use tokens emitted by getMIC to provide "secure framing", implementations should support the calculation and verification of MICs over zero-length messages.

The format of the input token that this method reads is defined in the specification for the underlying mechanism that will be used. This method will attempt to read one of these tokens per invocation. If the mechanism token contains a definitive start and end this method may block on the InputStream if only part of the token is available. If the start and end of the token are not definitive then the method will attempt to treat all available bytes as part of the token.

Other than the possible blocking behavior described above, this method is equivalent to the byte array based verifyMIC method.

Annotations
@Deprecated
since:11
Exceptions
GSSException:
containing the following major error codes: GSSException.DEFECTIVE_TOKEN GSSException.BAD_MIC GSSException.CONTEXT_EXPIRED GSSException.FAILURE
wrapback to summary
public byte[] wrap(byte[] inBuf, int offset, int len, MessageProp msgProp) throws GSSException

Implements org.ietf.jgss.GSSContext.wrap.

Doc from org.ietf.jgss.GSSContext.wrap.

Applies per-message security services over the established security context. The method will return a token with the application supplied data and a cryptographic MIC over it. The data may be encrypted if confidentiality (privacy) was requested.

The MessageProp object is instantiated by the application and used to specify a QOP value which selects cryptographic algorithms, and a privacy service to optionally encrypt the message. The underlying mechanism that is used in the call may not be able to provide the privacy service. It sets the actual privacy service that it does provide in this MessageProp object which the caller should then query upon return. If the mechanism is not able to provide the requested QOP, it throws a GSSException with the BAD_QOP code.

Since some application-level protocols may wish to use tokens emitted by wrap to provide "secure framing", implementations should support the wrapping of zero-length messages.

The application will be responsible for sending the token to the peer.

Exceptions
GSSException:
containing the following major error codes: GSSException.CONTEXT_EXPIRED, GSSException.BAD_QOP, GSSException.FAILURE
wrapback to summary
public void wrap(InputStream inStream, OutputStream outStream, MessageProp msgProp) throws GSSException

Implements org.ietf.jgss.GSSContext.wrap.

Doc from org.ietf.jgss.GSSContext.wrap.

Deprecated

since 11.

Applies per-message security services over the established security context using streams. The method will return a token with the application supplied data and a cryptographic MIC over it. The data may be encrypted if confidentiality (privacy) was requested. This method is equivalent to the byte array based wrap method.

The application will be responsible for sending the token to the peer. Typically, the application would ensure this by calling the flush method on an OutputStream that encapsulates the connection between the two peers.

The MessageProp object is instantiated by the application and used to specify a QOP value which selects cryptographic algorithms, and a privacy service to optionally encrypt the message. The underlying mechanism that is used in the call may not be able to provide the privacy service. It sets the actual privacy service that it does provide in this MessageProp object which the caller should then query upon return. If the mechanism is not able to provide the requested QOP, it throws a GSSException with the BAD_QOP code.

Since some application-level protocols may wish to use tokens emitted by wrap to provide "secure framing", implementations should support the wrapping of zero-length messages.

Annotations
@Deprecated
since:11
Exceptions
GSSException:
containing the following major error codes: GSSException.CONTEXT_EXPIRED, GSSException.BAD_QOP, GSSException.FAILURE