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


001:        package org.bouncycastle.asn1.tsp;
002:
003:        import org.bouncycastle.asn1.ASN1Encodable;
004:        import org.bouncycastle.asn1.ASN1EncodableVector;
005:        import org.bouncycastle.asn1.ASN1InputStream;
006:        import org.bouncycastle.asn1.ASN1OctetString;
007:        import org.bouncycastle.asn1.ASN1Sequence;
008:        import org.bouncycastle.asn1.ASN1TaggedObject;
009:        import org.bouncycastle.asn1.DERBoolean;
010:        import org.bouncycastle.asn1.DERGeneralizedTime;
011:        import org.bouncycastle.asn1.DERInteger;
012:        import org.bouncycastle.asn1.DERObject;
013:        import org.bouncycastle.asn1.DERObjectIdentifier;
014:        import org.bouncycastle.asn1.DERSequence;
015:        import org.bouncycastle.asn1.DERTaggedObject;
016:        import org.bouncycastle.asn1.x509.GeneralName;
017:        import org.bouncycastle.asn1.x509.X509Extensions;
018:
019:        import java.io.IOException;
020:        import java.util.Enumeration;
021:
022:        public class TSTInfo extends ASN1Encodable {
023:            DERInteger version;
024:
025:            DERObjectIdentifier tsaPolicyId;
026:
027:            MessageImprint messageImprint;
028:
029:            DERInteger serialNumber;
030:
031:            DERGeneralizedTime genTime;
032:
033:            Accuracy accuracy;
034:
035:            DERBoolean ordering;
036:
037:            DERInteger nonce;
038:
039:            GeneralName tsa;
040:
041:            X509Extensions extensions;
042:
043:            public static TSTInfo getInstance(Object o) {
044:                if (o == null || o instanceof  TSTInfo) {
045:                    return (TSTInfo) o;
046:                } else if (o instanceof  ASN1Sequence) {
047:                    return new TSTInfo((ASN1Sequence) o);
048:                } else if (o instanceof  ASN1OctetString) {
049:                    try {
050:                        return getInstance(new ASN1InputStream(
051:                                ((ASN1OctetString) o).getOctets()).readObject());
052:                    } catch (IOException ioEx) {
053:                        throw new IllegalArgumentException(
054:                                "Bad object format in 'TSTInfo' factory.");
055:                    }
056:                }
057:
058:                throw new IllegalArgumentException(
059:                        "Unknown object in 'TSTInfo' factory : "
060:                                + o.getClass().getName() + ".");
061:            }
062:
063:            public TSTInfo(ASN1Sequence seq) {
064:                Enumeration e = seq.getObjects();
065:
066:                // version
067:                version = DERInteger.getInstance(e.nextElement());
068:
069:                // tsaPolicy
070:                tsaPolicyId = DERObjectIdentifier.getInstance(e.nextElement());
071:
072:                // messageImprint
073:                messageImprint = MessageImprint.getInstance(e.nextElement());
074:
075:                // serialNumber
076:                serialNumber = DERInteger.getInstance(e.nextElement());
077:
078:                // genTime
079:                genTime = DERGeneralizedTime.getInstance(e.nextElement());
080:
081:                // default for ordering
082:                ordering = new DERBoolean(false);
083:
084:                while (e.hasMoreElements()) {
085:                    DERObject o = (DERObject) e.nextElement();
086:
087:                    if (o instanceof  ASN1TaggedObject) {
088:                        DERTaggedObject tagged = (DERTaggedObject) o;
089:
090:                        switch (tagged.getTagNo()) {
091:                        case 0:
092:                            tsa = GeneralName.getInstance(tagged, true);
093:                            break;
094:                        case 1:
095:                            extensions = X509Extensions.getInstance(tagged,
096:                                    false);
097:                            break;
098:                        default:
099:                            throw new IllegalArgumentException(
100:                                    "Unknown tag value " + tagged.getTagNo());
101:                        }
102:                    } else if (o instanceof  DERSequence) {
103:                        accuracy = Accuracy.getInstance(o);
104:                    } else if (o instanceof  DERBoolean) {
105:                        ordering = DERBoolean.getInstance(o);
106:                    } else if (o instanceof  DERInteger) {
107:                        nonce = DERInteger.getInstance(o);
108:                    }
109:
110:                }
111:            }
112:
113:            public TSTInfo(DERObjectIdentifier tsaPolicyId,
114:                    MessageImprint messageImprint, DERInteger serialNumber,
115:                    DERGeneralizedTime genTime, Accuracy accuracy,
116:                    DERBoolean ordering, DERInteger nonce, GeneralName tsa,
117:                    X509Extensions extensions) {
118:                version = new DERInteger(1);
119:                this .tsaPolicyId = tsaPolicyId;
120:                this .messageImprint = messageImprint;
121:                this .serialNumber = serialNumber;
122:                this .genTime = genTime;
123:
124:                this .accuracy = accuracy;
125:                this .ordering = ordering;
126:                this .nonce = nonce;
127:                this .tsa = tsa;
128:                this .extensions = extensions;
129:            }
130:
131:            public MessageImprint getMessageImprint() {
132:                return messageImprint;
133:            }
134:
135:            public DERObjectIdentifier getPolicy() {
136:                return tsaPolicyId;
137:            }
138:
139:            public DERInteger getSerialNumber() {
140:                return serialNumber;
141:            }
142:
143:            public Accuracy getAccuracy() {
144:                return accuracy;
145:            }
146:
147:            public DERGeneralizedTime getGenTime() {
148:                return genTime;
149:            }
150:
151:            public DERBoolean getOrdering() {
152:                return ordering;
153:            }
154:
155:            public DERInteger getNonce() {
156:                return nonce;
157:            }
158:
159:            public GeneralName getTsa() {
160:                return tsa;
161:            }
162:
163:            public X509Extensions getExtensions() {
164:                return extensions;
165:            }
166:
167:            /**
168:             * <pre>
169:             * 
170:             *     TSTInfo ::= SEQUENCE  {
171:             *        version                      INTEGER  { v1(1) },
172:             *        policy                       TSAPolicyId,
173:             *        messageImprint               MessageImprint,
174:             *          -- MUST have the same value as the similar field in
175:             *          -- TimeStampReq
176:             *        serialNumber                 INTEGER,
177:             *         -- Time-Stamping users MUST be ready to accommodate integers
178:             *         -- up to 160 bits.
179:             *        genTime                      GeneralizedTime,
180:             *        accuracy                     Accuracy                 OPTIONAL,
181:             *        ordering                     BOOLEAN             DEFAULT FALSE,
182:             *        nonce                        INTEGER                  OPTIONAL,
183:             *          -- MUST be present if the similar field was present
184:             *          -- in TimeStampReq.  In that case it MUST have the same value.
185:             *        tsa                          [0] GeneralName          OPTIONAL,
186:             *        extensions                   [1] IMPLICIT Extensions   OPTIONAL  }
187:             * 
188:             * </pre>
189:             */
190:            public DERObject toASN1Object() {
191:                ASN1EncodableVector seq = new ASN1EncodableVector();
192:                seq.add(version);
193:
194:                seq.add(tsaPolicyId);
195:                seq.add(messageImprint);
196:                seq.add(serialNumber);
197:                seq.add(genTime);
198:
199:                if (accuracy != null) {
200:                    seq.add(accuracy);
201:                }
202:
203:                if (ordering != null && ordering.isTrue()) {
204:                    seq.add(ordering);
205:                }
206:
207:                if (nonce != null) {
208:                    seq.add(nonce);
209:                }
210:
211:                if (tsa != null) {
212:                    seq.add(new DERTaggedObject(true, 0, tsa));
213:                }
214:
215:                if (extensions != null) {
216:                    seq.add(new DERTaggedObject(false, 1, extensions));
217:                }
218:
219:                return new DERSequence(seq);
220:            }
221:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.