Source Code Cross Referenced for TimeStampReq.java in  » Apache-Harmony-Java-SE » org-package » org » apache » harmony » security » x509 » 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 » Apache Harmony Java SE » org package » org.apache.harmony.security.x509.tsp 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one
003:         * or more contributor license agreements.  See the NOTICE file
004:         * distributed with this work for additional information
005:         * regarding copyright ownership.  The ASF licenses this file
006:         * to you under the Apache License, Version 2.0 (the
007:         * "License"); you may not use this file except in compliance
008:         * with the License.  You may obtain a copy of the License at
009:         *
010:         *   http://www.apache.org/licenses/LICENSE-2.0
011:         *
012:         * Unless required by applicable law or agreed to in writing,
013:         * software distributed under the License is distributed on an
014:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015:         * KIND, either express or implied.  See the License for the
016:         * specific language governing permissions and limitations
017:         * under the License.    
018:         */
019:
020:        package org.apache.harmony.security.x509.tsp;
021:
022:        import java.math.BigInteger;
023:
024:        import org.apache.harmony.security.asn1.ASN1Boolean;
025:        import org.apache.harmony.security.asn1.ASN1Implicit;
026:        import org.apache.harmony.security.asn1.ASN1Integer;
027:        import org.apache.harmony.security.asn1.ASN1Oid;
028:        import org.apache.harmony.security.asn1.ASN1Sequence;
029:        import org.apache.harmony.security.asn1.ASN1Type;
030:        import org.apache.harmony.security.asn1.BerInputStream;
031:        import org.apache.harmony.security.asn1.ObjectIdentifier;
032:        import org.apache.harmony.security.x509.Extensions;
033:
034:        /**
035:         * As defined in Time-Stamp Protocol (TSP)
036:         * (http://www.ietf.org/rfc/rfc3161.txt)
037:         * 
038:         * TimeStampReq ::= SEQUENCE  {
039:         *    version                      INTEGER  { v1(1) },
040:         *    messageImprint               MessageImprint,
041:         *      --a hash algorithm OID and the hash value of the data to be
042:         *      --time-stamped
043:         *    reqPolicy             TSAPolicyId              OPTIONAL,
044:         *    nonce                 INTEGER                  OPTIONAL,
045:         *    certReq               BOOLEAN                  DEFAULT FALSE,
046:         *    extensions            [0] IMPLICIT Extensions  OPTIONAL  
047:         *  }
048:         *  
049:         *  TSAPolicyId ::= OBJECT IDENTIFIER
050:         */
051:        public class TimeStampReq {
052:            private final int version;
053:
054:            private final MessageImprint messageImprint;
055:
056:            private final String reqPolicy;
057:
058:            private final BigInteger nonce;
059:
060:            private final Boolean certReq;
061:
062:            private final Extensions extensions;
063:
064:            private byte[] encoding;
065:
066:            public TimeStampReq(int version, MessageImprint messageImprint,
067:                    String reqPolicy, BigInteger nonce, Boolean certReq,
068:                    Extensions extensions) {
069:                this .version = version;
070:                this .messageImprint = messageImprint;
071:                this .reqPolicy = reqPolicy;
072:                this .nonce = nonce;
073:                this .certReq = certReq;
074:                this .extensions = extensions;
075:            }
076:
077:            private TimeStampReq(int version, MessageImprint messageImprint,
078:                    String reqPolicy, BigInteger nonce, Boolean certReq,
079:                    Extensions extensions, byte[] encoding) {
080:                this (version, messageImprint, reqPolicy, nonce, certReq,
081:                        extensions);
082:                this .encoding = encoding;
083:            }
084:
085:            public String toString() {
086:                StringBuffer res = new StringBuffer();
087:                res.append("-- TimeStampReq:");
088:                res.append("\nversion : ");
089:                res.append(version);
090:                res.append("\nmessageImprint:  ");
091:                res.append(messageImprint);
092:                res.append("\nreqPolicy:  ");
093:                res.append(reqPolicy);
094:                res.append("\nnonce:  ");
095:                res.append(nonce);
096:                res.append("\ncertReq:  ");
097:                res.append(certReq);
098:                res.append("\nextensions:  ");
099:                res.append(extensions);
100:                res.append("\n-- TimeStampReq End\n");
101:                return res.toString();
102:            }
103:
104:            /**
105:             * Returns ASN.1 encoded form of this TimeStampReq.
106:             * @return a byte array containing ASN.1 encoded form.
107:             */
108:            public byte[] getEncoded() {
109:                if (encoding == null) {
110:                    encoding = ASN1.encode(this );
111:                }
112:                return encoding;
113:            }
114:
115:            /**
116:             * @return Returns the certReq.
117:             */
118:            public Boolean getCertReq() {
119:                return certReq;
120:            }
121:
122:            /**
123:             * @return Returns the extensions.
124:             */
125:            public Extensions getExtensions() {
126:                return extensions;
127:            }
128:
129:            /**
130:             * @return Returns the messageImprint.
131:             */
132:            public MessageImprint getMessageImprint() {
133:                return messageImprint;
134:            }
135:
136:            /**
137:             * @return Returns the nonce.
138:             */
139:            public BigInteger getNonce() {
140:                return nonce;
141:            }
142:
143:            /**
144:             * @return Returns the reqPolicy.
145:             */
146:            public String getReqPolicy() {
147:                return reqPolicy;
148:            }
149:
150:            /**
151:             * @return Returns the version.
152:             */
153:            public int getVersion() {
154:                return version;
155:            }
156:
157:            public static final ASN1Sequence ASN1 = new ASN1Sequence(
158:                    new ASN1Type[] { ASN1Integer.getInstance(), // version
159:                            MessageImprint.ASN1, // messageImprint 
160:                            ASN1Oid.getInstance(), // reqPolicy
161:                            ASN1Integer.getInstance(), // nonce
162:                            ASN1Boolean.getInstance(), // certReq
163:                            new ASN1Implicit(0, Extensions.ASN1) }) {// extensions
164:
165:                {
166:                    setDefault(Boolean.FALSE, 4);
167:                    setOptional(2);
168:                    setOptional(3);
169:                    setOptional(5);
170:                }
171:
172:                protected Object getDecodedObject(BerInputStream in) {
173:                    Object[] values = (Object[]) in.content;
174:
175:                    String objID = (values[2] == null) ? null
176:                            : ObjectIdentifier.toString((int[]) values[2]);
177:                    BigInteger nonce = (values[3] == null) ? null
178:                            : new BigInteger((byte[]) values[3]);
179:
180:                    if (values[5] == null) {
181:                        return new TimeStampReq(ASN1Integer
182:                                .toIntValue(values[0]),
183:                                (MessageImprint) values[1], objID, nonce,
184:                                (Boolean) values[4], null, in.getEncoded());
185:                    } else {
186:                        return new TimeStampReq(ASN1Integer
187:                                .toIntValue(values[0]),
188:                                (MessageImprint) values[1], objID, nonce,
189:                                (Boolean) values[4], (Extensions) values[5], in
190:                                        .getEncoded());
191:                    }
192:                }
193:
194:                protected void getValues(Object object, Object[] values) {
195:                    TimeStampReq req = (TimeStampReq) object;
196:                    values[0] = ASN1Integer.fromIntValue(req.version);
197:                    values[1] = req.messageImprint;
198:                    values[2] = (req.reqPolicy == null) ? null
199:                            : ObjectIdentifier.toIntArray(req.reqPolicy);
200:                    values[3] = (req.nonce == null) ? null : req.nonce
201:                            .toByteArray();
202:                    values[4] = (req.certReq == null) ? Boolean.FALSE
203:                            : req.certReq;
204:                    values[5] = req.extensions;
205:                }
206:            };
207:
208:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.