Search in sources :

Example 1 with EncryptionSupport

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

the class PropertiesBackingEngineFactory method build.

/**
 * Builds the Backing Engine
 */
public BackingEngine build(Map<String, ?> options) {
    PropertiesBackingEngine engine = null;
    String usersFile = (String) options.get(USER_FILE);
    File f = new File(usersFile);
    Properties users;
    try {
        users = new Properties(f);
        EncryptionSupport encryptionSupport = new EncryptionSupport(options);
        engine = new PropertiesBackingEngine(users, encryptionSupport);
    } catch (IOException ioe) {
        LOGGER.warn("Cannot open users file: {}", usersFile);
    }
    return engine;
}
Also used : IOException(java.io.IOException) Properties(org.apache.felix.utils.properties.Properties) File(java.io.File) EncryptionSupport(org.apache.karaf.jaas.modules.encryption.EncryptionSupport)

Example 2 with EncryptionSupport

use of org.apache.karaf.jaas.modules.encryption.EncryptionSupport in project fabric8 by jboss-fuse.

the class ZookeeperBackingEngineFactory method build.

@Override
public BackingEngine build(Map options) {
    assertValid();
    ZookeeperBackingEngine engine = null;
    EncryptionSupport encryptionSupport = new BasicEncryptionSupport(options);
    String path = (String) options.get("path");
    if (path == null) {
        path = ZookeeperBackingEngine.USERS_NODE;
    }
    try {
        // build appropriate znodes
        if (curator != null) {
            CuratorFramework framework = curator.get();
            if (framework.checkExists().forPath(path) == null) {
                framework.create().creatingParentsIfNeeded().forPath(path);
            }
        }
        ZookeeperProperties users = new ZookeeperProperties(curator.get(), path);
        users.load();
        engine = new ZookeeperBackingEngine(users, encryptionSupport);
    } catch (Exception e) {
        LOGGER.warn("Cannot initialize engine", e);
    }
    return engine;
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) EncryptionSupport(org.apache.karaf.jaas.modules.encryption.EncryptionSupport)

Example 3 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 options) {
    this.subject = sub;
    this.callbackHandler = handler;
    this.options = options;
    this.rolePolicy = (String) options.get("role.policy");
    this.roleDiscriminator = (String) options.get("role.discriminator");
    this.debug = Boolean.parseBoolean((String) options.get("debug"));
    this.detailedLoginExcepion = Boolean.parseBoolean((String) options.get("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)

Example 4 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 = (String) options.get(JDBCUtils.DATASOURCE);
    BundleContext bundleContext = (BundleContext) options.get(BundleContext.class.getName());
    String addUserStatement = (String) options.get(JDBCLoginModule.INSERT_USER_STATEMENT);
    String addRoleStatement = (String) options.get(JDBCLoginModule.INSERT_ROLE_STATEMENT);
    String deleteRoleStatement = (String) options.get(JDBCLoginModule.DELETE_ROLE_STATEMENT);
    String deleteAllUserRolesStatement = (String) options.get(JDBCLoginModule.DELETE_ROLES_STATEMENT);
    String deleteUserStatement = (String) options.get(JDBCLoginModule.DELETE_USER_STATEMENT);
    String selectUsersQuery = (String) options.get(JDBCLoginModule.USER_QUERY);
    String selectRolesQuery = (String) options.get(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 5 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 = (String) options.get("role.policy");
    this.roleDiscriminator = (String) options.get("role.discriminator");
    this.debug = Boolean.parseBoolean((String) options.get("debug"));
    this.detailedLoginExcepion = Boolean.parseBoolean((String) options.get("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