com.ibm.security.jgss
Class GSSContextImpl
- java.lang.Object
com.ibm.security.jgss.GSSContextImpl
- public class GSSContextImpl
- extends java.lang.Object
- implements GSSContext
Based on the IETF RFC 2853 "Generic Security Service API Version 2: Java Bindings."
Field Summary
Fields inherited from interface org.ietf.jgss.GSSContext |
---|
DEFAULT_LIFETIME, INDEFINITE_LIFETIME |
Method Summary
Modifier and Type | Method and Description |
---|---|
|
acceptSecContext(byte[] inToken,int offset,int len)
|
|
acceptSecContext(java.io.InputStream inStream,java.io.OutputStream outStream)
|
|
dispose()
|
|
export()
|
|
getAnonymityState()
|
|
getConfState()
|
|
getCredDelegState()
|
getDelegCred()
|
|
|
getIntegState()
|
|
getLifetime()
|
getMech()
|
|
|
getMIC(byte[] inMsg,int offset,int len,MessageProp msgProp)
|
|
getMIC(java.io.InputStream inStream,java.io.OutputStream outStream,MessageProp msgProp)
|
|
getMutualAuthState()
|
|
getNegMechs(GSSCredential cred)
|
|
getReplayDetState()
|
|
getSequenceDetState()
|
getSrcName()
|
|
getTargName()
|
|
|
getWrapSizeLimit(int qop,boolean confReq,int maxTokenSize)
|
|
initSecContext(byte[] inputBuf,int offset,int len)
|
|
initSecContext(java.io.InputStream inStream,java.io.OutputStream outStream)
|
|
isEstablished()
|
|
isInitiator()
|
|
isProtReady()
|
|
isTransferable()
|
|
requestAnonymity(boolean state)
|
|
requestConf(boolean state)
|
|
requestCredDeleg(boolean state)
|
|
requestInteg(boolean state)
|
|
requestLifetime(int lifetime)
|
|
requestMutualAuth(boolean state)
|
|
requestReplayDet(boolean state)
|
|
requestSequenceDet(boolean state)
|
|
setChannelBinding(ChannelBinding cb)
|
|
setNegMechs(Oid[] mechTypes,GSSCredential credential)
|
|
toString()
|
|
unwrap(byte[] inBuf,int offset,int len,MessageProp msgProp)
|
|
unwrap(java.io.InputStream inStream,java.io.OutputStream outStream,MessageProp msgProp)
|
|
verifyMIC(byte[] inTok,int tokOffset,int tokLen,byte[] inMsg,int msgOffset,int msgLen,MessageProp msgProp)
|
|
verifyMIC(java.io.InputStream tokStream,java.io.InputStream msgStream,MessageProp msgProp)
|
|
wrap(byte[] inBuf,int offset,int len,MessageProp msgProp)
|
|
wrap(java.io.InputStream inStream,java.io.OutputStream outStream,MessageProp msgProp)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Method Detail
initSecContext
- public byte[] initSecContext(byte[] inputBuf,
- int offset,
- int len)
- throws GSSException
Upon completion of the context establishment, the available context options may be queried through the get methods.
initSecContext
in interface GSSContext
inputBuf
- Token generated by the peer. This parameter is ignored
on the first call. offset
- The offset within the inputBuf where the token begins. len
- The length of the token within the inputBuf (starting
at the offset). initSecContext
- public int initSecContext(java.io.InputStream inStream,
- java.io.OutputStream outStream)
- throws GSSException
GSSContext
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.
Upon completion of the context establishment, the available context options may be queried through the get methods.
initSecContext
in interface GSSContext
inStream
- Contains the token generated by the peer. This
parameter is ignored on the first call. outStream
- Output stream where the output token will be written.
During the final stage of context establishment, there
may be no bytes written. acceptSecContext
- public byte[] acceptSecContext( byte[] inToken,
- int offset,
- int len)
- throws GSSException
GSSContext
This method may return an output token which the application will need to send to the peer for further processing by the init call. "null" return value indicates that no token needs to be sent to the peer. 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.
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.
Upon completion of the context establishment, the available context options may be queried through the get methods.
acceptSecContext
in interface GSSContext
offset
- The offset within the inTok where the token begins. len
- The length of the token within the inTok (starting at
the offset). acceptSecContext
- public void acceptSecContext(java.io.InputStream inStream,
- java.io.OutputStream outStream)
- throws GSSException
GSSContext
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.
Upon completion of the context establishment, the available context options may be queried through the get methods.
acceptSecContext
in interface GSSContext
inStream
- Contains the token generated by the peer. outStream
- Output stream where the output token will be written.
During the final stage of context establishment, there
may be no bytes written. isEstablished
- public boolean isEstablished()
GSSContext
isEstablished
in interface GSSContext
dispose
- public void dispose()
- throws GSSException
GSSContext
dispose
in interface GSSContext
getWrapSizeLimit
- public int getWrapSizeLimit(int qop,
- boolean confReq,
- int maxTokenSize)
- throws GSSException
GSSContext
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.
Successful completion of this call does not guarantee that wrap will be able to protect a message of the computed length, since this ability may depend on the availability of system resources at the time that wrap is called. However, if the implementation itself imposes an upper limit on the length of messages that may be processed by wrap, the implementation should not return a value that is greater than this length.
getWrapSizeLimit
in interface GSSContext
qop
- Indicates the level of protection wrap will be asked
to provide. confReq
- Indicates if wrap will be asked to provide privacy
service. maxTokenSize
- The desired maximum size of the token emitted by wrap. wrap
- public byte[] wrap(byte[] inBuf,
- int offset,
- int len,
- MessageProp msgProp)
- throws GSSException
GSSContext
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.
wrap
in interface GSSContext
inBuf
- Application data to be protected. offset
- The offset within the inBuf where the data begins. len
- The length of the data within the inBuf (starting at
the offset). msgProp
- Instance of MessageProp that is used by the
application to set the desired QOP and privacy state.
Set the desired QOP to 0 to request the default QOP.
Upon return from this method, this object will contain
the the actual privacy state that was applied to the
message by the underlying mechanism. wrap
- public void wrap(java.io.InputStream inStream,
- java.io.OutputStream outStream,
- MessageProp msgProp)
- throws GSSException
GSSContext
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.
wrap
in interface GSSContext
inStream
- Input stream containing the application data to be
protected. outStream
- The output stream to write the protected message to.
The application is responsible for sending this to the
other peer for processing in its unwrap method. msgProp
- Instance of MessageProp that is used by the
application to set the desired QOP and privacy state.
Set the desired QOP to 0 to request the default QOP.
Upon return from this method, this object will contain
the the actual privacy state that was applied to the
message by the underlying mechanism. unwrap
- public byte[] unwrap(byte[] inBuf,
- int offset,
- int len,
- MessageProp msgProp)
- throws GSSException
GSSContext
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.
unwrap
in interface GSSContext
inBuf
- GSS-API wrap token received from peer. offset
- The offset within the inBuf where the token begins. len
- The length of the token within the inBuf (starting at
the offset). msgProp
- Upon return from the method, this object will contain
the applied QOP, the privacy state of the message, and
supplementary information described in 4.12.3 stating
whether the token was a duplicate, old, out of
sequence or arriving after a gap. unwrap
- public void unwrap(java.io.InputStream inStream,
- java.io.OutputStream outStream,
- MessageProp msgProp)
- throws GSSException
GSSContext
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.
unwrap
in interface GSSContext
inStream
- Input stream containing the GSS-API wrap token
received from the peer. outStream
- The output stream to write the application message to. msgProp
- Upon return from the method, this object will contain
the applied QOP, the privacy state of the message, and
supplementary information described in 4.12.3 stating
whether the token was a duplicate, old, out of
sequence or arriving after a gap. getMIC
- public byte[] getMIC(byte[] inMsg,
- int offset,
- int len,
- MessageProp msgProp)
- throws GSSException
GSSContext
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.
getMIC
in interface GSSContext
inMsg
- Message to generate MIC over. offset
- The offset within the inMsg where the token begins. len
- The length of the token within the inMsg (starting at
the offset). msgProp
- Instance of MessageProp that is used by the
application to set the desired QOP. Set the desired
QOP to 0 in msgProp to request the default QOP.
Alternatively pass in "null" for msgProp to request
default QOP. getMIC
- public void getMIC(java.io.InputStream inStream,
- java.io.OutputStream outStream,
- MessageProp msgProp)
- throws GSSException
GSSContext
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.
getMIC
in interface GSSContext
inStream
- Input stream containing the message to
generate MIC over. outStream
- Output stream to write the GSS-API output
token to. msgProp
- Instance of MessageProp that is used by the
application to set the desired QOP. Set the desired
QOP to 0 in msgProp to request the default QOP.
Alternatively pass in "null" for msgProp to request
default QOP. verifyMIC
- public void verifyMIC(byte[] inTok,
- int tokOffset,
- int tokLen,
- byte[] inMsg,
- int msgOffset,
- int msgLen,
- MessageProp msgProp)
- throws GSSException
GSSContext
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.
verifyMIC
in interface GSSContext
inTok
- Token generated by peer's getMIC method. tokOffset
- The offset within the inTok where the token begins. inMsg
- Application message to verify the cryptographic MIC
over. msgOffset
- The offset within the inMsg where the message begins. msgLen
- The length of the message within the inMsg (starting
at the offset). msgProp
- Upon return from the method, this object will contain
the applied QOP and supplementary information
described in 4.12.3 stating whether the token was a
duplicate, old, out of sequence or arriving after a
gap. The confidentiality state will be set to
"false". verifyMIC
- public void verifyMIC(java.io.InputStream tokStream,
- java.io.InputStream msgStream,
- MessageProp msgProp)
- throws GSSException
GSSContext
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.
verifyMIC
in interface GSSContext
tokStream
- Input stream containing the token generated by peer's
getMIC method. msgStream
- Input stream containing the application message to
verify the cryptographic MIC over. msgProp
- Upon return from the method, this object will contain
the applied QOP and supplementary information
described in 4.12.3 stating whether the token was a
duplicate, old, out of sequence or arriving after a
gap. The confidentiality state will be set to "false". export
- public byte[] export()
- throws GSSException
GSSContext
export
in interface GSSContext
requestMutualAuth
- public void requestMutualAuth(boolean state)
- throws GSSException
GSSContext
requestMutualAuth
in interface GSSContext
state
- Boolean representing if mutual authentication should
be requested during context establishment. requestReplayDet
- public void requestReplayDet(boolean state)
- throws GSSException
GSSContext
requestReplayDet
in interface GSSContext
state
- Boolean representing if replay detection is desired
over the established context. requestSequenceDet
- public void requestSequenceDet( boolean state)
- throws GSSException
GSSContext
requestSequenceDet
in interface GSSContext
state
- Boolean representing if sequence detection is desired
over the established context. requestCredDeleg
- public void requestCredDeleg(boolean state)
- throws GSSException
GSSContext
requestCredDeleg
in interface GSSContext
requestAnonymity
- public void requestAnonymity(boolean state)
- throws GSSException
GSSContext
requestAnonymity
in interface GSSContext
requestConf
- public void requestConf(boolean state)
- throws GSSException
GSSContext
requestConf
in interface GSSContext
state
- Boolean indicating if confidentiality services are to
be requested for the context. requestInteg
- public void requestInteg(boolean state)
- throws GSSException
GSSContext
requestInteg
in interface GSSContext
state
- Boolean indicating if integrity services are to be
requested for the context. requestLifetime
- public void requestLifetime(int lifetime)
- throws GSSException
GSSContext
requestLifetime
in interface GSSContext
setChannelBinding
- public void setChannelBinding(ChannelBinding cb)
- throws GSSException
GSSContext
setChannelBinding
in interface GSSContext
setNegMechs
- public void setNegMechs(Oid[] mechTypes,
- GSSCredential credential)
- throws GSSException
getCredDelegState
- public boolean getCredDelegState( )
GSSContext
getCredDelegState
in interface GSSContext
getMutualAuthState
- public boolean getMutualAuthState( )
GSSContext
getMutualAuthState
in interface GSSContext
getReplayDetState
- public boolean getReplayDetState( )
GSSContext
getReplayDetState
in interface GSSContext
getSequenceDetState
- public boolean getSequenceDetState( )
GSSContext
getSequenceDetState
in interface GSSContext
getAnonymityState
- public boolean getAnonymityState( )
GSSContext
getAnonymityState
in interface GSSContext
isTransferable
- public boolean isTransferable()
- throws GSSException
GSSContext
isTransferable
in interface GSSContext
isProtReady
- public boolean isProtReady()
GSSContext
isProtReady
in interface GSSContext
getConfState
- public boolean getConfState()
GSSContext
getConfState
in interface GSSContext
getIntegState
- public boolean getIntegState()
GSSContext
getIntegState
in interface GSSContext
getLifetime
- public int getLifetime()
GSSContext
getLifetime
in interface GSSContext
getSrcName
- public GSSName getSrcName()
- throws GSSException
GSSContext
getSrcName
in interface GSSContext
getTargName
- public GSSName getTargName()
- throws GSSException
GSSContext
getTargName
in interface GSSContext
getMech
- public Oid getMech()
- throws GSSException
GSSContext
getMech
in interface GSSContext
getNegMechs
- public Oid[] getNegMechs(GSSCredential cred)
- throws GSSException
getDelegCred
- public GSSCredential getDelegCred( )
- throws GSSException
GSSContext
getCredDelegState
method to check for
availability of delegated credentials.
getDelegCred
in interface GSSContext
isInitiator
- public boolean isInitiator()
- throws GSSException
GSSContext
isInitiator
in interface GSSContext
toString
- public java.lang.String toString( )
toString
in class java.lang.Object
GSSContext