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


001:        package org.bouncycastle.jce.provider;
002:
003:        import org.bouncycastle.asn1.ASN1Sequence;
004:        import org.bouncycastle.asn1.DERNull;
005:        import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers;
006:        import org.bouncycastle.asn1.x509.AlgorithmIdentifier;
007:        import org.bouncycastle.asn1.x509.RSAPublicKeyStructure;
008:        import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;
009:        import org.bouncycastle.crypto.params.RSAKeyParameters;
010:
011:        import java.io.IOException;
012:        import java.math.BigInteger;
013:        import java.security.interfaces.RSAPublicKey;
014:        import java.security.spec.RSAPublicKeySpec;
015:
016:        public class JCERSAPublicKey implements  RSAPublicKey {
017:            static final long serialVersionUID = 2675817738516720772L;
018:
019:            private BigInteger modulus;
020:            private BigInteger publicExponent;
021:
022:            JCERSAPublicKey(RSAKeyParameters key) {
023:                this .modulus = key.getModulus();
024:                this .publicExponent = key.getExponent();
025:            }
026:
027:            JCERSAPublicKey(RSAPublicKeySpec spec) {
028:                this .modulus = spec.getModulus();
029:                this .publicExponent = spec.getPublicExponent();
030:            }
031:
032:            JCERSAPublicKey(RSAPublicKey key) {
033:                this .modulus = key.getModulus();
034:                this .publicExponent = key.getPublicExponent();
035:            }
036:
037:            JCERSAPublicKey(SubjectPublicKeyInfo info) {
038:                try {
039:                    RSAPublicKeyStructure pubKey = new RSAPublicKeyStructure(
040:                            (ASN1Sequence) info.getPublicKey());
041:
042:                    this .modulus = pubKey.getModulus();
043:                    this .publicExponent = pubKey.getPublicExponent();
044:                } catch (IOException e) {
045:                    throw new IllegalArgumentException(
046:                            "invalid info structure in RSA public key");
047:                }
048:            }
049:
050:            /**
051:             * return the modulus.
052:             *
053:             * @return the modulus.
054:             */
055:            public BigInteger getModulus() {
056:                return modulus;
057:            }
058:
059:            /**
060:             * return the public exponent.
061:             *
062:             * @return the public exponent.
063:             */
064:            public BigInteger getPublicExponent() {
065:                return publicExponent;
066:            }
067:
068:            public String getAlgorithm() {
069:                return "RSA";
070:            }
071:
072:            public String getFormat() {
073:                return "X.509";
074:            }
075:
076:            public byte[] getEncoded() {
077:                SubjectPublicKeyInfo info = new SubjectPublicKeyInfo(
078:                        new AlgorithmIdentifier(
079:                                PKCSObjectIdentifiers.rsaEncryption,
080:                                new DERNull()), new RSAPublicKeyStructure(
081:                                getModulus(), getPublicExponent())
082:                                .getDERObject());
083:
084:                return info.getDEREncoded();
085:            }
086:
087:            public int hashCode() {
088:                return this .getModulus().hashCode()
089:                        ^ this .getPublicExponent().hashCode();
090:            }
091:
092:            public boolean equals(Object o) {
093:                if (o == this ) {
094:                    return true;
095:                }
096:
097:                if (!(o instanceof  RSAPublicKey)) {
098:                    return false;
099:                }
100:
101:                RSAPublicKey key = (RSAPublicKey) o;
102:
103:                return getModulus().equals(key.getModulus())
104:                        && getPublicExponent().equals(key.getPublicExponent());
105:            }
106:
107:            public String toString() {
108:                StringBuffer buf = new StringBuffer();
109:                String nl = System.getProperty("line.separator");
110:
111:                buf.append("RSA Public Key").append(nl);
112:                buf.append("            modulus: ").append(
113:                        this .getModulus().toString(16)).append(nl);
114:                buf.append("    public exponent: ").append(
115:                        this .getPublicExponent().toString(16)).append(nl);
116:
117:                return buf.toString();
118:            }
119:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.