예제: 사용자 정의 SSL 신뢰 결정을 위한 사용자 정의 신뢰 관리자 개발

다음은 샘플 사용자 정의 신뢰 관리자의 예제입니다. 사용자 정의 신뢰 관리자는 신뢰 결정을 내리지는 않지만 대신 결정을 내리기 위해 참조하는 X.509 인증서의 정보를 사용합니다.

사용자 정의 신뢰 관리자를 빌드하고 패키지한 후 순수 클라이언트의 ssl.client.props 파일 또는 관리 콘솔의 SSLConfiguration TrustManager 링크에서 이를 구성하십시오. 신뢰 관리자에 대한 자세한 정보는 X.509 인증서 신뢰 의사결정에 대한 신뢰 관리자 제어의 내용을 참조하십시오.
참고: 이 예제는 샘플로만 사용해야 하며 지원되지 않습니다.
import java.security.cert.X509Certificate;
import javax.net.ssl.*;
import com.ibm.wsspi.ssl.TrustManagerExtendedInfo;

public final class CustomTrustManager implements X509TrustManager,
TrustManagerExtendedInfo
{
    private static ThreadLocal threadLocStorage = new ThreadLocal();
    private java.util.Properties sslConfig = null;
    private java.util.Properties props = null;

    public CustomTrustManager()
    {
    }

    /**
     * Method called by WebSphere Application Server run time to set the target
     * host information and potentially other connection info in the future.
     * This needs to be set on ThreadLocal since the same trust manager can be
     * used by multiple connections.
     * 
     * @param java.util.Map - Contains information about the connection.
     */
    public void setExtendedInfo(java.util.Map info)
    {
        threadLocStorage.set(info);
    }

    /**
     * Method called internally to retrieve information about the connection. 
     * 
     * @return java.util.Map - Contains information about the connection.
     */
    private java.util.Map getExtendedInfo()
    {
        return (java.util.Map) threadLocStorage.get();
    }

    /**
     * Method called by WebSphere Application Server run time to set the custom
     * properties.
     * 
     * @param java.util.Properties - custom props
     */
    public void setCustomProperties(java.util.Properties customProps)
    {
        props = customProps;
    }

    /**
     * Method called internally to the custom properties set in the Trust Manager
     * configuration.
     * 
     * @return java.util.Properties - information set in the configuration.
     */
    private java.util.Properties getCustomProperties()
    {
        return props;
    }

    /**
     * Method called by WebSphere Application Server runtime to set the SSL
     * configuration properties being used for this connection.
     * 
     * @param java.util.Properties - contains a property for the SSL configuration.
     */
    public void setSSLConfig(java.util.Properties config)
    {
        sslConfig = config;    
    }

    /**
     * Method called by TrustManager to get access to the SSL configuration for 
     * this connection.
     * 
     * @return java.util.Properties
     */
    public java.util.Properties getSSLConfig ()
    {
        return sslConfig;
    }

    /**
     * Method called on the server-side for establishing trust with a client.
     * See API documentation for javax.net.ssl.X509TrustManager.
     */
    public void checkClientTrusted(X509Certificate[] chain, String authType) 
        throws java.security.cert.CertificateException
    {
        for (int j=0; j<chain.length; j++)
        {
            System.out.println("Client certificate information:");
            System.out.println(  "Subject DN:"  + chain[j].getSubjectDN());
            System.out.println(  "Issuer DN:"  + chain[j].getIssuerDN());
            System.out.println(  "Serial number:"  + chain[j].getSerialNumber());
            System.out.println("");
        }
    }


    /**
     * Method called on the client-side for establishing trust with a server.
     * See API documentation for javax.net.ssl.X509TrustManager.
     */
    public void checkServerTrusted(X509Certificate[] chain, String authType) 
        throws java.security.cert.CertificateException
    {
        for (int j=0; j<chain.length; j++)
        {
            System.out.println("Server certificate information:");
            System.out.println(  "Subject DN:"  + chain[j].getSubjectDN());
            System.out.println(  "Issuer DN:"  + chain[j].getIssuerDN());
            System.out.println(  "Serial number:"  + chain[j].getSerialNumber());
            System.out.println("");
        }
    }

    /**
     * Return an array of certificate authority certificates which are trusted 
     * for authenticating peers. You can return null here since the IbmX509
     * or IbmPKIX will provide a default set of issuers.
     *
     * See API documentation for javax.net.ssl.X509TrustManager.
     */
    public X509Certificate[] getAcceptedIssuers()
    {
        		     return null;
    }
}

주제 유형을 표시하는 아이콘 참조 주제



시간소인 아이콘 마지막 업데이트 날짜: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=rsec_ssldevcustomtrustmgr
파일 이름:rsec_ssldevcustomtrustmgr.html