sun.security.mule.jgss
Class GSSContextImpl

java.lang.Object
  extended by sun.security.mule.jgss.GSSContextImpl
All Implemented Interfaces:
GSSContext

public class GSSContextImpl
extends Object
implements GSSContext

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
 
Fields inherited from interface org.ietf.jgss.GSSContext
DEFAULT_LIFETIME, INDEFINITE_LIFETIME
 
Constructor Summary
GSSContextImpl(GSSManagerImpl gssManager, byte[] interProcessToken)
          Creates a GSSContextImpl out of a previously exported GSSContext.
GSSContextImpl(GSSManagerImpl gssManager, GSSCredential myCred)
          Creates a GSSContextImpl on the context acceptor's side.
GSSContextImpl(GSSManagerImpl gssManager, GSSName peer, Oid mech, GSSCredential myCred, int lifetime)
          Creates a GSSContextImp on the context initiator's side.
 
Method Summary
 byte[] acceptSecContext(byte[] inTok, int offset, int len)
           
 void acceptSecContext(InputStream inStream, OutputStream outStream)
           
 void dispose()
           
 byte[] export()
           
 boolean getAnonymityState()
           
 boolean getConfState()
           
 boolean getCredDelegState()
           
 GSSCredential getDelegCred()
           
 boolean getIntegState()
           
 int getLifetime()
           
 Oid getMech()
           
 byte[] getMIC(byte[] inMsg, int offset, int len, MessageProp msgProp)
           
 void getMIC(InputStream inStream, OutputStream outStream, MessageProp msgProp)
           
 boolean getMutualAuthState()
           
 boolean getReplayDetState()
           
 boolean getSequenceDetState()
           
 GSSName getSrcName()
           
 GSSName getTargName()
           
 int getWrapSizeLimit(int qop, boolean confReq, int maxTokenSize)
           
 byte[] initSecContext(byte[] inputBuf, int offset, int len)
           
 int initSecContext(InputStream inStream, OutputStream outStream)
           
 boolean isEstablished()
           
 boolean isInitiator()
           
 boolean isProtReady()
           
 boolean isTransferable()
           
 void requestAnonymity(boolean state)
           
 void requestConf(boolean state)
           
 void requestCredDeleg(boolean state)
           
 void requestInteg(boolean state)
           
 void requestLifetime(int lifetime)
           
 void requestMutualAuth(boolean state)
           
 void requestReplayDet(boolean state)
           
 void requestSequenceDet(boolean state)
           
 void resetStateToInProgress()
           
 void setChannelBinding(ChannelBinding channelBindings)
           
 byte[] unwrap(byte[] inBuf, int offset, int len, MessageProp msgProp)
           
 void unwrap(InputStream inStream, OutputStream outStream, MessageProp msgProp)
           
 void verifyMIC(byte[] inTok, int tokOffset, int tokLen, byte[] inMsg, int msgOffset, int msgLen, MessageProp msgProp)
           
 void verifyMIC(InputStream tokStream, InputStream msgStream, MessageProp msgProp)
           
 byte[] wrap(byte[] inBuf, int offset, int len, MessageProp msgProp)
           
 void wrap(InputStream inStream, OutputStream outStream, MessageProp msgProp)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GSSContextImpl

public GSSContextImpl(GSSManagerImpl gssManager,
                      GSSName peer,
                      Oid mech,
                      GSSCredential myCred,
                      int lifetime)
               throws GSSException
Creates a GSSContextImp on the context initiator's side.

Throws:
GSSException

GSSContextImpl

public GSSContextImpl(GSSManagerImpl gssManager,
                      GSSCredential myCred)
               throws GSSException
Creates a GSSContextImpl on the context acceptor's side.

Throws:
GSSException

GSSContextImpl

public GSSContextImpl(GSSManagerImpl gssManager,
                      byte[] interProcessToken)
               throws GSSException
Creates a GSSContextImpl out of a previously exported GSSContext.

Throws:
GSSException
See Also:
isTransferable()
Method Detail

resetStateToInProgress

public void resetStateToInProgress()

initSecContext

public byte[] initSecContext(byte[] inputBuf,
                             int offset,
                             int len)
                      throws GSSException
Specified by:
initSecContext in interface GSSContext
Throws:
GSSException

initSecContext

public int initSecContext(InputStream inStream,
                          OutputStream outStream)
                   throws GSSException
Specified by:
initSecContext in interface GSSContext
Throws:
GSSException

acceptSecContext

public byte[] acceptSecContext(byte[] inTok,
                               int offset,
                               int len)
                        throws GSSException
Specified by:
acceptSecContext in interface GSSContext
Throws:
GSSException

acceptSecContext

public void acceptSecContext(InputStream inStream,
                             OutputStream outStream)
                      throws GSSException
Specified by:
acceptSecContext in interface GSSContext
Throws:
GSSException

isEstablished

public boolean isEstablished()
Specified by:
isEstablished in interface GSSContext

getWrapSizeLimit

public int getWrapSizeLimit(int qop,
                            boolean confReq,
                            int maxTokenSize)
                     throws GSSException
Specified by:
getWrapSizeLimit in interface GSSContext
Throws:
GSSException

wrap

public byte[] wrap(byte[] inBuf,
                   int offset,
                   int len,
                   MessageProp msgProp)
            throws GSSException
Specified by:
wrap in interface GSSContext
Throws:
GSSException

wrap

public void wrap(InputStream inStream,
                 OutputStream outStream,
                 MessageProp msgProp)
          throws GSSException
Specified by:
wrap in interface GSSContext
Throws:
GSSException

unwrap

public byte[] unwrap(byte[] inBuf,
                     int offset,
                     int len,
                     MessageProp msgProp)
              throws GSSException
Specified by:
unwrap in interface GSSContext
Throws:
GSSException

unwrap

public void unwrap(InputStream inStream,
                   OutputStream outStream,
                   MessageProp msgProp)
            throws GSSException
Specified by:
unwrap in interface GSSContext
Throws:
GSSException

getMIC

public byte[] getMIC(byte[] inMsg,
                     int offset,
                     int len,
                     MessageProp msgProp)
              throws GSSException
Specified by:
getMIC in interface GSSContext
Throws:
GSSException

getMIC

public void getMIC(InputStream inStream,
                   OutputStream outStream,
                   MessageProp msgProp)
            throws GSSException
Specified by:
getMIC in interface GSSContext
Throws:
GSSException

verifyMIC

public void verifyMIC(byte[] inTok,
                      int tokOffset,
                      int tokLen,
                      byte[] inMsg,
                      int msgOffset,
                      int msgLen,
                      MessageProp msgProp)
               throws GSSException
Specified by:
verifyMIC in interface GSSContext
Throws:
GSSException

verifyMIC

public void verifyMIC(InputStream tokStream,
                      InputStream msgStream,
                      MessageProp msgProp)
               throws GSSException
Specified by:
verifyMIC in interface GSSContext
Throws:
GSSException

export

public byte[] export()
              throws GSSException
Specified by:
export in interface GSSContext
Throws:
GSSException

requestMutualAuth

public void requestMutualAuth(boolean state)
                       throws GSSException
Specified by:
requestMutualAuth in interface GSSContext
Throws:
GSSException

requestReplayDet

public void requestReplayDet(boolean state)
                      throws GSSException
Specified by:
requestReplayDet in interface GSSContext
Throws:
GSSException

requestSequenceDet

public void requestSequenceDet(boolean state)
                        throws GSSException
Specified by:
requestSequenceDet in interface GSSContext
Throws:
GSSException

requestCredDeleg

public void requestCredDeleg(boolean state)
                      throws GSSException
Specified by:
requestCredDeleg in interface GSSContext
Throws:
GSSException

requestAnonymity

public void requestAnonymity(boolean state)
                      throws GSSException
Specified by:
requestAnonymity in interface GSSContext
Throws:
GSSException

requestConf

public void requestConf(boolean state)
                 throws GSSException
Specified by:
requestConf in interface GSSContext
Throws:
GSSException

requestInteg

public void requestInteg(boolean state)
                  throws GSSException
Specified by:
requestInteg in interface GSSContext
Throws:
GSSException

requestLifetime

public void requestLifetime(int lifetime)
                     throws GSSException
Specified by:
requestLifetime in interface GSSContext
Throws:
GSSException

setChannelBinding

public void setChannelBinding(ChannelBinding channelBindings)
                       throws GSSException
Specified by:
setChannelBinding in interface GSSContext
Throws:
GSSException

getCredDelegState

public boolean getCredDelegState()
Specified by:
getCredDelegState in interface GSSContext

getMutualAuthState

public boolean getMutualAuthState()
Specified by:
getMutualAuthState in interface GSSContext

getReplayDetState

public boolean getReplayDetState()
Specified by:
getReplayDetState in interface GSSContext

getSequenceDetState

public boolean getSequenceDetState()
Specified by:
getSequenceDetState in interface GSSContext

getAnonymityState

public boolean getAnonymityState()
Specified by:
getAnonymityState in interface GSSContext

isTransferable

public boolean isTransferable()
                       throws GSSException
Specified by:
isTransferable in interface GSSContext
Throws:
GSSException

isProtReady

public boolean isProtReady()
Specified by:
isProtReady in interface GSSContext

getConfState

public boolean getConfState()
Specified by:
getConfState in interface GSSContext

getIntegState

public boolean getIntegState()
Specified by:
getIntegState in interface GSSContext

getLifetime

public int getLifetime()
Specified by:
getLifetime in interface GSSContext

getSrcName

public GSSName getSrcName()
                   throws GSSException
Specified by:
getSrcName in interface GSSContext
Throws:
GSSException

getTargName

public GSSName getTargName()
                    throws GSSException
Specified by:
getTargName in interface GSSContext
Throws:
GSSException

getMech

public Oid getMech()
            throws GSSException
Specified by:
getMech in interface GSSContext
Throws:
GSSException

getDelegCred

public GSSCredential getDelegCred()
                           throws GSSException
Specified by:
getDelegCred in interface GSSContext
Throws:
GSSException

isInitiator

public boolean isInitiator()
                    throws GSSException
Specified by:
isInitiator in interface GSSContext
Throws:
GSSException

dispose

public void dispose()
             throws GSSException
Specified by:
dispose in interface GSSContext
Throws:
GSSException


Copyright © 2013. All Rights Reserved.