01: /*
02: * Copyright 1999-2003 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04: *
05: * This code is free software; you can redistribute it and/or modify it
06: * under the terms of the GNU General Public License version 2 only, as
07: * published by the Free Software Foundation. Sun designates this
08: * particular file as subject to the "Classpath" exception as provided
09: * by Sun in the LICENSE file that accompanied this code.
10: *
11: * This code is distributed in the hope that it will be useful, but WITHOUT
12: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14: * version 2 for more details (a copy is included in the LICENSE file that
15: * accompanied this code).
16: *
17: * You should have received a copy of the GNU General Public License version
18: * 2 along with this work; if not, write to the Free Software Foundation,
19: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20: *
21: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22: * CA 95054 USA or visit www.sun.com if you need additional information or
23: * have any questions.
24: */
25:
26: package com.sun.jndi.ldap;
27:
28: import java.util.Vector;
29: import javax.naming.*;
30: import javax.naming.directory.*;
31: import javax.naming.spi.*;
32:
33: import com.sun.jndi.toolkit.ctx.Continuation;
34:
35: final class LdapBindingEnumeration extends LdapNamingEnumeration {
36:
37: LdapBindingEnumeration(LdapCtx homeCtx, LdapResult answer,
38: Name remain, Continuation cont) throws NamingException {
39: super (homeCtx, answer, remain, cont);
40: }
41:
42: protected NameClassPair createItem(String dn, Attributes attrs,
43: Vector respCtls) throws NamingException {
44:
45: Object obj = null;
46: String atom = getAtom(dn);
47:
48: if (attrs.get(Obj.JAVA_ATTRIBUTES[Obj.CLASSNAME]) != null) {
49: // serialized object or object reference
50: obj = Obj.decodeObject(attrs);
51: }
52: if (obj == null) {
53: // DirContext object
54: obj = new LdapCtx(homeCtx, dn);
55: }
56:
57: CompositeName cn = new CompositeName();
58: cn.add(atom);
59:
60: try {
61: obj = DirectoryManager.getObjectInstance(obj, cn, homeCtx,
62: homeCtx.envprops, attrs);
63:
64: } catch (NamingException e) {
65: throw e;
66:
67: } catch (Exception e) {
68: NamingException ne = new NamingException(
69: "problem generating object using object factory");
70: ne.setRootCause(e);
71: throw ne;
72: }
73:
74: Binding binding;
75: if (respCtls != null) {
76: binding = new BindingWithControls(cn.toString(), obj,
77: homeCtx.convertControls(respCtls));
78: } else {
79: binding = new Binding(cn.toString(), obj);
80: }
81: binding.setNameInNamespace(dn);
82: return binding;
83: }
84:
85: protected LdapNamingEnumeration getReferredResults(
86: LdapReferralContext refCtx) throws NamingException {
87: // repeat the original operation at the new context
88: return (LdapNamingEnumeration) refCtx.listBindings(listArg);
89: }
90: }
|