|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Throwable
java.lang.Exception
net.rim.device.cldc.io.ssl.TLSException
net.rim.device.api.crypto.tls.TLSAlertException
public class 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 occurred 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."); break; case AlertProtocol.CRITICAL: System.out.println( "This was a critical alert." ); break; case AlertProtocol.FATAL: System.out.println( "This is a fatal alert." ); break; default: System.out.println( "Unknown alert level." ); break; } // 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 getAlertLevel()
public byte getAlertDescription()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal