Source Code Cross Referenced for CertTemplate.java in  » Authentication-Authorization » ejbca » com » novosec » pkix » asn1 » crmf » 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 » Authentication Authorization » ejbca » com.novosec.pkix.asn1.crmf 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // CMP implementation copyright (c) 2003 NOVOSEC AG (http://www.novosec.com)
002:        //
003:        // Author: Maik Stohn
004:        //
005:        // Permission is hereby granted, free of charge, to any person obtaining a copy of this
006:        // software and associated documentation files (the "Software"), to deal in the Software
007:        // without restriction, including without limitation the rights to use, copy, modify, merge,
008:        // publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
009:        // to whom the Software is furnished to do so, subject to the following conditions:
010:        //
011:        // The above copyright notice and this permission notice shall be included in all copies or
012:        // substantial portions of the Software.
013:        //
014:        // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
015:        // BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
016:        // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
017:        // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
018:        // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
019:
020:        package com.novosec.pkix.asn1.crmf;
021:
022:        import java.util.Enumeration;
023:
024:        import org.bouncycastle.asn1.ASN1EncodableVector;
025:        import org.bouncycastle.asn1.ASN1Sequence;
026:        import org.bouncycastle.asn1.ASN1TaggedObject;
027:        import org.bouncycastle.asn1.DERBitString;
028:        import org.bouncycastle.asn1.DEREncodable;
029:        import org.bouncycastle.asn1.DERInteger;
030:        import org.bouncycastle.asn1.DERObject;
031:        import org.bouncycastle.asn1.DERSequence;
032:        import org.bouncycastle.asn1.DERTaggedObject;
033:        import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
034:        import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
035:        import org.bouncycastle.asn1.x509.X509Extensions;
036:        import org.bouncycastle.asn1.x509.X509Name;
037:
038:        /**
039:         * ASN.1 structure DER En/DeCoder.
040:         *
041:         * <pre>
042:         *   CertTemplate ::= SEQUENCE {
043:         *       version      [0] Version               OPTIONAL,
044:         *       serialNumber [1] INTEGER               OPTIONAL,
045:         *       signingAlg   [2] AlgorithmIdentifier   OPTIONAL,
046:         *       issuer       [3] Name                  OPTIONAL,
047:         *       validity     [4] OptionalValidity      OPTIONAL,
048:         *       subject      [5] Name                  OPTIONAL,
049:         *       publicKey    [6] SubjectPublicKeyInfo  OPTIONAL,
050:         *       issuerUID    [7] UniqueIdentifier      OPTIONAL,
051:         *       subjectUID   [8] UniqueIdentifier      OPTIONAL,
052:         *       extensions   [9] Extensions            OPTIONAL }
053:         *
054:         * </pre>
055:         */
056:        public class CertTemplate implements  DEREncodable {
057:            // name is not a choice type --> tag it implicit...no but it should be explicit?
058:            // Change to explicit by PrimeKey Solutions AB, Tomas Gustavsson
059:            public static final boolean bNameIsExplicit = true;
060:
061:            private DERInteger version = null;
062:            private DERInteger serialNumber = null;
063:            private AlgorithmIdentifier signingAlg = null;
064:            private X509Name issuer = null;
065:            private OptionalValidity validity = null;
066:            private X509Name subject = null;
067:            private SubjectPublicKeyInfo publicKey = null;
068:            private DERBitString issuerUID = null;
069:            private DERBitString subjectUID = null;
070:            private X509Extensions extensions = null;
071:
072:            public static CertTemplate getInstance(ASN1TaggedObject obj,
073:                    boolean explicit) {
074:                return getInstance(ASN1Sequence.getInstance(obj, explicit));
075:            }
076:
077:            public static CertTemplate getInstance(Object obj) {
078:                if (obj == null) {
079:                    return new CertTemplate();
080:                } else if (obj instanceof  CertTemplate) {
081:                    return (CertTemplate) obj;
082:                } else if (obj instanceof  ASN1Sequence) {
083:                    return new CertTemplate((ASN1Sequence) obj);
084:                } else {
085:                    throw new IllegalArgumentException(
086:                            "unknown object in factory");
087:                }
088:            }
089:
090:            public CertTemplate(ASN1Sequence seq) {
091:                Enumeration e = (seq == null ? null : seq.getObjects());
092:                while (e != null && e.hasMoreElements()) {
093:                    DERTaggedObject obj = (DERTaggedObject) e.nextElement();
094:                    int tagno = (obj == null ? -1 : obj.getTagNo());
095:                    switch (tagno) {
096:                    case 0:
097:                        this .version = DERInteger.getInstance(obj, false);
098:                        break;
099:                    case 1:
100:                        this .serialNumber = DERInteger.getInstance(obj, false);
101:                        break;
102:                    case 2:
103:                        this .signingAlg = AlgorithmIdentifier.getInstance(obj,
104:                                false);
105:                        break;
106:                    case 3:
107:                        this .issuer = X509Name
108:                                .getInstance(obj, bNameIsExplicit);
109:                        break;
110:                    case 4:
111:                        this .validity = OptionalValidity
112:                                .getInstance(obj, false);
113:                        break;
114:                    case 5:
115:                        this .subject = X509Name.getInstance(obj,
116:                                bNameIsExplicit);
117:                        break;
118:                    case 6:
119:                        this .publicKey = SubjectPublicKeyInfo.getInstance(obj,
120:                                false);
121:                        break;
122:                    case 7:
123:                        this .issuerUID = DERBitString.getInstance(obj, false);
124:                        break;
125:                    case 8:
126:                        this .subjectUID = DERBitString.getInstance(obj, false);
127:                        break;
128:                    case 9:
129:                        this .extensions = X509Extensions
130:                                .getInstance(obj, false);
131:                        break;
132:                    default:
133:                        throw new IllegalArgumentException(
134:                                "invalid asn1 sequence");
135:                    }
136:                }
137:            }
138:
139:            public CertTemplate() {
140:            }
141:
142:            public DERInteger getVersion() {
143:                return version;
144:            }
145:
146:            public void setVersion(DERInteger version) {
147:                this .version = version;
148:            }
149:
150:            public DERInteger getSerialNumber() {
151:                return serialNumber;
152:            }
153:
154:            public void setSerialNumber(DERInteger serialNumber) {
155:                this .serialNumber = serialNumber;
156:            }
157:
158:            public AlgorithmIdentifier getSigningAlg() {
159:                return signingAlg;
160:            }
161:
162:            public void setSigningAlg(AlgorithmIdentifier signingAlg) {
163:                this .signingAlg = signingAlg;
164:            }
165:
166:            public X509Name getIssuer() {
167:                return issuer;
168:            }
169:
170:            public void setIssuer(X509Name issuer) {
171:                this .issuer = issuer;
172:            }
173:
174:            public OptionalValidity getValidity() {
175:                return validity;
176:            }
177:
178:            public void setValidity(OptionalValidity validity) {
179:                this .validity = validity;
180:            }
181:
182:            public X509Name getSubject() {
183:                return subject;
184:            }
185:
186:            public void setSubject(X509Name subject) {
187:                this .subject = subject;
188:            }
189:
190:            public SubjectPublicKeyInfo getPublicKey() {
191:                return publicKey;
192:            }
193:
194:            public void setPublicKey(SubjectPublicKeyInfo publicKey) {
195:                this .publicKey = publicKey;
196:            }
197:
198:            public DERBitString getIssuerUID() {
199:                return issuerUID;
200:            }
201:
202:            public void setIssuerUID(DERBitString issuerUID) {
203:                this .issuerUID = issuerUID;
204:            }
205:
206:            public DERBitString getSubjectUID() {
207:                return subjectUID;
208:            }
209:
210:            public void setSubjectUID(DERBitString subjectUID) {
211:                this .subjectUID = subjectUID;
212:            }
213:
214:            public X509Extensions getExtensions() {
215:                return extensions;
216:            }
217:
218:            public void setExtensions(X509Extensions extensions) {
219:                this .extensions = extensions;
220:            }
221:
222:            public DERObject getDERObject() {
223:                ASN1EncodableVector v = new ASN1EncodableVector();
224:
225:                if (version != null)
226:                    v.add(new DERTaggedObject(false, 0, version));
227:                if (serialNumber != null)
228:                    v.add(new DERTaggedObject(false, 1, serialNumber));
229:                if (signingAlg != null)
230:                    v.add(new DERTaggedObject(false, 2, signingAlg));
231:                if (issuer != null)
232:                    v.add(new DERTaggedObject(bNameIsExplicit, 3, issuer));
233:                if (validity != null)
234:                    v.add(new DERTaggedObject(false, 4, validity));
235:                if (subject != null)
236:                    v.add(new DERTaggedObject(bNameIsExplicit, 5, subject));
237:                if (publicKey != null)
238:                    v.add(new DERTaggedObject(false, 6, publicKey));
239:                if (issuerUID != null)
240:                    v.add(new DERTaggedObject(false, 7, issuerUID));
241:                if (subjectUID != null)
242:                    v.add(new DERTaggedObject(false, 8, subjectUID));
243:                if (extensions != null)
244:                    v.add(new DERTaggedObject(false, 9, extensions));
245:
246:                return new DERSequence(v);
247:            }
248:
249:            public String toString() {
250:                StringBuffer sb = new StringBuffer(this .getClass().getName());
251:                sb.append(" (");
252:
253:                if (this .getVersion() != null)
254:                    sb.append("version: " + this .getVersion() + ", ");
255:
256:                if (this .getSerialNumber() != null)
257:                    sb.append("serialNumber: " + this .getSerialNumber() + ", ");
258:
259:                if (this .getSigningAlg() != null)
260:                    sb.append("signingAlg: " + this .getSigningAlg() + ", ");
261:
262:                if (this .getIssuer() != null)
263:                    sb.append("issuer: " + this .getIssuer() + ", ");
264:
265:                if (this .getValidity() != null)
266:                    sb.append("validity: " + this .getValidity() + ", ");
267:
268:                if (this .getSubject() != null)
269:                    sb.append("subject: " + this .getSubject() + ", ");
270:
271:                if (this .getPublicKey() != null)
272:                    sb.append("publicKey: " + this .getPublicKey() + ", ");
273:
274:                if (this .getIssuerUID() != null)
275:                    sb.append("issuerUID: " + this .getIssuerUID() + ", ");
276:
277:                if (this .getSubjectUID() != null)
278:                    sb.append("subjectUID: " + this .getSubjectUID() + ", ");
279:
280:                if (this .getExtensions() != null)
281:                    sb.append("extensions: " + this .getExtensions() + ", ");
282:
283:                sb.append("hashCode: " + Integer.toHexString(this .hashCode())
284:                        + ")");
285:                return sb.toString();
286:            }
287:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.