|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 package javax.microedition.pki; |
|
20 |
|
21 import java.io.IOException; |
|
22 |
|
23 public class CertificateException |
|
24 extends IOException |
|
25 { |
|
26 public static final byte BAD_EXTENSIONS = 1; |
|
27 public static final byte CERTIFICATE_CHAIN_TOO_LONG = 2; |
|
28 public static final byte EXPIRED = 3; |
|
29 public static final byte UNAUTHORIZED_INTERMEDIATE_CA = 4; |
|
30 public static final byte MISSING_SIGNATURE = 5; |
|
31 public static final byte NOT_YET_VALID = 6; |
|
32 public static final byte SITENAME_MISMATCH = 7; |
|
33 public static final byte UNRECOGNIZED_ISSUER = 8; |
|
34 public static final byte UNSUPPORTED_SIGALG = 9; |
|
35 public static final byte INAPPROPRIATE_KEY_USAGE = 10; |
|
36 public static final byte BROKEN_CHAIN = 11; |
|
37 public static final byte ROOT_CA_EXPIRED = 12; |
|
38 public static final byte UNSUPPORTED_PUBLIC_KEY_TYPE = 13; |
|
39 public static final byte VERIFICATION_FAILED = 14; |
|
40 |
|
41 |
|
42 |
|
43 private final Certificate iCert; |
|
44 private final byte iReason; |
|
45 |
|
46 |
|
47 |
|
48 public CertificateException(Certificate aCert, byte aReason) |
|
49 { |
|
50 this(null, aCert, aReason); |
|
51 } |
|
52 |
|
53 |
|
54 |
|
55 public CertificateException(String aMessage, Certificate aCert, byte aReason) |
|
56 { |
|
57 super(aMessage); |
|
58 iCert = aCert; |
|
59 switch (aReason) |
|
60 { |
|
61 case BAD_EXTENSIONS: |
|
62 case CERTIFICATE_CHAIN_TOO_LONG: |
|
63 case EXPIRED: |
|
64 case UNAUTHORIZED_INTERMEDIATE_CA: |
|
65 case MISSING_SIGNATURE: |
|
66 case NOT_YET_VALID: |
|
67 case SITENAME_MISMATCH: |
|
68 case UNRECOGNIZED_ISSUER: |
|
69 case UNSUPPORTED_SIGALG: |
|
70 case INAPPROPRIATE_KEY_USAGE: |
|
71 case BROKEN_CHAIN: |
|
72 case ROOT_CA_EXPIRED: |
|
73 case UNSUPPORTED_PUBLIC_KEY_TYPE: |
|
74 case VERIFICATION_FAILED: |
|
75 iReason = aReason; |
|
76 break; |
|
77 default: |
|
78 throw new IllegalArgumentException(); |
|
79 } |
|
80 } |
|
81 |
|
82 |
|
83 |
|
84 public Certificate getCertificate() |
|
85 { |
|
86 return iCert; |
|
87 } |
|
88 |
|
89 |
|
90 |
|
91 public byte getReason() |
|
92 { |
|
93 return iReason; |
|
94 } |
|
95 } |