Source Code Cross Referenced for CRLNumberExtension.java in  » 6.0-JDK-Modules » j2me » sun » security » 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 » 6.0 JDK Modules » j2me » sun.security.x509 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)CRLNumberExtension.java	1.14 06/10/10
003:         *
004:         * Copyright  1990-2006 Sun Microsystems, Inc. All Rights Reserved.  
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER  
006:         *   
007:         * This program is free software; you can redistribute it and/or  
008:         * modify it under the terms of the GNU General Public License version  
009:         * 2 only, as published by the Free Software Foundation.   
010:         *   
011:         * This program is distributed in the hope that it will be useful, but  
012:         * WITHOUT ANY WARRANTY; without even the implied warranty of  
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU  
014:         * General Public License version 2 for more details (a copy is  
015:         * included at /legal/license.txt).   
016:         *   
017:         * You should have received a copy of the GNU General Public License  
018:         * version 2 along with this work; if not, write to the Free Software  
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  
020:         * 02110-1301 USA   
021:         *   
022:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa  
023:         * Clara, CA 95054 or visit www.sun.com if you need additional  
024:         * information or have any questions. 
025:         *
026:         */
027:
028:        package sun.security.x509;
029:
030:        import java.io.IOException;
031:        import java.io.InputStream;
032:        import java.io.OutputStream;
033:        import java.lang.reflect.Array;
034:        import java.math.BigInteger;
035:        import java.util.Enumeration;
036:
037:        import sun.security.util.*;
038:
039:        /**
040:         * Represent the CRL Number Extension.
041:         *
042:         * <p>This extension, if present, conveys a monotonically increasing
043:         * sequence number for each CRL issued by a given CA through a specific
044:         * CA X.500 Directory entry or CRL distribution point. This extension
045:         * allows users to easily determine when a particular CRL supersedes
046:         * another CRL.
047:         *
048:         * @author Hemma Prafullchandra
049:         * @version 1.7
050:         * @see Extension
051:         * @see CertAttrSet
052:         */
053:        public class CRLNumberExtension extends Extension implements 
054:                CertAttrSet {
055:
056:            /**
057:             * Attribute name.
058:             */
059:            public static final String NAME = "CRLNumber";
060:            public static final String NUMBER = "value";
061:
062:            private BigInteger crlNumber = null;
063:
064:            // Encode this extension value
065:            private void encodeThis() throws IOException {
066:                if (crlNumber == null) {
067:                    this .extensionValue = null;
068:                    return;
069:                }
070:                DerOutputStream os = new DerOutputStream();
071:                os.putInteger(this .crlNumber);
072:                this .extensionValue = os.toByteArray();
073:            }
074:
075:            /**
076:             * Create a CRLNumberExtension with the integer value .
077:             * The criticality is set to false.
078:             *
079:             * @param crlNum the value to be set for the extension.
080:             */
081:            public CRLNumberExtension(int crlNum) throws IOException {
082:                this .crlNumber = BigInteger.valueOf(crlNum);
083:                this .extensionId = PKIXExtensions.CRLNumber_Id;
084:                this .critical = false;
085:                encodeThis();
086:            }
087:
088:            /**
089:             * Create a CRLNumberExtension with the BigInteger value .
090:             * The criticality is set to false.
091:             *
092:             * @param crlNum the value to be set for the extension.
093:             */
094:            public CRLNumberExtension(BigInteger crlNum) throws IOException {
095:                this .crlNumber = crlNum;
096:                this .extensionId = PKIXExtensions.CRLNumber_Id;
097:                this .critical = false;
098:                encodeThis();
099:            }
100:
101:            /**
102:             * Create the extension from the passed DER encoded value of the same.
103:             *
104:             * @param critical true if the extension is to be treated as critical.
105:             * @param value Array of DER encoded bytes of the actual value.
106:             * @exception IOException on error.
107:             */
108:            public CRLNumberExtension(Boolean critical, Object value)
109:                    throws IOException {
110:                this .extensionId = PKIXExtensions.CRLNumber_Id;
111:                this .critical = critical.booleanValue();
112:
113:                int len = Array.getLength(value);
114:                byte[] extValue = new byte[len];
115:                for (int i = 0; i < len; i++) {
116:                    extValue[i] = Array.getByte(value, i);
117:                }
118:                this .extensionValue = extValue;
119:                DerValue val = new DerValue(extValue);
120:                this .crlNumber = val.getBigInteger();
121:            }
122:
123:            /**
124:             * Set the attribute value.
125:             */
126:            public void set(String name, Object obj) throws IOException {
127:                if (name.equalsIgnoreCase(NUMBER)) {
128:                    if (!(obj instanceof  BigInteger)) {
129:                        throw new IOException(
130:                                "Attribute must be of type BigInteger.");
131:                    }
132:                    crlNumber = (BigInteger) obj;
133:                } else {
134:                    throw new IOException("Attribute name not recognized by"
135:                            + " CertAttrSet:CRLNumber.");
136:                }
137:                encodeThis();
138:            }
139:
140:            /**
141:             * Get the attribute value.
142:             */
143:            public Object get(String name) throws IOException {
144:                if (name.equalsIgnoreCase(NUMBER)) {
145:                    if (crlNumber == null)
146:                        return null;
147:                    else
148:                        return crlNumber;
149:                } else {
150:                    throw new IOException("Attribute name not recognized by"
151:                            + " CertAttrSet:CRLNumber.");
152:                }
153:            }
154:
155:            /**
156:             * Delete the attribute value.
157:             */
158:            public void delete(String name) throws IOException {
159:                if (name.equalsIgnoreCase(NUMBER)) {
160:                    crlNumber = null;
161:                } else {
162:                    throw new IOException("Attribute name not recognized by"
163:                            + " CertAttrSet:CRLNumber.");
164:                }
165:                encodeThis();
166:            }
167:
168:            /**
169:             * Returns a printable representation of the CRLNumberExtension.
170:             */
171:            public String toString() {
172:                String s = super .toString()
173:                        + "CRL Number: "
174:                        + ((crlNumber == null) ? "" : Debug
175:                                .toHexString(crlNumber)) + "\n";
176:                return (s);
177:            }
178:
179:            /**
180:             * Decode the extension from the InputStream.
181:             *
182:             * @param in the InputStream to unmarshal the contents from.
183:             * @exception IOException on decoding or validity errors.
184:             */
185:            public void decode(InputStream in) throws IOException {
186:                throw new IOException("Method not to be called directly.");
187:            }
188:
189:            /**
190:             * Write the extension to the DerOutputStream.
191:             *
192:             * @param out the DerOutputStream to write the extension to.
193:             * @exception IOException on encoding errors.
194:             */
195:            public void encode(OutputStream out) throws IOException {
196:                DerOutputStream tmp = new DerOutputStream();
197:
198:                if (this .extensionValue == null) {
199:                    this .extensionId = PKIXExtensions.CRLNumber_Id;
200:                    this .critical = true;
201:                    encodeThis();
202:                }
203:                super .encode(tmp);
204:                out.write(tmp.toByteArray());
205:            }
206:
207:            /**
208:             * Return an enumeration of names of attributes existing within this
209:             * attribute.
210:             */
211:            public Enumeration getElements() {
212:                AttributeNameEnumeration elements = new AttributeNameEnumeration();
213:                elements.addElement(NUMBER);
214:                return (elements.elements());
215:            }
216:
217:            /**
218:             * Return the name of this attribute.
219:             */
220:            public String getName() {
221:                return (NAME);
222:            }
223:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.