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:security.AuthenticationManager.java
private static Hashtable<String, String> buildEnvContext(String username, String password, String contextFactory, String ldapUrl, String principalDomain) { Hashtable<String, String> env = new Hashtable<>(11); env.put(Context.INITIAL_CONTEXT_FACTORY, contextFactory); env.put(Context.PROVIDER_URL, ldapUrl); env.put(Context.SECURITY_PRINCIPAL, username + principalDomain); env.put(Context.SECURITY_CREDENTIALS, password); return env;/*from w w w . j a v a2 s . c o m*/ }
From source file:it.doqui.index.ecmengine.client.engine.EcmEngineDirectDelegateImpl.java
protected EcmEngineManagementBusinessInterface createManagementService() throws Throwable { this.log.debug("[" + getClass().getSimpleName() + "::createManagementService] BEGIN "); Properties properties = new Properties(); /* Caricamento del file contenenti le properties su cui fare il binding */ rb = ResourceBundle.getBundle(ECMENGINE_PROPERTIES_FILE); /*/*from w ww . jav a 2s.c o m*/ * Caricamento delle proprieta' su cui fare il binding all'oggetto di business delle funzionalita' * implementate per il management. */ try { this.log.debug( "[" + getClass().getSimpleName() + "::createManagementService] P-Delegata di backoffice."); this.log.debug("[" + getClass().getSimpleName() + "::createManagementService] context factory vale : " + rb.getString(ECMENGINE_CONTEXT_FACTORY)); properties.put(Context.INITIAL_CONTEXT_FACTORY, rb.getString(ECMENGINE_CONTEXT_FACTORY)); this.log.debug("[" + getClass().getSimpleName() + "::createManagementService] url to connect vale : " + rb.getString(ECMENGINE_URL_TO_CONNECT)); properties.put(Context.PROVIDER_URL, rb.getString(ECMENGINE_URL_TO_CONNECT)); /* Controllo che la property cluster partition sia valorizzata per capire se * sto lavorando in una configurazione in cluster oppure no */ String clusterPartition = rb.getString(ECMENGINE_CLUSTER_PARTITION); this.log.debug("[" + getClass().getSimpleName() + "::createManagementService] clusterPartition vale : " + clusterPartition); if (clusterPartition != null && clusterPartition.length() > 0) { properties.put("jnp.partitionName", clusterPartition); this.log.debug( "[" + getClass().getSimpleName() + "::createManagementService] disable discovery vale : " + rb.getString(ECMENGINE_DISABLE_DISCOVERY)); properties.put("jnp.disableDiscovery", rb.getString(ECMENGINE_DISABLE_DISCOVERY)); } // Get an initial context InitialContext jndiContext = new InitialContext(properties); log.debug("[" + getClass().getSimpleName() + "::createManagementService] context istanziato"); // Get a reference to the Bean Object ref = jndiContext.lookup(ECMENGINE_MANAGEMENT_JNDI_NAME); // Get a reference from this to the Bean's Home interface EcmEngineManagementHome home = (EcmEngineManagementHome) PortableRemoteObject.narrow(ref, EcmEngineManagementHome.class); // Create an Adder object from the Home interface return home.create(); } catch (Throwable e) { this.log.error("[" + getClass().getSimpleName() + "::createManagementService] " + "Impossibile istanziare la P-Delegata di management: " + e.getMessage()); throw e; } finally { this.log.debug("[" + getClass().getSimpleName() + "::createManagementService] END "); } }
From source file:com.mirth.connect.connectors.jms.JmsDispatcherTests.java
private static ConnectionFactory lookupConnectionFactoryWithJndi(JmsConnectorProperties connectorProperties) throws Exception { Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.PROVIDER_URL, connectorProperties.getJndiProviderUrl()); env.put(Context.INITIAL_CONTEXT_FACTORY, connectorProperties.getJndiInitialContextFactory()); env.put(Context.SECURITY_PRINCIPAL, connectorProperties.getUsername()); env.put(Context.SECURITY_CREDENTIALS, connectorProperties.getPassword()); initialContext = new InitialContext(env); String connectionFactoryName = connectorProperties.getJndiConnectionFactoryName(); return (ConnectionFactory) initialContext.lookup(connectionFactoryName); }
From source file:net.sf.ehcache.distribution.JNDIRMICacheManagerPeerListener.java
/** * Gets the initial context/* w w w . java 2 s .c o m*/ * * @return an initial context * @throws NamingException if JNDI goes wrong */ private Context getInitialContext() throws NamingException { String initialContextFactory = System.getProperty(Context.INITIAL_CONTEXT_FACTORY); if (initialContextFactory != null && initialContextFactory.startsWith("net.sf.ehcache")) { // Put Context.PROVIDER_URL so unit tests can work Hashtable hashTable = new Hashtable(); hashTable.put(Context.PROVIDER_URL, "//localhost:" + port); return new InitialContext(hashTable); } return new InitialContext(); }
From source file:org.imirsel.plugins.JndiInitializeServlet.java
/**Called when the servlet starts -called only once. * /*from ww w.j ava2 s . c o m*/ */ @Override @SuppressWarnings("unchecked") public void init(ServletConfig config) throws ServletException { super.init(config); // initialize the ArtifactManagerImpl ArtifactManagerImpl.init(this.coreConfiguration.getPublicResourcesDirectory()); logger.info("Starting the JNDIInitialize Servlet: -loading various database contexts"); Properties nemaFlowServiceProperties = new Properties(); try { nemaFlowServiceProperties.load( JndiInitializeServlet.class.getClassLoader().getResourceAsStream("nemaflowservice.properties")); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); logger.severe(e1.getMessage()); throw new RuntimeException(e1); } try { Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY, "org.mortbay.naming.InitialContextFactory"); env.put(Context.PROVIDER_URL, "localhost:1099"); ctx = new InitialContext(env); } catch (Exception e) { logger.severe("Error configuring initial context " + e); throw new ServletException(e); } try { dataSourceFlowResults = getDataSource(nemaFlowServiceProperties); dataSourceJob = getDataSource(nemaFlowServiceProperties); } catch (Exception e) { e.printStackTrace(); logger.severe("Error getting properites " + e); } logger.info("binding flowresults datasource"); bindObject(PluginConstants.JOBRESULT_JNDI_SERVICE, dataSourceFlowResults); bindObject(PluginConstants.JOB_JNDI_SERVICE, dataSourceJob); createDataTablesIfNotExist(); this.inited(true); }
From source file:gda.jython.authenticator.LdapAuthenticator.java
private boolean checkAuthenticatedUsingServer(String ldapURL, String fedId, String password) throws NamingException { InitialLdapContext ctx = null; try {//from w w w.j a va 2 s. c o m Hashtable<String, String> env = new Hashtable<String, String>(); String principal = "CN=" + fedId + adminName; env.put(Context.INITIAL_CONTEXT_FACTORY, ldapContext); env.put(Context.SECURITY_AUTHENTICATION, "simple"); env.put(Context.SECURITY_PRINCIPAL, principal); env.put(Context.SECURITY_CREDENTIALS, password); env.put(Context.PROVIDER_URL, ldapURL); ctx = new InitialLdapContext(env, null); //if no exception then password is OK return true; } catch (AuthenticationException ae) { logger.error("LDAP AuthenticationException: " + StringEscapeUtils.escapeJava(ae.getMessage())); } finally { if (ctx != null) { try { ctx.close(); } catch (NamingException e) { } } } return false; }
From source file:org.apache.juddi.v3.auth.LdapExpandedAuthenticator.java
public void init(String url) throws NamingException, ConfigurationException { env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, AppConfig.getConfiguration() .getString(Property.JUDDI_AUTHENTICATOR_INITIAL_CONTEXT, "com.sun.jndi.ldap.LdapCtxFactory")); env.put(Context.SECURITY_AUTHENTICATION, AppConfig.getConfiguration().getString(Property.JUDDI_AUTHENTICATOR_STYLE, "simple")); env.put(Context.PROVIDER_URL, url); // organization ldap url, example ldap://localhost:389 this.url = url; try {// w ww .jav a2 s.c o m ctx = new InitialLdapContext(env, null); } catch (NamingException e) { logger.error("Naming exception " + e); throw e; } }
From source file:nl.nn.adapterframework.extensions.ifsa.jms.IfsaMessagingSourceFactory.java
protected Context createContext() throws NamingException { log.info("IFSA API installed version [" + IFSAConstants.getVersionInfo() + "]"); Hashtable env = new Hashtable(11); env.put(Context.INITIAL_CONTEXT_FACTORY, IFSA_INITIAL_CONTEXT_FACTORY); env.put(Context.PROVIDER_URL, getProviderUrl()); // Create context as required by IFSA 2.0. Ignore the possible deprecation.... return new IFSAContext((Context) new InitialContext(env)); }
From source file:org.apache.cloudstack.ldap.LdapContextFactory.java
private Hashtable<String, String> getEnvironment(final String principal, final String password, final String providerUrl, final boolean isSystemContext, Long domainId) { final String factory = _ldapConfiguration.getFactory(); String url = providerUrl == null ? _ldapConfiguration.getProviderUrl(domainId) : providerUrl; if (StringUtils.isEmpty(url) && domainId != null) { //try a default ldap implementation url = _ldapConfiguration.getProviderUrl(null); }/*from www.ja v a 2 s .c om*/ final Hashtable<String, String> environment = new Hashtable<>(); environment.put(Context.INITIAL_CONTEXT_FACTORY, factory); environment.put(Context.PROVIDER_URL, url); environment.put("com.sun.jndi.ldap.read.timeout", _ldapConfiguration.getReadTimeout(domainId).toString()); environment.put("com.sun.jndi.ldap.connect.pool", "true"); enableSSL(environment); setAuthentication(environment, isSystemContext, domainId); if (principal != null) { environment.put(Context.SECURITY_PRINCIPAL, principal); } if (password != null) { environment.put(Context.SECURITY_CREDENTIALS, password); } return environment; }
From source file:org.hyperic.hq.plugin.jboss.JBossUtil.java
public static MBeanServerConnection getMBeanServerConnection(String url) throws NamingException, RemoteException { Properties config = new Properties(); config.setProperty(Context.PROVIDER_URL, url); return getMBeanServerConnection(config); }