Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable https for java ejb Webservice

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

like image 451
AdemC Avatar asked Feb 23 '26 15:02

AdemC


1 Answers

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.

like image 76
perissf Avatar answered Feb 27 '26 03:02

perissf