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


001:        package org.bouncycastle.x509;
002:
003:        import org.bouncycastle.asn1.ASN1InputStream;
004:        import org.bouncycastle.asn1.x509.CertificatePair;
005:        import org.bouncycastle.asn1.x509.X509CertificateStructure;
006:        import org.bouncycastle.jce.provider.X509CertificateObject;
007:
008:        import java.io.IOException;
009:        import java.security.cert.CertificateEncodingException;
010:        import java.security.cert.CertificateParsingException;
011:        import java.security.cert.X509Certificate;
012:
013:        /**
014:         * This class contains a cross certificate pair. Cross certificates pairs may
015:         * contain two cross signed certificates from two CAs. A certificate from the
016:         * other CA to this CA is contained in the forward certificate, the certificate
017:         * from this CA to the other CA is contained in the reverse certificate.
018:         */
019:        public class X509CertificatePair {
020:            private X509Certificate forward;
021:            private X509Certificate reverse;
022:
023:            /**
024:             * Constructor.
025:             *
026:             * @param forward Certificate from the other CA to this CA.
027:             * @param reverse Certificate from this CA to the other CA.
028:             */
029:            public X509CertificatePair(X509Certificate forward,
030:                    X509Certificate reverse) {
031:                this .forward = forward;
032:                this .reverse = reverse;
033:            }
034:
035:            /**
036:             * Constructor from a ASN.1 CertificatePair structure.
037:             *
038:             * @param pair The <code>CertificatePair</code> ASN.1 object.
039:             */
040:            public X509CertificatePair(CertificatePair pair)
041:                    throws CertificateParsingException {
042:                if (pair.getForward() != null) {
043:                    this .forward = new X509CertificateObject(pair.getForward());
044:                }
045:                if (pair.getReverse() != null) {
046:                    this .reverse = new X509CertificateObject(pair.getReverse());
047:                }
048:            }
049:
050:            public byte[] getEncoded() throws CertificateEncodingException {
051:                X509CertificateStructure f = null;
052:                X509CertificateStructure r = null;
053:                try {
054:                    if (forward != null) {
055:                        f = X509CertificateStructure
056:                                .getInstance(new ASN1InputStream(forward
057:                                        .getEncoded()).readObject());
058:                    }
059:                    if (reverse != null) {
060:                        r = X509CertificateStructure
061:                                .getInstance(new ASN1InputStream(reverse
062:                                        .getEncoded()).readObject());
063:                    }
064:                    return new CertificatePair(f, r).getDEREncoded();
065:                } catch (IllegalArgumentException e) {
066:                    throw new ExtCertificateEncodingException(e.toString(), e);
067:                } catch (IOException e) {
068:                    throw new ExtCertificateEncodingException(e.toString(), e);
069:                }
070:            }
071:
072:            /**
073:             * Returns the certificate from the other CA to this CA.
074:             *
075:             * @return Returns the forward certificate.
076:             */
077:            public X509Certificate getForward() {
078:                return forward;
079:            }
080:
081:            /**
082:             * Return the certificate from this CA to the other CA.
083:             *
084:             * @return Returns the reverse certificate.
085:             */
086:            public X509Certificate getReverse() {
087:                return reverse;
088:            }
089:
090:            public boolean equals(Object o) {
091:                if (o == null) {
092:                    return false;
093:                }
094:                if (!(o instanceof  X509CertificatePair)) {
095:                    return false;
096:                }
097:                X509CertificatePair pair = (X509CertificatePair) o;
098:                boolean equalReverse = true;
099:                boolean equalForward = true;
100:                if (forward != null) {
101:                    equalForward = this .forward.equals(pair.forward);
102:                } else {
103:                    if (pair.forward != null) {
104:                        equalForward = false;
105:                    }
106:                }
107:                if (reverse != null) {
108:                    equalReverse = this .reverse.equals(pair.reverse);
109:                } else {
110:                    if (pair.reverse != null) {
111:                        equalReverse = false;
112:                    }
113:                }
114:                return equalForward && equalReverse;
115:            }
116:
117:            public int hashCode() {
118:                int hash = 0;
119:                if (forward != null) {
120:                    hash += forward.hashCode();
121:                }
122:                if (reverse != null) {
123:                    hash += reverse.hashCode();
124:                }
125:
126:                return hash;
127:            }
128:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.