Source Code Cross Referenced for CertificateException.java in  » Portal » Open-Portal » com » sun » portal » microedition » pki » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » Open Portal » com.sun.portal.microedition.pki 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)CertificateException.java	1.22 02/07/24 @(#)
003:         *
004:         * Copyright (c) 2001-2002 Sun Microsystems, Inc.  All rights reserved.
005:         * PROPRIETARY/CONFIDENTIAL
006:         * Use is subject to license terms.
007:         */
008:
009:        package com.sun.portal.microedition.pki;
010:
011:        import com.sun.portal.microedition.pki.Certificate;
012:
013:        import java.lang.String;
014:
015:        /**
016:         * The <CODE>CertificateException</CODE> encapsulates an error that
017:         * occurred while a <CODE>Certificate</CODE> is being used.  If multiple errors
018:         * are found within a <CODE>Certificate</CODE> the more significant error
019:         * should be reported in the exception. 
020:         * @since MIDP 2.0
021:         */
022:        public class CertificateException extends java.io.IOException {
023:
024:            /** The reason code for this exception */
025:            private byte reason;
026:
027:            /**
028:             * The certificate that caused the exception
029:             */
030:            private Certificate cert;
031:
032:            /**
033:             * Indicates a certificate has unrecognized critical extensions.
034:             * The value is 1.
035:             */
036:            public static final byte BAD_EXTENSIONS = 1;
037:
038:            /** 
039:             * Indicates the server certificate chain exceeds the length allowed
040:             * by an issuer's policy.
041:             * The value is 2.
042:             */
043:            public static final byte CERTIFICATE_CHAIN_TOO_LONG = 2;
044:
045:            /**
046:             * Indicates a certificate is expired.
047:             * The value is 3.
048:             */
049:            public static final byte EXPIRED = 3;
050:
051:            /**
052:             * Indicates an intermediate certificate in the chain does not have the
053:             * authority to be a intermediate CA. The value is 4.
054:             */
055:            public static final byte UNAUTHORIZED_INTERMEDIATE_CA = 4;
056:
057:            /**
058:             * Indicates a certificate object does not contain a signature.
059:             * The value is 5.
060:             */
061:            public static final byte MISSING_SIGNATURE = 5;
062:
063:            /**
064:             * Indicates a certificate is not yet valid.
065:             * The value is 6.
066:             */
067:            public static final byte NOT_YET_VALID = 6;
068:
069:            /**
070:             * Indicates a certificate does not contain the correct site name.
071:             * The value is 7.
072:             */
073:            public static final byte SITENAME_MISMATCH = 7;
074:
075:            /**
076:             * Indicates a certificate was issued by an unrecognized entity.
077:             * The value is 8.
078:             */
079:            public static final byte UNRECOGNIZED_ISSUER = 8;
080:
081:            /**
082:             * Indicates a certificate was signed using an unsupported algorithm.
083:             * The value is 9.
084:             */
085:            public static final byte UNSUPPORTED_SIGALG = 9;
086:
087:            /**
088:             * Indicates a certificate public key has been used in way deemed
089:             * inappropriate by the issuer. The value is 10.
090:             */
091:            public static final byte INAPPROPRIATE_KEY_USAGE = 10;
092:
093:            /**
094:             * Indicates a certificate in a chain was not issued by the next
095:             * authority in the chain. The value is 11.
096:             */
097:            public static final byte BROKEN_CHAIN = 11;
098:
099:            /**
100:             * Indicates the root CA's public key is expired. The value is 12.
101:             */
102:            public static final byte ROOT_CA_EXPIRED = 12;
103:
104:            /**
105:             * Indicates that type of the public key in a certificate is not
106:             * supported by the device. The value is 13.
107:             */
108:            public static final byte UNSUPPORTED_PUBLIC_KEY_TYPE = 13;
109:
110:            /**
111:             * Indicates a certificate failed verification.
112:             * The value is 14.
113:             */
114:            public static final byte VERIFICATION_FAILED = 14;
115:
116:            /**
117:             * Create a new exception with a <CODE>Certificate</CODE>
118:             * and specific error reason. The descriptive message for the new exception
119:             * will be automatically provided, based on the reason.
120:             * @param certificate the certificate that caused the exception
121:             * @param status the reason for the exception;
122:             *  the status MUST be between BAD_EXTENSIONS and VERIFICATION_FAILED
123:             *  inclusive.
124:             */
125:            public CertificateException(Certificate certificate, byte status) {
126:                super (getMessageForReason(status));
127:                cert = certificate;
128:                reason = status;
129:            }
130:
131:            /**
132:             * Create a new exception with a message, <CODE>Certificate</CODE>,
133:             * and specific error reason.
134:             * @param message a descriptive message
135:             * @param certificate the certificate that caused the exception
136:             * @param status the reason for the exception;
137:             *  the status MUST be between BAD_EXTENSIONS and VERIFICATION_FAILED
138:             *  inclusive.
139:             */
140:            public CertificateException(String message,
141:                    Certificate certificate, byte status) {
142:                super (message);
143:                cert = certificate;
144:                reason = status;
145:            }
146:
147:            /**
148:             * Get the <CODE>Certificate</CODE> that caused the exception.
149:             * @return the <CODE>Certificate</CODE> that included the failure.
150:             */
151:            public Certificate getCertificate() {
152:                return cert;
153:            }
154:
155:            /**
156:             * Get the reason code.
157:             * @return the reason code
158:             */
159:            public byte getReason() {
160:                return reason;
161:            }
162:
163:            // package private methods //
164:
165:            /**
166:             * Gets the exception message for a reason.
167:             *
168:             * @param reason reason code
169:             *
170:             * @return exception message
171:             */
172:            static String getMessageForReason(int reason) {
173:                switch (reason) {
174:                case BAD_EXTENSIONS:
175:                    return "Certificate has unrecognized critical extensions";
176:
177:                case CERTIFICATE_CHAIN_TOO_LONG:
178:                    return "Server certificate chain exceeds the length allowed "
179:                            + "by an issuer's policy";
180:
181:                case EXPIRED:
182:                    return "Certificate is expired";
183:
184:                case UNAUTHORIZED_INTERMEDIATE_CA:
185:                    return "Intermediate certificate in the chain does not have the "
186:                            + "authority to be an intermediate CA";
187:
188:                case MISSING_SIGNATURE:
189:                    return "Certificate object does not contain a signature";
190:
191:                case NOT_YET_VALID:
192:                    return "Certificate is not yet valid";
193:
194:                case SITENAME_MISMATCH:
195:                    return "Certificate does not contain the correct site name";
196:
197:                case UNRECOGNIZED_ISSUER:
198:                    return "Certificate was issued by an unrecognized entity";
199:
200:                case UNSUPPORTED_SIGALG:
201:                    return "Certificate was signed using an unsupported algorithm";
202:
203:                case INAPPROPRIATE_KEY_USAGE:
204:                    return "Certificate's public key has been used in a way deemed "
205:                            + "inappropriate by the issuer";
206:
207:                case BROKEN_CHAIN:
208:                    return "Certificate in a chain was not issued by the next "
209:                            + "authority in the chain";
210:
211:                case ROOT_CA_EXPIRED:
212:                    return "Root CA's public key is expired";
213:
214:                case UNSUPPORTED_PUBLIC_KEY_TYPE:
215:                    return "Certificate has a public key that is not a "
216:                            + "supported type";
217:
218:                case VERIFICATION_FAILED:
219:                    return "Certificate failed verification";
220:                }
221:
222:                return "Unknown reason (" + reason + ")";
223:            }
224:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.