0

에 나는 CXF의 웹 서비스에 WS-보안을 구현하고 다음은 뮬 흐름입니다 : -가 파일 WS-Security는 뮬

<context:property-placeholder location="classpath:conf/DBConnectionProp.properties"/> 
    <!-- Authentication security--> 
    <mule-ss:security-manager> 
      <mule-ss:delegate-security-provider name="memory-provider" delegate-ref="authenticationManager" /> 
     </mule-ss:security-manager> 
     <spring:beans> 
      <ss:authentication-manager alias="authenticationManager"> 
       <ss:authentication-provider> 
        <ss:user-service id="userService" > 
         <ss:user name="${username}" password="${password}" authorities="ROLE_ADMIN" /> 
        </ss:user-service> 
       </ss:authentication-provider> 
      </ss:authentication-manager> 
     </spring:beans> 

    <cxf:ws-security name="inboundSecurityConfig"> 
    <cxf:mule-security-manager /> 
    <cxf:ws-config> 
    <cxf:property key="action" value="UsernameToken" /> 
    </cxf:ws-config> 
    </cxf:ws-security> 

    <!-- Authentication security ends--> 

    <flow name="securedSoapService"> 
    <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8090" path="designation" doc:name="HTTP"> 
    <cxf:jaxws-service serviceClass="com.getdesignation.test.services.schema.maindata.v1.GetDesignation"> 
    <cxf:ws-security ref="inboundSecurityConfig"/> 
    </cxf:jaxws-service> 
    </http:inbound-endpoint> 
    <component class="com.getdesignation.vertu.services.schema.maindata.v1.Impl.GetDesignationImpl" /> 
    </flow> 

지금 문제는, 그것이 속성 파일에서 사용자 이름과 암호의 값을 읽지 않습니다. 속성 파일 <ss:user name="${username}" password="${password}" authorities="ROLE_ADMIN" />에서 값을 읽으려는 경우 전체 값을 문자열로 읽으므로 은 다음과 같이 예외가됩니다. 사용자 이름 및 암호 :

WARN 2014-09-18 21:23:41,426 [[SOAPSecurity2].connector.http.mule.default.receiver.02] org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor: 
org.apache.ws.security.WSSecurityException: The security token could not be authenticated or authorized 
    at org.mule.module.cxf.support.MuleSecurityManagerValidator.validate(MuleSecurityManagerValidator.java:57) 
    at org.apache.ws.security.processor.UsernameTokenProcessor.handleUsernameToken(UsernameTokenProcessor.java:153) 
    at org.apache.ws.security.processor.UsernameTokenProcessor.handleToken(UsernameTokenProcessor.java:66) 
    at org.apache.ws.security.WSSecurityEngine.processSecurityHeader(WSSecurityEngine.java:396) 
    at org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor.handleMessage(WSS4JInInterceptor.java:281) 
    at org.apache.cxf.ws.security.wss4j.WSS4JInInterceptor.handleMessage(WSS4JInInterceptor.java:100) 
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263) 
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:122) 

하지만 $ {username}과 $ {password}를 제거하고 사용자 이름과 암호를 직접 입력하면 잘 돌아갑니다. 등록 정보 파일에서 사용자 이름과 암호를 읽는 방법을 알지 못합니다. 도와주세요 .. proprties 파일에서 ws 보안 읽기를 구현하는 방법이 있습니까 ??? 사용

+0

"전체 값을 문자열로 읽음"이란 무엇을 의미합니까? 'username/password '속성은'conf/DBConnectionProp.properties'에 정의되어 있습니까? 나는 그 이름으로이 파일이 DB 접근을위한 특성을 포함하고 끝점을 확보하는 것이 아니라고 생각하기 때문에 상상할 수 없다. –

+0

예 David 거기에 정의한 사용자 이름 = 사용자 이름 password = password하지만 $ {username} 또는 $ {password}를 사용할 때 여전히 읽지 않습니다 –

+0

Mmmh, 속성 파일이로드되지 않은 것 같습니다. 'context-property-placeholder'에'ignore-resource-not-found = "false"를 추가 할 수 있습니까? –

답변

0

시도 :

username1=username 
password1=password 

과 :

어쩌면 이름과 같은 값을 가진 속성에 문제가있어 같은
<ss:user name="${username1}" password="${password1}" authorities="ROLE_ADMIN" /> 

. 데이비드 ... 에

0

덕분에이 이상한 문제였다 다윗과 같은 작업 솔루션은 말한다 : 나는 이름 또는 암호와 같은 키를 사용할 수 없습니다

<ss:user name="${username1}" password="${password1}" authorities="ROLE_ADMIN" /> 

업데이트이 오류는 "userName"속성이 Windows 환경 변수 "USERNAME"에 의해 무시된다는 사실 때문에 발생합니다.
ref : - https://support.mulesoft.com/s/article/ka434000000TOoDAAW/Bad-credentials-error-when-configuring-the-Spring-Security-Manager-with-properties