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


001:        package org.bouncycastle.jce;
002:
003:        import org.bouncycastle.asn1.ASN1InputStream;
004:        import org.bouncycastle.asn1.ASN1Sequence;
005:        import org.bouncycastle.asn1.DEROutputStream;
006:        import org.bouncycastle.asn1.x509.X509Name;
007:
008:        import java.io.ByteArrayOutputStream;
009:        import java.io.IOException;
010:        import java.security.Principal;
011:        import java.util.Hashtable;
012:        import java.util.Vector;
013:
014:        /**
015:         * a general extension of X509Name with a couple of extra methods and
016:         * constructors.
017:         * <p>
018:         * Objects of this type can be created from certificates and CRLs using the
019:         * PrincipalUtil class.
020:         * </p>
021:         * @see org.bouncycastle.jce.PrincipalUtil
022:         */
023:        public class X509Principal extends X509Name implements  Principal {
024:            private static ASN1Sequence readSequence(ASN1InputStream aIn)
025:                    throws IOException {
026:                try {
027:                    return ASN1Sequence.getInstance(aIn.readObject());
028:                } catch (IllegalArgumentException e) {
029:                    throw new IOException("not an ASN.1 Sequence: " + e);
030:                }
031:            }
032:
033:            /**
034:             * Constructor from an encoded byte array.
035:             */
036:            public X509Principal(byte[] bytes) throws IOException {
037:                super (readSequence(new ASN1InputStream(bytes)));
038:            }
039:
040:            /**
041:             * Constructor from an X509Name object.
042:             */
043:            public X509Principal(X509Name name) {
044:                super ((ASN1Sequence) name.getDERObject());
045:            }
046:
047:            /**
048:             * constructor from a table of attributes.
049:             * <p>
050:             * it's is assumed the table contains OID/String pairs.
051:             */
052:            public X509Principal(Hashtable attributes) {
053:                super (attributes);
054:            }
055:
056:            /**
057:             * constructor from a table of attributes and a vector giving the
058:             * specific ordering required for encoding or conversion to a string.
059:             * <p>
060:             * it's is assumed the table contains OID/String pairs.
061:             */
062:            public X509Principal(Vector ordering, Hashtable attributes) {
063:                super (ordering, attributes);
064:            }
065:
066:            /**
067:             * constructor from a vector of attribute values and a vector of OIDs.
068:             */
069:            public X509Principal(Vector oids, Vector values) {
070:                super (oids, values);
071:            }
072:
073:            /**
074:             * takes an X509 dir name as a string of the format "C=AU,ST=Victoria", or
075:             * some such, converting it into an ordered set of name attributes.
076:             */
077:            public X509Principal(String dirName) {
078:                super (dirName);
079:            }
080:
081:            /**
082:             * Takes an X509 dir name as a string of the format "C=AU,ST=Victoria", or
083:             * some such, converting it into an ordered set of name attributes. If reverse
084:             * is false the dir name will be encoded in the order of the (name, value) pairs 
085:             * presented, otherwise the encoding will start with the last (name, value) pair
086:             * and work back.
087:             */
088:            public X509Principal(boolean reverse, String dirName) {
089:                super (reverse, dirName);
090:            }
091:
092:            /**
093:             * Takes an X509 dir name as a string of the format "C=AU, ST=Victoria", or
094:             * some such, converting it into an ordered set of name attributes. lookUp 
095:             * should provide a table of lookups, indexed by lowercase only strings and
096:             * yielding a DERObjectIdentifier, other than that OID. and numeric oids
097:             * will be processed automatically.
098:             * <p>
099:             * If reverse is true, create the encoded version of the sequence starting
100:             * from the last element in the string.
101:             */
102:            public X509Principal(boolean reverse, Hashtable lookUp,
103:                    String dirName) {
104:                super (reverse, lookUp, dirName);
105:            }
106:
107:            public String getName() {
108:                return this .toString();
109:            }
110:
111:            /**
112:             * return a DER encoded byte array representing this object
113:             */
114:            public byte[] getEncoded() {
115:                ByteArrayOutputStream bOut = new ByteArrayOutputStream();
116:                DEROutputStream dOut = new DEROutputStream(bOut);
117:
118:                try {
119:                    dOut.writeObject(this );
120:                } catch (IOException e) {
121:                    throw new RuntimeException(e.toString());
122:                }
123:
124:                return bOut.toByteArray();
125:            }
126:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.