Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Este contenido no está disponible en el idioma seleccionado.
4.3. Tutorial II: JAAS Authentication
Overview Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
This tutorial shows you how to enable JAAS authentication on a broker installed in the OSGi container. Instead of creating a local instance of a JAAS realm (as you would for a standalone broker), the broker exploits Red Hat JBoss Fuse's support for container-wide JAAS realms, as shown in Figure 1.1, “OSGi Container Security Architecture”.
After the broker is secured by JAAS authentication, you can test it using the sample JMS clients from the standalone Red Hat JBoss A-MQ distribution. The JMS clients must first be modified, however, to provide the requisite username/password JMS credentials.
Prerequisites Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
This tutorial part builds on Section 4.1, “Tutorial I: SSL/TLS Security”. All of the prerequisites from the section called “Prerequisites” apply here and you must complete the previous tutorial part before proceeding.
Tutorial steps Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
To configure JAAS security for a broker deployed in the OSGi container, perform the following steps:
Configure the broker with the karaf realm Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
Configure the broker to authenticate JMS username/password credentials by checking them against the
karaf
JAAS realm. In the Maven project, edit the broker-spring.xml
file, adding the plugins
element, as highlighted in the following XML sample:
Customize the users.properties file Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
The
karaf
JAAS realm can be administered by editing the InstallDir/etc/users.properties
file, where the file contains entries in the following format:
Username=Password,Role1,Role2,...
Username=Password,Role1,Role2,...
For example, the default
users.properties
file shows a sample entry (which is commented out) for the user, smx
, with password, smx
, as follows:
#smx=smx,admin
#smx=smx,admin
Customize the
users.properties
file by adding at least one user entry with the admin
role. For example:
Username=Password,admin
Username=Password,admin
Build the broker bundle Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
Use Maven to build the broker bundle. Open a command prompt, switch the current directory to
ProjectDir/esb-security
, and then enter the following command:
mvn clean install
mvn clean install
Deploy the broker bundle Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
If you have not already done so, start up the Apache ServiceMix console (and container instance) by entering the following command in a new command prompt:
servicemix
servicemix
To deploy and activate the broker bundle, enter the following console command:
JBossFuse:karaf@root> osgi:install -s mvn:org.jbossfuse.example/esb-security
JBossFuse:karaf@root> osgi:install -s mvn:org.jbossfuse.example/esb-security
Specify JMS credentials for the consumer and the producer clients Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
To test the broker configured in the OSGi container, you are going to use the example consumer tool and producer tool supplied with the standalone version of Red Hat JBoss A-MQ.
You must modify the source code for the consumer and the producer clients in order to specify their JMS credentials.
To specify the JMS credentials for the consumer tool, edit the
ActiveMQInstallDir/example/src/ConsumerTool.java
file with your favorite text editor, setting the user and password strings, as shown. These strings are ultimately passed as arguments to the ActiveMQConnectionFactory.createConnection()
method.
To specify the JMS credentials for the producer tool, edit the
ActiveMQInstallDir/example/src/ProducerTool.java
file with your favorite text editor, setting the user and password strings, as shown.
Run the consumer with JMS credentials Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
To connect the consumer tool to the
ssl://localhost:61001
endpoint, change directory to ActiveMQInstallDir/example
and enter the following command:
ant consumer -Durl=ssl://localhost:61001 -Dmax=100
ant consumer -Durl=ssl://localhost:61001 -Dmax=100
You should see some output like the following:
Run the producer with JMS credentials Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
To connect the producer tool to the
ssl://localhost:61001
endpoint, open a new command prompt, change directory to example
and enter the following command:
ant producer -Durl=ssl://localhost:61001 -Dmax=100
ant producer -Durl=ssl://localhost:61001 -Dmax=100
In the window where the consumer tool is running, you should see some output like the following:
[java] Received: Message: 0 sent at: Thu Feb 05 09:27:43 GMT 2009 ... [java] Received: Message: 1 sent at: Thu Feb 05 09:27:43 GMT 2009 ... [java] Received: Message: 2 sent at: Thu Feb 05 09:27:43 GMT 2009 ... [java] Received: Message: 3 sent at: Thu Feb 05 09:27:43 GMT 2009 ...
[java] Received: Message: 0 sent at: Thu Feb 05 09:27:43 GMT 2009 ...
[java] Received: Message: 1 sent at: Thu Feb 05 09:27:43 GMT 2009 ...
[java] Received: Message: 2 sent at: Thu Feb 05 09:27:43 GMT 2009 ...
[java] Received: Message: 3 sent at: Thu Feb 05 09:27:43 GMT 2009 ...
Uninstall the broker bundle Copiar enlaceEnlace copiado en el portapapeles!
Copiar enlaceEnlace copiado en el portapapeles!
To uninstall the broker bundle, you need to know its bundle ID, BundleID, in which case you can uninstall it by entering the following console command:
JBossFuse:karaf@root> osgi:uninstall BundleID
JBossFuse:karaf@root> osgi:uninstall BundleID