|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
This interface encapsulates the GSS-API security context and provides the security services (wrap, unwrap, getMIC, verifyMIC) that are available over the context. Security contexts are established between peers using locally acquired credentials. Multiple contexts may exist simultaneously between a pair of peers, using the same or different set of credentials. GSS-API functions in a manner independent of the underlying transport protocol and depends on its calling application to transport its tokens between peers.
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 init 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. If an error occurs at any point, an exception will get thrown and the code will start executing in a catch block. If not, the normal flow of code continues and the application can make a call to the isEstablished() method. If this method returns false it indicates that a token is needed from its peer in order to continue the context establishment phase. A return value of true signals that the local end of the context is established. This may still require that a token be sent to the peer, if one is produced by GSS-API. 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 applications 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.
Field Summary | |
static int |
DEFAULT_LIFETIME
A lifetime constant representing the default context lifetime. |
static int |
INDEFINITE_LIFETIME
A lifetime constant representing indefinite context lifetime. |
Method Summary | |
byte[] |
acceptSecContext(byte[] inTok,
int offset,
int len)
Called by the context acceptor upon receiving a token from the peer. |
void |
acceptSecContext(java.io.InputStream inStream,
java.io.OutputStream outStream)
Called by the context acceptor upon receiving a token from the peer. |
void |
dispose()
Releases any system resources and cryptographic information stored in the context object. |
byte[] |
export()
Provided to support the sharing of work between multiple processes. |
boolean |
getAnonymityState()
Returns "true" if this is an anonymous context. |
boolean |
getConfState()
Returns the confidentiality service state over the context. |
boolean |
getCredDelegState()
Returns the state of the delegated credentials for the context. |
GSSCredential |
getDelegCred()
Returns the delegated credential object on the acceptor's side. |
boolean |
getIntegState()
Returns the integrity service state over the context. |
int |
getLifetime()
Returns the context lifetime in seconds. |
Oid |
getMech()
Returns the mechanism oid for this context. |
byte[] |
getMIC(byte[] inMsg,
int offset,
int len,
MessageProp msgProp)
Returns a token containing a cryptographic MIC for the supplied message, for transfer to the peer application. |
void |
getMIC(java.io.InputStream inStream,
java.io.OutputStream outStream,
MessageProp msgProp)
Produces a token containing a cryptographic MIC for the supplied message, for transfer to the peer application. |
boolean |
getMutualAuthState()
Returns the state of the mutual authentication option for the context. |
boolean |
getReplayDetState()
Returns the state of the replay detection option for the context. |
boolean |
getSequenceDetState()
Returns the state of the sequence detection option for the context. |
GSSName |
getSrcName()
Returns the name of the context initiator. |
GSSName |
getTargName()
Returns the name of the context target (acceptor). |
int |
getWrapSizeLimit(int qop,
boolean confReq,
int maxTokenSize)
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 the maxTokenSize bytes. |
byte[] |
initSecContext(byte[] InputBuf,
int offset,
int len)
Called by the context initiator to start the context creation process. |
int |
initSecContext(java.io.InputStream inStream,
java.io.OutputStream outStream)
Called by the context initiator to start the context creation process. |
boolean |
isEstablished()
Used during context establishment to determine the state of the context. |
boolean |
isInitiator()
Returns "true" if this is the initiator of the context. |
boolean |
isProtReady()
Returns "true" if the per message operations can be applied over the context. |
boolean |
isTransferable()
Returns "true" if the context is transferable to other processes through the use of the export method. |
void |
requestAnonymity(boolean state)
Requests anonymous support over the context. |
void |
requestConf(boolean state)
Requests that confidentiality service be available over the context. |
void |
requestCredDeleg(boolean state)
Sets the request state for the credential delegation flag for the context. |
void |
requestInteg(boolean state)
Requests that integrity services be available over the context. |
void |
requestLifetime(int lifetime)
Sets the desired lifetime for the context in seconds. |
void |
requestMutualAuth(boolean state)
Sets the request state of the mutual authentication flag for the context. |
void |
requestReplayDet(boolean state)
Sets the request state of the replay detection service for the context. |
void |
requestSequenceDet(boolean state)
Sets the request state for the sequence checking service of the context. |
void |
setChannelBinding(ChannelBinding cb)
Sets the channel bindings to be used during context establishment. |
byte[] |
unwrap(byte[] inBuf,
int offset,
int len,
MessageProp msgProp)
Used by the peer application to process tokens generated with the wrap call. |
void |
unwrap(java.io.InputStream inStream,
java.io.OutputStream outStream,
MessageProp msgProp)
Used by the peer application to process tokens generated with the wrap call. |
void |
verifyMIC(byte[] inTok,
int tokOffset,
int tokLen,
byte[] inMsg,
int msgOffset,
int msgLen,
MessageProp msgProp)
Verifies the cryptographic MIC, contained in the token parameter, over the supplied message. |
void |
verifyMIC(java.io.InputStream tokStream,
java.io.InputStream msgStream,
MessageProp msgProp)
Verifies the cryptographic MIC, contained in the token parameter, over the supplied message. |
byte[] |
wrap(byte[] inBuf,
int offset,
int len,
MessageProp msgProp)
Applies per-message security services over the established security context. |
void |
wrap(java.io.InputStream inStream,
java.io.OutputStream outStream,
MessageProp msgProp)
Allows to apply per-message security services over the established security context. |
Field Detail |
public static final int DEFAULT_LIFETIME
public static final int INDEFINITE_LIFETIME
Method Detail |
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.
offset
- The offset within the inputBuf where the token begins.len
- The length of the token within the inputBuf (starting
at the offset).
GSSException
public int initSecContext(java.io.InputStream inStream, java.io.OutputStream outStream) throws GSSException
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.
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.
GSSException
public byte[] acceptSecContext(byte[] inTok, int offset, int len) throws GSSException
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.
inTok
- Token generated by the peer.offset
- The offset within the inTok where the token begins.len
- The length of the token within the inTok (starting at
the offset).
GSSException
public void acceptSecContext(java.io.InputStream inStream, java.io.OutputStream outStream) throws GSSException
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.
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.
GSSException
public boolean isEstablished()
public void dispose() throws GSSException
GSSException
public int getWrapSizeLimit(int qop, boolean confReq, int maxTokenSize) throws GSSException
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.
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.
GSSException
public byte[] wrap(byte[] inBuf, int offset, int len, MessageProp msgProp) throws GSSException
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.
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.
GSSException
public void wrap(java.io.InputStream inStream, java.io.OutputStream outStream, MessageProp msgProp) throws GSSException
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.
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.
GSSException
public byte[] unwrap(byte[] inBuf, int offset, int len, MessageProp msgProp) throws GSSException
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.
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.
GSSException
public void unwrap(java.io.InputStream inStream, java.io.OutputStream outStream, MessageProp msgProp) throws GSSException
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.
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.
GSSException
public byte[] getMIC(byte[] inMsg, int offset, int len, MessageProp msgProp) throws GSSException
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.
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.
GSSException
public void getMIC(java.io.InputStream inStream, java.io.OutputStream outStream, MessageProp msgProp) throws GSSException
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.
inStream
- Input stream containing the message to
generate MIC over.outStream
- 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.
GSSException
public void verifyMIC(byte[] inTok, int tokOffset, int tokLen, byte[] inMsg, int msgOffset, int msgLen, MessageProp msgProp) throws GSSException
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.
inTok
- Token generated by peer's getMIC method.tokOffset
- The offset within the inTok where the token begins.tokLen
- The length of the token within the inTok (starting at
the offset).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".
GSSException
public void verifyMIC(java.io.InputStream tokStream, java.io.InputStream msgStream, MessageProp msgProp) throws GSSException
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.
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".
GSSException
public byte[] export() throws GSSException
This method deactivates the security context and creates an interprocess token which, when passed to the byte array constructor of the GSSContext interface 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.
GSSException
public void requestMutualAuth(boolean state) throws GSSException
state
- Boolean representing if mutual authentication should
be requested during context establishment.
GSSException
public void requestReplayDet(boolean state) throws GSSException
state
- Boolean representing if replay detection is desired
over the established context.
GSSException
public void requestSequenceDet(boolean state) throws GSSException
state
- Boolean representing if sequence detection is desired
over the established context.
GSSException
public void requestCredDeleg(boolean state) throws GSSException
state
- Boolean representing if credential delegation is
desired.
GSSException
public void requestAnonymity(boolean state) throws GSSException
state
- Boolean representing if anonymity support is
requested.
GSSException
public void requestConf(boolean state) throws GSSException
state
- Boolean indicating if confidentiality services are to
be requested for the context.
GSSException
public void requestInteg(boolean state) throws GSSException
state
- Boolean indicating if integrity services are to be
requested for the context.
GSSException
public void requestLifetime(int lifetime) throws GSSException
lifetime
- The desired context lifetime in seconds.
GSSException
public void setChannelBinding(ChannelBinding cb) throws GSSException
cb
- Channel bindings to be used.
GSSException
public boolean getCredDelegState()
public boolean getMutualAuthState()
public boolean getReplayDetState()
public boolean getSequenceDetState()
public boolean getAnonymityState()
public boolean isTransferable() throws GSSException
GSSException
public boolean isProtReady()
public boolean getConfState()
public boolean getIntegState()
public int getLifetime()
public GSSName getSrcName() throws GSSException
GSSException
public GSSName getTargName() throws GSSException
GSSException
public Oid getMech() throws GSSException
GSSException
public GSSCredential getDelegCred() throws GSSException
GSSException
public boolean isInitiator() throws GSSException
GSSException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |