5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * The contents of this file are subject to the terms
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * of the Common Development and Distribution License
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * (the License). You may not use this file except in
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * compliance with the License.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * You can obtain a copy of the License at
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * See the License for the specific language governing
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * permission and limitations under the License.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * When distributing Covered Code, include this CDDL
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Header Notice in each file and include the License file
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * If applicable, add the following below the CDDL Header,
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * with the fields enclosed by brackets [] replaced by
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * your own identifying information:
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * $Id: AMX509TrustManager.java,v 1.3 2008/08/21 20:11:13 beomsuk Exp $
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterimport com.sun.identity.shared.configuration.SystemPropertiesManager;
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * The <code>AMX509TrustManager</code> class implements JSSE X509TrustManager
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * interface. This implementation is the same as JSSE default implementation
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * except it can manage user specified truststore.
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Fosterpublic class AMX509TrustManager implements X509TrustManager {
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster static final String javahome = System.getProperty("java.home");
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster static final String seperator = System.getProperty("file.separator", "/");
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster // Construct dir name for default trust store
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster // javahome + seperator + "lib" + seperator + "security" +
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster // seperator + "cacerts";
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster trustStoreType = System.getProperty("javax.net.ssl.trustStoreType",
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster trustStore = System.getProperty("javax.net.ssl.trustStore",
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster trustAllServerCerts = Boolean.valueOf(SystemPropertiesManager.get(
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster "com.iplanet.am.jssproxy.trustAllServerCerts", "false"))
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster trustKeyStore = KeyStore.getInstance(trustStoreType);
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster FileInputStream fis = new FileInputStream(trustStore);
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster Provider sProviders[] = Security.getProviders();
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster if (sProviders[i].getName().equalsIgnoreCase("IBMJSSE2")) {
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster tmf = TrustManagerFactory.getInstance(algorithm, provider);
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster /** create sunX509KeyManager
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * for example:
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Create/load a truststore
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * Get instance of a "SunX509" TrustManagerFactory "tmf"
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster * init the TrustManagerFactory with the truststore
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster public void checkServerTrusted(X509Certificate[] chain, String authType)
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster sunX509TrustManager.checkServerTrusted(chain, authType);
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster public void checkClientTrusted(X509Certificate[] chain, String authType)
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster sunX509TrustManager.checkClientTrusted(chain, authType);
5c099afa7c9361afc2f4477fec0e3018588d7840Allan Foster public X509Certificate[] getAcceptedIssuers() {