//
// DontValidateCertificate.java
//
// The contents of this file are subject to the SNIA Public License Version 1.0
// (the "License"); you may not use this file except in compliance with the
// License. You may obtain a copy of the License at
//
//      http://www.snia.org/resources/openSource.html
//
// Software distributed under the License is distributed on an "AS IS" basis,
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
// License for the specific language governing rights and limitations
// under the License.
//
// The Original Code is DontValidateCertificate.java
//
// The Initial Developer of the Original Code is Bapu Patil.
//
// Contributor(s):
//
//
//
// Revision 1.1  2002/05/15 09:36:59 bpatil 
// Initial revision
//

package org.snia.wbemcmd.xml;

import java.util.Enumeration;
import java.security.cert.X509Certificate;
import java.security.cert.CertificateException;
import java.security.SecureRandom;
import java.security.KeyStore;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import javax.net.ssl.TrustManagerFactory;

/**
 * DontValidateCertificate implements the X509TrustManager interface. CertficateManager
 * trusts known certificate chains, and queries the user to approve unknown
 * chains. 
 */

public class DontValidateCertificate implements X509TrustManager
{

        X509TrustManager  myX509TrustManager;
        private KeyStore keyStore;

        /**
         * CertficateManager constructor 
         */
        public DontValidateCertificate() 
        { 
        }

        /**
         * checkClientTrusted checks to see if the chain is in the keyStore object.
         * This is done with a call to checkChainTrusted.
         */
        public boolean isClientTrusted(X509Certificate[] chain)
        {
            return true;
        }

        /*
         * isServerTrusted verifies to see if the chain is in the keyStore object.
         * This is done with a call to isChainTrusted. If not it queries the
         * user to see if the chain should be trusted.
         */
        public boolean isServerTrusted(X509Certificate[] chain)
        {
            return true;
        }

        /*
         * getAcceptedIssuers retrieves all of the certificates in the keyStore
         * and returns them in an X509Certificate array.
         */
        public X509Certificate[] getAcceptedIssuers()
        {
            return null;
        }

        //
        // isChainTrusted searches the keyStore for any certificate in the
        // certificate chain.
        //
        private boolean isChainTrusted(X509Certificate[] chain)
        {
            boolean trusted = true;

            return trusted;
        }
       
       public void checkClientTrusted(X509Certificate[] chain,
                               String authType)
                        throws CertificateException  
       { 
       }


       public void checkServerTrusted(X509Certificate[] chain,
                               String authType)
                        throws CertificateException  
       { 
            
       }
  
}
