SHOW Signed
 

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

java.lang.Object
  |
  +--java.lang.Throwable
        |
        +--java.lang.Exception
              |
              +--net.rim.device.cldc.io.ssl.TLSException
                    |
                    +--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 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 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:
JDE 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.
Since:
JDE 3.6.0
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.

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.
Since:
JDE 3.6.0
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.
Method Detail

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.
Since:
JDE 3.6.0
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.

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.
Since:
JDE 3.6.0
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.



Copyright 1999-2009 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.