Maven + Apache Felix + CXF: Securing a Service with HTTP Basic Authentication
This is another post in series Maven + Apache Felix + CXF + DOSGi Series. Here I will describe how to secure CXF published web services with HTTP basic authentication. You can find the sources on my GitHub account.
We will have three projects here. The first one defines an interface for a service. Another one provides implementation for it. And the third one will provide security.
dosgiSecurity
dosgiSecurity-api
dosgiSecurity-impl
dosgiSecurity-security
dosgiSecurity will be just a holder project.
Our interface HelloService in bundle dosgiSecurity-api will be similar to the one we defined in
Maven + Apache Felix + CXF: RESTful Webservice with CXF. Using POST.
It is another post in Maven + Apache Felix + CXF + DOSGi Series.
In this post I showed you how to create a RESTful webservice consuming and creating a String. However, the example was using @GET method. Here I will show, what changes need to be done in order to consume input from @POST. As usual, sources are available in the end of the post.
Simply change @GET to @POST and remove
Mule ESB: Building a Self-Contained Standalone Web App with Maven
This example demonstrates how to build standalone self-contained Mule ESB web application, which can be deployed to a Java web container, e.g. Tomcat. The sources used are taken from Mule ESB "hello" example, which is distributed together with Mule.
You can obtain the sources from this post on my github:
https://github.com/mah01/examples/tree/master/muleHelloStandalone
I will just show the keypoints of the application and changes, that were different from "hello" application in Mule distributable.
First of all, the
Discovering Version of Java in a BAT File
Sometimes in a BAT file we need to know what Java version are we running -- is it 32bit or 64bit. Here is a sample bat file, which depending on a Java version uses different native library directory:
@echo off
:: At this point you can place assumptions about Java version. It is still better than nothing anyway. In this particular case, we rely on a knowledge of Java version during installation time (with IzPack). Or you can just specify default value here, for example by default assume that 32 version is being run
set JVM_VERSION=""
if $SYSTEM_os_arch==x86 (
set JVM_VERSION=32
) else (
set JVM_VERSION=64
)
:: End of assumption section
:: Now trying to find out, what is current jvm version.
set TEMP_FILE=%TEMP%\javaCheck%RANDOM%%TIME:~9,5%.txt
java -version 2>%TEMP_FILE%
FOR /F "tokens=*" %%i in (%TEMP_FILE%) do (
echo %%i | find "HotSpot" >nul
if not errorlevel 1 (
echo %%i | find "64-Bit" >nul
if not errorlevel 1 (
set JVM_VERSION=64
) else (
set JVM_VERSION=32
)
)
)
del %TEMP_FILE%
if %JVM_VERSION%==32 (
set NATIVE_JARS=$INSTALL_PATH/lib/32
) else (
set NATIVE_JARS=$INSTALL_PATH/lib/64
)
start "App" javaw -classpath .;"%NATIVE_JARS%/*" my.app.App
The trick is to redirect java -version to a temporary file. Then try to find a line with "HotSpot" substring. If that line contains "64-Bit", then it is 64bit version Java. Otherwise it is 32bit.
CXF RESTful Webservices: Running on a Different Port
This is a short post in Maven + Apache Felix + CXF + DOSGi Series
If you want webservices to be published on a different port, add the following to your config.properties:
org.osgi.service.http.port=8081
And also change the publishing line in the Activator:
restProps.put("org.apache.cxf.rs.address", "http://localhost:8081/");
Maven + Apache Felix + CXF: Creating a RESTful Webservice with CXF. Consuming an Object
This is the following post in Maven + Apache Felix + CXF + DOSGi series.
Here we continue working with RESTful webservices. In the last post I showed how to returne an Object in XML with JAXB, and this post will based on it. In this post I will show how to consume an object. The title is rather misleading, but what I meant is "consuming XML and converting it to an object". Again, it is assumed that you followed the setup from the first post in the series. You will find attached sources in the end of the post.
We will have the same Felix Launcher project as in the previous post. To remind you, we will use
Maven + Apache Felix + CXF: Creating a RESTful Webservice with CXF. Returning and Object.
It is another post in series Maven + Apache Felix + CXF + DOSGi.
This example is based on a post about simple JAX-RS webservice with CXF. But this post describes a way how to return a more complex object, instead of a String.
First, we create a class in our test.bundle bundle MyMessage in package test.bundle:
package test.bundle;
public class MyMessage {
private String message;
public MyMessage(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
}
We will return this object in XML format to REST webservice requester. We will use
Maven + Apache Felix + CXF: Creating a RESTful Webservice with CXF. A Simple String Example.
This is next post in Maven + Apache Felix + CXF + DOSGi series.
This is example is based on the sample application developed in previous post. Again, it is assumed here that you are using M2Eclipse plugin, if you want to run examples from Eclipse.
As usual, source is included in the end of the post.
First of, we need to
Maven + Apache Felix: Best Practices
This is another post in Maven + Apache Felix + CXF + DOSGi series. As was shown in Maven + Apache Felix: Easy Development and Debugging With Eclipse post, it is easy to develop projects with Maven and Apache Felix. But how about really big projects. How to maintain configuration and easily manage the bundles?
The answer is simple -- use the
Maven + Apache Felix: Easy Development and Debugging With Eclipse
This is a first post on in series about Maven + Apache Felix + CXF + DOSGi. Here we will combine Maven, Apache Felix and Eclipse. You have to use M2Eclipse plugin for this (or similar Maven-Eclipse integration plugin).
The problem:
- Integrating Felix with Eclipse tutorial requires manual download and configuration of Felix distributable into workspace
- Felix allows deploying only jar bundles, which is inappropriate for easy development and debugging
We can use the power of Maven and these two resources to solve both problems.
The idea about the first one is to