Source Code Cross Referenced for X509Certificate.java in  » Apache-Harmony-Java-SE » javax-package » javax » security » cert » 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 » Apache Harmony Java SE » javax package » javax.security.cert 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:
018:        /**
019:         * @author Alexander Y. Kleymenov
020:         * @version $Revision$
021:         */package javax.security.cert;
022:
023:        import java.io.ByteArrayInputStream;
024:        import java.io.InputStream;
025:        import java.lang.reflect.Constructor;
026:        import java.math.BigInteger;
027:        import java.security.AccessController;
028:        import java.security.InvalidKeyException;
029:        import java.security.NoSuchAlgorithmException;
030:        import java.security.NoSuchProviderException;
031:        import java.security.Principal;
032:        import java.security.PublicKey;
033:        import java.security.Security;
034:        import java.security.SignatureException;
035:        import java.security.cert.CertificateFactory;
036:        import java.util.Date;
037:        import javax.security.cert.Certificate;
038:        import javax.security.cert.CertificateEncodingException;
039:        import javax.security.cert.CertificateException;
040:        import javax.security.cert.CertificateExpiredException;
041:        import javax.security.cert.CertificateNotYetValidException;
042:
043:        import org.apache.harmony.security.internal.nls.Messages;
044:
045:        /**
046:         * @com.intel.drl.spec_ref
047:         */
048:        public abstract class X509Certificate extends Certificate {
049:
050:            private static Constructor constructor;
051:
052:            static {
053:                try {
054:                    String classname = (String) AccessController
055:                            .doPrivileged(new java.security.PrivilegedAction() {
056:                                public Object run() {
057:                                    return Security
058:                                            .getProperty("cert.provider.x509v1"); //$NON-NLS-1$
059:                                }
060:                            });
061:                    Class cl = Class.forName(classname);
062:                    constructor = cl
063:                            .getConstructor(new Class[] { InputStream.class });
064:                } catch (Throwable e) {
065:                }
066:            }
067:
068:            /**
069:             * @com.intel.drl.spec_ref
070:             */
071:            public X509Certificate() {
072:                super ();
073:            }
074:
075:            /**
076:             * @com.intel.drl.spec_ref
077:             */
078:            public static final X509Certificate getInstance(InputStream inStream)
079:                    throws CertificateException {
080:                if (inStream == null) {
081:                    throw new CertificateException(Messages
082:                            .getString("security.87")); //$NON-NLS-1$
083:                }
084:                if (constructor != null) {
085:                    try {
086:                        return (X509Certificate) constructor
087:                                .newInstance(new Object[] { inStream });
088:                    } catch (Throwable e) {
089:                        throw new CertificateException(e.getMessage());
090:                    }
091:                }
092:
093:                final java.security.cert.X509Certificate cert;
094:                try {
095:                    CertificateFactory cf = CertificateFactory
096:                            .getInstance("X.509"); //$NON-NLS-1$
097:                    cert = (java.security.cert.X509Certificate) cf
098:                            .generateCertificate(inStream);
099:                } catch (java.security.cert.CertificateException e) {
100:                    throw new CertificateException(e.getMessage());
101:                }
102:
103:                return new X509Certificate() {
104:
105:                    public byte[] getEncoded()
106:                            throws CertificateEncodingException {
107:                        try {
108:                            return cert.getEncoded();
109:                        } catch (java.security.cert.CertificateEncodingException e) {
110:                            throw new CertificateEncodingException(e
111:                                    .getMessage());
112:                        }
113:                    }
114:
115:                    public void verify(PublicKey key)
116:                            throws CertificateException,
117:                            NoSuchAlgorithmException, InvalidKeyException,
118:                            NoSuchProviderException, SignatureException {
119:                        try {
120:                            cert.verify(key);
121:                        } catch (java.security.cert.CertificateException e) {
122:                            throw new CertificateException(e.getMessage());
123:                        }
124:                    }
125:
126:                    public void verify(PublicKey key, String sigProvider)
127:                            throws CertificateException,
128:                            NoSuchAlgorithmException, InvalidKeyException,
129:                            NoSuchProviderException, SignatureException {
130:                        try {
131:                            cert.verify(key, sigProvider);
132:                        } catch (java.security.cert.CertificateException e) {
133:                            throw new CertificateException(e.getMessage());
134:                        }
135:                    }
136:
137:                    public String toString() {
138:                        return cert.toString();
139:                    }
140:
141:                    public PublicKey getPublicKey() {
142:                        return cert.getPublicKey();
143:                    }
144:
145:                    public void checkValidity()
146:                            throws CertificateExpiredException,
147:                            CertificateNotYetValidException {
148:                        try {
149:                            cert.checkValidity();
150:                        } catch (java.security.cert.CertificateNotYetValidException e) {
151:                            throw new CertificateNotYetValidException(e
152:                                    .getMessage());
153:                        } catch (java.security.cert.CertificateExpiredException e) {
154:                            throw new CertificateExpiredException(e
155:                                    .getMessage());
156:                        }
157:                    }
158:
159:                    public void checkValidity(Date date)
160:                            throws CertificateExpiredException,
161:                            CertificateNotYetValidException {
162:                        try {
163:                            cert.checkValidity(date);
164:                        } catch (java.security.cert.CertificateNotYetValidException e) {
165:                            throw new CertificateNotYetValidException(e
166:                                    .getMessage());
167:                        } catch (java.security.cert.CertificateExpiredException e) {
168:                            throw new CertificateExpiredException(e
169:                                    .getMessage());
170:                        }
171:                    }
172:
173:                    public int getVersion() {
174:                        return 2;
175:                    }
176:
177:                    public BigInteger getSerialNumber() {
178:                        return cert.getSerialNumber();
179:                    }
180:
181:                    public Principal getIssuerDN() {
182:                        return cert.getIssuerDN();
183:                    }
184:
185:                    public Principal getSubjectDN() {
186:                        return cert.getSubjectDN();
187:                    }
188:
189:                    public Date getNotBefore() {
190:                        return cert.getNotBefore();
191:                    }
192:
193:                    public Date getNotAfter() {
194:                        return cert.getNotAfter();
195:                    }
196:
197:                    public String getSigAlgName() {
198:                        return cert.getSigAlgName();
199:                    }
200:
201:                    public String getSigAlgOID() {
202:                        return cert.getSigAlgOID();
203:                    }
204:
205:                    public byte[] getSigAlgParams() {
206:                        return cert.getSigAlgParams();
207:                    }
208:                };
209:            }
210:
211:            /**
212:             * @com.intel.drl.spec_ref
213:             */
214:            public static final X509Certificate getInstance(byte[] certData)
215:                    throws CertificateException {
216:                if (certData == null) {
217:                    throw new CertificateException(Messages
218:                            .getString("security.88")); //$NON-NLS-1$
219:                }
220:                ByteArrayInputStream bais = new ByteArrayInputStream(certData);
221:                return getInstance(bais);
222:            }
223:
224:            /**
225:             * @com.intel.drl.spec_ref
226:             */
227:            public abstract void checkValidity()
228:                    throws CertificateExpiredException,
229:                    CertificateNotYetValidException;
230:
231:            /**
232:             * @com.intel.drl.spec_ref
233:             */
234:            public abstract void checkValidity(Date date)
235:                    throws CertificateExpiredException,
236:                    CertificateNotYetValidException;
237:
238:            /**
239:             * @com.intel.drl.spec_ref
240:             */
241:            public abstract int getVersion();
242:
243:            /**
244:             * @com.intel.drl.spec_ref
245:             */
246:            public abstract BigInteger getSerialNumber();
247:
248:            /**
249:             * @com.intel.drl.spec_ref
250:             */
251:            public abstract Principal getIssuerDN();
252:
253:            /**
254:             * @com.intel.drl.spec_ref
255:             */
256:            public abstract Principal getSubjectDN();
257:
258:            /**
259:             * @com.intel.drl.spec_ref
260:             */
261:            public abstract Date getNotBefore();
262:
263:            /**
264:             * @com.intel.drl.spec_ref
265:             */
266:            public abstract Date getNotAfter();
267:
268:            /**
269:             * @com.intel.drl.spec_ref
270:             */
271:            public abstract String getSigAlgName();
272:
273:            /**
274:             * @com.intel.drl.spec_ref
275:             */
276:            public abstract String getSigAlgOID();
277:
278:            /**
279:             * @com.intel.drl.spec_ref
280:             */
281:            public abstract byte[] getSigAlgParams();
282:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.