Source Code Cross Referenced for CertStore.java in  » Apache-Harmony-Java-SE » java-package » java » security » cert » 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 » Apache Harmony Java SE » java package » java.security.cert 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  Licensed to the Apache Software Foundation (ASF) under one or more
003:         *  contributor license agreements.  See the NOTICE file distributed with
004:         *  this work for additional information regarding copyright ownership.
005:         *  The ASF licenses this file to You under the Apache License, Version 2.0
006:         *  (the "License"); you may not use this file except in compliance with
007:         *  the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         *  Unless required by applicable law or agreed to in writing, software
012:         *  distributed under the License is distributed on an "AS IS" BASIS,
013:         *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         *  See the License for the specific language governing permissions and
015:         *  limitations under the License.
016:         */
017:
018:        /**
019:         * @author Vera Y. Petrashkova
020:         * @version $Revision$
021:         */package java.security.cert;
022:
023:        import java.security.AccessController;
024:        import java.security.InvalidAlgorithmParameterException;
025:        import java.security.NoSuchAlgorithmException;
026:        import java.security.NoSuchProviderException;
027:        import java.security.Provider;
028:        import java.security.Security;
029:        import java.util.Collection;
030:
031:        import org.apache.harmony.security.fortress.Engine;
032:        import org.apache.harmony.security.internal.nls.Messages;
033:
034:        /**
035:         * @com.intel.drl.spec_ref
036:         * 
037:         */
038:
039:        public class CertStore {
040:
041:            // Store spi implementation service name
042:            private static final String SERVICE = "CertStore"; //$NON-NLS-1$
043:
044:            // Used to access common engine functionality
045:            private static Engine engine = new Engine(SERVICE);
046:
047:            // Store default property name
048:            private static final String PROPERTYNAME = "certstore.type"; //$NON-NLS-1$
049:
050:            // Default value of CertStore type. It returns if certpathbuild.type
051:            // property is not defined in java.security file
052:            private static final String DEFAULTPROPERTY = "LDAP"; //$NON-NLS-1$
053:
054:            // Store used provider
055:            private final Provider provider;
056:
057:            // Store CertStoreSpi implementation
058:            private final CertStoreSpi spiImpl;
059:
060:            // Store used type
061:            private final String type;
062:
063:            // Store used parameters
064:            private final CertStoreParameters certStoreParams;
065:
066:            /**
067:             * @com.intel.drl.spec_ref
068:             */
069:            protected CertStore(CertStoreSpi storeSpi, Provider provider,
070:                    String type, CertStoreParameters params) {
071:                this .provider = provider;
072:                this .type = type;
073:                this .spiImpl = storeSpi;
074:                this .certStoreParams = params;
075:            }
076:
077:            /**
078:             * @com.intel.drl.spec_ref
079:             * 
080:             * throws NullPointerException if type is null (instead of
081:             * NoSuchAlgorithmException as in 1.4 release)
082:             */
083:            public static CertStore getInstance(String type,
084:                    CertStoreParameters params)
085:                    throws InvalidAlgorithmParameterException,
086:                    NoSuchAlgorithmException {
087:                if (type == null) {
088:                    throw new NullPointerException(Messages
089:                            .getString("security.07")); //$NON-NLS-1$
090:                }
091:                try {
092:                    synchronized (engine) {
093:                        engine.getInstance(type, params);
094:                        return new CertStore((CertStoreSpi) engine.spi,
095:                                engine.provider, type, params);
096:                    }
097:                } catch (NoSuchAlgorithmException e) {
098:                    Throwable th = e.getCause();
099:                    if (th == null) {
100:                        throw e;
101:                    } else {
102:                        throw new InvalidAlgorithmParameterException(e
103:                                .getMessage(), th);
104:                    }
105:                }
106:            }
107:
108:            /**
109:             * @com.intel.drl.spec_ref
110:             * 
111:             * throws NullPointerException if type is null (instead of
112:             * NoSuchAlgorithmException as in 1.4 release)
113:             * 
114:             * FIXME: IllegalArgumentException when provider is empty
115:             */
116:            public static CertStore getInstance(String type,
117:                    CertStoreParameters params, String provider)
118:                    throws InvalidAlgorithmParameterException,
119:                    NoSuchAlgorithmException, NoSuchProviderException {
120:                if ((provider == null) || (provider.length() == 0)) {
121:                    throw new IllegalArgumentException(Messages
122:                            .getString("security.02")); //$NON-NLS-1$
123:                }
124:                Provider impProvider = Security.getProvider(provider);
125:                if (impProvider == null) {
126:                    throw new NoSuchProviderException(provider);
127:                }
128:                return getInstance(type, params, impProvider);
129:            }
130:
131:            /**
132:             * @com.intel.drl.spec_ref
133:             * 
134:             * throws NullPointerException if type is null (instead of
135:             * NoSuchAlgorithmException as in 1.4 release)
136:             */
137:            public static CertStore getInstance(String type,
138:                    CertStoreParameters params, Provider provider)
139:                    throws NoSuchAlgorithmException,
140:                    InvalidAlgorithmParameterException {
141:                if (provider == null) {
142:                    throw new IllegalArgumentException(Messages
143:                            .getString("security.04")); //$NON-NLS-1$
144:                }
145:                if (type == null) {
146:                    throw new NullPointerException(Messages
147:                            .getString("security.07")); //$NON-NLS-1$
148:                }
149:                try {
150:                    synchronized (engine) {
151:                        engine.getInstance(type, provider, params);
152:                        return new CertStore((CertStoreSpi) engine.spi,
153:                                provider, type, params);
154:                    }
155:                } catch (NoSuchAlgorithmException e) {
156:                    Throwable th = e.getCause();
157:                    if (th == null) {
158:                        throw e;
159:                    } else {
160:                        throw new InvalidAlgorithmParameterException(e
161:                                .getMessage(), th);
162:                    }
163:                }
164:            }
165:
166:            /**
167:             * @com.intel.drl.spec_ref
168:             */
169:            public final String getType() {
170:                return type;
171:            }
172:
173:            /**
174:             * @com.intel.drl.spec_ref
175:             */
176:            public final Provider getProvider() {
177:                return provider;
178:            }
179:
180:            /**
181:             * @com.intel.drl.spec_ref
182:             */
183:            public final CertStoreParameters getCertStoreParameters() {
184:                if (certStoreParams == null) {
185:                    return null;
186:                } else {
187:                    return (CertStoreParameters) certStoreParams.clone();
188:                }
189:            }
190:
191:            /**
192:             * @com.intel.drl.spec_ref
193:             */
194:            public final Collection<? extends Certificate> getCertificates(
195:                    CertSelector selector) throws CertStoreException {
196:                return spiImpl.engineGetCertificates(selector);
197:            }
198:
199:            /**
200:             * @com.intel.drl.spec_ref
201:             */
202:            public final Collection<? extends CRL> getCRLs(CRLSelector selector)
203:                    throws CertStoreException {
204:                return spiImpl.engineGetCRLs(selector);
205:            }
206:
207:            /**
208:             * @com.intel.drl.spec_ref
209:             */
210:            public static final String getDefaultType() {
211:                String defaultType = AccessController
212:                        .doPrivileged(new java.security.PrivilegedAction<String>() {
213:                            public String run() {
214:                                return Security.getProperty(PROPERTYNAME);
215:                            }
216:                        });
217:                return (defaultType == null ? DEFAULTPROPERTY : defaultType);
218:            }
219:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.