Source Code Cross Referenced for SunMSCAPI.java in  » 6.0-JDK-Platform » windows » sun » security » mscapi » 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 Platform » windows » sun.security.mscapi 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005-2007 Sun Microsystems, Inc.  All Rights Reserved.
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004:         *
005:         * This code is free software; you can redistribute it and/or modify it
006:         * under the terms of the GNU General Public License version 2 only, as
007:         * published by the Free Software Foundation.  Sun designates this
008:         * particular file as subject to the "Classpath" exception as provided
009:         * by Sun in the LICENSE file that accompanied this code.
010:         *
011:         * This code is distributed in the hope that it will be useful, but WITHOUT
012:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014:         * version 2 for more details (a copy is included in the LICENSE file that
015:         * accompanied this code).
016:         *
017:         * You should have received a copy of the GNU General Public License version
018:         * 2 along with this work; if not, write to the Free Software Foundation,
019:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020:         *
021:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022:         * CA 95054 USA or visit www.sun.com if you need additional information or
023:         * have any questions.
024:         */
025:
026:        package sun.security.mscapi;
027:
028:        import java.security.AccessController;
029:        import java.security.PrivilegedAction;
030:        import java.security.Provider;
031:        import java.security.ProviderException;
032:        import java.util.HashMap;
033:        import java.util.Map;
034:
035:        import sun.security.action.PutAllAction;
036:
037:        /**
038:         * A Cryptographic Service Provider for the Microsoft Crypto API.
039:         *
040:         * @since 1.6
041:         */
042:
043:        public final class SunMSCAPI extends Provider {
044:
045:            private static final long serialVersionUID = 8622598936488630849L; //TODO
046:
047:            private static final String INFO = "Sun's Microsoft Crypto API provider";
048:
049:            // Quick check to see if we are signed.
050:            // The definitive check happens via verifySelfIntegrity() when
051:            // we actually try to use encryption.
052:            private static final boolean registerEncryption = (SunMSCAPI.class
053:                    .getSigners() != null);
054:
055:            static {
056:                AccessController.doPrivileged(new PrivilegedAction() {
057:                    public Object run() {
058:                        System.loadLibrary("sunmscapi");
059:                        return null;
060:                    }
061:                });
062:            }
063:
064:            public SunMSCAPI() {
065:                super ("SunMSCAPI", 1.7d, INFO);
066:
067:                // if there is no security manager installed, put directly into
068:                // the provider. Otherwise, create a temporary map and use a
069:                // doPrivileged() call at the end to transfer the contents
070:                final Map map = (System.getSecurityManager() == null) ? (Map) this 
071:                        : new HashMap();
072:
073:                /*
074:                 * Secure random
075:                 */
076:                map
077:                        .put("SecureRandom.Windows-PRNG",
078:                                "sun.security.mscapi.PRNG");
079:
080:                /*
081:                 * Key store
082:                 */
083:                map.put("KeyStore.Windows-MY",
084:                        "sun.security.mscapi.KeyStore$MY");
085:                map.put("KeyStore.Windows-ROOT",
086:                        "sun.security.mscapi.KeyStore$ROOT");
087:
088:                /*
089:                 * Signature engines
090:                 */
091:                map.put("Signature.SHA1withRSA",
092:                        "sun.security.mscapi.RSASignature$SHA1");
093:                map.put("Signature.MD5withRSA",
094:                        "sun.security.mscapi.RSASignature$MD5");
095:                map.put("Signature.MD2withRSA",
096:                        "sun.security.mscapi.RSASignature$MD2");
097:
098:                // supported key classes
099:                map.put("Signature.SHA1withRSA SupportedKeyClasses",
100:                        "sun.security.mscapi.Key");
101:                map.put("Signature.MD5withRSA SupportedKeyClasses",
102:                        "sun.security.mscapi.Key");
103:                map.put("Signature.MD2withRSA SupportedKeyClasses",
104:                        "sun.security.mscapi.Key");
105:                map.put("Signature.NONEwithRSA SupportedKeyClasses",
106:                        "sun.security.mscapi.Key");
107:
108:                /*
109:                 * Key Pair Generator engines
110:                 */
111:                map.put("KeyPairGenerator.RSA",
112:                        "sun.security.mscapi.RSAKeyPairGenerator");
113:                map.put("KeyPairGenerator.RSA KeySize", "1024");
114:
115:                /*
116:                 * Cipher engines
117:                 * (omit registration of crypto engine when provider is unsigned)
118:                 */
119:                if (registerEncryption) {
120:                    map.put("Cipher.RSA", "sun.security.mscapi.RSACipher");
121:                    map.put("Cipher.RSA/ECB/PKCS1Padding",
122:                            "sun.security.mscapi.RSACipher");
123:                    map.put("Cipher.RSA SupportedModes", "ECB");
124:                    map.put("Cipher.RSA SupportedPaddings", "PKCS1PADDING");
125:                    map.put("Cipher.RSA SupportedKeyClasses",
126:                            "sun.security.mscapi.Key");
127:                }
128:
129:                if (map != this ) {
130:                    AccessController.doPrivileged(new PutAllAction(this , map));
131:                }
132:            }
133:
134:            // set to true once self verification is complete
135:            private static volatile boolean integrityVerified;
136:
137:            static void verifySelfIntegrity(Class c) {
138:                if (integrityVerified) {
139:                    return;
140:                }
141:                doVerifySelfIntegrity(c);
142:            }
143:
144:            private static synchronized void doVerifySelfIntegrity(Class c) {
145:                /* RSA CERTIFICATE USED TO SIGN SUNMSCAPI.JAR
146:                 Owner: CN=Sun Microsystems Inc, OU=Java Software Code Signing,
147:                 O=Sun Microsystems Inc
148:                 Issuer: CN=JCE Code Signing CA, OU=Java Software Code Signing,
149:                 O=Sun Microsystems Inc, L=Palo Alto, ST=CA, C=US
150:                 Serial number: 21f
151:                 Valid from: Wed Nov 23 14:49:41 PST 2005 until: Sat Nov 27 14:49:41 PST 2010
152:                 Certificate fingerprints:
153:                 MD5:  8E:42:68:F7:22:2F:57:F3:F0:F0:19:CE:AE:F3:8F:60
154:                 SHA1: CD:3E:0C:8A:32:E3:EF:40:21:C8:5B:34:98:9A:66:CF:E1:60:25:48
155:                 */
156:                final String CERT = "-----BEGIN CERTIFICATE-----\n"
157:                        + "MIICnTCCAlugAwIBAgICAh8wCwYHKoZIzjgEAwUAMIGQMQswCQYDVQQGEwJVUzEL"
158:                        + "MAkGA1UECBMCQ0ExEjAQBgNVBAcTCVBhbG8gQWx0bzEdMBsGA1UEChMUU3VuIE1p"
159:                        + "Y3Jvc3lzdGVtcyBJbmMxIzAhBgNVBAsTGkphdmEgU29mdHdhcmUgQ29kZSBTaWdu"
160:                        + "aW5nMRwwGgYDVQQDExNKQ0UgQ29kZSBTaWduaW5nIENBMB4XDTA1MTEyMzIyNDk0"
161:                        + "MVoXDTEwMTEyNzIyNDk0MVowYzEdMBsGA1UEChMUU3VuIE1pY3Jvc3lzdGVtcyBJ"
162:                        + "bmMxIzAhBgNVBAsTGkphdmEgU29mdHdhcmUgQ29kZSBTaWduaW5nMR0wGwYDVQQD"
163:                        + "ExRTdW4gTWljcm9zeXN0ZW1zIEluYzCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkC"
164:                        + "gYEA16bKo6tC3OHFDNfPXLKXMCMtIyeubNnsEtlvrH34HhfF+ZmpSliLCvQ15ms7"
165:                        + "05vy4XgZUbZ3mgSOlLRMAGRo6596ePhc+0Z6yeKhbb3LZ8iz97ZIptkHGOshj9cf"
166:                        + "cSRPYmorUug9OsybMdIfQXazxT9mZJ9Yx5IDw6xak7kVbpUCAwEAAaOBiDCBhTAR"
167:                        + "BglghkgBhvhCAQEEBAMCBBAwDgYDVR0PAQH/BAQDAgXgMB0GA1UdDgQWBBRI319j"
168:                        + "Cbhc9DWJVltXgfrMybHNjzAfBgNVHSMEGDAWgBRl4vSGydNO8JFOWKJq9dh4WprB"
169:                        + "pjAgBgNVHREEGTAXgRV5dS1jaGluZy5wZW5nQHN1bi5jb20wCwYHKoZIzjgEAwUA"
170:                        + "Ay8AMCwCFFBFmED9s3OoN9rbXfQV3+brJPW/AhQr+Wq1MlubAvnfjrlqeksh0QaD"
171:                        + "AQ==" + "\n-----END CERTIFICATE-----";
172:                integrityVerified = JarVerifierImpl.doVerification(c, CERT);
173:                if (integrityVerified == false) {
174:                    throw new ProviderException(
175:                            "The SunMSCAPI provider may have been tampered with.");
176:                }
177:            }
178:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.