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


001:        package org.bouncycastle.asn1.x509.sigi;
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.DERGeneralizedTime;
008:        import org.bouncycastle.asn1.DERInteger;
009:        import org.bouncycastle.asn1.DERObject;
010:        import org.bouncycastle.asn1.DERPrintableString;
011:        import org.bouncycastle.asn1.DERSequence;
012:        import org.bouncycastle.asn1.DERTaggedObject;
013:        import org.bouncycastle.asn1.x500.DirectoryString;
014:
015:        import java.math.BigInteger;
016:        import java.util.Enumeration;
017:
018:        /**
019:         * Contains personal data for the otherName field in the subjectAltNames
020:         * extension.
021:         * <p/>
022:         * <pre>
023:         *     PersonalData ::= SEQUENCE {
024:         *       nameOrPseudonym NameOrPseudonym,
025:         *       nameDistinguisher [0] INTEGER OPTIONAL,
026:         *       dateOfBirth [1] GeneralizedTime OPTIONAL,
027:         *       placeOfBirth [2] DirectoryString OPTIONAL,
028:         *       gender [3] PrintableString OPTIONAL,
029:         *       postalAddress [4] DirectoryString OPTIONAL
030:         *       }
031:         * </pre>
032:         *
033:         * @see org.bouncycastle.asn1.x509.sigi.NameOrPseudonym
034:         * @see org.bouncycastle.asn1.x509.sigi.SigIObjectIdentifiers
035:         */
036:        public class PersonalData extends ASN1Encodable {
037:            private NameOrPseudonym nameOrPseudonym;
038:            private BigInteger nameDistinguisher;
039:            private DERGeneralizedTime dateOfBirth;
040:            private DirectoryString placeOfBirth;
041:            private String gender;
042:            private DirectoryString postalAddress;
043:
044:            public static PersonalData getInstance(Object obj) {
045:                if (obj == null || obj instanceof  PersonalData) {
046:                    return (PersonalData) obj;
047:                }
048:
049:                if (obj instanceof  ASN1Sequence) {
050:                    return new PersonalData((ASN1Sequence) obj);
051:                }
052:
053:                throw new IllegalArgumentException(
054:                        "illegal object in getInstance: "
055:                                + obj.getClass().getName());
056:            }
057:
058:            /**
059:             * Constructor from ASN1Sequence.
060:             * <p/>
061:             * The sequence is of type NameOrPseudonym:
062:             * <p/>
063:             * <pre>
064:             *     PersonalData ::= SEQUENCE {
065:             *       nameOrPseudonym NameOrPseudonym,
066:             *       nameDistinguisher [0] INTEGER OPTIONAL,
067:             *       dateOfBirth [1] GeneralizedTime OPTIONAL,
068:             *       placeOfBirth [2] DirectoryString OPTIONAL,
069:             *       gender [3] PrintableString OPTIONAL,
070:             *       postalAddress [4] DirectoryString OPTIONAL
071:             *       }
072:             * </pre>
073:             *
074:             * @param seq The ASN.1 sequence.
075:             */
076:            private PersonalData(ASN1Sequence seq) {
077:                if (seq.size() < 1) {
078:                    throw new IllegalArgumentException("Bad sequence size: "
079:                            + seq.size());
080:                }
081:
082:                Enumeration e = seq.getObjects();
083:
084:                nameOrPseudonym = NameOrPseudonym.getInstance(e.nextElement());
085:
086:                while (e.hasMoreElements()) {
087:                    ASN1TaggedObject o = ASN1TaggedObject.getInstance(e
088:                            .nextElement());
089:                    int tag = o.getTagNo();
090:                    switch (tag) {
091:                    case 0:
092:                        nameDistinguisher = DERInteger.getInstance(o, false)
093:                                .getValue();
094:                        break;
095:                    case 1:
096:                        dateOfBirth = DERGeneralizedTime.getInstance(o, false);
097:                        break;
098:                    case 2:
099:                        placeOfBirth = DirectoryString.getInstance(o, true);
100:                        break;
101:                    case 3:
102:                        gender = DERPrintableString.getInstance(o, false)
103:                                .getString();
104:                        break;
105:                    case 4:
106:                        postalAddress = DirectoryString.getInstance(o, true);
107:                        break;
108:                    default:
109:                        throw new IllegalArgumentException("Bad tag number: "
110:                                + o.getTagNo());
111:                    }
112:                }
113:            }
114:
115:            /**
116:             * Constructor from a given details.
117:             *
118:             * @param nameOrPseudonym   Name or pseudonym.
119:             * @param nameDistinguisher Name distinguisher.
120:             * @param dateOfBirth       Date of birth.
121:             * @param placeOfBirth      Place of birth.
122:             * @param gender            Gender.
123:             * @param postalAddress     Postal Address.
124:             */
125:            public PersonalData(NameOrPseudonym nameOrPseudonym,
126:                    BigInteger nameDistinguisher,
127:                    DERGeneralizedTime dateOfBirth,
128:                    DirectoryString placeOfBirth, String gender,
129:                    DirectoryString postalAddress) {
130:                this .nameOrPseudonym = nameOrPseudonym;
131:                this .dateOfBirth = dateOfBirth;
132:                this .gender = gender;
133:                this .nameDistinguisher = nameDistinguisher;
134:                this .postalAddress = postalAddress;
135:                this .placeOfBirth = placeOfBirth;
136:            }
137:
138:            public NameOrPseudonym getNameOrPseudonym() {
139:                return nameOrPseudonym;
140:            }
141:
142:            public BigInteger getNameDistinguisher() {
143:                return nameDistinguisher;
144:            }
145:
146:            public DERGeneralizedTime getDateOfBirth() {
147:                return dateOfBirth;
148:            }
149:
150:            public DirectoryString getPlaceOfBirth() {
151:                return placeOfBirth;
152:            }
153:
154:            public String getGender() {
155:                return gender;
156:            }
157:
158:            public DirectoryString getPostalAddress() {
159:                return postalAddress;
160:            }
161:
162:            /**
163:             * Produce an object suitable for an ASN1OutputStream.
164:             * <p/>
165:             * Returns:
166:             * <p/>
167:             * <pre>
168:             *     PersonalData ::= SEQUENCE {
169:             *       nameOrPseudonym NameOrPseudonym,
170:             *       nameDistinguisher [0] INTEGER OPTIONAL,
171:             *       dateOfBirth [1] GeneralizedTime OPTIONAL,
172:             *       placeOfBirth [2] DirectoryString OPTIONAL,
173:             *       gender [3] PrintableString OPTIONAL,
174:             *       postalAddress [4] DirectoryString OPTIONAL
175:             *       }
176:             * </pre>
177:             *
178:             * @return a DERObject
179:             */
180:            public DERObject toASN1Object() {
181:                ASN1EncodableVector vec = new ASN1EncodableVector();
182:                vec.add(nameOrPseudonym);
183:                if (nameDistinguisher != null) {
184:                    vec.add(new DERTaggedObject(false, 0, new DERInteger(
185:                            nameDistinguisher)));
186:                }
187:                if (dateOfBirth != null) {
188:                    vec.add(new DERTaggedObject(false, 1, dateOfBirth));
189:                }
190:                if (placeOfBirth != null) {
191:                    vec.add(new DERTaggedObject(true, 2, placeOfBirth));
192:                }
193:                if (gender != null) {
194:                    vec.add(new DERTaggedObject(false, 3,
195:                            new DERPrintableString(gender, true)));
196:                }
197:                if (postalAddress != null) {
198:                    vec.add(new DERTaggedObject(true, 4, postalAddress));
199:                }
200:                return new DERSequence(vec);
201:            }
202:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.