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

public Class SpNegoContext

extends Object
implements GSSContextSpi
Class Inheritance
All Implemented Interfaces
sun.security.jgss.spi.GSSContextSpi
Imports
java.io.*, java.security.Provider, java.util.Objects, org.ietf.jgss.*, sun.security.jgss.*, sun.security.jgss.spi.*, sun.security.util.*

Implements the mechanism specific context class for SPNEGO GSS-API mechanism
Author
Seema Malkani
Since
1.6

Field Summary

Modifier and TypeField and Description
private ChannelBinding
private boolean
private boolean
pack-priv static final Debug
private boolean
private byte[]
private final SpNegoMechFactory
private final boolean
private boolean
private Oid
private int
private GSSContext
private boolean
private final SpNegoCredElement
private GSSNameSpi
private GSSNameSpi
private boolean
private boolean
private int
private static final int
private static final int
private static final int
private static final int

Constructor Summary

AccessConstructor and Description
public
SpNegoContext(SpNegoMechFactory factory, GSSNameSpi peerName, GSSCredentialSpi myCred, int lifetime)

Constructor for SpNegoContext to be called on the context initiator's side.

public
SpNegoContext(SpNegoMechFactory factory, GSSCredentialSpi myCred)

Constructor for SpNegoContext to be called on the context acceptor's side.

public
SpNegoContext(SpNegoMechFactory factory, byte[] interProcessToken)

Constructor for SpNegoContext to import a previously exported context.

Method Summary

Modifier and TypeMethod and Description
public final byte[]

Returns:

any token required to be sent to the peer It is responsibility of the caller to send the token to its peer for processing.
acceptSecContext
(InputStream
contains the token received from the peer.
is
,
int mechTokenSize)

Implements sun.security.jgss.spi.GSSContextSpi.acceptSecContext.

Deprecated since 11.

Acceptor's context establishment call.

public final void
dispose()

Implements sun.security.jgss.spi.GSSContextSpi.dispose.

Releases context resources and terminates the context between 2 peer.

public final byte[]
export()

Implements sun.security.jgss.spi.GSSContextSpi.export.

Produces a token representing this context.

public final boolean
private Oid[]
getAvailableMechs()

obtain the available mechanisms

pack-priv final ChannelBinding
public final boolean
getConfState()

Implements sun.security.jgss.spi.GSSContextSpi.getConfState.

Is confidentiality available?

private BitArray
getContextFlags()

get the context flags

public final boolean
getCredDelegState()

Implements sun.security.jgss.spi.GSSContextSpi.getCredDelegState.

Is credential delegation enabled?

public final GSSCredentialSpi

Returns:

GSSCredentialSpi object for the delegated credential
getDelegCred
()

Implements sun.security.jgss.spi.GSSContextSpi.getDelegCred.

Returns the delegated credential for the context.

public final boolean
private byte[]
getEncodedMechs(Oid[] mechSet)

get the DER encoded MechList

public final boolean
public final int
getLifetime()

Implements sun.security.jgss.spi.GSSContextSpi.getLifetime.

The lifetime remaining for this context.

public final Oid

Returns:

the Oid of this context
getMech
()

Implements sun.security.jgss.spi.GSSContextSpi.getMech.

Returns the mechanism oid.

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

Implements sun.security.jgss.spi.GSSContextSpi.getMIC.

public final void
getMIC(InputStream is, OutputStream os, MessageProp msgProp)

Implements sun.security.jgss.spi.GSSContextSpi.getMIC.

Deprecated since 11.

Applies per-message integrity services.

public final boolean
getMutualAuthState()

Implements sun.security.jgss.spi.GSSContextSpi.getMutualAuthState.

Is mutual authentication enabled?

public final Oid
public final Provider
public final boolean
getReplayDetState()

Implements sun.security.jgss.spi.GSSContextSpi.getReplayDetState.

Is replay detection enabled on the GSS wrap and MIC tokens?

public final boolean
getSequenceDetState()

Implements sun.security.jgss.spi.GSSContextSpi.getSequenceDetState.

Is sequence checking enabled on the GSS Wrap and MIC tokens?

public final GSSNameSpi
public final GSSNameSpi
public final int
getWrapSizeLimit(int qop, boolean confReq, int maxTokSize)

Implements sun.security.jgss.spi.GSSContextSpi.getWrapSizeLimit.

Queries the context for largest data size to accommodate the specified protection and for the token to remain less than maxTokSize.

private byte[]
GSS_acceptSecContext(byte[] token)

call gss_accept_sec_context for the corresponding underlying mechanism

private byte[]
GSS_initSecContext(byte[] token)

call gss_init_sec_context for the corresponding underlying mechanism

public final byte[]

Returns:

any token required to be sent to the peer It is responsibility of the caller to send the token to its peer for processing.
initSecContext
(InputStream
contains the token received from the peer. On the first call it will be ignored.
is
,
int mechTokenSize)

Implements sun.security.jgss.spi.GSSContextSpi.initSecContext.

Deprecated since 11.

Initiator context establishment call.

public Object
inquireSecContext(String type)

Implements sun.security.jgss.spi.GSSContextSpi.inquireSecContext.

Retrieve attribute of the context for type.

public final boolean
public final boolean

Returns:

boolean indicating if this is initiator (true) or target (false)
isInitiator
()

Implements sun.security.jgss.spi.GSSContextSpi.isInitiator.

Tests if this is the initiator side of the context.

public final boolean
public final boolean

Returns:

boolean indicating if per-message methods can be called.
isProtReady
()

Implements sun.security.jgss.spi.GSSContextSpi.isProtReady.

Tests if the context can be used for per-message service.

public final boolean
private static Oid
negotiate_mech_type(Oid[] supported_mechSet, Oid[] mechSet)

This routine compares the received mechset to the mechset that this server can support.

private static String
printState(int state)

public final void
public final void
requestConf(boolean value)

Implements sun.security.jgss.spi.GSSContextSpi.requestConf.

Requests that confidentiality be available.

public final void
requestCredDeleg(boolean value)

Implements sun.security.jgss.spi.GSSContextSpi.requestCredDeleg.

Requests that credential delegation be done during context establishment.

public final void
requestDelegPolicy(boolean value)

Implements sun.security.jgss.spi.GSSContextSpi.requestDelegPolicy.

Requests that deleg policy be respected.

public final void
requestInteg(boolean value)

Implements sun.security.jgss.spi.GSSContextSpi.requestInteg.

Requests that integrity be available.

public void
requestLifetime(int lifetime)

Implements sun.security.jgss.spi.GSSContextSpi.requestLifetime.

Requests the desired lifetime.

public final void
requestMutualAuth(boolean value)

Implements sun.security.jgss.spi.GSSContextSpi.requestMutualAuth.

Requests that mutual authentication be done during context establishment.

public final void
requestReplayDet(boolean value)

Implements sun.security.jgss.spi.GSSContextSpi.requestReplayDet.

Requests that replay detection be done on the GSS wrap and MIC tokens.

public final void
requestSequenceDet(boolean value)

Implements sun.security.jgss.spi.GSSContextSpi.requestSequenceDet.

Requests that sequence checking be done on the GSS wrap and MIC tokens.

public final void
setChannelBinding(ChannelBinding channelBinding)

Implements sun.security.jgss.spi.GSSContextSpi.setChannelBinding.

Sets the channel bindings to be used during context establishment.

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

Implements sun.security.jgss.spi.GSSContextSpi.unwrap.

For apps that want simplicity and don't care about buffer copies.

public final void
unwrap(InputStream is, OutputStream os, MessageProp msgProp)

Implements sun.security.jgss.spi.GSSContextSpi.unwrap.

Deprecated since 11.

Retrieves the message token previously encapsulated in the wrap call.

private boolean
verifyMechListMIC(byte[] mechTypes, byte[] token)

verify MIC on MechList

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

Implements sun.security.jgss.spi.GSSContextSpi.verifyMIC.

public final void
verifyMIC(InputStream is, InputStream msgStr, MessageProp msgProp)

Implements sun.security.jgss.spi.GSSContextSpi.verifyMIC.

Deprecated since 11.

Checks the integrity of the supplied tokens.

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

Implements sun.security.jgss.spi.GSSContextSpi.wrap.

For apps that want simplicity and don't care about buffer copies.

public final void
wrap(InputStream is, OutputStream os, MessageProp msgProp)

Implements sun.security.jgss.spi.GSSContextSpi.wrap.

Deprecated since 11.

Provides per-message token encapsulation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

channelBindingback to summary
private ChannelBinding channelBinding
confStateback to summary
private boolean confState
credDelegStateback to summary
private boolean credDelegState
DEBUGback to summary
pack-priv static final Debug DEBUG
delegPolicyStateback to summary
private boolean delegPolicyState
DER_mechTypesback to summary
private byte[] DER_mechTypes
factoryback to summary
private final SpNegoMechFactory factory
initiatorback to summary
private final boolean initiator
integStateback to summary
private boolean integState
internal_mechback to summary
private Oid internal_mech
lifetimeback to summary
private int lifetime
mechContextback to summary
private GSSContext mechContext
mutualAuthStateback to summary
private boolean mutualAuthState
myCredback to summary
private final SpNegoCredElement myCred
myNameback to summary
private GSSNameSpi myName
peerNameback to summary
private GSSNameSpi peerName
replayDetStateback to summary
private boolean replayDetState
sequenceDetStateback to summary
private boolean sequenceDetState
stateback to summary
private int state
STATE_DELETEDback to summary
private static final int STATE_DELETED
STATE_DONEback to summary
private static final int STATE_DONE
STATE_IN_PROCESSback to summary
private static final int STATE_IN_PROCESS
STATE_NEWback to summary
private static final int STATE_NEW

Constructor Detail

SpNegoContextback to summary
public SpNegoContext(SpNegoMechFactory factory, GSSNameSpi peerName, GSSCredentialSpi myCred, int lifetime) throws GSSException

Constructor for SpNegoContext to be called on the context initiator's side.

SpNegoContextback to summary
public SpNegoContext(SpNegoMechFactory factory, GSSCredentialSpi myCred) throws GSSException

Constructor for SpNegoContext to be called on the context acceptor's side.

SpNegoContextback to summary
public SpNegoContext(SpNegoMechFactory factory, byte[] interProcessToken) throws GSSException

Constructor for SpNegoContext to import a previously exported context.

Method Detail

acceptSecContextback to summary
public final byte[] acceptSecContext(InputStream is, int mechTokenSize) throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.acceptSecContext.

Deprecated

since 11.

Acceptor's context establishment call. This method may be required to be called several times. A CONTINUE_NEEDED return call indicates that more calls are needed after the next token is received from the peer.

Parameters
is:InputStream

contains the token received from the peer.

Returns:byte[]

any token required to be sent to the peer It is responsibility of the caller to send the token to its peer for processing.

Annotations
@Deprecated
since:11
Exceptions
GSSException:

Doc from sun.security.jgss.spi.GSSContextSpi.acceptSecContext.

may be thrown

disposeback to summary
public final void dispose() throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.dispose.

Doc from sun.security.jgss.spi.GSSContextSpi.dispose.

Releases context resources and terminates the context between 2 peer.

Exceptions
GSSException:
may be thrown
exportback to summary
public final byte[] export() throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.export.

Doc from sun.security.jgss.spi.GSSContextSpi.export.

Produces a token representing this context. After this call the context will no longer be usable until an import is performed on the returned token.

Exceptions
GSSException:
may be thrown
getAnonymityStateback to summary
public final boolean getAnonymityState()

Implements sun.security.jgss.spi.GSSContextSpi.getAnonymityState.

getAvailableMechsback to summary
private Oid[] getAvailableMechs()

obtain the available mechanisms

getChannelBindingback to summary
pack-priv final ChannelBinding getChannelBinding()
getConfStateback to summary
public final boolean getConfState()

Implements sun.security.jgss.spi.GSSContextSpi.getConfState.

Is confidentiality available?

getContextFlagsback to summary
private BitArray getContextFlags()

get the context flags

getCredDelegStateback to summary
public final boolean getCredDelegState()

Implements sun.security.jgss.spi.GSSContextSpi.getCredDelegState.

Is credential delegation enabled?

getDelegCredback to summary
public final GSSCredentialSpi getDelegCred() throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.getDelegCred.

Returns the delegated credential for the context. This is an optional feature of contexts which not all mechanisms will support. A context can be requested to support credential delegation by using the CRED_DELEG. This is only valid on the acceptor side of the context.

Returns:GSSCredentialSpi

GSSCredentialSpi object for the delegated credential

See Also
GSSContext#getCredDelegState
getDelegPolicyStateback to summary
public final boolean getDelegPolicyState()

Implements sun.security.jgss.spi.GSSContextSpi.getDelegPolicyState.

Is deleg policy respected?

getEncodedMechsback to summary
private byte[] getEncodedMechs(Oid[] mechSet) throws IOException, GSSException

get the DER encoded MechList

getIntegStateback to summary
public final boolean getIntegState()

Implements sun.security.jgss.spi.GSSContextSpi.getIntegState.

Is integrity available?

getLifetimeback to summary
public final int getLifetime()

Implements sun.security.jgss.spi.GSSContextSpi.getLifetime.

The lifetime remaining for this context.

getMechback to summary
public final Oid getMech()

Implements sun.security.jgss.spi.GSSContextSpi.getMech.

Returns the mechanism oid.

Returns:Oid

the Oid of this context

getMICback to summary
public final byte[] getMIC(byte[] inMsg, int offset, int len, MessageProp msgProp) throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.getMIC.

getMICback to summary
public final void getMIC(InputStream is, OutputStream os, MessageProp msgProp) throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.getMIC.

Doc from sun.security.jgss.spi.GSSContextSpi.getMIC.

Deprecated

since 11.

Applies per-message integrity services.

Annotations
@Deprecated
since:11
getMutualAuthStateback to summary
public final boolean getMutualAuthState()

Implements sun.security.jgss.spi.GSSContextSpi.getMutualAuthState.

Is mutual authentication enabled? Since this is from the client's perspective, it essentially meas that the server is being authenticated.

getNegotiatedMechback to summary
public final Oid getNegotiatedMech()
getProviderback to summary
public final Provider getProvider()

Implements sun.security.jgss.spi.GSSContextSpi.getProvider.

getReplayDetStateback to summary
public final boolean getReplayDetState()

Implements sun.security.jgss.spi.GSSContextSpi.getReplayDetState.

Is replay detection enabled on the GSS wrap and MIC tokens? We enable replay detection if sequence checking is enabled.

getSequenceDetStateback to summary
public final boolean getSequenceDetState()

Implements sun.security.jgss.spi.GSSContextSpi.getSequenceDetState.

Is sequence checking enabled on the GSS Wrap and MIC tokens? We enable sequence checking if replay detection is enabled.

getSrcNameback to summary
public final GSSNameSpi getSrcName() throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.getSrcName.

getTargNameback to summary
public final GSSNameSpi getTargName() throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.getTargName.

getWrapSizeLimitback to summary
public final int getWrapSizeLimit(int qop, boolean confReq, int maxTokSize) throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.getWrapSizeLimit.

Doc from sun.security.jgss.spi.GSSContextSpi.getWrapSizeLimit.

Queries the context for largest data size to accommodate the specified protection and for the token to remain less than maxTokSize.

Exceptions
GSSException:
may be thrown
GSS_acceptSecContextback to summary
private byte[] GSS_acceptSecContext(byte[] token) throws GSSException

call gss_accept_sec_context for the corresponding underlying mechanism

GSS_initSecContextback to summary
private byte[] GSS_initSecContext(byte[] token) throws GSSException

call gss_init_sec_context for the corresponding underlying mechanism

initSecContextback to summary
public final byte[] initSecContext(InputStream is, int mechTokenSize) throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.initSecContext.

Deprecated

since 11.

Initiator context establishment call. This method may be required to be called several times. A CONTINUE_NEEDED return call indicates that more calls are needed after the next token is received from the peer.

Parameters
is:InputStream

contains the token received from the peer. On the first call it will be ignored.

Returns:byte[]

any token required to be sent to the peer It is responsibility of the caller to send the token to its peer for processing.

Annotations
@Deprecated
since:11
Exceptions
GSSException:

Doc from sun.security.jgss.spi.GSSContextSpi.initSecContext.

may be thrown

inquireSecContextback to summary
public Object inquireSecContext(String type) throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.inquireSecContext.

Retrieve attribute of the context for type.

Exceptions
GSSException:

Doc from sun.security.jgss.spi.GSSContextSpi.inquireSecContext.

see ExtendedGSSContext#inquireSecContext for details

isEstablishedback to summary
public final boolean isEstablished()

Implements sun.security.jgss.spi.GSSContextSpi.isEstablished.

isInitiatorback to summary
public final boolean isInitiator()

Implements sun.security.jgss.spi.GSSContextSpi.isInitiator.

Tests if this is the initiator side of the context.

Returns:boolean

boolean indicating if this is initiator (true) or target (false)

isMechContextEstablishedback to summary
public final boolean isMechContextEstablished()
isProtReadyback to summary
public final boolean isProtReady()

Implements sun.security.jgss.spi.GSSContextSpi.isProtReady.

Tests if the context can be used for per-message service. Context may allow the calls to the per-message service functions before being fully established.

Returns:boolean

boolean indicating if per-message methods can be called.

isTransferableback to summary
public final boolean isTransferable() throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.isTransferable.

negotiate_mech_typeback to summary
private static Oid negotiate_mech_type(Oid[] supported_mechSet, Oid[] mechSet)

This routine compares the received mechset to the mechset that this server can support. It looks sequentially through the mechset and the first one that matches what the server can support is chosen as the negotiated mechanism. If one is found, negResult is set to ACCEPT_COMPLETE, otherwise we return NULL and negResult is set to REJECT.

printStateback to summary
private static String printState(int state)
requestAnonymityback to summary
public final void requestAnonymity(boolean value) throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.requestAnonymity.

requestConfback to summary
public final void requestConf(boolean value) throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.requestConf.

Requests that confidentiality be available.

requestCredDelegback to summary
public final void requestCredDeleg(boolean value) throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.requestCredDeleg.

Requests that credential delegation be done during context establishment.

requestDelegPolicyback to summary
public final void requestDelegPolicy(boolean value) throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.requestDelegPolicy.

Requests that deleg policy be respected.

requestIntegback to summary
public final void requestInteg(boolean value) throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.requestInteg.

Requests that integrity be available.

requestLifetimeback to summary
public void requestLifetime(int lifetime) throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.requestLifetime.

Requests the desired lifetime. Can only be used on the context initiator's side.

requestMutualAuthback to summary
public final void requestMutualAuth(boolean value) throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.requestMutualAuth.

Requests that mutual authentication be done during context establishment. Since this is fromm the client's perspective, it essentially requests that the server be authenticated.

requestReplayDetback to summary
public final void requestReplayDet(boolean value) throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.requestReplayDet.

Requests that replay detection be done on the GSS wrap and MIC tokens.

requestSequenceDetback to summary
public final void requestSequenceDet(boolean value) throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.requestSequenceDet.

Requests that sequence checking be done on the GSS wrap and MIC tokens.

setChannelBindingback to summary
public final void setChannelBinding(ChannelBinding channelBinding) throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.setChannelBinding.

Sets the channel bindings to be used during context establishment.

setContextFlagsback to summary
private void setContextFlags()
unwrapback to summary
public final byte[] unwrap(byte[] inBuf, int offset, int len, MessageProp msgProp) throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.unwrap.

Doc from sun.security.jgss.spi.GSSContextSpi.unwrap.

For apps that want simplicity and don't care about buffer copies.

unwrapback to summary
public final void unwrap(InputStream is, OutputStream os, MessageProp msgProp) throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.unwrap.

Doc from sun.security.jgss.spi.GSSContextSpi.unwrap.

Deprecated

since 11.

Retrieves the message token previously encapsulated in the wrap call.

Annotations
@Deprecated
since:11
Exceptions
GSSException:
may be thrown
verifyMechListMICback to summary
private boolean verifyMechListMIC(byte[] mechTypes, byte[] token) throws GSSException

verify MIC on MechList

verifyMICback to summary
public final void verifyMIC(byte[] inTok, int tokOffset, int tokLen, byte[] inMsg, int msgOffset, int msgLen, MessageProp msgProp) throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.verifyMIC.

verifyMICback to summary
public final void verifyMIC(InputStream is, InputStream msgStr, MessageProp msgProp) throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.verifyMIC.

Doc from sun.security.jgss.spi.GSSContextSpi.verifyMIC.

Deprecated

since 11.

Checks the integrity of the supplied tokens. This token was previously generated by getMIC.

Annotations
@Deprecated
since:11
Exceptions
GSSException:
may be thrown
wrapback to summary
public final byte[] wrap(byte[] inBuf, int offset, int len, MessageProp msgProp) throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.wrap.

Doc from sun.security.jgss.spi.GSSContextSpi.wrap.

For apps that want simplicity and don't care about buffer copies.

wrapback to summary
public final void wrap(InputStream is, OutputStream os, MessageProp msgProp) throws GSSException

Implements sun.security.jgss.spi.GSSContextSpi.wrap.

Doc from sun.security.jgss.spi.GSSContextSpi.wrap.

Deprecated

since 11.

Provides per-message token encapsulation.

Annotations
@Deprecated
since:11
Exceptions
GSSException:
may be thrown