public DirContext createSubcontext(Name name, Attributes attrs) throws NamingException { if (name.size() == 1) { return createSubcontext(name.get(0), attrs); } else { DirContext ctx = getContinuationDirContext(name); try { return ctx.createSubcontext(name.getSuffix(1), attrs); } finally { ctx.close(); } } }
public Attributes getAttributes(Name name, String[] attrIds) throws NamingException { if (name.size() == 1) { return getAttributes(name.get(0), attrIds); } else { DirContext ctx = getContinuationDirContext(name); try { return ctx.getAttributes(name.getSuffix(1), attrIds); } finally { ctx.close(); } } }
public DirContext getSchemaClassDefinition(Name name) throws NamingException { if (name.size() == 1) { return getSchemaClassDefinition(name.get(0)); } else { DirContext ctx = getContinuationDirContext(name); try { return ctx.getSchemaClassDefinition(name.getSuffix(1)); } finally { ctx.close(); } } }
public void modifyAttributes(Name name, ModificationItem[] mods) throws NamingException { if (name.size() == 1) { modifyAttributes(name.get(0), mods); } else { DirContext ctx = getContinuationDirContext(name); try { ctx.modifyAttributes(name.getSuffix(1), mods); } finally { ctx.close(); } } }
public void rebind(Name name, Object obj, Attributes attrs) throws NamingException { if (name.size() == 1) { rebind(name.get(0), obj, attrs); } else { DirContext ctx = getContinuationDirContext(name); try { ctx.rebind(name.getSuffix(1), obj, attrs); } finally { ctx.close(); } } }
public NamingEnumeration<SearchResult> search(Name name, String filter, SearchControls cons) throws NamingException { if (name.size() == 1) { return search(name.get(0), filter, cons); } else { DirContext ctx = getContinuationDirContext(name); try { return ctx.search(name.getSuffix(1), filter, cons); } finally { ctx.close(); } } }
public NamingEnumeration<SearchResult> search(Name name, Attributes matchingAttributes) throws NamingException { if (name.size() == 1) { return search(name.get(0), matchingAttributes); } else { DirContext ctx = getContinuationDirContext(name); try { return ctx.search(name.getSuffix(1), matchingAttributes); } finally { ctx.close(); } } }
/** * Gets the context in which to continue the operation. This method is called when this context is * asked to process a multicomponent Name in which the first component is a URL. Treat the first * component like a junction: resolve it and then use DirectoryManager.getContinuationDirContext() * to get the target context in which to operate on the remainder of the name (n.getSuffix(1)). Do * this in case intermediate contexts are not DirContext. */ protected DirContext getContinuationDirContext(Name n) throws NamingException { Object obj = lookup(n.get(0)); CannotProceedException cpe = new CannotProceedException(); cpe.setResolvedObj(obj); cpe.setEnvironment(myEnv); return DirectoryManager.getContinuationDirContext(cpe); }
protected NameClassPair createItem(String dn, Attributes attrs, Vector respCtls) throws NamingException { Object obj = null; String relStart; // name relative to starting search context String relHome; // name relative to homeCtx.currentDN boolean relative = true; // whether relative to currentDN // need to strip off all but lowest component of dn // so that is relative to current context (currentDN) try { Name parsed = new LdapName(dn); // System.err.println("dn string: " + dn); // System.err.println("dn name: " + parsed); if (startName != null && parsed.startsWith(startName)) { relStart = parsed.getSuffix(startName.size()).toString(); relHome = parsed.getSuffix(homeCtx.currentParsedDN.size()).toString(); } else { relative = false; relHome = relStart = LdapURL.toUrlString( homeCtx.hostname, homeCtx.port_number, dn, homeCtx.hasLdapsScheme); } } catch (NamingException e) { // could not parse name relative = false; relHome = relStart = LdapURL.toUrlString( homeCtx.hostname, homeCtx.port_number, dn, homeCtx.hasLdapsScheme); } // Name relative to search context CompositeName cn = new CompositeName(); if (!relStart.equals("")) { cn.add(relStart); } // Name relative to homeCtx CompositeName rcn = new CompositeName(); if (!relHome.equals("")) { rcn.add(relHome); } // System.err.println("relStart: " + cn); // System.err.println("relHome: " + rcn); // Fix attributes to be able to get schema homeCtx.setParents(attrs, rcn); // only generate object when requested if (searchArgs.cons.getReturningObjFlag()) { if (attrs.get(Obj.JAVA_ATTRIBUTES[Obj.CLASSNAME]) != null) { // Entry contains Java-object attributes (ser/ref object) // serialized object or object reference obj = Obj.decodeObject(attrs); } if (obj == null) { obj = new LdapCtx(homeCtx, dn); } // Call getObjectInstance before removing unrequested attributes try { // rcn is either relative to homeCtx or a fully qualified DN obj = DirectoryManager.getObjectInstance( obj, rcn, (relative ? homeCtx : null), homeCtx.envprops, attrs); } catch (NamingException e) { throw e; } catch (Exception e) { NamingException ne = new NamingException("problem generating object using object factory"); ne.setRootCause(e); throw ne; } // remove Java attributes from result, if necessary // Even if CLASSNAME attr not there, there might be some // residual attributes String[] reqAttrs; if ((reqAttrs = searchArgs.reqAttrs) != null) { // create an attribute set for those requested Attributes rattrs = new BasicAttributes(true); // caseignore for (int i = 0; i < reqAttrs.length; i++) { rattrs.put(reqAttrs[i], null); } for (int i = 0; i < Obj.JAVA_ATTRIBUTES.length; i++) { // Remove Java-object attributes if not requested if (rattrs.get(Obj.JAVA_ATTRIBUTES[i]) == null) { attrs.remove(Obj.JAVA_ATTRIBUTES[i]); } } } } /* * name in search result is either the stringified composite name * relative to the search context that can be passed directly to * methods of the search context, or the fully qualified DN * which can be used with the initial context. */ SearchResult sr; if (respCtls != null) { sr = new SearchResultWithControls( (relative ? cn.toString() : relStart), obj, attrs, relative, homeCtx.convertControls(respCtls)); } else { sr = new SearchResult((relative ? cn.toString() : relStart), obj, attrs, relative); } sr.setNameInNamespace(dn); return sr; }
public void modifyAttributes(Name name, ModificationItem[] mods) throws NamingException { modifyAttributes(name.toString(), mods); }
public void modifyAttributes(Name name, int mod_op, Attributes attrs) throws NamingException { modifyAttributes(name.toString(), mod_op, attrs); }
public Attributes getAttributes(Name name, String[] attrIds) throws NamingException { return getAttributes(name.toString(), attrIds); }
public Attributes getAttributes(Name name) throws NamingException { return getAttributes(name.toString()); }