Home

Awesome

fabric8-cxf-shiro

This example project is comprehended by the following:

Pre-requisites

Build and install

mvn clean install

Provisioning

Installation and initial configuration

cd <FABRIC8_PATH>
bin/fusefabric

If everything goes well, you should get a Fabric shell that looks like this:

Please wait while Fabric8 is loading...
100% [========================================================================]

______    _          _      _____
|  ___|  | |        (_)    |  _  |
| |_ __ _| |__  _ __ _  ___ \ V /
|  _/ _` | '_ \| '__| |/ __|/ _ \
| || (_| | |_) | |  | | (__| |_| |
\_| \__,_|_.__/|_|  |_|\___\_____/
  Fabric8 Container (1.1.0.CR1)
  http://fabric8.io/

Type 'help' to get started
and 'help [cmd]' for help on a specific command.
Hit '<ctrl-d>' or 'osgi:shutdown' to shutdown this container.

Open a browser to http://localhost:8181 to access the management console

Create a new Fabric via 'fabric:create'
or join an existing Fabric via 'fabric:join [someUrls]'

Fabric8:karaf@root>

Start Fabric Ensemble

fabric:create --clean --wait-for-provisioning

Define our own profile

profile-create --parents feature-dosgi cxf-shiro-example
profile-edit --repositories mvn:com.github.pires.example/feature-hazelcast/0.2-SNAPSHOT/xml/features cxf-shiro-example
profile-edit --repositories mvn:com.github.pires.example/feature-persistence/0.2-SNAPSHOT/xml/features cxf-shiro-example
profile-edit --repositories mvn:com.github.pires.example/feature-rest/0.2-SNAPSHOT/xml/features cxf-shiro-example
profile-edit --features hazelcast cxf-shiro-example
profile-edit --features persistence-aries-hibernate cxf-shiro-example
profile-edit --features cxf-shiro cxf-shiro-example
profile-edit --bundles mvn:com.github.pires.example/datasource-hsqldb/0.2-SNAPSHOT cxf-shiro-example
profile-edit --bundles mvn:com.github.pires.example/service/0.2-SNAPSHOT cxf-shiro-example
profile-edit --bundles mvn:com.github.pires.example/service-impl/0.2-SNAPSHOT cxf-shiro-example
profile-edit --bundles mvn:com.github.pires.example/cxf-shiro/0.2-SNAPSHOT cxf-shiro-example

Create and run new container with newly created profile

container-create-child --profile cxf-shiro-example root cxf-shiro-example-test1

Testing

In Hawt.io UI, go to API tab (in the parent container), check the host and port where AuthenticationManager is available and point it down. Test the REST endpoint as you wish!

REST API (JSON)

Initialize scenario

PUT /demo/auth

Login

POST /demo/auth (Content-Type: application/json)

Example JSON:
{
  "username":"admin@example.com",
  "password":["1","2","3"]
}

Check the response headers and write down be-token, for usage in authenticated requests.

View profile

Set be-token header to the value you've written before.

GET /demo/auth

You should see admin@example.com in the response body.