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


001:        package org.bouncycastle.asn1.cmp;
002:
003:        import org.bouncycastle.asn1.ASN1Encodable;
004:        import org.bouncycastle.asn1.ASN1EncodableVector;
005:        import org.bouncycastle.asn1.ASN1OctetString;
006:        import org.bouncycastle.asn1.ASN1Sequence;
007:        import org.bouncycastle.asn1.ASN1TaggedObject;
008:        import org.bouncycastle.asn1.DERGeneralizedTime;
009:        import org.bouncycastle.asn1.DERInteger;
010:        import org.bouncycastle.asn1.DERObject;
011:        import org.bouncycastle.asn1.DERSequence;
012:        import org.bouncycastle.asn1.DERTaggedObject;
013:        import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
014:        import org.bouncycastle.asn1.x509.GeneralName;
015:
016:        import java.util.Enumeration;
017:
018:        public class PKIHeader extends ASN1Encodable {
019:            private DERInteger pvno;
020:            private GeneralName sender;
021:            private GeneralName recipient;
022:            private DERGeneralizedTime messageTime;
023:            private AlgorithmIdentifier protectionAlg;
024:            private ASN1OctetString senderKID; // KeyIdentifier
025:            private ASN1OctetString recipKID; // KeyIdentifier
026:            private ASN1OctetString transactionID;
027:            private ASN1OctetString senderNonce;
028:            private ASN1OctetString recipNonce;
029:            private PKIFreeText freeText;
030:            private ASN1Sequence generalInfo;
031:
032:            private PKIHeader(ASN1Sequence seq) {
033:                Enumeration en = seq.getObjects();
034:
035:                pvno = DERInteger.getInstance(en.nextElement());
036:                sender = GeneralName.getInstance(en.nextElement());
037:                recipient = GeneralName.getInstance(en.nextElement());
038:
039:                while (en.hasMoreElements()) {
040:                    ASN1TaggedObject tObj = (ASN1TaggedObject) en.nextElement();
041:
042:                    switch (tObj.getTagNo()) {
043:                    case 0:
044:                        messageTime = DERGeneralizedTime
045:                                .getInstance(tObj, true);
046:                        break;
047:                    case 1:
048:                        protectionAlg = AlgorithmIdentifier.getInstance(tObj,
049:                                true);
050:                        break;
051:                    case 2:
052:                        senderKID = ASN1OctetString.getInstance(tObj, true);
053:                        break;
054:                    case 3:
055:                        recipKID = ASN1OctetString.getInstance(tObj, true);
056:                        break;
057:                    case 4:
058:                        transactionID = ASN1OctetString.getInstance(tObj, true);
059:                        break;
060:                    case 5:
061:                        senderNonce = ASN1OctetString.getInstance(tObj, true);
062:                        break;
063:                    case 6:
064:                        recipNonce = ASN1OctetString.getInstance(tObj, true);
065:                        break;
066:                    case 7:
067:                        freeText = PKIFreeText.getInstance(tObj, true);
068:                        break;
069:                    case 8:
070:                        generalInfo = ASN1Sequence.getInstance(tObj, true);
071:                        break;
072:                    default:
073:                        throw new IllegalArgumentException(
074:                                "unknown tag number: " + tObj.getTagNo());
075:                    }
076:                }
077:            }
078:
079:            public static PKIHeader getInstance(Object o) {
080:                if (o instanceof  PKIHeader) {
081:                    return (PKIHeader) o;
082:                }
083:
084:                if (o instanceof  ASN1Sequence) {
085:                    return new PKIHeader((ASN1Sequence) o);
086:                }
087:
088:                throw new IllegalArgumentException("Invalid object: "
089:                        + o.getClass().getName());
090:            }
091:
092:            public DERInteger getPvno() {
093:                return pvno;
094:            }
095:
096:            public GeneralName getSender() {
097:                return sender;
098:            }
099:
100:            public GeneralName getRecipient() {
101:                return recipient;
102:            }
103:
104:            /**
105:             * <pre>
106:             *  PKIHeader ::= SEQUENCE {
107:             *            pvno                INTEGER     { cmp1999(1), cmp2000(2) },
108:             *            sender              GeneralName,
109:             *            -- identifies the sender
110:             *            recipient           GeneralName,
111:             *            -- identifies the intended recipient
112:             *            messageTime     [0] GeneralizedTime         OPTIONAL,
113:             *            -- time of production of this message (used when sender
114:             *            -- believes that the transport will be "suitable"; i.e.,
115:             *            -- that the time will still be meaningful upon receipt)
116:             *            protectionAlg   [1] AlgorithmIdentifier     OPTIONAL,
117:             *            -- algorithm used for calculation of protection bits
118:             *            senderKID       [2] KeyIdentifier           OPTIONAL,
119:             *            recipKID        [3] KeyIdentifier           OPTIONAL,
120:             *            -- to identify specific keys used for protection
121:             *            transactionID   [4] OCTET STRING            OPTIONAL,
122:             *            -- identifies the transaction; i.e., this will be the same in
123:             *            -- corresponding request, response, certConf, and PKIConf
124:             *            -- messages
125:             *            senderNonce     [5] OCTET STRING            OPTIONAL,
126:             *            recipNonce      [6] OCTET STRING            OPTIONAL,
127:             *            -- nonces used to provide replay protection, senderNonce
128:             *            -- is inserted by the creator of this message; recipNonce
129:             *            -- is a nonce previously inserted in a related message by
130:             *            -- the intended recipient of this message
131:             *            freeText        [7] PKIFreeText             OPTIONAL,
132:             *            -- this may be used to indicate context-specific instructions
133:             *            -- (this field is intended for human consumption)
134:             *            generalInfo     [8] SEQUENCE SIZE (1..MAX) OF
135:             *                                 InfoTypeAndValue     OPTIONAL
136:             *            -- this may be used to convey context-specific information
137:             *            -- (this field not primarily intended for human consumption)
138:             * }
139:             * </pre>
140:             * @return a basic ASN.1 object representation.
141:             */
142:            public DERObject toASN1Object() {
143:                ASN1EncodableVector v = new ASN1EncodableVector();
144:
145:                v.add(pvno);
146:                v.add(sender);
147:                v.add(recipient);
148:                addOptional(v, 0, messageTime);
149:                addOptional(v, 1, protectionAlg);
150:                addOptional(v, 2, senderKID);
151:                addOptional(v, 3, recipKID);
152:                addOptional(v, 4, transactionID);
153:                addOptional(v, 5, senderNonce);
154:                addOptional(v, 6, recipNonce);
155:                addOptional(v, 7, freeText);
156:                addOptional(v, 8, generalInfo);
157:
158:                return new DERSequence(v);
159:            }
160:
161:            private void addOptional(ASN1EncodableVector v, int tagNo,
162:                    ASN1Encodable obj) {
163:                if (obj != null) {
164:                    v.add(new DERTaggedObject(true, tagNo, obj));
165:                }
166:            }
167:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.