gpt4 book ai didi

java - cxf 端点的 Spring 基本身份验证?

转载 作者:行者123 更新时间:2023-11-29 08:47:16 25 4
gpt4 key购买 nike

我在示例文件夹中有一个来自 Apache Camel Bundle 的 camel-config.xml(示例是 camel-example-cxf-proxy)。配置文件是:

<?xml version="1.0" encoding="UTF-8"?>

<!-- START SNIPPET: e1 -->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
xmlns:cxf="http://camel.apache.org/schema/cxf"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd">

<!-- spring property placeholder, ignore resource not found as the file resource is for unit testing -->
<context:property-placeholder location="classpath:incident.properties,file:target/custom.properties"
ignore-resource-not-found="true"/>

<!-- Use a bean to start and stop the real web service (is not Camel specific) -->
<!-- In a real use-case the real web service would be probably located on another server
but we simulate this in the same JVM -->
<bean id="realWebService" class="org.apache.camel.example.cxf.proxy.RealWebServiceBean"
init-method="start" destroy-method="stop">
<!-- url of the real web service we have proxied -->
<property name="url" value="http://localhost:${real.port}/real-webservice"/>
</bean>

<!-- bean that enriches the SOAP request -->
<bean id="enrichBean" class="org.apache.camel.example.cxf.proxy.EnrichBean"/>

<!-- this is the CXF web service we use as the front end -->
<cxf:cxfEndpoint id="reportIncident"
address="http://localhost:${proxy.port}/camel-example-cxf-proxy/webservices/incident"
endpointName="s:ReportIncidentEndpoint"
serviceName="s:ReportIncidentEndpointService"
wsdlURL="etc/report_incident.wsdl"
xmlns:s="http://reportincident.example.camel.apache.org"/>

<!-- this is the Camel route which proxies the real web service and forwards SOAP requests to it -->
<camelContext xmlns="http://camel.apache.org/schema/spring">

<!-- property which contains port number -->
<propertyPlaceholder id="properties" location="classpath:incident.properties,file:target/custom.properties"/>

<endpoint id="callRealWebService" uri="http://localhost:${real.port}/real-webservice?throwExceptionOnFailure=false"/>

<route>
<!-- CXF consumer using MESSAGE format -->
<from uri="cxf:bean:reportIncident?dataFormat=MESSAGE"/>
<!-- log input received -->
<to uri="log:input"/>
<!-- enrich the input by ensure the incidentId parameter is set -->
<to uri="bean:enrichBean"/>
<!-- send proxied request to real web service -->
<to ref="callRealWebService"/>
<!-- log answer from real web service -->
<to uri="log:output"/>
</route>

</camelContext>

</beans>
<!-- END SNIPPET: e1 -->

现在我可以创建代理服务了。我正在寻找的是,我想对配置文件的以下部分实现基本身份验证,即

<!-- this is the CXF web service we use as the front end -->
<cxf:cxfEndpoint id="reportIncident"
address="http://localhost:${proxy.port}/camel-example-cxf-proxy/webservices/incident"
endpointName="s:ReportIncidentEndpoint"
serviceName="s:ReportIncidentEndpointService"
wsdlURL="etc/report_incident.wsdl"
xmlns:s="http://reportincident.example.camel.apache.org"/>

我不明白,如何做到这一点。用谷歌搜索但无法找到任何具体内容。期待您的解决方案。提前致谢。

最佳答案

Jetty 支持设置客户 security handler ,你可以像this一样将这个处理程序注入(inject) jetty 引擎.

关于java - cxf 端点的 Spring 基本身份验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24485993/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com