001    /*
002     * Licensed Materials - Property of IBM
003     * Restricted Materials of IBM
004     *
005     * com.ibm.rational.wvcm.stp.cc.CcTrustManagerCallback
006     *
007     * (C) Copyright IBM Corporation 2011.  All Rights Reserved.
008     * Note to U.S. Government Users Restricted Rights:  Use, duplication or 
009     * disclosure restricted by GSA ADP  Schedule Contract with IBM Corp.
010     */
011    package com.ibm.rational.wvcm.stp.cc;
012    
013    import java.security.cert.CertificateException;
014    import java.security.cert.X509Certificate;
015    import java.util.List;
016    
017    /**
018     * This callback is used to handle SSL Certificate problems when initiating a
019     * connection to a remote CCRC WAN server over HTTPS. The callback is not
020     * invoked if the certificate is stored and trusted on the client already.
021     */
022    public interface CcTrustManagerCallback {
023        
024        /**
025         * Provides the caller details about what is wrong with a certificate
026         */
027        public enum CertificateStatus {
028            /**
029             * The certificate is not trusted
030             */
031            CERTIFICATE_NOT_TRUSTED,
032            
033            /**
034             * The certificate's date is out of range
035             */
036            CERTIFICATE_DATE_OUT_OF_RANGE,
037            
038            /**
039             * The certificate's name does not match what is trusted in the store
040             */
041            CERTIFICATE_NAME_MISMATCH
042        }
043        
044        /**
045         * The caller provides a response in reply to the callback to indicate
046         * how to handle the certificate problem.
047         */
048        public enum CertificateResponse {
049            
050            /**
051             * Temporarily accept the certificate for this session.
052             */
053            ACCEPT_CERTIFICATE_TEMPORARILY,
054            
055            /**
056             * Accept this certificate and install it into the key store
057             */
058            ACCEPT_AND_INSTALL_CERTIFICATE,
059            
060            /**
061             * Reject this certificate for this session.
062             */
063            REJECT_CERTIFICATE
064        }
065        
066        /**
067         * Callback is invoked when there is a problem with the certificate provided
068         * by the server. Check the <code>CertificateException</code> and the 
069         * <code>CertificateStatus</code> for more details. Respond to the
070         * certificate problem using a <code>CertificateResponse</code>
071         * 
072         * @param cert Java x.509 certificate
073         * @param status List of certificate problems
074         * @param certEx Java certificate exception
075         * @return CertificateResponse accept/install/reject
076         */
077        CertificateResponse getCertificateResponse(
078                X509Certificate cert,
079                List<CertificateStatus> status,
080                CertificateException certEx);
081    
082    }