List of usage examples for javax.naming Context PROVIDER_URL
String PROVIDER_URL
To view the source code for javax.naming Context PROVIDER_URL.
Click Source Link
From source file:hsa.awp.common.naming.TestLdapDirectoryAdapter.java
/** * Adds expectations for context configuration to the adapter. * * @throws Exception if something went wrong. *///from w ww . j a v a2s .c om private void mockExpectConfiguration() throws Exception { mockery.checking(new Expectations() { { oneOf(directoryContext).addToEnvironment(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); oneOf(directoryContext).addToEnvironment(Context.PROVIDER_URL, ldapConfig.getProperty("naming.providerURL")); oneOf(directoryContext).addToEnvironment(Context.SECURITY_PRINCIPAL, ldapConfig.getProperty("naming.securityPrincipal")); oneOf(directoryContext).addToEnvironment(Context.SECURITY_CREDENTIALS, ldapConfig.getProperty("naming.securityCredentials")); oneOf(directoryContext).addToEnvironment(Context.SECURITY_PROTOCOL, ldapConfig.getProperty("naming.securityProtocol")); oneOf(directoryContext).addToEnvironment(Context.SECURITY_AUTHENTICATION, ldapConfig.getProperty("naming.securityAuthentication")); } }); }
From source file:org.easy.ldap.LdapContextFactory.java
/** * @param orgId/*from www. j a va 2s . c o m*/ * @return * @throws NamingException */ public DirContext createOrgContext(String orgId) throws NamingException { Hashtable<String, String> environment = getEnviroment(); environment.put(Context.PROVIDER_URL, createProviderUrl(namingFactory.createTenantDn(orgId).toString())); return createContext(environment); }
From source file:org.apache.axis2.transport.amqp.common.AMQPConnectionFactoryManager.java
/** * Get the AMQP connection factory that matches the given properties, i.e. referring to * the same underlying connection factory. Used by the AMQPSender to determine if already * available resources should be used for outgoing messages * * @param props a Map of connection factory JNDI properties and name * @return the AMQP connection factory or null if no connection factory compatible * with the given properties exists *///from w w w . java 2 s.c om public AMQPConnectionFactory getAMQPConnectionFactory(Map<String, String> props) { for (AMQPConnectionFactory cf : connectionFactories.values()) { Map<String, String> cfProperties = cf.getParameters(); if (equals(props.get(AMQPConstants.PARAM_AMQP_CONFAC), cfProperties.get(AMQPConstants.PARAM_AMQP_CONFAC)) && equals(props.get(Context.PROVIDER_URL), cfProperties.get(Context.PROVIDER_URL)) && equals(props.get(Context.SECURITY_PRINCIPAL), cfProperties.get(Context.SECURITY_PRINCIPAL)) && equals(props.get(Context.SECURITY_CREDENTIALS), cfProperties.get(Context.SECURITY_CREDENTIALS))) { return cf; } } return null; }
From source file:com.heliumv.factory.BaseCall.java
private Context getInitialContext() throws NamingException { Context env = (Context) new InitialContext().lookup("java:comp/env"); String namingFactory = (String) env.lookup(Context.INITIAL_CONTEXT_FACTORY); String urlProvider = (String) env.lookup(Context.PROVIDER_URL); log.debug("namingFactory = {" + namingFactory + "}"); log.debug("urlProvider = {" + urlProvider + "}"); Hashtable<String, String> environment = new Hashtable<String, String>(); environment.put(Context.INITIAL_CONTEXT_FACTORY, namingFactory); environment.put(Context.PROVIDER_URL, urlProvider); return new InitialContext(environment); }
From source file:no.smint.anthropos.ldap.LDAP.java
/** * Binds anonymously to the LDAP server. Returns a <code>Hashtable</code> to use for searching etc. * @return <code>Hashtable</code> with the binding to the server. *//* w ww .j av a 2 s. c om*/ public static Hashtable<String, Object> config() { Hashtable<String, Object> env = new Hashtable<String, Object>(); //Connection details env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, host); env.put(Context.SECURITY_AUTHENTICATION, "none"); //Optional for testing purposes //env.put(Context.SECURITY_AUTHENTICATION, "simple"); //env.put(Context.SECURITY_PRINCIPAL, "uid=birgith.do,ou=System Users,dc=studentmeidene,dc=no"); //env.put(Context.SECURITY_CREDENTIALS, "overrated rapid machine"); return env; }
From source file:org.apache.jackrabbit.ocm.spring.RepositoryUtil.java
/** * Get a repository/*from ww w .j a v a2 s .co m*/ * * @param repositoryName The repository name * @return a JCR repository reference * * @throws RepositoryException when it is not possible to get the repository. * Before calling this method, the repository has to be registered (@see RepositoryUtil#registerRepository(String, String, String) */ public static Repository getRepository(String repositoryName) throws RepositoryException { try { Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.jackrabbit.core.jndi.provider.DummyInitialContextFactory"); env.put(Context.PROVIDER_URL, "localhost"); InitialContext ctx = new InitialContext(env); Repository repository = (Repository) ctx.lookup(repositoryName); return repository; } catch (Exception e) { throw new RepositoryException("Impossible to get the repository : " + repositoryName, e); } }
From source file:org.apache.axis2.transport.jms.JMSConnectionFactoryManager.java
/** * Get the JMS connection factory that matches the given properties, i.e. referring to * the same underlying connection factory. Used by the JMSSender to determine if already * available resources should be used for outgoing messages * * @param props a Map of connection factory JNDI properties and name * @return the JMS connection factory or null if no connection factory compatible * with the given properties exists *//*from w ww .j a v a2 s . c om*/ public JMSConnectionFactory getJMSConnectionFactory(Map<String, String> props) { for (JMSConnectionFactory cf : connectionFactories.values()) { Map<String, String> cfProperties = cf.getParameters(); if (equals(props.get(JMSConstants.PARAM_CONFAC_JNDI_NAME), cfProperties.get(JMSConstants.PARAM_CONFAC_JNDI_NAME)) && equals(props.get(Context.INITIAL_CONTEXT_FACTORY), cfProperties.get(Context.INITIAL_CONTEXT_FACTORY)) && equals(props.get(Context.PROVIDER_URL), cfProperties.get(Context.PROVIDER_URL)) && equals(props.get(Context.SECURITY_PRINCIPAL), cfProperties.get(Context.SECURITY_PRINCIPAL)) && equals(props.get(Context.SECURITY_CREDENTIALS), cfProperties.get(Context.SECURITY_CREDENTIALS))) { return cf; } } return null; }
From source file:org.rhq.plugins.jbossas5.connection.RemoteProfileServiceConnectionProvider.java
protected AbstractProfileServiceConnection doConnect() { Properties env = new Properties(); env.setProperty(Context.PROVIDER_URL, this.providerURL); // Always use the non-login context factory, since we'll use JAAS for authentication if a username/password was // provided./*w ww . j av a 2 s .c o m*/ env.setProperty(Context.INITIAL_CONTEXT_FACTORY, NAMING_CONTEXT_FACTORY); env.setProperty(JNP_TIMEOUT_JNP_INIT_PROP, String.valueOf(JNP_TIMEOUT)); env.setProperty(JNP_SOTIMEOUT_JNP_INIT_PROP, String.valueOf(JNP_SO_TIMEOUT)); env.setProperty(JNP_DISABLE_DISCOVERY_JNP_INIT_PROP, String.valueOf(JNP_DISABLE_DISCOVERY)); log.debug("Connecting to Profile Service via remote JNDI using env [" + env + "]..."); this.initialContext = createInitialContext(env); ProfileService profileService = (ProfileService) lookup(this.initialContext, PROFILE_SERVICE_JNDI_NAME); ManagementView managementView = (ManagementView) lookup(this.initialContext, MANAGEMENT_VIEW_JNDI_NAME); DeploymentManager deploymentManager = (DeploymentManager) lookup(this.initialContext, DEPLOYMENT_MANAGER_JNDI_NAME); AbstractProfileServiceConnection profileServiceConnection; if (this.principal != null) { // Use a connection that will perform a JAAS login prior to all invocations. profileServiceConnection = new JaasAuthenticationProxyProfileServiceConnection(this, profileService, managementView, deploymentManager); } else { profileServiceConnection = new BasicProfileServiceConnection(this, profileService, managementView, deploymentManager); } return profileServiceConnection; }
From source file:org.jamwiki.ldap.LdapUserHandler.java
/** * Connect to the LDAP server and return a context. * * @return The LDAP context to use when retrieving user information. *///from w w w .jav a 2s.c o m private InitialDirContext getContext(String username, String password) throws Exception { // Set up the environment for creating the initial context Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, Environment.getValue(Environment.PROP_LDAP_FACTORY_CLASS)); env.put(Context.PROVIDER_URL, Environment.getValue(Environment.PROP_LDAP_URL)); if (!StringUtils.isBlank(username)) { // "simple" "DIGEST-MD5" env.put(Context.SECURITY_AUTHENTICATION, Environment.getValue(Environment.PROP_LDAP_SECURITY_AUTHENTICATION)); // cn=login, ou=NewHires, o=JNDITutorial env.put(Context.SECURITY_PRINCIPAL, username); env.put(Context.SECURITY_CREDENTIALS, password); } InitialDirContext ctx = new InitialDirContext(env); return ctx; }
From source file:org.apache.directory.server.core.jndi.LdapJndiPropertiesTest.java
License:asdf
@Test public void testAuthWithNoCredsStrong() throws Exception { Hashtable<String, Object> env = new Hashtable<String, Object>(); env.put(Context.SECURITY_PRINCIPAL, ""); env.put(Context.SECURITY_AUTHENTICATION, "DIGEST-MD5 CRAM-MD5"); env.put(Context.PROVIDER_URL, ""); LdapJndiProperties props = LdapJndiProperties.getLdapJndiProperties(env); assertEquals(AuthenticationLevel.STRONG, props.getAuthenticationLevel()); assertTrue(props.getCredentials() == null); }