2016-08-09 2 views
1

HTTPS를 사용하여 CXF 클라이언트에서 서버 (SOAP 끝점)로 메시지를 보내도록 모듈을 구현하려고합니다. https://camel.apache.org/how-to-switch-the-cxf-consumer-between-http-and-https-without-touching-the-spring-configuration.htmlCXF with Camel - HTTPS

다음 구성이 핵심입니다 : : 여기 가이드에 따라이를 달성 할 수 있어요

<ctx:property-placeholder location="classpath:orderEntry.cfg" /> 
<!-- other properties --> 
<http:conduit name="{http://www.company.com/product/orderEntry/service/1}OrderEntry.http-conduit"> 
    <http:tlsClientParameters disableCNCheck="true"> 
     <sec:trustManagers> 
     <sec:keyStore type="JKS" password="${trustStore.password}" file="${trustStore.file}"/> 
     </sec:trustManagers> 
     <!-- other config --> 
    </http:tlsClientParameters> 
</http:conduit> 

위의 구성은 이러한 속성이 저장되어있는 설정 파일을 참조 :

orderEntry.cfg 
-------------- 
endpointUri=https://localhost:8181/OrderEntry 
trustStore.password=password 
trustStore.file=etc/myApp.ts 

앞서 언급했듯이 가이드를 따르면 https를 통해 메시지를 보낼 수 있습니다.

그러나 암호는 여기에 일반 텍스트로 저장됩니다. 암호가 필요할 때 http 도관에 제공하는 Java 코드 (암호화된 소스에서 암호를 읽을 수 있음)에서 암호를 유선으로 가져올 수있는 방법이 있습니까?

답변

1

file 접두어로 위치 속성 값을 사용해 보셨습니까?

예. location="file:/my/custom/location/orderEntry.cfg"

참조 : https://stackoverflow.com/a/17303537

업데이트 : 은 사용자 정의 빈과 작동하는 경우, 당신은 빈으로 신뢰 관리자를 만들 시도하고 울부 짖는 소리와 같은 도관 구성에 주입 할 수

blueprint.xml

<bean id="serviceTrustManager" 
     class="my.app.security.KeyStores" factory-method="loadTrustManagers"> 
    <argument index="0" value="${my.app.service.trustStorePath}"/> 
    <argument index="1" value="${my.app.service.trustStoreEncryptedPassword}"/> 
</bean> 
<http:conduit name="{http://www.company.com/product/orderEntry/service/1}OrderEntry.http-conduit"> 
    <http:tlsClientParameters disableCNCheck="true"> 
     <sec:trustManagers ref="serviceTrustManager"/> 
    </http:tlsClientParameters> 
</http:conduit> 

자바 코드 :

public class KeyStores { 
    public static TrustManager[] loadTrustManagers(String trustStorePath, String trustStoreEncryptedPassword) { 
     String trustStoreDecryptedPassword = PasswordDescriptor.decryptPassword(trustStoreEncryptedPassword); //Password decryption logic here 
     KeyStore trustStore = KeyStores.loadKeyStore("JKS", trustStorePath, trustStoreDecryptedPassword); //IO logic here 
     TrustManagerFactory trustFactory; 
     try { 
      trustFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); 
      trustFactory.init(trustStore); 
     } catch (NoSuchAlgorithmException | KeyStoreException ex) { 
      throw new IllegalStateException(ex); 
     } 
     return trustFactory.getTrustManagers(); 
    } 
} 
,
+0

예. 속성 자리 표시자를 사용하여 파일을 사용하려고 시도했으며 속성을 선택할 수 있습니다. 그러나 암호화해야 할 필요가 여전히 만족스럽지 않습니다. 나는 "convertProperties"메소드 (여기 보이는 것처럼 : https://kayalvizhiameen.blogspot.in/2014/04/handling-obfuscated-property-values-in.html)를 오버라이드하려고했으나 http : conduit 엘리먼트를 돕지 못했다. - 그러나, 그것은 자신을 초기화하는 콩을 위해 작동합니다. – Ram

+0

업데이트 된 제안을 시도하고 알려 드리겠습니다. 감사!! – Ram

+1

@Ram Hey. 어떻게 된거야? – Pawel