net.rim.device.api.crypto.tls
Class TLSAlertException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by net.rim.device.cldc.io.ssl.TLSException
              extended by net.rim.device.api.crypto.tls.TLSAlertException

public class TLSAlertException
extends TLSException

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." );
    }
 }
 

Category:
Signed: This element is only accessible by signed applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

Constructor Summary
Category: Signed TLSAlertException(byte alertLevel, byte alertDescription)
          Initializes the exception with the alert level and description that can be used when catching the exception later.
Category: Signed 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
Category: Signed  byte getAlertDescription()
          Returns the alert description that was used to instantiate this exception.
Category: Signed  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

TLSAlertException

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 applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

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 applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0


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 applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0

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 applications. If you intend to use this element, please visit http://www.blackberry.com/go/codesigning to obtain a set of code signing keys. Code signing is only required for applications running on BlackBerry smartphones; development on BlackBerry Smartphone Simulators can occur without code signing.
Since:
BlackBerry API 3.6.0





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