cxf accept the one-way server-side SSL authentication

Important URL:
http://old.nabble.com/jaxws-ssl-client-that-accepts-all-certificates-td16826257.html
http://cwiki.apache.org/CXF20DOC/client-http-transport-including-ssl-support.html
The first is the official wiki, this certification process to add structure and detail through the configuration of the CXF support for SSL
The second parameter to which this configuration

 package com.cxf.client;

import java.util.Iterator;
import java.util.List;

import javax.net.ssl.TrustManager;
import javax.xml.namespace.QName;

import org.apache.cxf.configuration.jsse.TLSClientParameters;
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.transport.http.HTTPConduit;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public final class Client {

    private Client() {
    }

    public static void main(String args[]) throws Exception {
        ClassPathXmlApplicationContext context
            = new ClassPathXmlApplicationContext(new String[] {"com/cxf/client/client-beans.xml"});
        ICardInfoWebService client = (ICardInfoWebService)context.getBean("client");
//-------------------------------------------------------
                org.apache.cxf.endpoint.Client proxy = ClientProxy.getClient(client);
                HTTPConduit conduit = (HTTPConduit) proxy.getConduit();
                TLSClientParameters tls= new TLSClientParameters();
        tls.setTrustManagers( new TrustManager[]{ new TrustAllX509TrustManager()});
        tcp.setDisableCNCheck(true);// Accept the server-side authentication
        conduit.setTlsClientParameters(tcp);
//-------------------------------------------------------
List<TxnDtlAccountVo> list = client.findTxnDtlAccountInfo(txnDtlAccountVo);
        }
}

Configuration file com / cxf / client / client-beans.xml

<?xml version="1.0" encoding="UTF-8"?>
<!-- START SNIPPET: beans -->
<beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:jaxws="http://cxf.apache.org/jaxws"
        xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schema/jaxws.xsd">

    <bean
      factory-bean="clientFactory" factory-method="create"/>
        <bean>
<property name="serviceClass" value="com.cxf.client.ICardInfoWebService"/>
<property name="address" value="https://127.0.0.1:8443/manage/services/myWebService"/>
        </bean>
</beans>
分类:Java 时间:2008-08-11 人气:320
分享到:
blog comments powered by Disqus

相关文章

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.670 (s). 13 q(s)