Top Description Fields Constructors Methods
sun.security.jgss.krb5

pack-priv Class WrapToken

extends MessageToken
Class Inheritance
Imports
org.ietf.jgss.*, sun.security.jgss.*, java.io.InputStream, .OutputStream, .IOException, .ByteArrayOutputStream, sun.security.krb5.Confounder

This class represents a token emitted by the GSSContext.wrap() call. It is a MessageToken except that it also contains plaintext or encrypted data at the end. A wrapToken has certain other rules that are peculiar to it and different from a MICToken, which is another type of MessageToken. All data in a WrapToken is prepended by a random counfounder of 8 bytes. All data in a WrapToken is also padded with one to eight bytes where all bytes are equal in value to the number of bytes being padded. Thus, all application data is replaced by (confounder || data || padding).
Author
Mayank Upadhyay

Field Summary

Modifier and TypeField and Description
pack-priv byte[]
pack-priv static final int
CONFOUNDER_SIZE

The size of the random confounder used in a WrapToken.

private byte[]
private int
private int
private final int
private InputStream
pack-priv byte[]
pack-priv static final byte[][]
private final boolean
private boolean
private byte[]
private int
private int
Inherited from sun.security.jgss.krb5.MessageToken:
cipherHelperSEAL_ALG_ARCFOUR_HMACSEAL_ALG_DESSEAL_ALG_DES3_KDSEAL_ALG_NONESGN_ALG_DES_MACSGN_ALG_DES_MAC_MD5SGN_ALG_HMAC_MD5_ARCFOURSGN_ALG_HMAC_SHA1_DES3_KD

Constructor Summary

AccessConstructor and Description
public
WrapToken(Krb5Context
the mechanism context associated with this token
context
,
byte[]
the bytes of the token
tokenBytes
,
int
the offset of the token
tokenOffset
,
int
the length of the token
tokenLen
,
MessageProp
the MessageProp into which characteristics of the parsed token will be stored.
prop
)

Constructs a WrapToken from token bytes obtained from the peer.

public
WrapToken(Krb5Context
the mechanism context associated with this token
context
,
InputStream
the InputStream containing the token bytes
is
,
MessageProp
the MessageProp into which characteristics of the parsed token will be stored.
prop
)

Constructs a WrapToken from token bytes read on the fly from an InputStream.

public
WrapToken(Krb5Context context, MessageProp prop, byte[] dataBytes, int dataOffset, int dataLen)

Method Summary

Modifier and TypeMethod and Description
public void
encode(OutputStream
the OutputStream to which this should be written
os
)

Overrides sun.security.jgss.krb5.MessageToken.encode.

Encodes a GSSHeader and this token onto an OutputStream.

public byte[]
public int
encode(byte[] outToken, int offset)

public byte[]

Returns:

a byte array containing the application data
getData
()

Obtains the application data that was transmitted in this WrapToken.

public int

Returns:

the size of the data written
getData
(byte[]
the output buffer into which the data must be written
dataBuf
,
int
the offset at which to write the data
dataBufOffset
)

Obtains the application data that was transmitted in this WrapToken, writing it into an application provided output array.

private void
getDataFromBuffer(byte[]
the output buffer into which the data must be written
dataBuf
,
int
the offset at which to write the data
dataBufOffset
)

Helper routine to obtain the application data transmitted in this WrapToken.

private void
getDataFromStream(byte[]
the output buffer into which the data must be written
dataBuf
,
int
the offset at which to write the data
dataBufOffset
)

Helper routine to obtain the application data transmitted in this WrapToken.

protected int
getKrb5TokenSize()

Overrides sun.security.jgss.krb5.MessageToken.getKrb5TokenSize.

Obtains the size of this token.

private byte[]

Returns:

the padding to be applied
getPadding
(int
the length of the application data
len
)

Helper routine to pick the right padding for a certain length of application data.

protected int
getSealAlg(boolean
true if the application desired confidentiality on this token, false otherwise
conf
,
int
the qop requested by the application
qop
)

Implements abstract sun.security.jgss.krb5.MessageToken.getSealAlg.

Obtains the encryption algorithm that should be used in this token given the state of confidentiality the application requested.

pack-priv static int
getSizeLimit(int qop, boolean confReq, int maxTokenSize, CipherHelper ch)

Inherited from sun.security.jgss.krb5.MessageToken:
genSignAndSeqNumbergetChecksumgetConfStategetEncSeqNumbergetGSSHeadergetSequenceNumbergetSgnAlggetTokenIdgetTokenSizegetTokenSizeverifySignAndSeqNumber

Field Detail

confounderback to summary
pack-priv byte[] confounder
CONFOUNDER_SIZEback to summary
pack-priv static final int CONFOUNDER_SIZE

The size of the random confounder used in a WrapToken.

dataBytesback to summary
private byte[] dataBytes
dataLenback to summary
private int dataLen
dataOffsetback to summary
private int dataOffset
dataSizeback to summary
private final int dataSize
isback to summary
private InputStream is
paddingback to summary
pack-priv byte[] padding
padsback to summary
pack-priv static final byte[][] pads
privacyback to summary
private final boolean privacy
readTokenFromInputStreamback to summary
private boolean readTokenFromInputStream
tokenBytesback to summary
private byte[] tokenBytes
tokenLenback to summary
private int tokenLen
tokenOffsetback to summary
private int tokenOffset

Constructor Detail

WrapTokenback to summary
public WrapToken(Krb5Context context, byte[] tokenBytes, int tokenOffset, int tokenLen, MessageProp prop) throws GSSException

Constructs a WrapToken from token bytes obtained from the peer.

Parameters
context:Krb5Context

the mechanism context associated with this token

tokenBytes:byte[]

the bytes of the token

tokenOffset:int

the offset of the token

tokenLen:int

the length of the token

prop:MessageProp

the MessageProp into which characteristics of the parsed token will be stored.

Exceptions
GSSException:
if the token is defective
WrapTokenback to summary
public WrapToken(Krb5Context context, InputStream is, MessageProp prop) throws GSSException

Constructs a WrapToken from token bytes read on the fly from an InputStream.

Parameters
context:Krb5Context

the mechanism context associated with this token

is:InputStream

the InputStream containing the token bytes

prop:MessageProp

the MessageProp into which characteristics of the parsed token will be stored.

Exceptions
GSSException:
if the token is defective or if there is a problem reading from the InputStream
WrapTokenback to summary
public WrapToken(Krb5Context context, MessageProp prop, byte[] dataBytes, int dataOffset, int dataLen) throws GSSException

Method Detail

encodeback to summary
public void encode(OutputStream os) throws IOException, GSSException

Overrides sun.security.jgss.krb5.MessageToken.encode.

Doc from sun.security.jgss.krb5.MessageToken.encode.

Encodes a GSSHeader and this token onto an OutputStream.

Parameters
os:OutputStream

the OutputStream to which this should be written

Exceptions
GSSException:
if an error occurs while writing to the OutputStream
encodeback to summary
public byte[] encode() throws IOException, GSSException
encodeback to summary
public int encode(byte[] outToken, int offset) throws IOException, GSSException
getDataback to summary
public byte[] getData() throws GSSException

Obtains the application data that was transmitted in this WrapToken.

Returns:byte[]

a byte array containing the application data

Exceptions
GSSException:
if an error occurs while decrypting any cipher text and checking for validity
getDataback to summary
public int getData(byte[] dataBuf, int dataBufOffset) throws GSSException

Obtains the application data that was transmitted in this WrapToken, writing it into an application provided output array.

Parameters
dataBuf:byte[]

the output buffer into which the data must be written

dataBufOffset:int

the offset at which to write the data

Returns:int

the size of the data written

Exceptions
GSSException:
if an error occurs while decrypting any cipher text and checking for validity
getDataFromBufferback to summary
private void getDataFromBuffer(byte[] dataBuf, int dataBufOffset) throws GSSException

Helper routine to obtain the application data transmitted in this WrapToken. It is called if the WrapToken was constructed with a byte array as input.

Parameters
dataBuf:byte[]

the output buffer into which the data must be written

dataBufOffset:int

the offset at which to write the data

Exceptions
GSSException:
if an error occurs while decrypting any cipher text and checking for validity
getDataFromStreamback to summary
private void getDataFromStream(byte[] dataBuf, int dataBufOffset) throws GSSException

Helper routine to obtain the application data transmitted in this WrapToken. It is called if the WrapToken was constructed with an Inputstream.

Parameters
dataBuf:byte[]

the output buffer into which the data must be written

dataBufOffset:int

the offset at which to write the data

Exceptions
GSSException:
if an error occurs while decrypting any cipher text and checking for validity
getKrb5TokenSizeback to summary
protected int getKrb5TokenSize() throws GSSException

Overrides sun.security.jgss.krb5.MessageToken.getKrb5TokenSize.

Doc from sun.security.jgss.krb5.MessageToken.getKrb5TokenSize.

Obtains the size of this token. Note that this excludes the size of the GSSHeader.

Returns:int

token size

getPaddingback to summary
private byte[] getPadding(int len)

Helper routine to pick the right padding for a certain length of application data. Every application message has some padding between 1 and 8 bytes.

Parameters
len:int

the length of the application data

Returns:byte[]

the padding to be applied

getSealAlgback to summary
protected int getSealAlg(boolean conf, int qop) throws GSSException

Implements abstract sun.security.jgss.krb5.MessageToken.getSealAlg.

Doc from sun.security.jgss.krb5.MessageToken.getSealAlg.

Obtains the encryption algorithm that should be used in this token given the state of confidentiality the application requested. Requested qop must be consistent with negotiated session key.

Parameters
conf:boolean

true if the application desired confidentiality on this token, false otherwise

qop:int

the qop requested by the application

Exceptions
GSSException:
if qop is incompatible with the negotiated session key
getSizeLimitback to summary
pack-priv static int getSizeLimit(int qop, boolean confReq, int maxTokenSize, CipherHelper ch) throws GSSException