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


001:        package org.bouncycastle.ocsp;
002:
003:        import org.bouncycastle.asn1.ASN1Sequence;
004:        import org.bouncycastle.asn1.DERObjectIdentifier;
005:        import org.bouncycastle.asn1.DEROutputStream;
006:        import org.bouncycastle.asn1.ocsp.ResponseData;
007:        import org.bouncycastle.asn1.ocsp.SingleResponse;
008:        import org.bouncycastle.asn1.x509.X509Extension;
009:        import org.bouncycastle.asn1.x509.X509Extensions;
010:
011:        import java.io.ByteArrayOutputStream;
012:        import java.text.ParseException;
013:        import java.util.Date;
014:        import java.util.Enumeration;
015:        import java.util.HashSet;
016:        import java.util.Set;
017:
018:        public class RespData implements  java.security.cert.X509Extension {
019:            ResponseData data;
020:
021:            public RespData(ResponseData data) {
022:                this .data = data;
023:            }
024:
025:            public int getVersion() {
026:                return data.getVersion().getValue().intValue() + 1;
027:            }
028:
029:            public RespID getResponderId() {
030:                return new RespID(data.getResponderID());
031:            }
032:
033:            public Date getProducedAt() {
034:                try {
035:                    return data.getProducedAt().getDate();
036:                } catch (ParseException e) {
037:                    throw new IllegalStateException("ParseException:"
038:                            + e.getMessage());
039:                }
040:            }
041:
042:            public SingleResp[] getResponses() {
043:                ASN1Sequence s = data.getResponses();
044:                SingleResp[] rs = new SingleResp[s.size()];
045:
046:                for (int i = 0; i != rs.length; i++) {
047:                    rs[i] = new SingleResp(SingleResponse.getInstance(s
048:                            .getObjectAt(i)));
049:                }
050:
051:                return rs;
052:            }
053:
054:            public X509Extensions getResponseExtensions() {
055:                return data.getResponseExtensions();
056:            }
057:
058:            /**
059:             * RFC 2650 doesn't specify any critical extensions so we return true
060:             * if any are encountered.
061:             * 
062:             * @return true if any critical extensions are present.
063:             */
064:            public boolean hasUnsupportedCriticalExtension() {
065:                Set extns = getCriticalExtensionOIDs();
066:                if (extns != null && !extns.isEmpty()) {
067:                    return true;
068:                }
069:
070:                return false;
071:            }
072:
073:            private Set getExtensionOIDs(boolean critical) {
074:                Set set = new HashSet();
075:                X509Extensions extensions = this .getResponseExtensions();
076:
077:                if (extensions != null) {
078:                    Enumeration e = extensions.oids();
079:
080:                    while (e.hasMoreElements()) {
081:                        DERObjectIdentifier oid = (DERObjectIdentifier) e
082:                                .nextElement();
083:                        X509Extension ext = extensions.getExtension(oid);
084:
085:                        if (critical == ext.isCritical()) {
086:                            set.add(oid.getId());
087:                        }
088:                    }
089:                }
090:
091:                return set;
092:            }
093:
094:            public Set getCriticalExtensionOIDs() {
095:                return getExtensionOIDs(true);
096:            }
097:
098:            public Set getNonCriticalExtensionOIDs() {
099:                return getExtensionOIDs(false);
100:            }
101:
102:            public byte[] getExtensionValue(String oid) {
103:                X509Extensions exts = this .getResponseExtensions();
104:
105:                if (exts != null) {
106:                    X509Extension ext = exts
107:                            .getExtension(new DERObjectIdentifier(oid));
108:
109:                    if (ext != null) {
110:                        ByteArrayOutputStream bOut = new ByteArrayOutputStream();
111:                        DEROutputStream dOut = new DEROutputStream(bOut);
112:
113:                        try {
114:                            dOut.writeObject(ext.getValue());
115:
116:                            return bOut.toByteArray();
117:                        } catch (Exception e) {
118:                            throw new RuntimeException("error encoding "
119:                                    + e.toString());
120:                        }
121:                    }
122:                }
123:
124:                return null;
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.