@Override public Hashtable<?, ?> getEnvironment() throws NamingException { return delegating.getEnvironment(); }
String dnsUrls = (String) ctx.getEnvironment().get("java.naming.provider.url");
private DirContext obtainDirContext() { try { DirContext context = dirContextSupplier.get(); binaryAttributesBackup = context.getEnvironment().get(ENV_BINARY_ATTRIBUTES); context.addToEnvironment(ENV_BINARY_ATTRIBUTES, String.join(" ", certificateAttribute, certificateChainAttribute, keyAttribute)); return context; } catch (NamingException e) { throw log.failedToObtainDirContext(e); } }
private NamingEnumeration<SearchResult> searchWithPagination() throws NamingException, IOException { Control[] controlsBackup = null; Object binaryAttributesBackup = null; // backup and set environment if (pageSize != 0 && context instanceof LdapContext) { controlsBackup = ((LdapContext)context).getRequestControls(); ((LdapContext)context).setRequestControls(new Control[]{ new PagedResultsControl(pageSize, cookie, Control.CRITICAL) }); } if (binaryAttributes != null && binaryAttributes.size() != 0) { // set attributes which should be returned in binary form binaryAttributesBackup = context.getEnvironment().get(ENV_BINARY_ATTRIBUTES); context.addToEnvironment(ENV_BINARY_ATTRIBUTES, String.join(" ", binaryAttributes)); } NamingEnumeration<SearchResult> results = context.search(new LdapName(searchDn), filter, filterArgs, createSearchControls()); // revert environment change if (binaryAttributes != null && binaryAttributes.size() != 0) { if (binaryAttributesBackup == null) { context.removeFromEnvironment(ENV_BINARY_ATTRIBUTES); } else { context.addToEnvironment(ENV_BINARY_ATTRIBUTES, binaryAttributesBackup); } } if (pageSize != 0 && context instanceof LdapContext) { ((LdapContext)context).setRequestControls(controlsBackup); } return results; }
dirContext.getEnvironment().forEach(props::put); props.put(LdapContext.PROVIDER_URL, namingProviderURL); props.put(LdapContext.SECURITY_PRINCIPAL, distinguishedName);
@Override public String executeWithContext(DirContext ctx) throws NamingException { Object version = ctx.getEnvironment().get("java.naming.ldap.version"); if (version != null) { return (String) version; } return null; }
public static List<String> getDnsServers() throws NamingException { Hashtable<String, String> env = new Hashtable<String, String>(); env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.dns.DnsContextFactory"); DirContext ctx = null; List<String> dnsServers = new ArrayList<String>(); try { ctx = new InitialDirContext(env); String dnsString = (String) ctx.getEnvironment().get("java.naming.provider.url"); for (String each : dnsString.split(" ")) { dnsServers.add(each.replace("dns://", "")); } } catch (Exception e) { NoOp.noOp(); } finally { if (ctx != null) { ctx.close(); } } return dnsServers; } }
@Override public Hashtable<?, ?> getEnvironment() throws NamingException { return delegating.getEnvironment(); }
@Override public synchronized Hashtable<?, ?> getEnvironment() throws NamingException { return this.delegate.getEnvironment(); }
@Override public Hashtable<?, ?> getEnvironment() throws NamingException { return delegating.getEnvironment(); }
/** * Retrieves the environment in effect for this context. See class * description for more details on environment properties. * The caller should not make any changes to the object returned: their * effect on the context is undefined. The environment of this context * may be changed using addToEnvironment() and removeFromEnvironment(). * * @return the environment of this context; never null * @exception NamingException if a naming exception is encountered */ @Override public Hashtable<?,?> getEnvironment() throws NamingException { return dirContext.getEnvironment(); }
@Override public Hashtable<?, ?> getEnvironment() throws NamingException { return delegating.getEnvironment(); }
/** * Retrieves the environment in effect for this context. See class * description for more details on environment properties. * The caller should not make any changes to the object returned: their * effect on the context is undefined. The environment of this context * may be changed using addToEnvironment() and removeFromEnvironment(). * * @return the environment of this context; never null * @exception NamingException if a naming exception is encountered */ public Hashtable<?,?> getEnvironment() throws NamingException { return dirContext.getEnvironment(); }
/** * Retrieves the environment in effect for this context. See class * description for more details on environment properties. * The caller should not make any changes to the object returned: their * effect on the context is undefined. The environment of this context * may be changed using addToEnvironment() and removeFromEnvironment(). * * @return the environment of this context; never null * @exception NamingException if a naming exception is encountered */ @Override public Hashtable<?,?> getEnvironment() throws NamingException { return dirContext.getEnvironment(); }
private Hashtable getLdapBindProps() { Hashtable ldapProperties = new Hashtable(); try { ldapProperties = (Hashtable) dirContext.getEnvironment().clone(); } catch (NamingException ex) { LOGGER.log(Level.SEVERE, null, ex); } return ldapProperties; }
@Override public String getString() { try{ return( String.valueOf( ctx.getEnvironment())); }catch( Throwable e ){ return( Debug.getNestedExceptionMessage(e)); } } }
public NamingEnumeration<SearchResult> search(String filter, Object... args) throws NamingException { if (LOG.isLoggable(Level.FINER)) { Map<Object,Object> env = new HashMap<>(context.getEnvironment()); if (env.containsKey(Context.SECURITY_CREDENTIALS)) { env.put(Context.SECURITY_CREDENTIALS, "…"); } LOG.log(Level.FINER, "searching {0}{1} in {2} using {3} with scope {4} returning {5}", new Object[] {filter, Arrays.toString(args), baseDN, env, controls.getSearchScope(), Arrays.toString(controls.getReturningAttributes())}); } return context.search(baseDN, filter,args,controls); } }
private DirContext obtainDirContext() { try { DirContext context = dirContextSupplier.get(); binaryAttributesBackup = context.getEnvironment().get(ENV_BINARY_ATTRIBUTES); context.addToEnvironment(ENV_BINARY_ATTRIBUTES, String.join(" ", certificateAttribute, certificateChainAttribute, keyAttribute)); return context; } catch (NamingException e) { throw log.failedToObtainDirContext(e); } }
private DirContext obtainDirContext() { try { DirContext context = dirContextSupplier.get(); binaryAttributesBackup = context.getEnvironment().get(ENV_BINARY_ATTRIBUTES); context.addToEnvironment(ENV_BINARY_ATTRIBUTES, String.join(" ", certificateAttribute, certificateChainAttribute, keyAttribute)); return context; } catch (NamingException e) { throw log.failedToObtainDirContext(e); } }
private DirContext obtainDirContext() { try { DirContext context = dirContextSupplier.get(); binaryAttributesBackup = context.getEnvironment().get(ENV_BINARY_ATTRIBUTES); context.addToEnvironment(ENV_BINARY_ATTRIBUTES, String.join(" ", certificateAttribute, certificateChainAttribute, keyAttribute)); return context; } catch (NamingException e) { throw log.failedToObtainDirContext(e); } }