为java ejb Webservice启用https [英] Enable https for java ejb Webservice

查看:109
本文介绍了为java ejb Webservice启用https的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ejb 3和glassfish 3.1.1开发webservice。我正在使用Netbeans 7.0,并想知道如何在端口8181上为此Web服务启用https。



我不需要任何身份验证方法,只需通过https!



Thx



Adem

解决方案

您需要指定安全连接,如here 。基本上,在您的部署描述符web.xml中,您需要设置:

 < security-constraint> 
...
< user-data-constraint>
< transport-guarantee> CONFIDENTIAL< / transport-guarantee>
< / user-data-constraint>
< / security-constraint>

但是, NetBeans 将为您插入代码:打开 web.xml ,单击编辑器顶部的安全选项卡,然后单击添加安全约束按钮。键入一个名称,以URL格式写/ *,设置所有Http方法,并指定机密作为传输保证。



如果您没有 web.xml ,因为您正在部署Enterprise Java Bean,请创建一个新的GlassFish描述符 glassfish-ejb-jar .xml 并按此填写(或参阅此处文件层次结构):

 < glassfish-ejb-jar> 
< enterprise-beans>
< ejb>
< ejb-name> Hello< / ejb-name>
< webservice-endpoint>
< port-component-name> Hello< / port-component-name>
< transport-guarantee> CONFIDENTIAL< / transport-guarantee>
< / webservice-endpoint>
< / ejb>
< / enterprise-beans> />
< / glassfish-ejb-jar>

您的应用程序将从现在起使用端口8181。



有关如何在Netbeans Web应用程序中设置安全性的更多信息,请参见此处 此处了解有关证书。


i'm developing a webservice with ejb 3 and glassfish 3.1.1. I'm using Netbeans 7.0 and would like to know, how to enable https on port 8181 for this webservice.

I dont need any authentication method, just secure the communication through https!

Thx

Adem

解决方案

You need to specify a secure connection as explained here. Essentially, in your deployment descriptor web.xml you need to set:

<security-constraint>
    ...
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>

However NetBeans will insert the code for you: open web.xml, click the Security tab along the top of the editor, then click the Add Security Constraint button. Type a name, in URL pattern write /*, set All Http Methods, and specify Confidential as Transport Guarantee.

If you don't have web.xml, because you are deploying just the Enterprise Java Bean, create a New GlassFish Descriptor glassfish-ejb-jar.xml and fill it like this (or see here the file hierarchy):

<glassfish-ejb-jar>
  <enterprise-beans>
    <ejb>
      <ejb-name>Hello</ejb-name>
      <webservice-endpoint>
        <port-component-name>Hello</port-component-name>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
      </webservice-endpoint>
    </ejb>  
  </enterprise-beans>/>
</glassfish-ejb-jar>

Your application will use port 8181 from now on.

See here for further information about how to setup security in a Netbeans web application and here for learning about certificates.

这篇关于为java ejb Webservice启用https的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆