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;
}
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;
}
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);
}
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;
}
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);
}
Aggregations