@Override public synchronized void close() { ctx.close(); }
public synchronized void createSubcontext(String name, Attributes attrs) throws NamingException { ctx.createSubcontextAndClose(name, attrs); }
public synchronized void destroySubcontext(String dn) throws NamingException { ctx.destroySubcontext(dn); }
public Attributes getAttributes(String name, String[] attrIds) throws NamingException { try { return ctx.getAttributes(name, attrIds); } catch (CommunicationException e) { reconnect(); return ctx.getAttributes(name, attrIds); } }
public boolean exists(String dn) throws NamingException { try { ctx.getAttributes(dn); return true; } catch (NameNotFoundException e) { return false; } }
public synchronized void destroySubcontextWithChilds(String name) throws NamingException { NamingEnumeration<NameClassPair> list = ctx.list(name); try { while (list.hasMore()) destroySubcontextWithChilds(list.next().getNameInNamespace()); } finally { LdapUtils.safeClose(list); } ctx.destroySubcontext(name); }
public NamingEnumeration<SearchResult> search(String dn, String filter, String... attrs) throws NamingException { SearchControls ctls = new SearchControls(); ctls.setSearchScope(SearchControls.ONELEVEL_SCOPE); ctls.setReturningObjFlag(false); ctls.setReturningAttributes(attrs); return ctx.search(dn, filter, ctls); }
private void storeCertificates(String dn, X509Certificate... certs) throws CertificateEncodingException, NamingException { byte[][] vals = new byte[certs.length][]; for (int i = 0; i < vals.length; i++) vals[i] = certs[i].getEncoded(); Attributes attrs = ctx.getAttributes(dn, new String[] { "objectClass" } ); ModificationItem replaceCert = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr(userCertificate, vals )); ctx.modifyAttributes(dn, LdapUtils.hasObjectClass(attrs, pkiUser) ? new ModificationItem[] { replaceCert } : new ModificationItem[] { new ModificationItem( DirContext.ADD_ATTRIBUTE, LdapUtils.attr("objectClass", pkiUser )), replaceCert }); }
public void replaceAttributes(String dn, Attributes attrs) throws NamingException { ctx.modifyAttributes(dn, DirContext.REPLACE_ATTRIBUTE, attrs); }
@SuppressWarnings("unchecked") public LdapDicomConfiguration(Hashtable<?,?> env) throws ConfigurationException { Hashtable<String,String> map = new Hashtable(); for (Map.Entry<?, ?> entry : env.entrySet()) map.put((String) entry.getKey(), StringUtils.replaceSystemProperties((String) entry.getValue())); try { // split baseDN from LDAP URL String s = map.get(Context.PROVIDER_URL); int end = s.lastIndexOf('/'); map.put(Context.PROVIDER_URL, s.substring(0, end)); this.baseDN = s.substring(end+1); this.ctx = new ReconnectDirContext(map); } catch (Exception e) { throw new ConfigurationException(e); } }
public Attributes getAttributes(String name) throws NamingException { try { return ctx.getAttributes(name); } catch (CommunicationException e) { reconnect(); return ctx.getAttributes(name); } }
public boolean exists(String dn) throws NamingException { try { ctx.getAttributes(dn); return true; } catch (NameNotFoundException e) { return false; } }
public synchronized void destroySubcontextWithChilds(String name) throws NamingException { NamingEnumeration<NameClassPair> list = ctx.list(name); try { while (list.hasMore()) destroySubcontextWithChilds(list.next().getNameInNamespace()); } finally { LdapUtils.safeClose(list); } ctx.destroySubcontext(name); }
public NamingEnumeration<SearchResult> search(String dn, String filter, String... attrs) throws NamingException { SearchControls ctls = new SearchControls(); ctls.setSearchScope(SearchControls.ONELEVEL_SCOPE); ctls.setReturningObjFlag(false); ctls.setReturningAttributes(attrs); return ctx.search(dn, filter, ctls); }
private void storeCertificates(String dn, X509Certificate... certs) throws CertificateEncodingException, NamingException { byte[][] vals = new byte[certs.length][]; for (int i = 0; i < vals.length; i++) vals[i] = certs[i].getEncoded(); Attributes attrs = ctx.getAttributes(dn, new String[] { "objectClass" } ); ModificationItem replaceCert = new ModificationItem( DirContext.REPLACE_ATTRIBUTE, attr(userCertificate, vals )); ctx.modifyAttributes(dn, LdapUtils.hasObjectClass(attrs, pkiUser) ? new ModificationItem[] { replaceCert } : new ModificationItem[] { new ModificationItem( DirContext.ADD_ATTRIBUTE, LdapUtils.attr("objectClass", pkiUser )), replaceCert }); }
public void replaceAttributes(String dn, Attributes attrs) throws NamingException { ctx.modifyAttributes(dn, DirContext.REPLACE_ATTRIBUTE, attrs); }
@SuppressWarnings("unchecked") public LdapDicomConfiguration(Hashtable<?,?> env) throws ConfigurationException { Hashtable<String,String> map = new Hashtable(); for (Map.Entry<?, ?> entry : env.entrySet()) map.put((String) entry.getKey(), StringUtils.replaceSystemProperties((String) entry.getValue())); try { // split baseDN from LDAP URL String s = map.get(Context.PROVIDER_URL); int end = s.lastIndexOf('/'); map.put(Context.PROVIDER_URL, s.substring(0, end)); this.baseDN = s.substring(end+1); this.ctx = new ReconnectDirContext(map); } catch (Exception e) { throw new ConfigurationException(e); } }
public NamingEnumeration<SearchResult> search(String name, String filter, SearchControls cons) throws NamingException { try { return ctx.search(name, filter, cons); } catch (CommunicationException e) { reconnect(); return ctx.search(name, filter, cons); } }
public Attributes getAttributes(String name, String[] attrIDs) throws NamingException { return ctx.getAttributes(name, attrIDs); }
public NamingEnumeration<SearchResult> search(String deviceName, String[] attrsArray, String filter) throws NamingException { return deviceName != null ? search(deviceRef(deviceName), filter, attrsArray) : ctx.search(devicesDN, filter, searchControlSubtreeScope(0, attrsArray, true)); }