Data de postagem: Jul 06, 2010 10:29:30 AM
A partir da versão 9.2.0.49 do iEngine é possível configurar o JavaServer para usar, entre outras funcionalidade, a funcionalidade de conexão segura através do HTTPS.
Para configurar HTTPS é necessário ter o seu certificado digital e o da autorizada certificadora no formato JKS(Java Key Store).
A importação e geração de certificado no formato JKS é feito pela a ferramenta keytool.exe que vem na distribuição da JSDK(Java Software Developement Kit).
Não há necessidade de usar certificado da autoridade certificadora se o seu certificado é auto-assinado.
Mais detalhes sobre a ferramenta keytool.exe em: http://java.sun.com/j2se/1.3/docs/tooldocs/win32/keytool.html.
A configuração é feita através de um arquivo XML. O Objeto javaServer, na versão 9.2.0.49, passa a ter uma nova propriedade chamada: javaServer.configFileName. Nesta propriedade deve ser 'setado' o caminho completo do arquivo de configuração.
Segue abaixo o exemplo de um XML de configuração da porta 8888 do JavaServer para usar HTTPS:
<?xml version="1.0" encoding="UTF-8"?>
<!--
** Configuração do BUS do CXF.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sec="http://cxf.apache.org/configuration/security"
xmlns:http="http://cxf.apache.org/transports/http/configuration"
xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
xsi:schemaLocation="
http://cxf.apache.org/configuration/security
http://cxf.apache.org/schemas/configuration/security.xsd
http://cxf.apache.org/transports/http/configuration
http://cxf.apache.org/schemas/configuration/http-conf.xsd
http://cxf.apache.org/transports/http-jetty/configuration
http://cxf.apache.org/schemas/configuration/http-jetty.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<!--
Use <http:destination> e suas tags filhas para configurar o Endpoint do servidor HTTP.
A tag http:destination tem apenas um unico atributo, name, que faz referência a tag <port> do WSDL que correponde ao Endpoint.
O valor para o atributo name tem a seguinte forma: portQName.http-destination.
O exemplo abaixo mostra a tag <http:destination> sendo usada para adicionar uma configuração para um Endpoint que foi
espeficicadopelo seguinte trecho do WSDL "<port binding="widgetSOAPBinding" name="widgetSOAPPort>", considerando que o
namespace alvo do Endpoint é http://widgets.widgetvendor.net.
Ex.:
<http-conf:destination name="{http://widgets/widgetvendor.net}widgetSOAPPort.http-destination>
...
</http-conf:destination>
-->
<http:destination name="{http://test.webservice.engine.unum.com.br/}WSTestImplPort.http-destination">
</http:destination>
<httpj:engine-factory>
<httpj:engine port="8888">
<httpj:tlsServerParameters>
<!--Certificado da aplicação-->
<sec:keyManagers keyPassword="password">
<sec:keyStore type="JKS" password="password"
file="g:/minha_keystore.jks"/>
</sec:keyManagers>
<!--Certificado da Autoridade Certificadora que assinou o certificado da aplicação-->
<sec:trustManagers>
<sec:keyStore type="JKS" password="password"
file="g:/keystore_da_autor_certificadora.jks"/>
</sec:trustManagers>
<!--
Filtro de algoritmos de criptografia aceitos. O possíveis filtros são:
SSL_RSA_WITH_RC4_128_MD5, SSL_RSA_WITH_RC4_128_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA,
TLS_DHE_DSS_WITH_AES_128_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA,
SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA,
SSL_RSA_WITH_DES_CBC_SHA, SSL_DHE_RSA_WITH_DES_CBC_SHA, SSL_DHE_DSS_WITH_DES_CBC_SHA, SSL_RSA_EXPORT_WITH_RC4_40_MD5,
SSL_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA,
SSL_RSA_WITH_NULL_MD5, SSL_RSA_WITH_NULL_SHA, SSL_DH_anon_WITH_RC4_128_MD5, TLS_DH_anon_WITH_AES_128_CBC_SHA,
SSL_DH_anon_WITH_3DES_EDE_CBC_SHA, SSL_DH_anon_WITH_DES_CBC_SHA, SSL_DH_anon_EXPORT_WITH_RC4_40_MD5,
SSL_DH_anon_EXPORT_WITH_DES40_CBC_SHA, TLS_KRB5_WITH_RC4_128_SHA, TLS_KRB5_WITH_RC4_128_MD5,
TLS_KRB5_WITH_3DES_EDE_CBC_SHA,
TLS_KRB5_WITH_3DES_EDE_CBC_MD5, TLS_KRB5_WITH_DES_CBC_SHA, TLS_KRB5_WITH_DES_CBC_MD5, TLS_KRB5_EXPORT_WITH_RC4_40_SHA,
TLS_KRB5_EXPORT_WITH_RC4_40_MD5, TLS_KRB5_EXPORT_WITH_DES_CBC_40_SHA, TLS_KRB5_EXPORT_WITH_DES_CBC_40_MD5.
-->
<sec:cipherSuitesFilter>
<sec:include>.*_EXPORT_.*</sec:include>
<sec:include>.*_EXPORT1024_.*</sec:include>
<sec:include>.*_WITH_3DES_.*</sec:include>
<sec:include>.*_WITH_AES_.*</sec:include>
<sec:include>.*_WITH_NULL_.*</sec:include>
<sec:exclude>.*_DH_anon_.*</sec:exclude>
</sec:cipherSuitesFilter>
<!--Habilita/dabilita a autenticação do client-->
<sec:clientAuthentication want="false" required="false"/>
</httpj:tlsServerParameters>
</httpj:engine>
</httpj:engine-factory>
</beans>
Supunha que o arquivo de configuração esteja gravado em c:\config\serverconfig.xml. Para publicar o o serviço use:
javaServer.configFileName = "c:\\config\\serverconfig.xml"
javaServer.publishService( "https://127.0.0.1:8888/WSTest", "br.com.unum.engine.webservise.teste.WSTesteImpl" )
IMPORTANTE: Se o arquivo <Diretório do iEngine>\cxf-config.xml existir ele será automaticamente usado como arquivo de configuração default, dispensando o desenvolvedor de 'setar' um valor para a propriedade javaServer.configFileName
IMPORTANTE: Algumas distribuições da versão 1.6 da JRE possuem bug. Sugerimos realizar a atualização da sua JRE antes de usa o ambiente Java integrado com o iEngine. Para mais detalhes, clique aqui.