Red Hat AMQ 6
As of February 2025, Red Hat is no longer supporting Red Hat AMQ 6. If you are using AMQ 6, please upgrade: Migrating to AMQ 7.Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 2. Securing the Red Hat JBoss A-MQ Container
Abstract
2.1. JAAS Authentication Link kopierenLink in die Zwischenablage kopiert!
Abstract
2.1.1. Default JAAS Realm Link kopierenLink in die Zwischenablage kopiert!
Overview Link kopierenLink in die Zwischenablage kopiert!
Default JAAS realm Link kopierenLink in die Zwischenablage kopiert!
karaf
realm, which is used by default to secure all aspects of the container.
How to integrate an application with JAAS Link kopierenLink in die Zwischenablage kopiert!
karaf
realm in your own applications. Simply configure karaf
as the name of the JAAS realm that you want to use.
Default JAAS login modules Link kopierenLink in die Zwischenablage kopiert!
karaf
default realm. In this default configuration, the karaf
realm deploys two JAAS login modules, which are enabled simultaneously. To see the deployed login modules, enter the jaas:realms
console command, as follows:
JBossFuse:karaf@root> jaas:realms Index Realm Module Class 1 karaf org.apache.karaf.jaas.modules.properties.PropertiesLoginModule 2 karaf org.apache.karaf.jaas.modules.publickey.PublickeyLoginModule
JBossFuse:karaf@root> jaas:realms
Index Realm Module Class
1 karaf org.apache.karaf.jaas.modules.properties.PropertiesLoginModule
2 karaf org.apache.karaf.jaas.modules.publickey.PublickeyLoginModule
Configuring the properties login module Link kopierenLink in die Zwischenablage kopiert!
InstallDir/etc/users.properties
file using a text editor and add a line with the following syntax:
Username=Password[,Role1][,Role2]...
Username=Password[,Role1][,Role2]...
jdoe
user with password, topsecret
, and role, admin
, you could create an entry like the following:
jdoe=topsecret,admin
jdoe=topsecret,admin
admin
role gives full administrative privileges to the jdoe
user.
Configuring the public key login module Link kopierenLink in die Zwischenablage kopiert!
InstallDir/etc/keys.properties
file using a text editor and add a line with the following syntax:
Username=PublicKey,Role1,Role2,...
Username=PublicKey,Role1,Role2,...
jdoe
user with the admin
role by adding the following entry to the InstallDir/etc/keys.properties
file (on a single line):
id_rsa.pub
file here. Insert just the block of symbols which represents the public key itself.
Encrypting the stored passwords Link kopierenLink in die Zwischenablage kopiert!
InstallDir/etc/users.properties
file in plaintext format. To protect the passwords in this file, you must set the file permissions of the users.properties
file so that it can be read only by administrators. To provide additional protection, you can optionally encrypt the stored passwords using a message digest algorithm.
InstallDir/etc/org.apache.karaf.jaas.cfg
file and set the encryption properties as described in the comments. For example, the following settings would enable basic encryption using the MD5 message digest algorithm:
org.apache.karaf.jaas.cfg
file are applied only to the default karaf
realm in a standalone container. The have no effect on a fabric container and no effect on a custom realm.
Overriding the default realm Link kopierenLink in die Zwischenablage kopiert!
karaf
realm by defining a higher ranking karaf
realm. This ensures that all of the Red Hat JBoss A-MQ security components switch to use your custom realm. For details of how to define and deploy custom JAAS realms, see Section 2.1.2, “Defining JAAS Realms”.
2.1.2. Defining JAAS Realms Link kopierenLink in die Zwischenablage kopiert!
Overview Link kopierenLink in die Zwischenablage kopiert!
jaas:config
element for defining JAAS realms in a blueprint configuration file. The JAAS realms defined in this way are made available to all of the application bundles deployed in the container, making it possible to share the JAAS security infrastructure across the whole container.
Namespace Link kopierenLink in die Zwischenablage kopiert!
jaas:config
element is defined in the http://karaf.apache.org/xmlns/jaas/v1.0.0
namespace. When defining a JAAS realm you will need to include the line shown in Example 2.1, “JAAS Blueprint Namespace”.
Example 2.1. JAAS Blueprint Namespace
xmlns:jaas="http://karaf.apache.org/xmlns/jaas/v1.0.0"
xmlns:jaas="http://karaf.apache.org/xmlns/jaas/v1.0.0"
Configuring a JAAS realm Link kopierenLink in die Zwischenablage kopiert!
jaas:config
element is shown in Example 2.2, “Defining a JAAS Realm in Blueprint XML”.
Example 2.2. Defining a JAAS Realm in Blueprint XML
jaas:config
- Defines the JAAS realm. It has the following attributes:
name
—specifies the name of the JAAS realm.rank
—specifies an optional rank for resolving naming conflicts between JAAS realms . When two or more JAAS realms are registered under the same name, the OSGi container always picks the realm instance with the highest rank.
jaas:module
- Defines a JAAS login module in the current realm.
jaas:module
has the following attributes:className
—the fully-qualified class name of a JAAS login module. The specified class must be available from the bundle classloader.flags
—determines what happens upon success or failure of the login operation. Table 2.1, “Flags for Defining a JAAS Module” describes the valid values.Expand Table 2.1. Flags for Defining a JAAS Module Value Description required
Authentication of this login module must succeed. Always proceed to the next login module in this entry, irrespective of success or failure. requisite
Authentication of this login module must succeed. If success, proceed to the next login module; if failure, return immediately without processing the remaining login modules. sufficient
Authentication of this login module is not required to succeed. If success, return immediately without processing the remaining login modules; if failure, proceed to the next login module. optional
Authentication of this login module is not required to succeed. Always proceed to the next login module in this entry, irrespective of success or failure.
The contents of ajaas:module
element is a space separated list of property settings, which are used to initialize the JAAS login module instance. The specific properties are determined by the JAAS login module and must be put into the proper format.NoteYou can define multiple login modules in a realm.
Converting standard JAAS login properties to XML Link kopierenLink in die Zwischenablage kopiert!
PropertiesLogin
realm using the Apache ActiveMQ properties login module class, PropertiesLoginModule
:
Example 2.3. Standard JAAS Properties
PropertiesLogin { org.apache.activemq.jaas.PropertiesLoginModule required org.apache.activemq.jaas.properties.user="users.properties" org.apache.activemq.jaas.properties.group="groups.properties"; };
PropertiesLogin {
org.apache.activemq.jaas.PropertiesLoginModule required
org.apache.activemq.jaas.properties.user="users.properties"
org.apache.activemq.jaas.properties.group="groups.properties";
};
jaas:config
element in a blueprint file, is shown in Example 2.4, “Blueprint JAAS Properties”.
Example 2.4. Blueprint JAAS Properties
Example Link kopierenLink in die Zwischenablage kopiert!
LDAPLogin
realm to use JBoss A-MQ's LDAPLoginModule
class, which connects to the LDAP server located at ldap://localhost:10389.
Example 2.5. Configuring a JAAS Realm
2.1.3. JAAS Properties Login Module Link kopierenLink in die Zwischenablage kopiert!
Overview Link kopierenLink in die Zwischenablage kopiert!
jaas:*
console commands.
InstallDir/etc/users.properties
file.
Supported credentials Link kopierenLink in die Zwischenablage kopiert!
Implementation classes Link kopierenLink in die Zwischenablage kopiert!
org.apache.karaf.jaas.modules.properties.PropertiesLoginModule
- Implements the JAAS login module.
org.apache.karaf.jaas.modules.properties.PropertiesBackingEngineFactory
- Must be exposed as an OSGi service. This service makes it possible for you to manage the user data using the
jaas:*
console commands from the Apache Karaf shell (see chapter "JAAS Console Commands" in "Console Reference").
Options Link kopierenLink in die Zwischenablage kopiert!
users
- Location of the user properties file.
Format of the user properties file Link kopierenLink in die Zwischenablage kopiert!
Username=Password[,Role][,Role]...
Username=Password[,Role][,Role]...
Sample Blueprint configuration Link kopierenLink in die Zwischenablage kopiert!
karaf
realm using the properties login module, where the default karaf
realm is overridden by setting the rank
attribute to 2
:
BackingEngineFactory
bean as an OSGi service, so that the jaas:*
console commands can manage the user data.
2.1.4. JAAS OSGi Config Login Module Link kopierenLink in die Zwischenablage kopiert!
Overview Link kopierenLink in die Zwischenablage kopiert!
etc/PersistentID.cfg
or using any method of configuration that is supported by the OSGi Config Admin Service. The jaas:*
console commands are not supported, however.
Supported credentials Link kopierenLink in die Zwischenablage kopiert!
Implementation classes Link kopierenLink in die Zwischenablage kopiert!
org.apache.karaf.jaas.modules.osgi.OsgiConfigLoginModule
- Implements the JAAS login module.
jaas:*
console commands.
Options Link kopierenLink in die Zwischenablage kopiert!
pid
- The persistent ID of the OSGi configuration containing the user data. In the OSGi Config Admin standard, a persistent ID references a set of related configuration properties.
Location of the configuration file Link kopierenLink in die Zwischenablage kopiert!
PersistentID
, is stored in the following file:
InstallDir/etc/PersistentID.cfg
InstallDir/etc/PersistentID.cfg
Format of the configuration file Link kopierenLink in die Zwischenablage kopiert!
PersistentID.cfg
configuration file is used to store username, password, and role data for the OSGi config login module. Each user is represented by a single line in the configuration file, where a line has the following form:
Username=Password[,Role][,Role]...
Username=Password[,Role][,Role]...
Sample Blueprint configuration Link kopierenLink in die Zwischenablage kopiert!
karaf
realm using the OSGi config login module, where the default karaf
realm is overridden by setting the rank
attribute to 2
:
InstallDir/etc/org.jboss.example.osgiconfigloginmodule.cfg
, and it is not possible to edit the configuration using the jaas:*
console commands.
2.1.5. JAAS Public Key Login Module Link kopierenLink in die Zwischenablage kopiert!
Overview Link kopierenLink in die Zwischenablage kopiert!
jaas:*
console commands are not supported, however.
InstallDir/etc/keys.properties
file.
Supported credentials Link kopierenLink in die Zwischenablage kopiert!
Implementation classes Link kopierenLink in die Zwischenablage kopiert!
org.apache.karaf.jaas.modules.publickey.PublickeyLoginModule
- Implements the JAAS login module.
jaas:*
console commands.
Options Link kopierenLink in die Zwischenablage kopiert!
users
- Location of the user properties file for the public key login module.
Format of the user properties file Link kopierenLink in die Zwischenablage kopiert!
Username=PublicKey[,Role][,Role]...
Username=PublicKey[,Role][,Role]...
~/.ssh/id_rsa.pub
in a UNIX system).
jdoe
with the admin
role, you would create an entry like the following:
id_rsa.pub
file here. Insert just the block of symbols which represents the public key itself.
Sample Blueprint configuration Link kopierenLink in die Zwischenablage kopiert!
karaf
realm using the public key login module, where the default karaf
realm is overridden by setting the rank
attribute to 2
:
InstallDir/etc/keys.properties
, and it is not possible to edit the configuration using the jaas:*
console commands.
2.1.6. JAAS JDBC Login Module Link kopierenLink in die Zwischenablage kopiert!
Overview Link kopierenLink in die Zwischenablage kopiert!
jaas:*
console commands (where the backing engine uses configured SQL queries to perform the relevant database updates).
Supported credentials Link kopierenLink in die Zwischenablage kopiert!
Implementation classes Link kopierenLink in die Zwischenablage kopiert!
org.apache.karaf.jaas.modules.jdbc.JDBCLoginModule
- Implements the JAAS login module.
org.apache.karaf.jaas.modules.jdbc.JDBCBackingEngineFactory
- Must be exposed as an OSGi service. This service makes it possible for you to manage the user data using the
jaas:*
console commands from the Apache Karaf shell (see chapter "JAAS Console Commands" in "Console Reference").
Options Link kopierenLink in die Zwischenablage kopiert!
- datasource
- The JDBC data source, specified either as an OSGi service or as a JNDI name. You can specify a data source's OSGi service using the following syntax:
osgi:ServiceInterfaceName[/ServicePropertiesFilter]
osgi:ServiceInterfaceName[/ServicePropertiesFilter]
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The ServiceInterfaceName is the interface or class that is exported by the data source's OSGi service (usuallyjavax.sql.DataSource
).Because multiple data sources can be exported as OSGi services in a container, it is usually necessary to specify a filter, ServicePropertiesFilter, to select the particular data source that you want. Filters on OSGi services are applied to the service property settings and follow a syntax that is borrowed from LDAP filter syntax. - query.password
- The SQL query that retrieves the user's password. The query can contain a single question mark character,
?
, which is substituted by the username at run time. - query.role
- The SQL query that retrieves the user's roles. The query can contain a single question mark character,
?
, which is substituted by the username at run time. - insert.user
- The SQL query that creates a new user entry. The query can contain two question marks,
?
, characters: the first question mark is substituted by the username and the second question mark is substituted by the password at run time. - insert.role
- The SQL query that adds a role to a user entry. The query can contain two question marks,
?
, characters: the first question mark is substituted by the username and the second question mark is substituted by the role at run time. - delete.user
- The SQL query that deletes a user entry. The query can contain a single question mark character,
?
, which is substituted by the username at run time. - delete.role
- The SQL query that deletes a role from a user entry. The query can contain two question marks,
?
, characters: the first question mark is substituted by the username and the second question mark is substituted by the role at run time. - delete.roles
- The SQL query that deletes multiple roles from a user entry. The query can contain a single question mark character,
?
, which is substituted by the username at run time.
Example of setting up a JDBC login module Link kopierenLink in die Zwischenablage kopiert!
Create the database tables Link kopierenLink in die Zwischenablage kopiert!
users
table and roles
table:
users
table stores username/password data and the roles
table associates a username with one or more roles.
Create the data source Link kopierenLink in die Zwischenablage kopiert!
javax.sql.DataSource
type) using code like the following in a Blueprint file:
Specify the data source as an OSGi service Link kopierenLink in die Zwischenablage kopiert!
datasource
option of the JDBC login module can reference the data source's OSGi service using the following syntax:
osgi:javax.sql.DataSource/(osgi.jndi.service.name=jdbc/karafdb)
osgi:javax.sql.DataSource/(osgi.jndi.service.name=jdbc/karafdb)
javax.sql.DataSource
is the interface type of the exported OSGi service and the filter, (osgi.jndi.service.name=jdbc/karafdb)
, selects the particular javax.sql.DataSource
instance whose osgi.jndi.service.name
service property has the value, jdbc/karafdb
.
karaf
realm with a JDBC login module that references the sample MySQL data source:
JDBCBackingEngineFactory
instance, which enables you to manage the user data using the jaas:*
console commands.
2.1.7. JAAS LDAP Login Module Link kopierenLink in die Zwischenablage kopiert!
Overview Link kopierenLink in die Zwischenablage kopiert!
jaas:*
console commands are not supported.
Supported credentials Link kopierenLink in die Zwischenablage kopiert!
Implementation classes Link kopierenLink in die Zwischenablage kopiert!
org.apache.karaf.jaas.modules.ldap.LDAPLoginModule
- Implements the JAAS login module.
jaas:*
console commands.
Options Link kopierenLink in die Zwischenablage kopiert!
connection.url
- The LDAP connection URL—for example,
ldap://hostname
. connection.username
- Admin username to connect to the LDAP server. This parameter is optional: if it is not provided, the LDAP connection will be anonymous.
connection.password
- Admin password to connect to the LDAP server. Used only if the
connection.username
is also specified. user.base.dn
- The LDAP base DN used to look up roles—for example,
ou=role,dc=apache,dc=org
. user.filter
- The LDAP filter used to look up a user's role—for example,
(member:=uid=%u)
. user.search.subtree
- If
true
, the user lookup is recursive (SUBTREE
). Iffalse
, the user lookup is performed only at the first level (ONELEVEL
). role.base.dn
- The LDAP base DN used to look up roles—for example,
ou=role,dc=apache,dc=org
. role.filter
- The LDAP filter used to look up a user's role—for example,
(member:=uid=%u)
. role.name.attribute
- The LDAP role attribute containing the role value used by Apache Karaf—for example,
cn
. role.search.subtree
- If
true
, the role lookup is recursive (SUBTREE
). Iffalse
, the role lookup is performed only at the first level (ONELEVEL
). authentication
- Define the authentication back-end used on the LDAP server. The default is
simple
. initial.context.factory
- Define the initial context factory used to connect to the LDAP server. The default is
com.sun.jndi.ldap.LdapCtxFactory
. ssl
- If
true
or if the protocol on theconnection.url
isldaps
, an SSL connection will be used. ssl.provider
- Specifies the SSL provider.
ssl.protocol
- The protocol version to use. You must set this property to
TLSv1
, in order to prevent the SSLv3 protocol from being used (POODLE vulnerability). ssl.algorithm
- The algorithm to use for the
KeyManagerFactory
and theTrustManagerFactory
—for example,PKIX
. ssl.keystore
- The ID of the keystore that stores the LDAP client's own X.509 certificate (required only if SSL client authentication is enabled on the LDAP server). The keystore must be deployed using a
jaas:keystore
element (see the section called “Sample Blueprint configuration”). ssl.keyalias
- The keystore alias of the LDAP client's own X.509 certificate (required only if there is more than one certificate stored in the keystore specified by
ssl.keystore
). ssl.truststore
- The ID of the keystore that stores trusted CA certificates, which are used to verify the LDAP server's certificate (the LDAP server's certificate chain must be signed by one of the certificates in the truststore). The keystore must be deployed using a
jaas:keystore
element.
Sample Blueprint configuration Link kopierenLink in die Zwischenablage kopiert!
karaf
realm using the LDAP login module, where the default karaf
realm is overridden by setting the rank
attribute to 2
:
ssl.protocol
to TLSv1
, in order to protect against the Poodle vulnerability (CVE-2014-3566)
2.1.8. Encrypting Stored Passwords Link kopierenLink in die Zwischenablage kopiert!
Overview Link kopierenLink in die Zwischenablage kopiert!
Options Link kopierenLink in die Zwischenablage kopiert!
encryption.enabled
- Set to
true
, to enable password encryption. encryption.name
- Name of the encryption service, which has been registered as an OSGi service.
encryption.prefix
- Prefix for encrypted passwords.
encryption.suffix
- Suffix for encrypted passwords.
encryption.algorithm
- Specifies the name of the encryption algorithm—for example,
MD5
orSHA-1
. You can specify one of the following encryption algorithms:MD2
MD5
SHA-1
SHA-256
SHA-384
SHA-512
encryption.encoding
- Encrypted passwords encoding:
hexadecimal
orbase64
. encryption.providerName
(Jasypt only)- Name of the
java.security.Provider
instance that is to provide the digest algorithm. encryption.providerClassName
(Jasypt only)- Class name of the security provider that is to provide the digest algorithm
encryption.iterations
(Jasypt only)- Number of times to apply the hash function recursively.
encryption.saltSizeBytes
(Jasypt only)- Size of the salt used to compute the digest.
encryption.saltGeneratorClassName
(Jasypt only)- Class name of the salt generator.
role.policy
- Specifies the policy for identifying role principals. Can have the values,
prefix
orgroup
. role.discriminator
- Specifies the discriminator value to be used by the role policy.
Encryption services Link kopierenLink in die Zwischenablage kopiert!
org.apache.karaf.jaas.modules.EncryptionService
interface and exporting an instance of the encryption service as an OSGi service. Two alternative implementations of the encryption service are provided:
Basic encryption service Link kopierenLink in die Zwischenablage kopiert!
encryption.name
property to the value, basic
. In the basic encryption service, the message digest algorithms are provided by the SUN security provider (the default security provider in the Oracle JDK).
Jasypt encryption Link kopierenLink in die Zwischenablage kopiert!
jasypt-encryption
feature. For example, you can install Jasypt encryption by entering the following console command:
JBossFuse:karaf@root> features:install jasypt-encryption
JBossFuse:karaf@root> features:install jasypt-encryption
encryption.name
property to the value, jasypt
.
Example of a login module with Jasypt encryption Link kopierenLink in die Zwischenablage kopiert!
jasypt-encryption
feature, you could deploy a properties login module with Jasypt encryption using the following Blueprint configuration: