Source Code Cross Referenced for DisplayText.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.ASN1Choice;
004:        import org.bouncycastle.asn1.ASN1Encodable;
005:        import org.bouncycastle.asn1.ASN1TaggedObject;
006:        import org.bouncycastle.asn1.DERObject;
007:        import org.bouncycastle.asn1.DERBMPString;
008:        import org.bouncycastle.asn1.DERIA5String;
009:        import org.bouncycastle.asn1.DERUTF8String;
010:        import org.bouncycastle.asn1.DERVisibleString;
011:        import org.bouncycastle.asn1.DERString;
012:
013:        /**
014:         * <code>DisplayText</code> class, used in
015:         * <code>CertificatePolicies</code> X509 V3 extensions (in policy qualifiers).
016:         *
017:         * <p>It stores a string in a chosen encoding. 
018:         * <pre>
019:         * DisplayText ::= CHOICE {
020:         *      ia5String        IA5String      (SIZE (1..200)),
021:         *      visibleString    VisibleString  (SIZE (1..200)),
022:         *      bmpString        BMPString      (SIZE (1..200)),
023:         *      utf8String       UTF8String     (SIZE (1..200)) }
024:         * </pre>
025:         * @see PolicyQualifierInfo
026:         * @see PolicyInformation
027:         */
028:        public class DisplayText extends ASN1Encodable implements  ASN1Choice {
029:            /**
030:             * Constant corresponding to ia5String encoding. 
031:             *
032:             */
033:            public static final int CONTENT_TYPE_IA5STRING = 0;
034:            /**
035:             * Constant corresponding to bmpString encoding. 
036:             *
037:             */
038:            public static final int CONTENT_TYPE_BMPSTRING = 1;
039:            /**
040:             * Constant corresponding to utf8String encoding. 
041:             *
042:             */
043:            public static final int CONTENT_TYPE_UTF8STRING = 2;
044:            /**
045:             * Constant corresponding to visibleString encoding. 
046:             *
047:             */
048:            public static final int CONTENT_TYPE_VISIBLESTRING = 3;
049:
050:            /**
051:             * Describe constant <code>DISPLAY_TEXT_MAXIMUM_SIZE</code> here.
052:             *
053:             */
054:            public static final int DISPLAY_TEXT_MAXIMUM_SIZE = 200;
055:
056:            int contentType;
057:            DERString contents;
058:
059:            /**
060:             * Creates a new <code>DisplayText</code> instance.
061:             *
062:             * @param type the desired encoding type for the text. 
063:             * @param text the text to store. Strings longer than 200
064:             * characters are truncated. 
065:             */
066:            public DisplayText(int type, String text) {
067:                if (text.length() > DISPLAY_TEXT_MAXIMUM_SIZE) {
068:                    // RFC3280 limits these strings to 200 chars
069:                    // truncate the string
070:                    text = text.substring(0, DISPLAY_TEXT_MAXIMUM_SIZE);
071:                }
072:
073:                contentType = type;
074:                switch (type) {
075:                case CONTENT_TYPE_IA5STRING:
076:                    contents = (DERString) new DERIA5String(text);
077:                    break;
078:                case CONTENT_TYPE_UTF8STRING:
079:                    contents = (DERString) new DERUTF8String(text);
080:                    break;
081:                case CONTENT_TYPE_VISIBLESTRING:
082:                    contents = (DERString) new DERVisibleString(text);
083:                    break;
084:                case CONTENT_TYPE_BMPSTRING:
085:                    contents = (DERString) new DERBMPString(text);
086:                    break;
087:                default:
088:                    contents = (DERString) new DERUTF8String(text);
089:                    break;
090:                }
091:            }
092:
093:            /**
094:             * Creates a new <code>DisplayText</code> instance.
095:             *
096:             * @param text the text to encapsulate. Strings longer than 200
097:             * characters are truncated. 
098:             */
099:            public DisplayText(String text) {
100:                // by default use UTF8String
101:                if (text.length() > DISPLAY_TEXT_MAXIMUM_SIZE) {
102:                    text = text.substring(0, DISPLAY_TEXT_MAXIMUM_SIZE);
103:                }
104:
105:                contentType = CONTENT_TYPE_UTF8STRING;
106:                contents = new DERUTF8String(text);
107:            }
108:
109:            /**
110:             * Creates a new <code>DisplayText</code> instance.
111:             * <p>Useful when reading back a <code>DisplayText</code> class
112:             * from it's ASN1Encodable/DEREncodable form. 
113:             *
114:             * @param de a <code>DEREncodable</code> instance. 
115:             */
116:            public DisplayText(DERString de) {
117:                contents = de;
118:            }
119:
120:            public static DisplayText getInstance(Object de) {
121:                if (de instanceof  DERString) {
122:                    return new DisplayText((DERString) de);
123:                } else if (de instanceof  DisplayText) {
124:                    return (DisplayText) de;
125:                }
126:
127:                throw new IllegalArgumentException(
128:                        "illegal object in getInstance");
129:            }
130:
131:            public static DisplayText getInstance(ASN1TaggedObject obj,
132:                    boolean explicit) {
133:                return getInstance(obj.getObject()); // must be explicitly tagged
134:            }
135:
136:            public DERObject toASN1Object() {
137:                return (DERObject) contents;
138:            }
139:
140:            /**
141:             * Returns the stored <code>String</code> object. 
142:             *
143:             * @return the stored text as a <code>String</code>. 
144:             */
145:            public String getString() {
146:                return contents.getString();
147:            }
148:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.