Source Code Cross Referenced for ObjectDigestInfo.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 org.bouncycastle.asn1.ASN1Encodable;
004:        import org.bouncycastle.asn1.ASN1EncodableVector;
005:        import org.bouncycastle.asn1.ASN1Sequence;
006:        import org.bouncycastle.asn1.ASN1TaggedObject;
007:        import org.bouncycastle.asn1.DERBitString;
008:        import org.bouncycastle.asn1.DEREnumerated;
009:        import org.bouncycastle.asn1.DERObject;
010:        import org.bouncycastle.asn1.DERObjectIdentifier;
011:        import org.bouncycastle.asn1.DERSequence;
012:
013:        /**
014:         * ObjectDigestInfo ASN.1 structure used in v2 attribute certificates.
015:         * 
016:         * <pre>
017:         *  
018:         *    ObjectDigestInfo ::= SEQUENCE {
019:         *         digestedObjectType  ENUMERATED {
020:         *                 publicKey            (0),
021:         *                 publicKeyCert        (1),
022:         *                 otherObjectTypes     (2) },
023:         *                         -- otherObjectTypes MUST NOT
024:         *                         -- be used in this profile
025:         *         otherObjectTypeID   OBJECT IDENTIFIER OPTIONAL,
026:         *         digestAlgorithm     AlgorithmIdentifier,
027:         *         objectDigest        BIT STRING
028:         *    }
029:         *   
030:         * </pre>
031:         * 
032:         */
033:        public class ObjectDigestInfo extends ASN1Encodable {
034:            /**
035:             * The public key is hashed.
036:             */
037:            public final static int publicKey = 0;
038:
039:            /**
040:             * The public key certificate is hashed.
041:             */
042:            public final static int publicKeyCert = 1;
043:
044:            /**
045:             * An other object is hashed.
046:             */
047:            public final static int otherObjectDigest = 2;
048:
049:            DEREnumerated digestedObjectType;
050:
051:            DERObjectIdentifier otherObjectTypeID;
052:
053:            AlgorithmIdentifier digestAlgorithm;
054:
055:            DERBitString objectDigest;
056:
057:            public static ObjectDigestInfo getInstance(Object obj) {
058:                if (obj == null || obj instanceof  ObjectDigestInfo) {
059:                    return (ObjectDigestInfo) obj;
060:                }
061:
062:                if (obj instanceof  ASN1Sequence) {
063:                    return new ObjectDigestInfo((ASN1Sequence) obj);
064:                }
065:
066:                throw new IllegalArgumentException(
067:                        "illegal object in getInstance: "
068:                                + obj.getClass().getName());
069:            }
070:
071:            public static ObjectDigestInfo getInstance(ASN1TaggedObject obj,
072:                    boolean explicit) {
073:                return getInstance(ASN1Sequence.getInstance(obj, explicit));
074:            }
075:
076:            /**
077:             * Constructor from given details.
078:             * <p>
079:             * If <code>digestedObjectType</code> is not {@link #publicKeyCert} or
080:             * {@link #publicKey} <code>otherObjectTypeID</code> must be given,
081:             * otherwise it is ignored.
082:             * 
083:             * @param digestedObjectType The digest object type.
084:             * @param otherObjectTypeID The object type ID for
085:             *            <code>otherObjectDigest</code>.
086:             * @param digestAlgorithm The algorithm identifier for the hash.
087:             * @param objectDigest The hash value.
088:             */
089:            public ObjectDigestInfo(int digestedObjectType,
090:                    String otherObjectTypeID,
091:                    AlgorithmIdentifier digestAlgorithm, byte[] objectDigest) {
092:                this .digestedObjectType = new DEREnumerated(digestedObjectType);
093:                if (digestedObjectType == otherObjectDigest) {
094:                    this .otherObjectTypeID = new DERObjectIdentifier(
095:                            otherObjectTypeID);
096:                }
097:
098:                this .digestAlgorithm = digestAlgorithm;
099:
100:                this .objectDigest = new DERBitString(objectDigest);
101:            }
102:
103:            private ObjectDigestInfo(ASN1Sequence seq) {
104:                if (seq.size() > 4 || seq.size() < 3) {
105:                    throw new IllegalArgumentException("Bad sequence size: "
106:                            + seq.size());
107:                }
108:
109:                digestedObjectType = DEREnumerated.getInstance(seq
110:                        .getObjectAt(0));
111:
112:                int offset = 0;
113:
114:                if (seq.size() == 4) {
115:                    otherObjectTypeID = DERObjectIdentifier.getInstance(seq
116:                            .getObjectAt(1));
117:                    offset++;
118:                }
119:
120:                digestAlgorithm = AlgorithmIdentifier.getInstance(seq
121:                        .getObjectAt(1 + offset));
122:
123:                objectDigest = DERBitString.getInstance(seq
124:                        .getObjectAt(2 + offset));
125:            }
126:
127:            public DEREnumerated getDigestedObjectType() {
128:                return digestedObjectType;
129:            }
130:
131:            public DERObjectIdentifier getOtherObjectTypeID() {
132:                return otherObjectTypeID;
133:            }
134:
135:            public AlgorithmIdentifier getDigestAlgorithm() {
136:                return digestAlgorithm;
137:            }
138:
139:            public DERBitString getObjectDigest() {
140:                return objectDigest;
141:            }
142:
143:            /**
144:             * Produce an object suitable for an ASN1OutputStream.
145:             * 
146:             * <pre>
147:             *  
148:             *    ObjectDigestInfo ::= SEQUENCE {
149:             *         digestedObjectType  ENUMERATED {
150:             *                 publicKey            (0),
151:             *                 publicKeyCert        (1),
152:             *                 otherObjectTypes     (2) },
153:             *                         -- otherObjectTypes MUST NOT
154:             *                         -- be used in this profile
155:             *         otherObjectTypeID   OBJECT IDENTIFIER OPTIONAL,
156:             *         digestAlgorithm     AlgorithmIdentifier,
157:             *         objectDigest        BIT STRING
158:             *    }
159:             *   
160:             * </pre>
161:             */
162:            public DERObject toASN1Object() {
163:                ASN1EncodableVector v = new ASN1EncodableVector();
164:
165:                v.add(digestedObjectType);
166:
167:                if (otherObjectTypeID != null) {
168:                    v.add(otherObjectTypeID);
169:                }
170:
171:                v.add(digestAlgorithm);
172:                v.add(objectDigest);
173:
174:                return new DERSequence(v);
175:            }
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.