APIdia Launch Partner
Top Description Fields Constructors Methods
sun.security.jgss

public Class GSSHeader

extends Object
Class Inheritance
Imports
org.ietf.jgss.GSSException, java.io.InputStream, .OutputStream, .IOException, sun.security.util.*

This class represents the mechanism independent part of a GSS-API context establishment token. Some mechanisms may choose to encode all subsequent tokens as well such that they start with an encoding of an instance of this class. e.g., The Kerberos v5 GSS-API Mechanism uses this header for all GSS-API tokens.

The format is specified in RFC 2743 section 3.1.

Author
Mayank Upadhyay

Field Summary

Modifier and TypeField and Description
private final ObjectIdentifier
private final byte[]
private final int
public static final int
TOKEN_ID

The tag defined in the GSS-API mechanism independent token format.

Constructor Summary

AccessConstructor and Description
public
GSSHeader(ObjectIdentifier
the Oid of the mechanism which generated the token
mechOid
,
int
the length of the subsequent portion that the mechanism will be adding.
mechTokenLength
)

Creates a GSSHeader instance whose encoding can be used as the prefix for a particular mechanism token.

public
GSSHeader(InputStream is)

Reads in a GSSHeader from an InputStream.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the number of bytes that are output as a result of this encoding
encode
(OutputStream
the OutputStream to which the token should be written.
os
)

Encodes this GSSHeader instance onto the provided OutputStream.

private int
getLenFieldSize(int len)

Used to determine the number of bytes that will be need to encode the length field of the GSSHeader.

public int

Returns:

the length of the encoding of this GSSHeader instance.
getLength
()

Used to obtain the length of the encoding of this GSSHeader.

private int

Returns:

the length or -1 if indefinite length found.
getLength
(InputStream in)

Get a length from the input stream, allowing for at most 32 bits of encoding to be used.

private int

Returns:

the length or -1 if indefinite length found.
getLength
(int lenByte, InputStream in)

Get a length from the input stream, allowing for at most 32 bits of encoding to be used.

public static int

Returns:

the maximum size of mechanism token that can be used so as to not exceed maxTotalSize with the GSS-API token
getMaxMechTokenSize
(ObjectIdentifier
the Oid of the mechanism that will generate this GSS-API token
mechOid
,
int
the pre-determined value that serves as a maximum size for the complete GSS-API token (including a GSSHeader)
maxTotalSize
)

Used to determine what the maximum possible mechanism token size is if the complete GSSToken returned to the application (including a GSSHeader) is not to exceed some pre-determined value in size.

public int

Returns:

the length of the mechanism specific token portion that will follow this GSSHeader.
getMechTokenLength
()

Used to obtain the length of the mechanism specific token that will follow the encoding of this GSSHeader instance.

public ObjectIdentifier

Returns:

the Oid of the mechanism.
getOid
()

Used to obtain the Oid stored in this GSSHeader instance.

private int

Returns:

the number of bytes written
putLength
(int
the length of the attribute.
len
,
OutputStream
the outputstream to write the length to
out
)

Put the encoding of the length in the specified stream.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

mechOidback to summary
private final ObjectIdentifier mechOid
mechOidBytesback to summary
private final byte[] mechOidBytes
mechTokenLengthback to summary
private final int mechTokenLength
TOKEN_IDback to summary
public static final int TOKEN_ID

The tag defined in the GSS-API mechanism independent token format.

Constructor Detail

GSSHeaderback to summary
public GSSHeader(ObjectIdentifier mechOid, int mechTokenLength) throws IOException

Creates a GSSHeader instance whose encoding can be used as the prefix for a particular mechanism token.

Parameters
mechOid:ObjectIdentifier

the Oid of the mechanism which generated the token

mechTokenLength:int

the length of the subsequent portion that the mechanism will be adding.

GSSHeaderback to summary
public GSSHeader(InputStream is) throws IOException, GSSException

Reads in a GSSHeader from an InputStream. Typically, this would be used as part of reading the complete token from an InputStream that is obtained from a socket.

Method Detail

encodeback to summary
public int encode(OutputStream os) throws IOException

Encodes this GSSHeader instance onto the provided OutputStream.

Parameters
os:OutputStream

the OutputStream to which the token should be written.

Returns:int

the number of bytes that are output as a result of this encoding

getLenFieldSizeback to summary
private int getLenFieldSize(int len)

Used to determine the number of bytes that will be need to encode the length field of the GSSHeader.

getLengthback to summary
public int getLength()

Used to obtain the length of the encoding of this GSSHeader.

Returns:int

the length of the encoding of this GSSHeader instance.

getLengthback to summary
private int getLength(InputStream in) throws IOException

Get a length from the input stream, allowing for at most 32 bits of encoding to be used. (Not the same as getting a tagged integer!)

Returns:int

the length or -1 if indefinite length found.

Exceptions
IOException:
on parsing error or unsupported lengths.
getLengthback to summary
private int getLength(int lenByte, InputStream in) throws IOException

Get a length from the input stream, allowing for at most 32 bits of encoding to be used. (Not the same as getting a tagged integer!)

Returns:int

the length or -1 if indefinite length found.

Exceptions
IOException:
on parsing error or unsupported lengths.
getMaxMechTokenSizeback to summary
public static int getMaxMechTokenSize(ObjectIdentifier mechOid, int maxTotalSize)

Used to determine what the maximum possible mechanism token size is if the complete GSSToken returned to the application (including a GSSHeader) is not to exceed some pre-determined value in size.

Parameters
mechOid:ObjectIdentifier

the Oid of the mechanism that will generate this GSS-API token

maxTotalSize:int

the pre-determined value that serves as a maximum size for the complete GSS-API token (including a GSSHeader)

Returns:int

the maximum size of mechanism token that can be used so as to not exceed maxTotalSize with the GSS-API token

getMechTokenLengthback to summary
public int getMechTokenLength()

Used to obtain the length of the mechanism specific token that will follow the encoding of this GSSHeader instance.

Returns:int

the length of the mechanism specific token portion that will follow this GSSHeader.

getOidback to summary
public ObjectIdentifier getOid()

Used to obtain the Oid stored in this GSSHeader instance.

Returns:ObjectIdentifier

the Oid of the mechanism.

putLengthback to summary
private int putLength(int len, OutputStream out) throws IOException

Put the encoding of the length in the specified stream.

Parameters
len:int

the length of the attribute.

out:OutputStream

the outputstream to write the length to

Returns:int

the number of bytes written

Exceptions
IOException:
on writing errors.