package com.jscape.inet.ftps;

import javax.net.ssl.SSLSession;

/**
 * Certificate verifier interface.
 * <p/>
 * Client which implements this interface should implement the <code>verify</code> method to obtain the <code>X509Certificate</code> instance and verify it is a trusted certificate and implement
 * the <code>authorized</code> method to return whether or not certificate should be trusted.
 * <p/>
 * When connecting the client will first invoke the <code>authorized()</code> method.  If this method returns <code>false</code>, it will then invoke the <code>verify</code> method allowing you to check whether the certificate is valid.  Once the
 * <code>verify</code> method has been invoked it will invoke the <code>authorized</code> method once again.  In the <code>verify</code> method you should set a variable that can be read by the <code>authorized()</code> method to determine whether the certificate is valid.
 */
public interface FtpsCertificateVerifier {

    /**
     * Checks whether certificate is trusted.
     *
     * @return <code>true</code> if certificate is trusted
     */
    boolean authorized();

    /**
     * Invoked when handshake has completed.
     *
     * @param session contains the <code>X509Certificate</code> instance needed to verify if certificate is trusted
     */
    void verify(SSLSession session);
}
