It contains the alert level and description of the alert so
the protocol can make an educated assessment as to what has
occurred and can act accordingly.
In order to determine exactly what error occured you will can
find the error code in the AlertProtocol interface. It contains
all of the possible levels and descriptions that could be thrown
on the device.
Here is some sample code to find out exactly what error code was
thrown.
...
} catch( TLSAlertException e ) {
// Deal with the exception.
// Find out what level the alert was sent as.
switch( e.getAlertLevel() ) {
case AlertProtocol.WARNING:
System.out.println( "This was only a warning alert.");
case AlertProtocol.CRITICAL:
System.out.println( "This was a critical alert." );
case AlertProtocol.FATAL:
System.out.println( "This is a fatal alert." );
default:
System.out.println( "Unknown alert level." );
}
// Now you can do the same sort of switch statement for the alert description
// or you can bunch them into categories that you are going to be interested in.
// For example, you only care if the alert came as something wrong with the
// certificate. So, you do the following:
int description = e.getAlertDescription();
if( description <= AlertProtocol.NO_CERTIFICATE && description > AlertProtocol.CERTIFICATE_UNKNOWN ) {
System.out.println( "We care about this alert because it involves certificates." );
}
}
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
Constructor Summary
TLSAlertException(byte alertLevel,
byte alertDescription)
Initializes the exception with the alert level and
description that can be used when catching the exception
later.
TLSAlertException(byte alertLevel,
byte alertDescription,
String msg)
Initializes the exception with the alert level and
description that can be used when catching the exception
later.
Method Summary
byte
getAlertDescription()
Returns the alert description that was used to instantiate
this exception.
byte
getAlertLevel()
Returns the alert level that was used to instantiate
this exception.
Methods inherited from class net.rim.device.cldc.io.ssl.TLSException
public TLSAlertException(byte alertLevel,
byte alertDescription)
Initializes the exception with the alert level and
description that can be used when catching the exception
later.
Parameters:
alertLevel - The alert level of the alert that was
either received or sent.
alertDescription - A description of the circumstances under which
the alert was
either sent or received.
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
TLSAlertException
public TLSAlertException(byte alertLevel,
byte alertDescription,
String msg)
Initializes the exception with the alert level and
description that can be used when catching the exception
later.
Parameters:
alertLevel - The alert level of the alert that was
either received or sent.
alertDescription - A description of the alert that was
either sent or received.
msg - A descriptive String representing the circumstances of the alert.
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
Method Detail
getAlertLevel
public byte getAlertLevel()
Returns the alert level that was used to instantiate
this exception.
Returns:
A byte representing the alert level of the exception.
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
getAlertDescription
public byte getAlertDescription()
Returns the alert description that was used to instantiate
this exception.
Returns:
A byte representing the alert level of the exception.
Category:
Signed: This element is only accessible by signed clients. If you intend to use this element, please contact RIM to establish the necessary agreements that will allow you to have your COD files signed. Signing is only required for use on the device, development under the JDE can occur without signing the CODs.
Copyright 1999-2002 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved. Copyright 1993-2000 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved. Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.