< prev index next >

src/java.security.jgss/share/classes/sun/security/jgss/spi/GSSContextSpi.java

Print this page



  34 import java.io.InputStream;
  35 import java.io.OutputStream;
  36 import java.security.Provider;
  37 
  38 /**
  39  * This interface is implemented by a mechanism specific instance of a GSS
  40  * security context.
  41  * A GSSContextSpi object can be thought of having 3 states:
  42  *    -before initialization
  43  *    -during initialization with its peer
  44  *    -after it is established
  45  * <p>
  46  * The context options can only be requested in state 1. In state 3,
  47  * the per message operations are available to the callers. The get
  48  * methods for the context options will return the requested options
  49  * while in state 1 and 2, and the established values in state 3.
  50  * Some mechanisms may allow the access to the per-message operations
  51  * and the context flags before the context is fully established. The
  52  * isProtReady method is used to indicate that these services are
  53  * available.
  54  *<p>
  55  * <strong>
  56  * Context establishment tokens are defined in a mechanism independent
  57  * format in section 3.1 of RFC 2743. The GSS-Framework will add
  58  * and remove the mechanism independent header portion of this token format
  59  * depending on whether a token is received or is being sent. The mechanism
  60  * should only generate or expect to read the inner-context token portion..
  61  * <p>
  62  * On the other hands, tokens used for per-message calls are generated
  63  * entirely by the mechanism. It is possible that the mechanism chooses to
  64  * encase inner-level per-message tokens in a header similar to that used
  65  * for initial tokens, however, this is upto the mechanism to do. The token
  66  * to/from the per-message calls are opaque to the GSS-Framework.
  67  * </strong>
  68  * <p>
  69  * An attempt has been made to allow for reading the peer's tokens from an
  70  * InputStream and writing tokens for the peer to an OutputStream. This
  71  * allows applications to pass in streams that are obtained from their network
  72  * connections and thus minimize the buffer copies that will happen. This
  73  * is especially important for tokens generated by wrap() which are
  74  * proportional in size to the length of the application data being
  75  * wrapped, and are probably also the most frequently used type of tokens.
  76  * <p>
  77  * It is anticipated that most applications will want to use wrap() in a
  78  * fashion where they obtain the application bytes to wrap from a byte[]
  79  * but want to output the wrap token straight to an
  80  * OutputStream. Similarly, they will want to use unwrap() where they read
  81  * the token directly form an InputStream but output it to some byte[] for


 222      * the GSS-Framework from the mechanism independent GSS-API level
 223      * header.
 224      * @return any inner-context token required to be sent to the peer as
 225      * part of a GSS token. The mechanism should not add the mechanism
 226      * independent part of the token. The GSS-Framework will add that on
 227      * the way out.
 228      * @exception GSSException may be thrown
 229      */
 230     public byte[] acceptSecContext(InputStream is, int mechTokenSize)
 231                         throws GSSException;
 232 
 233     /**
 234      * Queries the context for largest data size to accommodate
 235      * the specified protection and for the token to remain less then
 236      * maxTokSize.
 237      *
 238      * @param qop the quality of protection that the context will be
 239      *    asked to provide.
 240      * @param confReq a flag indicating whether confidentiality will be
 241      *    requested or not
 242      * @param outputSize the maximum size of the output token
 243      * @return the maximum size for the input message that can be
 244      *    provided to the wrap() method in order to guarantee that these
 245      *    requirements are met.
 246      * @exception GSSException may be thrown
 247      */
 248     public int getWrapSizeLimit(int qop, boolean confReq, int maxTokSize)
 249                         throws GSSException;
 250 
 251     /**
 252      * Provides per-message token encapsulation.
 253      *
 254      * @param is the user-provided message to be protected
 255      * @param os the token to be sent to the peer. It includes
 256      *    the message from <i>is</i> with the requested protection.
 257      * @param msgPro on input it contains the requested qop and
 258      *    confidentiality state, on output, the applied values
 259      * @exception GSSException may be thrown
 260      * @see unwrap
 261      */
 262     public void wrap(InputStream is, OutputStream os, MessageProp msgProp)
 263         throws GSSException;
 264 
 265     /**
 266      * For apps that want simplicity and don't care about buffer copies.
 267      */
 268     public byte[] wrap(byte[] inBuf, int offset, int len,
 269                        MessageProp msgProp) throws GSSException;
 270 
 271     /**
 272      * For apps that care about buffer copies but either cannot use streams
 273      * or want to avoid them for whatever reason. (Say, they are using
 274      * block ciphers.)
 275      *
 276      * NOTE: This method is not defined in public class org.ietf.jgss.GSSContext
 277      *


 348      *
 349      * @param is the user-provided message
 350      * @param os the token to be sent to the peer along with the
 351      *    message token. The message token <b>is not</b> encapsulated.
 352      * @param msgProp on input the desired QOP and output the applied QOP
 353      * @exception GSSException
 354      */
 355     public void getMIC(InputStream is, OutputStream os,
 356                         MessageProp msgProp)
 357                 throws GSSException;
 358 
 359     public byte[] getMIC(byte[] inMsg, int offset, int len,
 360                          MessageProp msgProp) throws GSSException;
 361 
 362     /**
 363      * Checks the integrity of the supplied tokens.
 364      * This token was previously generated by getMIC.
 365      *
 366      * @param is token generated by getMIC
 367      * @param msgStr the message to check integrity for
 368      * @param msgProp will contain the applied QOP and confidentiality
 369      *    states of the token as well as any informatory status codes
 370      * @exception GSSException may be thrown
 371      */
 372     public void verifyMIC(InputStream is, InputStream msgStr,
 373                            MessageProp mProp) throws GSSException;
 374 
 375     public void verifyMIC(byte[] inTok, int tokOffset, int tokLen,
 376                           byte[] inMsg, int msgOffset, int msgLen,
 377                           MessageProp msgProp) throws GSSException;
 378 
 379     /**
 380      * Produces a token representing this context. After this call
 381      * the context will no longer be usable until an import is
 382      * performed on the returned token.
 383      *
 384      * @return exported context token
 385      * @exception GSSException may be thrown
 386      */
 387     public byte[] export() throws GSSException;
 388 

  34 import java.io.InputStream;
  35 import java.io.OutputStream;
  36 import java.security.Provider;
  37 
  38 /**
  39  * This interface is implemented by a mechanism specific instance of a GSS
  40  * security context.
  41  * A GSSContextSpi object can be thought of having 3 states:
  42  *    -before initialization
  43  *    -during initialization with its peer
  44  *    -after it is established
  45  * <p>
  46  * The context options can only be requested in state 1. In state 3,
  47  * the per message operations are available to the callers. The get
  48  * methods for the context options will return the requested options
  49  * while in state 1 and 2, and the established values in state 3.
  50  * Some mechanisms may allow the access to the per-message operations
  51  * and the context flags before the context is fully established. The
  52  * isProtReady method is used to indicate that these services are
  53  * available.
  54  * <p>
  55  * <strong>
  56  * Context establishment tokens are defined in a mechanism independent
  57  * format in section 3.1 of RFC 2743. The GSS-Framework will add
  58  * and remove the mechanism independent header portion of this token format
  59  * depending on whether a token is received or is being sent. The mechanism
  60  * should only generate or expect to read the inner-context token portion.
  61  * <br>
  62  * On the other hands, tokens used for per-message calls are generated
  63  * entirely by the mechanism. It is possible that the mechanism chooses to
  64  * encase inner-level per-message tokens in a header similar to that used
  65  * for initial tokens, however, this is upto the mechanism to do. The token
  66  * to/from the per-message calls are opaque to the GSS-Framework.
  67  * </strong>
  68  * <p>
  69  * An attempt has been made to allow for reading the peer's tokens from an
  70  * InputStream and writing tokens for the peer to an OutputStream. This
  71  * allows applications to pass in streams that are obtained from their network
  72  * connections and thus minimize the buffer copies that will happen. This
  73  * is especially important for tokens generated by wrap() which are
  74  * proportional in size to the length of the application data being
  75  * wrapped, and are probably also the most frequently used type of tokens.
  76  * <p>
  77  * It is anticipated that most applications will want to use wrap() in a
  78  * fashion where they obtain the application bytes to wrap from a byte[]
  79  * but want to output the wrap token straight to an
  80  * OutputStream. Similarly, they will want to use unwrap() where they read
  81  * the token directly form an InputStream but output it to some byte[] for


 222      * the GSS-Framework from the mechanism independent GSS-API level
 223      * header.
 224      * @return any inner-context token required to be sent to the peer as
 225      * part of a GSS token. The mechanism should not add the mechanism
 226      * independent part of the token. The GSS-Framework will add that on
 227      * the way out.
 228      * @exception GSSException may be thrown
 229      */
 230     public byte[] acceptSecContext(InputStream is, int mechTokenSize)
 231                         throws GSSException;
 232 
 233     /**
 234      * Queries the context for largest data size to accommodate
 235      * the specified protection and for the token to remain less then
 236      * maxTokSize.
 237      *
 238      * @param qop the quality of protection that the context will be
 239      *    asked to provide.
 240      * @param confReq a flag indicating whether confidentiality will be
 241      *    requested or not
 242      * @param maxTokSize the maximum size of the output token
 243      * @return the maximum size for the input message that can be
 244      *    provided to the wrap() method in order to guarantee that these
 245      *    requirements are met.
 246      * @exception GSSException may be thrown
 247      */
 248     public int getWrapSizeLimit(int qop, boolean confReq, int maxTokSize)
 249                         throws GSSException;
 250 
 251     /**
 252      * Provides per-message token encapsulation.
 253      *
 254      * @param is the user-provided message to be protected
 255      * @param os the token to be sent to the peer. It includes
 256      *    the message from <i>is</i> with the requested protection.
 257      * @param msgProp on input it contains the requested qop and
 258      *    confidentiality state, on output, the applied values
 259      * @exception GSSException may be thrown
 260      * @see unwrap
 261      */
 262     public void wrap(InputStream is, OutputStream os, MessageProp msgProp)
 263         throws GSSException;
 264 
 265     /**
 266      * For apps that want simplicity and don't care about buffer copies.
 267      */
 268     public byte[] wrap(byte[] inBuf, int offset, int len,
 269                        MessageProp msgProp) throws GSSException;
 270 
 271     /**
 272      * For apps that care about buffer copies but either cannot use streams
 273      * or want to avoid them for whatever reason. (Say, they are using
 274      * block ciphers.)
 275      *
 276      * NOTE: This method is not defined in public class org.ietf.jgss.GSSContext
 277      *


 348      *
 349      * @param is the user-provided message
 350      * @param os the token to be sent to the peer along with the
 351      *    message token. The message token <b>is not</b> encapsulated.
 352      * @param msgProp on input the desired QOP and output the applied QOP
 353      * @exception GSSException
 354      */
 355     public void getMIC(InputStream is, OutputStream os,
 356                         MessageProp msgProp)
 357                 throws GSSException;
 358 
 359     public byte[] getMIC(byte[] inMsg, int offset, int len,
 360                          MessageProp msgProp) throws GSSException;
 361 
 362     /**
 363      * Checks the integrity of the supplied tokens.
 364      * This token was previously generated by getMIC.
 365      *
 366      * @param is token generated by getMIC
 367      * @param msgStr the message to check integrity for
 368      * @param msgStr will contain the applied QOP and confidentiality
 369      *    states of the token as well as any informatory status codes
 370      * @exception GSSException may be thrown
 371      */
 372     public void verifyMIC(InputStream is, InputStream msgStr,
 373                            MessageProp mProp) throws GSSException;
 374 
 375     public void verifyMIC(byte[] inTok, int tokOffset, int tokLen,
 376                           byte[] inMsg, int msgOffset, int msgLen,
 377                           MessageProp msgProp) throws GSSException;
 378 
 379     /**
 380      * Produces a token representing this context. After this call
 381      * the context will no longer be usable until an import is
 382      * performed on the returned token.
 383      *
 384      * @return exported context token
 385      * @exception GSSException may be thrown
 386      */
 387     public byte[] export() throws GSSException;
 388 
< prev index next >