1 19 20 package com.maverick.ssl; 21 22 import java.text.MessageFormat ; 23 24 29 public class SSLException extends Exception { 30 31 34 public static final int CLOSE_NOTIFY = 0; 35 public static final int UNEXPECTED_MESSAGE = 10; 36 public static final int BAD_RECORD_MAC = 20; 37 public static final int DECOMPRESSION_FAILURE = 30; 38 public static final int HANDSHAKE_FAILURE = 40; 39 public static final int NO_CERTIFICATE = 41; 40 public static final int BAD_CERTIFICATE = 42; 41 public static final int UNSUPPORTED_CERTIFICATE = 43; 42 public static final int CERTIFICATE_REVOKED = 44; 43 public static final int CERTIFICATE_EXPIRED = 45; 44 public static final int CERTIFICATE_UNKNOWN = 46; 45 46 49 public static final int PROTOCOL_VIOLATION = 999; 50 public static final int UNSUPPORTED_OPERATION = 998; 51 public static final int INTERNAL_ERROR = 997; 52 public static final int UNEXPECTED_TERMINATION = 996; 53 public static final int READ_TIMEOUT = 997; 54 55 int status; 56 57 public SSLException(int status) { 58 super(getDescription(status)); 59 this.status = status; 60 } 61 62 public SSLException(int status, String msg) { 63 super(msg); 64 this.status = status; 65 } 66 67 public int getStatus() { 68 return status; 69 } 70 71 public static String getDescription(int status) { 72 switch (status) { 73 case CLOSE_NOTIFY: 74 return Messages.getString("SSLException.remoteSideClosedConnection"); case UNEXPECTED_MESSAGE: 76 return Messages.getString("SSLException.unexpectedMessage"); case BAD_RECORD_MAC: 78 return Messages.getString("SSLException.badRecordMAC"); case DECOMPRESSION_FAILURE: 80 return Messages.getString("SSLException.decompressionFailure"); case HANDSHAKE_FAILURE: 82 return Messages.getString("SSLException.handshakeFailure"); case NO_CERTIFICATE: 84 return Messages.getString("SSLException.noCert"); case BAD_CERTIFICATE: 86 return Messages.getString("SSLException.badCert"); case UNSUPPORTED_CERTIFICATE: 88 return Messages.getString("SSLException.unsupportedCert"); case CERTIFICATE_REVOKED: 90 return Messages.getString("SSLException.certRevoked"); case CERTIFICATE_EXPIRED: 92 return Messages.getString("SSLException.certExpired"); case CERTIFICATE_UNKNOWN: 94 return Messages.getString("SSLException.certUnknown"); case PROTOCOL_VIOLATION: 96 return Messages.getString("SSLException.protocolViolation"); case READ_TIMEOUT: 98 return Messages.getString("SSLException.readTimeout"); default: 100 return MessageFormat.format(Messages.getString("SSLException.unexpectedStatusError"), new Object [] { new Integer (status) }); 102 } 103 } 104 105 } 106 | Popular Tags |