Source Code Cross Referenced for V2TBSCertListGenerator.java in  » Security » Bouncy-Castle » org » bouncycastle » asn1 » x509 » 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 » Security » Bouncy Castle » org.bouncycastle.asn1.x509 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.bouncycastle.asn1.x509;
002:
003:        import java.io.IOException;
004:        import java.util.Enumeration;
005:        import java.util.Vector;
006:
007:        import org.bouncycastle.asn1.ASN1EncodableVector;
008:        import org.bouncycastle.asn1.ASN1Sequence;
009:        import org.bouncycastle.asn1.DERGeneralizedTime;
010:        import org.bouncycastle.asn1.DERInteger;
011:        import org.bouncycastle.asn1.DEROctetString;
012:        import org.bouncycastle.asn1.DERSequence;
013:        import org.bouncycastle.asn1.DERTaggedObject;
014:        import org.bouncycastle.asn1.DERUTCTime;
015:
016:        /**
017:         * Generator for Version 2 TBSCertList structures.
018:         * <pre>
019:         *  TBSCertList  ::=  SEQUENCE  {
020:         *       version                 Version OPTIONAL,
021:         *                                    -- if present, shall be v2
022:         *       signature               AlgorithmIdentifier,
023:         *       issuer                  Name,
024:         *       thisUpdate              Time,
025:         *       nextUpdate              Time OPTIONAL,
026:         *       revokedCertificates     SEQUENCE OF SEQUENCE  {
027:         *            userCertificate         CertificateSerialNumber,
028:         *            revocationDate          Time,
029:         *            crlEntryExtensions      Extensions OPTIONAL
030:         *                                          -- if present, shall be v2
031:         *                                 }  OPTIONAL,
032:         *       crlExtensions           [0]  EXPLICIT Extensions OPTIONAL
033:         *                                          -- if present, shall be v2
034:         *                                 }
035:         * </pre>
036:         *
037:         * <b>Note: This class may be subject to change</b>
038:         */
039:        public class V2TBSCertListGenerator {
040:            DERInteger version = new DERInteger(1);
041:
042:            AlgorithmIdentifier signature;
043:            X509Name issuer;
044:            Time this Update, nextUpdate = null;
045:            X509Extensions extensions = null;
046:            private Vector crlentries = null;
047:
048:            public V2TBSCertListGenerator() {
049:            }
050:
051:            public void setSignature(AlgorithmIdentifier signature) {
052:                this .signature = signature;
053:            }
054:
055:            public void setIssuer(X509Name issuer) {
056:                this .issuer = issuer;
057:            }
058:
059:            public void setThisUpdate(DERUTCTime this Update) {
060:                this .this Update = new Time(this Update);
061:            }
062:
063:            public void setNextUpdate(DERUTCTime nextUpdate) {
064:                this .nextUpdate = new Time(nextUpdate);
065:            }
066:
067:            public void setThisUpdate(Time this Update) {
068:                this .this Update = this Update;
069:            }
070:
071:            public void setNextUpdate(Time nextUpdate) {
072:                this .nextUpdate = nextUpdate;
073:            }
074:
075:            public void addCRLEntry(ASN1Sequence crlEntry) {
076:                if (crlentries == null) {
077:                    crlentries = new Vector();
078:                }
079:
080:                crlentries.addElement(crlEntry);
081:            }
082:
083:            public void addCRLEntry(DERInteger userCertificate,
084:                    DERUTCTime revocationDate, int reason) {
085:                addCRLEntry(userCertificate, new Time(revocationDate), reason);
086:            }
087:
088:            public void addCRLEntry(DERInteger userCertificate,
089:                    Time revocationDate, int reason) {
090:                addCRLEntry(userCertificate, revocationDate, reason, null);
091:            }
092:
093:            public void addCRLEntry(DERInteger userCertificate,
094:                    Time revocationDate, int reason,
095:                    DERGeneralizedTime invalidityDate) {
096:                Vector extOids = new Vector();
097:                Vector extValues = new Vector();
098:
099:                if (reason != 0) {
100:                    CRLReason crlReason = new CRLReason(reason);
101:
102:                    try {
103:                        extOids.addElement(X509Extensions.ReasonCode);
104:                        extValues.addElement(new X509Extension(false,
105:                                new DEROctetString(crlReason.getEncoded())));
106:                    } catch (IOException e) {
107:                        throw new IllegalArgumentException(
108:                                "error encoding reason: " + e);
109:                    }
110:                }
111:
112:                if (invalidityDate != null) {
113:                    try {
114:                        extOids.addElement(X509Extensions.InvalidityDate);
115:                        extValues
116:                                .addElement(new X509Extension(false,
117:                                        new DEROctetString(invalidityDate
118:                                                .getEncoded())));
119:                    } catch (IOException e) {
120:                        throw new IllegalArgumentException(
121:                                "error encoding invalidityDate: " + e);
122:                    }
123:                }
124:
125:                if (extOids.size() != 0) {
126:                    addCRLEntry(userCertificate, revocationDate,
127:                            new X509Extensions(extOids, extValues));
128:                } else {
129:                    addCRLEntry(userCertificate, revocationDate, null);
130:                }
131:            }
132:
133:            public void addCRLEntry(DERInteger userCertificate,
134:                    Time revocationDate, X509Extensions extensions) {
135:                ASN1EncodableVector v = new ASN1EncodableVector();
136:
137:                v.add(userCertificate);
138:                v.add(revocationDate);
139:
140:                if (extensions != null) {
141:                    v.add(extensions);
142:                }
143:
144:                addCRLEntry(new DERSequence(v));
145:            }
146:
147:            public void setExtensions(X509Extensions extensions) {
148:                this .extensions = extensions;
149:            }
150:
151:            public TBSCertList generateTBSCertList() {
152:                if ((signature == null) || (issuer == null)
153:                        || (this Update == null)) {
154:                    throw new IllegalStateException(
155:                            "Not all mandatory fields set in V2 TBSCertList generator.");
156:                }
157:
158:                ASN1EncodableVector v = new ASN1EncodableVector();
159:
160:                v.add(version);
161:                v.add(signature);
162:                v.add(issuer);
163:
164:                v.add(this Update);
165:                if (nextUpdate != null) {
166:                    v.add(nextUpdate);
167:                }
168:
169:                // Add CRLEntries if they exist
170:                if (crlentries != null) {
171:                    ASN1EncodableVector certs = new ASN1EncodableVector();
172:                    Enumeration it = crlentries.elements();
173:                    while (it.hasMoreElements()) {
174:                        certs.add((ASN1Sequence) it.nextElement());
175:                    }
176:                    v.add(new DERSequence(certs));
177:                }
178:
179:                if (extensions != null) {
180:                    v.add(new DERTaggedObject(0, extensions));
181:                }
182:
183:                return new TBSCertList(new DERSequence(v));
184:            }
185:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.