📄 certstore.java
字号:
throw nsae; } catch (InvocationTargetException ite) { Throwable t = ite.getCause(); if (t != null) { if (t instanceof InvalidAlgorithmParameterException) throw (InvalidAlgorithmParameterException)t; if (t instanceof NoSuchAlgorithmException) throw (NoSuchAlgorithmException)t; } NoSuchAlgorithmException nsae = new NoSuchAlgorithmException(type + " not found"); nsae.initCause(ite); throw nsae; } } /** * Returns a <code>CertStore</code> object that implements the specified * <code>CertStore</code> type, as supplied by the specified provider * and initialized with the specified parameters. * * <p>The <code>CertStore</code> that is returned is initialized with the * specified <code>CertStoreParameters</code>. The type of parameters * needed may vary between different types of <code>CertStore</code>s. * Note that the specified <code>CertStoreParameters</code> object is * cloned. * * @param type the requested <code>CertStore</code> type * @param params the initialization parameters (may be <code>null</code>) * @param provider the name of the provider * @return a <code>CertStore</code> object that implements the * specified type, as supplied by the specified provider * @throws NoSuchAlgorithmException if the requested type is not * available from the specified provider * @throws InvalidAlgorithmParameterException if the specified * initialization parameters are inappropriate for this * <code>CertStore</code> * @throws NoSuchProviderException if the provider has not been configured * @exception IllegalArgumentException if the <code>provider</code> is * null */ public static CertStore getInstance(String type, CertStoreParameters params, String provider) throws InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchProviderException { if (provider == null || provider.length() == 0) throw new IllegalArgumentException("missing provider"); try { if (implMethod == null) { throw new NoSuchAlgorithmException(type + " not found"); } // The underlying method is static, so we set the object // argument to null. Object[] objs = (Object[])implMethod.invoke(null, new Object[] { type, "CertStore", provider, params } ); return new CertStore((CertStoreSpi)objs[0], (Provider)objs[1], type, params); } catch (IllegalAccessException iae) { NoSuchAlgorithmException nsae = new NoSuchAlgorithmException(type + " not found"); nsae.initCause(iae); throw nsae; } catch (InvocationTargetException ite) { Throwable t = ite.getCause(); if (t != null) { if (t instanceof NoSuchProviderException) throw (NoSuchProviderException)t; if (t instanceof InvalidAlgorithmParameterException) throw (InvalidAlgorithmParameterException)t; if (t instanceof NoSuchAlgorithmException) throw (NoSuchAlgorithmException)t; } NoSuchAlgorithmException nsae = new NoSuchAlgorithmException(type + " not found"); nsae.initCause(ite); throw nsae; } } /** * Returns a <code>CertStore</code> object that implements the specified * <code>CertStore</code> type, as supplied by the specified provider and * initialized with the specified parameters. * Note: the <code>provider</code> doesn't have to be registered. * * <p>The <code>CertStore</code> that is returned is initialized with the * specified <code>CertStoreParameters</code>. The type of parameters * needed may vary between different types of <code>CertStore</code>s. * Note that the specified <code>CertStoreParameters</code> object is * cloned. * * @param type the requested <code>CertStore</code> type * @param params the initialization parameters (may be <code>null</code>) * @param provider the provider * @return a <code>CertStore</code> object that implements the * specified type, as supplied by the specified provider * @exception NoSuchAlgorithmException if the requested type is not * available from the specified provider * @throws InvalidAlgorithmParameterException if the specified * initialization parameters are inappropriate for this * <code>CertStore</code> * @exception IllegalArgumentException if the <code>provider</code> is * null */ public static CertStore getInstance(String type, CertStoreParameters params, Provider provider) throws NoSuchAlgorithmException, InvalidAlgorithmParameterException { if (provider == null) throw new IllegalArgumentException("missing provider"); if (implMethod2Set.booleanValue() == false) { synchronized (implMethod2Set) { if (implMethod2Set.booleanValue() == false) { implMethod2 = (Method) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { Method m = null; try { m = cl.getDeclaredMethod("getImpl", GET_IMPL_PARAMS2); if (m != null) m.setAccessible(true); } catch (NoSuchMethodException nsme) { } return m; } }); implMethod2Set = new Boolean(true); } } } if (implMethod2 == null) { throw new NoSuchAlgorithmException(type + " not found"); } try { // The underlying method is static, so we set the object // argument to null. Object[] objs = (Object[])implMethod2.invoke(null, new Object[] { type, "CertStore", provider, params } ); return new CertStore((CertStoreSpi)objs[0], (Provider)objs[1], type, params); } catch (IllegalAccessException iae) { NoSuchAlgorithmException nsae = new NoSuchAlgorithmException(type + " not found"); nsae.initCause(iae); throw nsae; } catch (InvocationTargetException ite) { Throwable t = ite.getCause(); if (t != null) { if (t instanceof InvalidAlgorithmParameterException) throw (InvalidAlgorithmParameterException)t; if (t instanceof NoSuchAlgorithmException) throw (NoSuchAlgorithmException)t; } NoSuchAlgorithmException nsae = new NoSuchAlgorithmException(type + " not found"); nsae.initCause(ite); throw nsae; } } /** * Returns the parameters used to initialize this <code>CertStore</code>. * Note that the <code>CertStoreParameters</code> object is cloned before * it is returned. * * @return the parameters used to initialize this <code>CertStore</code> * (may be <code>null</code>) */ public final CertStoreParameters getCertStoreParameters() { return (params == null ? null : (CertStoreParameters) params.clone()); } /** * Returns the type of this <code>CertStore</code>. * * @return the type of this <code>CertStore</code> */ public final String getType() { return this.type; } /** * Returns the provider of this <code>CertStore</code>. * * @return the provider of this <code>CertStore</code> */ public final Provider getProvider() { return this.provider; } /** * Returns the default <code>CertStore</code> type as specified in the * Java security properties file, or the string "LDAP" if no * such property exists. The Java security properties file is located in * the file named <JAVA_HOME>/lib/security/java.security, where * <JAVA_HOME> refers to the directory where the SDK was installed. * * <p>The default <code>CertStore</code> type can be used by applications * that do not want to use a hard-coded type when calling one of the * <code>getInstance</code> methods, and want to provide a default * <code>CertStore</code> type in case a user does not specify its own. * * <p>The default <code>CertStore</code> type can be changed by setting * the value of the "certstore.type" security property (in the Java * security properties file) to the desired type. * * @return the default <code>CertStore</code> type as specified in the * Java security properties file, or the string "LDAP" * if no such property exists. */ public final static String getDefaultType() { String cstype; cstype = (String)AccessController.doPrivileged(new PrivilegedAction() { public Object run() { return Security.getProperty(CERTSTORE_TYPE); } }); if (cstype == null) { cstype = "LDAP"; } return cstype; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -