|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--java.lang.Throwable
|
+--java.lang.Exception
|
+--net.rim.device.cldc.io.ssl.TLSException
|
+--net.rim.device.api.crypto.tls.TLSAlertException
Thrown when an alert is sent or received.
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." );
}
}
| 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 |
getException, toString |
| Methods inherited from class java.lang.Throwable |
getMessage, printStackTrace |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public TLSAlertException(byte alertLevel,
byte alertDescription)
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.
public TLSAlertException(byte alertLevel,
byte alertDescription,
String msg)
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.| Method Detail |
public byte getAlertDescription()
public byte getAlertLevel()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Copyright 1999-2008 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.