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