Source Code Cross Referenced for Holder.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.DERObject;
008:        import org.bouncycastle.asn1.DERSequence;
009:        import org.bouncycastle.asn1.DERTaggedObject;
010:
011:        /**
012:         * The Holder object.
013:         * <p>
014:         * For an v2 attribute certificate this is:
015:         * 
016:         * <pre>
017:         *            Holder ::= SEQUENCE {
018:         *                  baseCertificateID   [0] IssuerSerial OPTIONAL,
019:         *                           -- the issuer and serial number of
020:         *                           -- the holder's Public Key Certificate
021:         *                  entityName          [1] GeneralNames OPTIONAL,
022:         *                           -- the name of the claimant or role
023:         *                  objectDigestInfo    [2] ObjectDigestInfo OPTIONAL
024:         *                           -- used to directly authenticate the holder,
025:         *                           -- for example, an executable
026:         *            }
027:         * </pre>
028:         * 
029:         * <p>
030:         * For an v1 attribute certificate this is:
031:         * 
032:         * <pre>
033:         *         subject CHOICE {
034:         *          baseCertificateID [0] IssuerSerial,
035:         *          -- associated with a Public Key Certificate
036:         *          subjectName [1] GeneralNames },
037:         *          -- associated with a name
038:         * </pre>
039:         */
040:        public class Holder extends ASN1Encodable {
041:            IssuerSerial baseCertificateID;
042:
043:            GeneralNames entityName;
044:
045:            ObjectDigestInfo objectDigestInfo;
046:
047:            private int version = 1;
048:
049:            public static Holder getInstance(Object obj) {
050:                if (obj instanceof  Holder) {
051:                    return (Holder) obj;
052:                } else if (obj instanceof  ASN1Sequence) {
053:                    return new Holder((ASN1Sequence) obj);
054:                } else if (obj instanceof  ASN1TaggedObject) {
055:                    return new Holder((ASN1TaggedObject) obj);
056:                }
057:
058:                throw new IllegalArgumentException("unknown object in factory");
059:            }
060:
061:            /**
062:             * Constructor for a holder for an v1 attribute certificate.
063:             * 
064:             * @param tagObj The ASN.1 tagged holder object.
065:             */
066:            public Holder(ASN1TaggedObject tagObj) {
067:                switch (tagObj.getTagNo()) {
068:                case 0:
069:                    baseCertificateID = IssuerSerial.getInstance(tagObj, false);
070:                    break;
071:                case 1:
072:                    entityName = GeneralNames.getInstance(tagObj, false);
073:                    break;
074:                default:
075:                    throw new IllegalArgumentException("unknown tag in Holder");
076:                }
077:                version = 0;
078:            }
079:
080:            /**
081:             * Constructor for a holder for an v2 attribute certificate. *
082:             * 
083:             * @param seq The ASN.1 sequence.
084:             */
085:            public Holder(ASN1Sequence seq) {
086:                if (seq.size() > 3) {
087:                    throw new IllegalArgumentException("Bad sequence size: "
088:                            + seq.size());
089:                }
090:
091:                for (int i = 0; i != seq.size(); i++) {
092:                    ASN1TaggedObject tObj = ASN1TaggedObject.getInstance(seq
093:                            .getObjectAt(i));
094:
095:                    switch (tObj.getTagNo()) {
096:                    case 0:
097:                        baseCertificateID = IssuerSerial.getInstance(tObj,
098:                                false);
099:                        break;
100:                    case 1:
101:                        entityName = GeneralNames.getInstance(tObj, false);
102:                        break;
103:                    case 2:
104:                        objectDigestInfo = ObjectDigestInfo.getInstance(tObj,
105:                                false);
106:                        break;
107:                    default:
108:                        throw new IllegalArgumentException(
109:                                "unknown tag in Holder");
110:                    }
111:                }
112:                version = 1;
113:            }
114:
115:            public Holder(IssuerSerial baseCertificateID) {
116:                this .baseCertificateID = baseCertificateID;
117:            }
118:
119:            /**
120:             * Constructs a holder from a IssuerSerial.
121:             * @param baseCertificateID The IssuerSerial.
122:             * @param version The version of the attribute certificate. 
123:             */
124:            public Holder(IssuerSerial baseCertificateID, int version) {
125:                this .baseCertificateID = baseCertificateID;
126:                this .version = version;
127:            }
128:
129:            /**
130:             * Returns 1 for v2 attribute certificates or 0 for v1 attribute
131:             * certificates. 
132:             * @return The version of the attribute certificate.
133:             */
134:            public int getVersion() {
135:                return version;
136:            }
137:
138:            /**
139:             * Constructs a holder with an entityName for v2 attribute certificates or
140:             * with a subjectName for v1 attribute certificates.
141:             * 
142:             * @param entityName The entity or subject name.
143:             */
144:            public Holder(GeneralNames entityName) {
145:                this .entityName = entityName;
146:            }
147:
148:            /**
149:             * Constructs a holder with an entityName for v2 attribute certificates or
150:             * with a subjectName for v1 attribute certificates.
151:             * 
152:             * @param entityName The entity or subject name.
153:             * @param version The version of the attribute certificate. 
154:             */
155:            public Holder(GeneralNames entityName, int version) {
156:                this .entityName = entityName;
157:                this .version = version;
158:            }
159:
160:            /**
161:             * Constructs a holder from an object digest info.
162:             * 
163:             * @param objectDigestInfo The object digest info object.
164:             */
165:            public Holder(ObjectDigestInfo objectDigestInfo) {
166:                this .objectDigestInfo = objectDigestInfo;
167:            }
168:
169:            public IssuerSerial getBaseCertificateID() {
170:                return baseCertificateID;
171:            }
172:
173:            /**
174:             * Returns the entityName for an v2 attribute certificate or the subjectName
175:             * for an v1 attribute certificate.
176:             * 
177:             * @return The entityname or subjectname.
178:             */
179:            public GeneralNames getEntityName() {
180:                return entityName;
181:            }
182:
183:            public ObjectDigestInfo getObjectDigestInfo() {
184:                return objectDigestInfo;
185:            }
186:
187:            public DERObject toASN1Object() {
188:                if (version == 1) {
189:                    ASN1EncodableVector v = new ASN1EncodableVector();
190:
191:                    if (baseCertificateID != null) {
192:                        v.add(new DERTaggedObject(false, 0, baseCertificateID));
193:                    }
194:
195:                    if (entityName != null) {
196:                        v.add(new DERTaggedObject(false, 1, entityName));
197:                    }
198:
199:                    if (objectDigestInfo != null) {
200:                        v.add(new DERTaggedObject(false, 2, objectDigestInfo));
201:                    }
202:
203:                    return new DERSequence(v);
204:                } else {
205:                    if (entityName != null) {
206:                        return new DERTaggedObject(false, 1, entityName);
207:                    } else {
208:                        return new DERTaggedObject(false, 0, baseCertificateID);
209:                    }
210:                }
211:            }
212:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.