Search in sources :

Example 6 with EncryptionSupport

use of org.apache.karaf.jaas.modules.encryption.EncryptionSupport in project karaf by apache.

the class JDBCBackingEngineFactory method build.

/**
 * Build a Backing engine for the JDBCLoginModule.
 */
public BackingEngine build(Map<String, ?> options) {
    JDBCBackingEngine instance = null;
    String datasourceURL = JAASUtils.getString(options, JDBCUtils.DATASOURCE);
    BundleContext bundleContext = (BundleContext) options.get(BundleContext.class.getName());
    String addUserStatement = JAASUtils.getString(options, JDBCLoginModule.INSERT_USER_STATEMENT);
    String addRoleStatement = JAASUtils.getString(options, JDBCLoginModule.INSERT_ROLE_STATEMENT);
    String deleteRoleStatement = JAASUtils.getString(options, JDBCLoginModule.DELETE_ROLE_STATEMENT);
    String deleteAllUserRolesStatement = JAASUtils.getString(options, JDBCLoginModule.DELETE_ROLES_STATEMENT);
    String deleteUserStatement = JAASUtils.getString(options, JDBCLoginModule.DELETE_USER_STATEMENT);
    String selectUsersQuery = JAASUtils.getString(options, JDBCLoginModule.USER_QUERY);
    String selectRolesQuery = JAASUtils.getString(options, JDBCLoginModule.ROLE_QUERY);
    try {
        DataSource dataSource = JDBCUtils.createDatasource(bundleContext, datasourceURL);
        EncryptionSupport encryptionSupport = new EncryptionSupport(options);
        instance = new JDBCBackingEngine(dataSource, encryptionSupport);
        if (addUserStatement != null) {
            instance.setAddUserStatement(addUserStatement);
        }
        if (addRoleStatement != null) {
            instance.setAddRoleStatement(addRoleStatement);
        }
        if (deleteRoleStatement != null) {
            instance.setDeleteRoleStatement(deleteRoleStatement);
        }
        if (deleteAllUserRolesStatement != null) {
            instance.setDeleteAllUserRolesStatement(deleteAllUserRolesStatement);
        }
        if (deleteUserStatement != null) {
            instance.setDeleteUserStatement(deleteUserStatement);
        }
        if (selectUsersQuery != null) {
            instance.setSelectUsersQuery(selectUsersQuery);
        }
        if (selectRolesQuery != null) {
            instance.setSelectRolesQuery(selectRolesQuery);
        }
    } catch (Exception e) {
        LOGGER.error("Error creating JDBCBackingEngine.", e);
    }
    return instance;
}
Also used : BundleContext(org.osgi.framework.BundleContext) DataSource(javax.sql.DataSource) EncryptionSupport(org.apache.karaf.jaas.modules.encryption.EncryptionSupport)

Example 7 with EncryptionSupport

use of org.apache.karaf.jaas.modules.encryption.EncryptionSupport in project karaf by apache.

the class AbstractKarafLoginModule method initialize.

public void initialize(Subject sub, CallbackHandler handler, Map<String, ?> options) {
    this.subject = sub;
    this.callbackHandler = handler;
    this.options = options;
    this.rolePolicy = JAASUtils.getString(options, "role.policy");
    this.roleDiscriminator = JAASUtils.getString(options, "role.discriminator");
    this.debug = Boolean.parseBoolean(JAASUtils.getString(options, "debug"));
    this.detailedLoginExcepion = Boolean.parseBoolean(JAASUtils.getString(options, "detailed.login.exception"));
    // the bundle context is set in the Config JaasRealm by default
    this.bundleContext = (BundleContext) options.get(BundleContext.class.getName());
    encryptionSupport = new EncryptionSupport(options);
}
Also used : BundleContext(org.osgi.framework.BundleContext) EncryptionSupport(org.apache.karaf.jaas.modules.encryption.EncryptionSupport)

Aggregations

EncryptionSupport (org.apache.karaf.jaas.modules.encryption.EncryptionSupport)7 BundleContext (org.osgi.framework.BundleContext)4 File (java.io.File)2 IOException (java.io.IOException)2 CuratorFramework (org.apache.curator.framework.CuratorFramework)2 LockHandle (io.fabric8.api.LockHandle)1 Profile (io.fabric8.api.Profile)1 ProfileBuilder (io.fabric8.api.ProfileBuilder)1 Version (io.fabric8.api.Version)1 VersionBuilder (io.fabric8.api.VersionBuilder)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Properties (java.util.Properties)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 DataSource (javax.sql.DataSource)1 Properties (org.apache.felix.utils.properties.Properties)1 Encryption (org.apache.karaf.jaas.modules.Encryption)1 Bundle (org.osgi.framework.Bundle)1