com.sap.security.api.ticket

Class InfoUnit

java.lang.Object
  extended by com.sap.security.api.ticket.InfoUnit

public class InfoUnit
extends Object

An InfoUnit is the basic data type for storing information in SAP logon tickets. You need to use it if you want to retrieve information from the ticket other than the those available by API calls like TicketVerifier.getUser(), TicketVerifier.isValid().

Format of InfoUnits on Disk:

LengthTypeName
1INT1ID of InfoUnit (see ID_xxxx)
2INT2Length n of Content in bytes
<INT2 bytes>see belowContent (Type depends on ID)

Types of InfoUnits used in SAP Logon Ticket:

IDTypeName
ID_USERCHARUser name
ID_CREATE_CLIENTCHARSystemID of issuing System
ID_CREATE_NAMECHARSystemID of issuing System
ID_CREATE_TIMECHARCreation time of Ticket as String "yyyymmddhhmm"
ID_VALID_TIMEINT4Valid time (hours)
ID_VALID_TIME_MININT4Valid time (minutes)
ID_RFCCHARRFC Ticket
ID_FLAGSRAWFlags
ID_SIGNATURERAWPKCS#7 Signature
ID_LANGUAGECHARdefault language of the user
ID_USER_UTFUTF8user name (utf-8 encoded)
ID_AUTHSCHEMEUTF8Specifies which autscheme has been satisfied during logon
ID_RECIPIENT_CLIENTUTF8Specifies the recipient client of the assertion ticket.
ID_RECIPIENT_SIDUTF8Specifies the recipient system of the assertion ticket.

The values from 0x20 to 0x40 are reserved for additional user id. Currently, only 0x20 is used (by a portal user id which might differ from the SAP system user id). For the above identifiers the data types are as follows. INT4 denotes a 4-byte integer. RAW denotes a byte array, UTF8 denotes UTF-8 encoding. CHAR means that the infounit's content is a string value, encoded using an SAP codepage that you can get from the ticket. In order to get a java.lang.String object, please use one of the following methods:

By default, the tickets are created with SAP codepage 1100 (this is the equivalent of ISO 8859-1). However, you might get a ticket that has been created with a different codepage. For this case, here's a list of the most commonly used codepages:
SAP codepage numbercorresponding non-SAP codepage
4110UTF8
1100ISO8859_1
1140ISO8859_1
1401ISO8859_2
1500ISO8859_5
1610ISO8859_9
1700ISO8859_7
1800ISO8859_8
1900ISO8859_4
8200ISO2022JP
8700ISO8859_4
0120Cp500
1103Cp850
1160windows-1252
1404Cp1250
1504Cp1251
1614Cp1254
1704Cp1253
1804Cp1255
1904Cp1257
8604Cp874
8704Cp1256
8000SJIS
8100EUC_JP
8300Big5
8600TIS620


Field Summary
static HashMap codepageEncoding
          Map used to convert an SAP codepage into a ISO or window codepage.
static int ID_AUTHSCHEME
          see here for details.
static int ID_CREATE_CLIENT
          see here for details.
static int ID_CREATE_CLIENT_UTF
          see here for details.
static int ID_CREATE_NAME
          see here for details.
static int ID_CREATE_NAME_UTF
          see here for details.
static int ID_CREATE_TIME
          see here for details.
static int ID_CREATE_TIME_UTF
          see here for details.
static int ID_FLAGS
          see here for details.
static int ID_LANGUAGE
          see here for details.
static int ID_LANGUAGE_UTF
          see here for details.
static int ID_RECIPIENT_CLIENT
          see here for details.
static int ID_RECIPIENT_SID
          see here for details.
static int ID_RFC
          see here for details.
static int ID_SIGNATURE
          see here for details.
static int ID_USER
          see here for details.
static int ID_USER_UTF
          see here for details.
static int ID_VALID_TIME
          see here for details.
static int ID_VALID_TIME_MIN
          see here for details.
 
Constructor Summary
InfoUnit(InputStream in, int id, int len)
          Utility method.
InfoUnit(int id, byte[] data)
          Utility method.
 
Method Summary
static int bytesToInt(byte[] buffer)
          Transform a byte array into an int.
static int bytesToInt(byte[] buffer, int offset, int length)
          Transform part of a byte array to an integer.
static String bytesToString(byte[] buffer, int offset, int length, String encoding)
          Converts a byte array into a string.
static String bytesToString(byte[] buffer, String encoding)
          Converts a byte array into a string.
 byte[] getContent()
          Gets the content of an info unit.
 int getID()
          Get the ID of this InfoUnit.
 int getInt()
          Gets the content of an info unit as integer.
 String getString(String encoding)
          Get the Content of this InfoUnit as String.
static byte[] IntToBytes(int i)
          Transforms an integer into a byte array.
static byte[] jcharToSAPCP(String source, String SAPCodepage)
          Converts a java String to a byte array.
static byte[] jcharToUTF8(String source)
          Converts a java String to a byte array.
static InfoUnit readInfoUnit(InputStream in)
          Utility method.
static byte[] readRaw(InputStream in, int n)
          Utility method.
 void writeTo(OutputStream out)
          Utility method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ID_USER

public static final int ID_USER
see here for details.

See Also:
Constant Field Values

ID_CREATE_CLIENT

public static final int ID_CREATE_CLIENT
see here for details.

See Also:
Constant Field Values

ID_CREATE_NAME

public static final int ID_CREATE_NAME
see here for details.

See Also:
Constant Field Values

ID_CREATE_TIME

public static final int ID_CREATE_TIME
see here for details.

See Also:
Constant Field Values

ID_VALID_TIME

public static final int ID_VALID_TIME
see here for details.

See Also:
Constant Field Values

ID_RFC

public static final int ID_RFC
see here for details.

See Also:
Constant Field Values

ID_VALID_TIME_MIN

public static final int ID_VALID_TIME_MIN
see here for details.

See Also:
Constant Field Values

ID_FLAGS

public static final int ID_FLAGS
see here for details.

See Also:
Constant Field Values

ID_SIGNATURE

public static final int ID_SIGNATURE
see here for details.

See Also:
Constant Field Values

ID_LANGUAGE

public static final int ID_LANGUAGE
see here for details.

See Also:
Constant Field Values

ID_USER_UTF

public static final int ID_USER_UTF
see here for details.

See Also:
Constant Field Values

ID_CREATE_CLIENT_UTF

public static final int ID_CREATE_CLIENT_UTF
see here for details.

See Also:
Constant Field Values

ID_CREATE_NAME_UTF

public static final int ID_CREATE_NAME_UTF
see here for details.

See Also:
Constant Field Values

ID_CREATE_TIME_UTF

public static final int ID_CREATE_TIME_UTF
see here for details.

See Also:
Constant Field Values

ID_LANGUAGE_UTF

public static final int ID_LANGUAGE_UTF
see here for details.

See Also:
Constant Field Values

ID_AUTHSCHEME

public static final int ID_AUTHSCHEME
see here for details.

See Also:
Constant Field Values

ID_RECIPIENT_CLIENT

public static final int ID_RECIPIENT_CLIENT
see here for details.

See Also:
Constant Field Values

ID_RECIPIENT_SID

public static final int ID_RECIPIENT_SID
see here for details.

See Also:
Constant Field Values

codepageEncoding

public static HashMap codepageEncoding
Map used to convert an SAP codepage into a ISO or window codepage. For use by the java method String.getBytes(java.lang.String)

Constructor Detail

InfoUnit

public InfoUnit(InputStream in,
                int id,
                int len)
         throws IOException
Utility method.

Throws:
IOException

InfoUnit

public InfoUnit(int id,
                byte[] data)
Utility method.

Method Detail

getID

public int getID()
Get the ID of this InfoUnit. See identifiers

Returns:
the identifier of the info unit.

getContent

public byte[] getContent()
Gets the content of an info unit. The contents are returned as a byte array.

Returns:
content as byte array.

getString

public String getString(String encoding)
                 throws UnsupportedEncodingException
Get the Content of this InfoUnit as String.

Parameters:
encoding - java codepage for encoding
Throws:
UnsupportedEncodingException - if the encoding is unknown

getInt

public int getInt()
Gets the content of an info unit as integer. This call makes only sense for those info units whose type is INT4 (see table).

Returns:
info unit's integer value

writeTo

public void writeTo(OutputStream out)
             throws IOException
Utility method.

Throws:
IOException

readInfoUnit

public static InfoUnit readInfoUnit(InputStream in)
                             throws IOException
Utility method.

Throws:
IOException

bytesToInt

public static int bytesToInt(byte[] buffer)
Transform a byte array into an int. Makes only sense for units of type INT4.

Parameters:
buffer - byte array of length 4 from an info unit

bytesToInt

public static int bytesToInt(byte[] buffer,
                             int offset,
                             int length)
Transform part of a byte array to an integer. Same as bytesToInt(byte[]) but with a byte array region instead of an entire byte array.

Parameters:
buffer - byte array
offset - offset into the array
length - should be equal to 4

IntToBytes

public static byte[] IntToBytes(int i)
Transforms an integer into a byte array. The int is encoded as an platform independant byte array. This function is the counterpart of bytesToInt(byte[])

Parameters:
i - int to convert to
Returns:
byte array

bytesToString

public static String bytesToString(byte[] buffer,
                                   String encoding)
                            throws UnsupportedEncodingException
Converts a byte array into a string. The specified encoding is used.

Parameters:
buffer - encoded string
encoding - used encoding This parameter will be passed to the InputStreamReader.InputStreamReader(InputStream,String) constructor. See also TicketVerifier.getCodepage() and encodings.
Throws:
UnsupportedEncodingException - if the encoding is unknown

bytesToString

public static String bytesToString(byte[] buffer,
                                   int offset,
                                   int length,
                                   String encoding)
                            throws UnsupportedEncodingException
Converts a byte array into a string. Same as bytesToString(byte[], String) but with a byte array region instead of an entire byte array.

Throws:
UnsupportedEncodingException - if the encoding is unknown

readRaw

public static byte[] readRaw(InputStream in,
                             int n)
                      throws IOException
Utility method.

Throws:
IOException

jcharToSAPCP

public static byte[] jcharToSAPCP(String source,
                                  String SAPCodepage)
                           throws UnsupportedEncodingException,
                                  IOException
Converts a java String to a byte array. The specified SAP codepage is used as encoding. (This is the counter part of bytesToString(byte[], String)).

Throws:
UnsupportedEncodingException
IOException

jcharToUTF8

public static byte[] jcharToUTF8(String source)
                          throws UnsupportedEncodingException,
                                 IOException
Converts a java String to a byte array. Simply calls return jcharToSAPCP (source, "4110"); see jcharToSAPCP(String, String).

Throws:
UnsupportedEncodingException
IOException
Access Rights

This class can be accessed from:


SC DC
[sap.com] ENGINEAPI [sap.com] com.sap.security.api.sda
[sap.com] ENGFACADE [sap.com] tc/je/usermanagement/api
[sap.com] CORE-TOOLS [sap.com] com.sap.engine.client.lib


Copyright 2010 SAP AG Complete Copyright Notice