use of javax.naming.Context in project camel by apache.
the class DataFormatDataSetTest method createJndiContext.
@Override
protected Context createJndiContext() throws Exception {
PurchaseOrder bean = new PurchaseOrder();
bean.setName("Beer");
bean.setAmount(23);
bean.setPrice(2.5);
SimpleDataSet ds = new SimpleDataSet();
ds.setDefaultBody(bean);
ds.setSize(200);
Context context = super.createJndiContext();
context.bind("beer", ds);
return context;
}
use of javax.naming.Context in project camel by apache.
the class JcrAuthTestBase method createJndiContext.
@Override
protected Context createJndiContext() throws Exception {
Context context = super.createJndiContext();
repository = new TransientRepository(new File(REPO_PATH));
// set up a user to authenticate
SessionImpl session = (SessionImpl) repository.login(new SimpleCredentials("admin", "admin".toCharArray()));
UserManager userManager = session.getUserManager();
User user = (User) userManager.getAuthorizable("test");
if (user == null) {
user = userManager.createUser("test", "quatloos");
}
// set up permissions
String path = session.getRootNode().getPath();
AccessControlManager accessControlManager = session.getAccessControlManager();
AccessControlPolicyIterator acls = accessControlManager.getApplicablePolicies(path);
AccessControlList acl = null;
if (acls.hasNext()) {
acl = (AccessControlList) acls.nextAccessControlPolicy();
} else {
acl = (AccessControlList) accessControlManager.getPolicies(path)[0];
}
acl.addAccessControlEntry(user.getPrincipal(), accessControlManager.getSupportedPrivileges(path));
accessControlManager.setPolicy(path, acl);
session.save();
session.logout();
context.bind("repository", repository);
return context;
}
use of javax.naming.Context in project camel by apache.
the class JcrRouteTestSupport method createJndiContext.
@Override
protected Context createJndiContext() throws Exception {
File config = new File(CONFIG_FILE);
if (!config.exists()) {
throw new FileNotFoundException("Missing config file: " + config.getPath());
}
Context context = super.createJndiContext();
repository = new TransientRepository(CONFIG_FILE, REPO_PATH);
context.bind("repository", repository);
return context;
}
use of javax.naming.Context in project camel by apache.
the class JmsProviderTest method createJndiContext.
@Override
protected Context createJndiContext() throws Exception {
Context context = super.createJndiContext();
context.bind("activemq", ActiveMQComponent.activeMQComponent("vm://localhost"));
return context;
}
use of javax.naming.Context in project hadoop by apache.
the class LdapAuthenticationHandler method authenticateWithoutTlsExtension.
private void authenticateWithoutTlsExtension(String userDN, String password) throws AuthenticationException {
Hashtable<String, Object> env = new Hashtable<String, Object>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, providerUrl);
env.put(Context.SECURITY_AUTHENTICATION, SECURITY_AUTHENTICATION);
env.put(Context.SECURITY_PRINCIPAL, userDN);
env.put(Context.SECURITY_CREDENTIALS, password);
try {
// Create initial context
Context ctx = new InitialDirContext(env);
ctx.close();
logger.debug("Authentication successful for {}", userDN);
} catch (NamingException e) {
throw new AuthenticationException("Error validating LDAP user", e);
}
}
Aggregations