How to activate SSL(HTTPS) in Glassfish 3.0 embedded API? - java

We are implementing an application with a webservice as component and decided to use the Glassfish 3.0 embedded distri to provide the webservice. And it works.
We need a SSL(HTTPS) connection to the webservice, but we didn't find any documentation or hint how to activate it programmatically via the embedded API.
Thus we tried to configure the embedded Glassfish via domain.xml, what has a listener configured with SSL. And the port is reachable but only without SSL. The embedded Glassfish seem to ignore the configuration to activate SSL for the port.
Has anyone experience in configuring embedded Glassfish with SSL?

Ok,
sorry that it took so much time for my answer.
The programmatical embedded API seems not to porvide a way to do this task.
Except to run an asadmin command:
logger.debug("Configure port for SSL");
String command = "create-http-listener";
ParameterMap params = new ParameterMap();
params.add("listeneraddress", "0.0.0.0");
params.add("listenerport", "443");
params.add("defaultvs", "server");
params.add("securityenabled", "true");
params.add("enabled", "true");
params.add("DEFAULT", "http-listener2");
CommandRunner runner = server.getHabitat().getComponent(CommandRunner.class);
ActionReport report = server.getHabitat().getComponent(ActionReport.class);
runner.getCommandInvocation(command, report).parameters(params).execute();
Running this code is simmlar to execute:
asadmin create-http-listener --listeneraddress 0.0.0.0 --listenerport 443 --defaultvs server securityenabled=true --enabled=true http-listener2
But this solution creates a new port with SSL. Reconfigure the already started port would be a nice option.

Related

Embedded Jetty: How to set the JMX port in source code

We have system tests and when they start an Embedded Jetty boots via the setup. The Embedded Jetty includes a JMX server, too. Then we have tests which must connect to the JMX Server via:
JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://:<JMX_PORT>/jmxrmi");
JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
The problem is we cannot connect from the tests to the JMX server when we do not know the JMX port up front. Has anybody a clue how to specify the JMX port up front when the Embedded Jetty is built within the source code? The system property stuff is of no help here.

SSL exception when calling web service from server

I'm consuming a web service in a java class standalone and it works fine.
I deployed that class as a part of a web-app in tomcat apache and it works fine.
Then, I deployed it in a glassfish server and I get this error:
WSS1601: Transport binding configured in policy but incoming message was not SSL enabled
I have several weeks stuck here. Seems like some glassfish setting doesn't accepts that my web-app uses a web service that works through HTTP (this is, and has to be the case).
The webservice client was made with the web service client wizard tool of netbeans (it uses wsimport-JAX-WS). More details on the error trace from the server:
com.sun.xml.wss.impl.XWSSecurityRuntimeException: WSS1601: Transport binding configured in policy but incoming message was not SSL enabled
at com.sun.xml.wss.impl.policy.verifier.MessagePolicyVerifier.verifyPolicy(MessagePolicyVerifier.java:125)
Has anybody else faced this issue?
Any help or ideas appreciated.
EDIT: I tried generating the stubs using the axis2 tool and it works great, so i'm sensing some kind of error in jax-ws when used in glassfish.
I guess you are trying to access the service enables with SSL. Try invoking the service with https also you have to install the valid SSL certificate in the client JDK.
The following link explain how to obtain and install a signed certificate :
https://docs.oracle.com/cd/E19798-01/821-1794/aeogl/index.html
Good luck :)

Timeout while deploying Java Application to remote glassfish server from Netbeans

while deploying to a remote Glassfish 4.1 Server from Netbeans 8.0.1, i get a Timeout.
I configured the Glassfish Server by adding a new Server Instance and that seemed to work. I can see the applications running on the server and i am able to undeploy a application (directly from netbeans).
But when i try to deploy my application to the remote Server, i get a timeout Exception.
(i used enable-secure-admin to gain remote access from netbeans to the server)
What confuses me is, that when i enabled secure admin, i expected to see a https:// url in netbeans. But this url starts with http:// and i cant find an option to change this.
Server Attributes:
Host: [remote-ip]
DAS Port: 4848
Domain: domain1 (same as on the remote server)
Target: empty
Username PW : as set on the remote server
"Enable JDBC Driver Deployment" and "Preserve Sessions Across Redeployment" are checked
Could you please attach the logs.
most probably its issue with the grizzly jar.
Please try the patched grizzly jar and see if it works for you.
Checkout : https://java.net/jira/browse/GRIZZLY-1713 for the same

JAX-WS client authentication on proxy server

I'm trying to use JAX-WS api to send some soap messages on a client application. However, I'm behind a firewall and the only option is to use a proxy server to go outside.
I'm trying to find on google any answer about this and so far all fail: To Use System.setProperty for http.proxyHost, http.proxyPort, http.proxyUser, http.proxyPassword. To use Authenticator like is described here.
I'm running out of options, if someone could help me on this would be great.
Also, I have a option to use org.apache.commons.httpclient but then I need to generate manually the XML. So could you suggest any other approach or API for WS?
You can use ws import command when creating web client to configure proxy.
-httpproxy::
use above command to configure proxy.
How to do this depend on your IDE.
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r1/index.jsp?topic=/com.ibm.websphere.wsfep.multiplatform.doc/info/ae/ae/rwbs_wsimport.html
For Jax-ws webservice client, use the following
//set proxy info to the ClientProxyFeature
ClientProxyFeature cpf = new ClientProxyFeature();
cpf.setProxyHost("proxyhost");
cpf.setProxyPort(8888);
cpf.setProxyUserName("proxyuser");
cpf.setProxyPassword("proxypwd");
//get the port with the Feature
MyPort port = myService.getPort(cpf);

Client Web Service call over SSL using Apache Axis

I'm using Apache Axis 1.5.1 to code a web service client connecting to a service over SSL. My application is running in Tomcat with SSL configuration setup in JKS. However, when I connect to the server, the connection is failing because the cert from our client is not being sent to the server. Is this something that has to be set in the client through code? Also note that the server does not need any user name or password authentication. With SSL turned off, everything works fine.
Thanks,
Two common approaches here:
http://ws.apache.org/xmlrpc/ssl.html
WebLogic has its own stuff:
http://download.oracle.com/docs/cd/E12840_01/wls/docs103/security/SSL_client.html#wp1029670
As long as you have the certificates configured correctly in your trust store accessible to Tomcat, there are no changes to Apache Axis HTTP code.

Categories