Java Code Examples for javax.naming.directory.InitialDirContext#addToEnvironment()
The following examples show how to use
javax.naming.directory.InitialDirContext#addToEnvironment() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LdapManager.java From Openfire with Apache License 2.0 | 5 votes |
/** * Looks up an LDAP object by its DN and returns {@code true} if * the search was successful. * * @param ctx the Context to use for the lookup. * @param dn the object's dn to lookup. * @return true if the lookup was successful. * @throws NamingException if login credentials were wrong. */ private Boolean lookupExistence(InitialDirContext ctx, LdapName dn, String[] returnattrs) throws NamingException { Log.debug("In lookupExistence(ctx, dn, returnattrs), searchdn is: {}", dn); // Bind to the object's DN ctx.addToEnvironment(Context.PROVIDER_URL, getProviderURL(dn)); String filter = "(&(objectClass=*))"; SearchControls srcnt = new SearchControls(); srcnt.setSearchScope(SearchControls.OBJECT_SCOPE); srcnt.setReturningAttributes(returnattrs); NamingEnumeration<SearchResult> answer = null; try { answer = ctx.search( "", filter, srcnt); } catch (javax.naming.NameNotFoundException nex) { Log.debug("Unable to find ldap object {}.", dn); } if (answer == null || !answer.hasMoreElements()) { Log.debug(".... lookupExistence: DN not found."); return false; } else { Log.debug(".... lookupExistence: DN found."); return true; } }
Example 2
Source File: LDAPCertStore.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
/** * Create InitialDirContext. * * @param server Server DNS name hosting LDAP service * @param port Port at which server listens for requests * @throws InvalidAlgorithmParameterException if creation fails */ private void createInitialDirContext(String server, int port) throws InvalidAlgorithmParameterException { String url = "ldap://" + server + ":" + port; Hashtable<String,Object> env = new Hashtable<>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, url); // If property is set to true, disable application resource file lookup. boolean disableAppResourceFiles = AccessController.doPrivileged( new GetBooleanAction(PROP_DISABLE_APP_RESOURCE_FILES)); if (disableAppResourceFiles) { if (debug != null) { debug.println("LDAPCertStore disabling app resource files"); } env.put("com.sun.naming.disable.app.resource.files", "true"); } try { ctx = new InitialDirContext(env); /* * By default, follow referrals unless application has * overridden property in an application resource file. */ Hashtable<?,?> currentEnv = ctx.getEnvironment(); if (currentEnv.get(Context.REFERRAL) == null) { ctx.addToEnvironment(Context.REFERRAL, "throw"); } } catch (NamingException e) { if (debug != null) { debug.println("LDAPCertStore.engineInit about to throw " + "InvalidAlgorithmParameterException"); e.printStackTrace(); } Exception ee = new InvalidAlgorithmParameterException ("unable to create InitialDirContext using supplied parameters"); ee.initCause(e); throw (InvalidAlgorithmParameterException)ee; } }
Example 3
Source File: LDAPCertStore.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
/** * Create InitialDirContext. * * @param server Server DNS name hosting LDAP service * @param port Port at which server listens for requests * @throws InvalidAlgorithmParameterException if creation fails */ private void createInitialDirContext(String server, int port) throws InvalidAlgorithmParameterException { String url = "ldap://" + server + ":" + port; Hashtable<String,Object> env = new Hashtable<>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, url); // If property is set to true, disable application resource file lookup. boolean disableAppResourceFiles = AccessController.doPrivileged( new GetBooleanAction(PROP_DISABLE_APP_RESOURCE_FILES)); if (disableAppResourceFiles) { if (debug != null) { debug.println("LDAPCertStore disabling app resource files"); } env.put("com.sun.naming.disable.app.resource.files", "true"); } try { ctx = new InitialDirContext(env); /* * By default, follow referrals unless application has * overridden property in an application resource file. */ Hashtable<?,?> currentEnv = ctx.getEnvironment(); if (currentEnv.get(Context.REFERRAL) == null) { ctx.addToEnvironment(Context.REFERRAL, "throw"); } } catch (NamingException e) { if (debug != null) { debug.println("LDAPCertStore.engineInit about to throw " + "InvalidAlgorithmParameterException"); e.printStackTrace(); } Exception ee = new InvalidAlgorithmParameterException ("unable to create InitialDirContext using supplied parameters"); ee.initCause(e); throw (InvalidAlgorithmParameterException)ee; } }
Example 4
Source File: LDAPCertStore.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
/** * Create InitialDirContext. * * @param server Server DNS name hosting LDAP service * @param port Port at which server listens for requests * @throws InvalidAlgorithmParameterException if creation fails */ private void createInitialDirContext(String server, int port) throws InvalidAlgorithmParameterException { String url = "ldap://" + server + ":" + port; Hashtable<String,Object> env = new Hashtable<>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, url); // If property is set to true, disable application resource file lookup. boolean disableAppResourceFiles = AccessController.doPrivileged( new GetBooleanAction(PROP_DISABLE_APP_RESOURCE_FILES)); if (disableAppResourceFiles) { if (debug != null) { debug.println("LDAPCertStore disabling app resource files"); } env.put("com.sun.naming.disable.app.resource.files", "true"); } try { ctx = new InitialDirContext(env); /* * By default, follow referrals unless application has * overridden property in an application resource file. */ Hashtable<?,?> currentEnv = ctx.getEnvironment(); if (currentEnv.get(Context.REFERRAL) == null) { ctx.addToEnvironment(Context.REFERRAL, "follow"); } } catch (NamingException e) { if (debug != null) { debug.println("LDAPCertStore.engineInit about to throw " + "InvalidAlgorithmParameterException"); e.printStackTrace(); } Exception ee = new InvalidAlgorithmParameterException ("unable to create InitialDirContext using supplied parameters"); ee.initCause(e); throw (InvalidAlgorithmParameterException)ee; } }
Example 5
Source File: LDAPCertStore.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
/** * Create InitialDirContext. * * @param server Server DNS name hosting LDAP service * @param port Port at which server listens for requests * @throws InvalidAlgorithmParameterException if creation fails */ private void createInitialDirContext(String server, int port) throws InvalidAlgorithmParameterException { String url = "ldap://" + server + ":" + port; Hashtable<String,Object> env = new Hashtable<>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, url); // If property is set to true, disable application resource file lookup. boolean disableAppResourceFiles = AccessController.doPrivileged( new GetBooleanAction(PROP_DISABLE_APP_RESOURCE_FILES)); if (disableAppResourceFiles) { if (debug != null) { debug.println("LDAPCertStore disabling app resource files"); } env.put("com.sun.naming.disable.app.resource.files", "true"); } try { ctx = new InitialDirContext(env); /* * By default, follow referrals unless application has * overridden property in an application resource file. */ Hashtable<?,?> currentEnv = ctx.getEnvironment(); if (currentEnv.get(Context.REFERRAL) == null) { ctx.addToEnvironment(Context.REFERRAL, "throw"); } } catch (NamingException e) { if (debug != null) { debug.println("LDAPCertStore.engineInit about to throw " + "InvalidAlgorithmParameterException"); e.printStackTrace(); } Exception ee = new InvalidAlgorithmParameterException ("unable to create InitialDirContext using supplied parameters"); ee.initCause(e); throw (InvalidAlgorithmParameterException)ee; } }
Example 6
Source File: LDAPCertStore.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
/** * Create InitialDirContext. * * @param server Server DNS name hosting LDAP service * @param port Port at which server listens for requests * @throws InvalidAlgorithmParameterException if creation fails */ private void createInitialDirContext(String server, int port) throws InvalidAlgorithmParameterException { String url = "ldap://" + server + ":" + port; Hashtable<String,Object> env = new Hashtable<>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, url); // If property is set to true, disable application resource file lookup. boolean disableAppResourceFiles = AccessController.doPrivileged( new GetBooleanAction(PROP_DISABLE_APP_RESOURCE_FILES)); if (disableAppResourceFiles) { if (debug != null) { debug.println("LDAPCertStore disabling app resource files"); } env.put("com.sun.naming.disable.app.resource.files", "true"); } try { ctx = new InitialDirContext(env); /* * By default, follow referrals unless application has * overridden property in an application resource file. */ Hashtable<?,?> currentEnv = ctx.getEnvironment(); if (currentEnv.get(Context.REFERRAL) == null) { ctx.addToEnvironment(Context.REFERRAL, "throw"); } } catch (NamingException e) { if (debug != null) { debug.println("LDAPCertStore.engineInit about to throw " + "InvalidAlgorithmParameterException"); e.printStackTrace(); } Exception ee = new InvalidAlgorithmParameterException ("unable to create InitialDirContext using supplied parameters"); ee.initCause(e); throw (InvalidAlgorithmParameterException)ee; } }
Example 7
Source File: LDAPCertStore.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Create InitialDirContext. * * @param server Server DNS name hosting LDAP service * @param port Port at which server listens for requests * @throws InvalidAlgorithmParameterException if creation fails */ private void createInitialDirContext(String server, int port) throws InvalidAlgorithmParameterException { String url = "ldap://" + server + ":" + port; Hashtable<String,Object> env = new Hashtable<>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, url); // If property is set to true, disable application resource file lookup. boolean disableAppResourceFiles = AccessController.doPrivileged( new GetBooleanAction(PROP_DISABLE_APP_RESOURCE_FILES)); if (disableAppResourceFiles) { if (debug != null) { debug.println("LDAPCertStore disabling app resource files"); } env.put("com.sun.naming.disable.app.resource.files", "true"); } try { ctx = new InitialDirContext(env); /* * By default, follow referrals unless application has * overridden property in an application resource file. */ Hashtable<?,?> currentEnv = ctx.getEnvironment(); if (currentEnv.get(Context.REFERRAL) == null) { ctx.addToEnvironment(Context.REFERRAL, "follow"); } } catch (NamingException e) { if (debug != null) { debug.println("LDAPCertStore.engineInit about to throw " + "InvalidAlgorithmParameterException"); e.printStackTrace(); } Exception ee = new InvalidAlgorithmParameterException ("unable to create InitialDirContext using supplied parameters"); ee.initCause(e); throw (InvalidAlgorithmParameterException)ee; } }
Example 8
Source File: LDAPCertStore.java From hottub with GNU General Public License v2.0 | 4 votes |
/** * Create InitialDirContext. * * @param server Server DNS name hosting LDAP service * @param port Port at which server listens for requests * @throws InvalidAlgorithmParameterException if creation fails */ private void createInitialDirContext(String server, int port) throws InvalidAlgorithmParameterException { String url = "ldap://" + server + ":" + port; Hashtable<String,Object> env = new Hashtable<>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, url); // If property is set to true, disable application resource file lookup. boolean disableAppResourceFiles = AccessController.doPrivileged( new GetBooleanAction(PROP_DISABLE_APP_RESOURCE_FILES)); if (disableAppResourceFiles) { if (debug != null) { debug.println("LDAPCertStore disabling app resource files"); } env.put("com.sun.naming.disable.app.resource.files", "true"); } try { ctx = new InitialDirContext(env); /* * By default, follow referrals unless application has * overridden property in an application resource file. */ Hashtable<?,?> currentEnv = ctx.getEnvironment(); if (currentEnv.get(Context.REFERRAL) == null) { ctx.addToEnvironment(Context.REFERRAL, "follow"); } } catch (NamingException e) { if (debug != null) { debug.println("LDAPCertStore.engineInit about to throw " + "InvalidAlgorithmParameterException"); e.printStackTrace(); } Exception ee = new InvalidAlgorithmParameterException ("unable to create InitialDirContext using supplied parameters"); ee.initCause(e); throw (InvalidAlgorithmParameterException)ee; } }
Example 9
Source File: LDAPCertStore.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
/** * Create InitialDirContext. * * @param server Server DNS name hosting LDAP service * @param port Port at which server listens for requests * @throws InvalidAlgorithmParameterException if creation fails */ private void createInitialDirContext(String server, int port) throws InvalidAlgorithmParameterException { String url = "ldap://" + server + ":" + port; Hashtable<String,Object> env = new Hashtable<>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, url); // If property is set to true, disable application resource file lookup. boolean disableAppResourceFiles = AccessController.doPrivileged( new GetBooleanAction(PROP_DISABLE_APP_RESOURCE_FILES)); if (disableAppResourceFiles) { if (debug != null) { debug.println("LDAPCertStore disabling app resource files"); } env.put("com.sun.naming.disable.app.resource.files", "true"); } try { ctx = new InitialDirContext(env); /* * By default, follow referrals unless application has * overridden property in an application resource file. */ Hashtable<?,?> currentEnv = ctx.getEnvironment(); if (currentEnv.get(Context.REFERRAL) == null) { ctx.addToEnvironment(Context.REFERRAL, "follow"); } } catch (NamingException e) { if (debug != null) { debug.println("LDAPCertStore.engineInit about to throw " + "InvalidAlgorithmParameterException"); e.printStackTrace(); } Exception ee = new InvalidAlgorithmParameterException ("unable to create InitialDirContext using supplied parameters"); ee.initCause(e); throw (InvalidAlgorithmParameterException)ee; } }
Example 10
Source File: LDAPCertStore.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
/** * Create InitialDirContext. * * @param server Server DNS name hosting LDAP service * @param port Port at which server listens for requests * @throws InvalidAlgorithmParameterException if creation fails */ private void createInitialDirContext(String server, int port) throws InvalidAlgorithmParameterException { String url = "ldap://" + server + ":" + port; Hashtable<String,Object> env = new Hashtable<>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, url); // If property is set to true, disable application resource file lookup. boolean disableAppResourceFiles = AccessController.doPrivileged( new GetBooleanAction(PROP_DISABLE_APP_RESOURCE_FILES)); if (disableAppResourceFiles) { if (debug != null) { debug.println("LDAPCertStore disabling app resource files"); } env.put("com.sun.naming.disable.app.resource.files", "true"); } try { ctx = new InitialDirContext(env); /* * By default, follow referrals unless application has * overridden property in an application resource file. */ Hashtable<?,?> currentEnv = ctx.getEnvironment(); if (currentEnv.get(Context.REFERRAL) == null) { ctx.addToEnvironment(Context.REFERRAL, "follow"); } } catch (NamingException e) { if (debug != null) { debug.println("LDAPCertStore.engineInit about to throw " + "InvalidAlgorithmParameterException"); e.printStackTrace(); } Exception ee = new InvalidAlgorithmParameterException ("unable to create InitialDirContext using supplied parameters"); ee.initCause(e); throw (InvalidAlgorithmParameterException)ee; } }
Example 11
Source File: LDAPCertStore.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
/** * Create InitialDirContext. * * @param server Server DNS name hosting LDAP service * @param port Port at which server listens for requests * @throws InvalidAlgorithmParameterException if creation fails */ private void createInitialDirContext(String server, int port) throws InvalidAlgorithmParameterException { String url = "ldap://" + server + ":" + port; Hashtable<String,Object> env = new Hashtable<>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, url); // If property is set to true, disable application resource file lookup. boolean disableAppResourceFiles = AccessController.doPrivileged( new GetBooleanAction(PROP_DISABLE_APP_RESOURCE_FILES)); if (disableAppResourceFiles) { if (debug != null) { debug.println("LDAPCertStore disabling app resource files"); } env.put("com.sun.naming.disable.app.resource.files", "true"); } try { ctx = new InitialDirContext(env); /* * By default, follow referrals unless application has * overridden property in an application resource file. */ Hashtable<?,?> currentEnv = ctx.getEnvironment(); if (currentEnv.get(Context.REFERRAL) == null) { ctx.addToEnvironment(Context.REFERRAL, "throw"); } } catch (NamingException e) { if (debug != null) { debug.println("LDAPCertStore.engineInit about to throw " + "InvalidAlgorithmParameterException"); e.printStackTrace(); } Exception ee = new InvalidAlgorithmParameterException ("unable to create InitialDirContext using supplied parameters"); ee.initCause(e); throw (InvalidAlgorithmParameterException)ee; } }
Example 12
Source File: LDAPCertStore.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
/** * Create InitialDirContext. * * @param server Server DNS name hosting LDAP service * @param port Port at which server listens for requests * @throws InvalidAlgorithmParameterException if creation fails */ private void createInitialDirContext(String server, int port) throws InvalidAlgorithmParameterException { String url = "ldap://" + server + ":" + port; Hashtable<String,Object> env = new Hashtable<>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, url); // If property is set to true, disable application resource file lookup. boolean disableAppResourceFiles = AccessController.doPrivileged( new GetBooleanAction(PROP_DISABLE_APP_RESOURCE_FILES)); if (disableAppResourceFiles) { if (debug != null) { debug.println("LDAPCertStore disabling app resource files"); } env.put("com.sun.naming.disable.app.resource.files", "true"); } try { ctx = new InitialDirContext(env); /* * By default, follow referrals unless application has * overridden property in an application resource file. */ Hashtable<?,?> currentEnv = ctx.getEnvironment(); if (currentEnv.get(Context.REFERRAL) == null) { ctx.addToEnvironment(Context.REFERRAL, "follow"); } } catch (NamingException e) { if (debug != null) { debug.println("LDAPCertStore.engineInit about to throw " + "InvalidAlgorithmParameterException"); e.printStackTrace(); } Exception ee = new InvalidAlgorithmParameterException ("unable to create InitialDirContext using supplied parameters"); ee.initCause(e); throw (InvalidAlgorithmParameterException)ee; } }
Example 13
Source File: LDAPCertStore.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
/** * Create InitialDirContext. * * @param server Server DNS name hosting LDAP service * @param port Port at which server listens for requests * @throws InvalidAlgorithmParameterException if creation fails */ private void createInitialDirContext(String server, int port) throws InvalidAlgorithmParameterException { String url = "ldap://" + server + ":" + port; Hashtable<String,Object> env = new Hashtable<>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); env.put(Context.PROVIDER_URL, url); // If property is set to true, disable application resource file lookup. boolean disableAppResourceFiles = AccessController.doPrivileged( new GetBooleanAction(PROP_DISABLE_APP_RESOURCE_FILES)); if (disableAppResourceFiles) { if (debug != null) { debug.println("LDAPCertStore disabling app resource files"); } env.put("com.sun.naming.disable.app.resource.files", "true"); } try { ctx = new InitialDirContext(env); /* * By default, follow referrals unless application has * overridden property in an application resource file. */ Hashtable<?,?> currentEnv = ctx.getEnvironment(); if (currentEnv.get(Context.REFERRAL) == null) { ctx.addToEnvironment(Context.REFERRAL, "follow"); } } catch (NamingException e) { if (debug != null) { debug.println("LDAPCertStore.engineInit about to throw " + "InvalidAlgorithmParameterException"); e.printStackTrace(); } Exception ee = new InvalidAlgorithmParameterException ("unable to create InitialDirContext using supplied parameters"); ee.initCause(e); throw (InvalidAlgorithmParameterException)ee; } }