Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/com/sun/jndi/ldap/LdapBindingEnumeration.java
38924 views
/*1* Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package com.sun.jndi.ldap;2627import java.security.AccessControlContext;28import java.security.AccessController;29import java.security.PrivilegedActionException;30import java.security.PrivilegedExceptionAction;31import java.util.Vector;32import javax.naming.*;33import javax.naming.directory.*;34import javax.naming.ldap.Control;35import javax.naming.spi.*;3637import com.sun.jndi.toolkit.ctx.Continuation;3839final class LdapBindingEnumeration40extends AbstractLdapNamingEnumeration<Binding> {4142private final AccessControlContext acc = AccessController.getContext();4344LdapBindingEnumeration(LdapCtx homeCtx, LdapResult answer, Name remain,45Continuation cont) throws NamingException46{47super(homeCtx, answer, remain, cont);48}4950@Override51protected Binding52createItem(String dn, Attributes attrs, Vector<Control> respCtls)53throws NamingException {5455Object obj = null;56String atom = getAtom(dn);5758if (attrs.get(Obj.JAVA_ATTRIBUTES[Obj.CLASSNAME]) != null) {59// serialized object or object reference60try {61obj = AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {62@Override63public Object run() throws NamingException {64return Obj.decodeObject(attrs);65}66}, acc);67} catch (PrivilegedActionException e) {68throw (NamingException)e.getException();69}70}71if (obj == null) {72// DirContext object73obj = new LdapCtx(homeCtx, dn);74}7576CompositeName cn = new CompositeName();77cn.add(atom);7879try {80obj = DirectoryManager.getObjectInstance(obj, cn, homeCtx,81homeCtx.envprops, attrs);8283} catch (NamingException e) {84throw e;8586} catch (Exception e) {87NamingException ne =88new NamingException(89"problem generating object using object factory");90ne.setRootCause(e);91throw ne;92}9394Binding binding;95if (respCtls != null) {96binding = new BindingWithControls(cn.toString(), obj,97homeCtx.convertControls(respCtls));98} else {99binding = new Binding(cn.toString(), obj);100}101binding.setNameInNamespace(dn);102return binding;103}104105@Override106protected AbstractLdapNamingEnumeration<? extends NameClassPair> getReferredResults(107LdapReferralContext refCtx) throws NamingException{108// repeat the original operation at the new context109return (AbstractLdapNamingEnumeration<? extends NameClassPair>)refCtx.listBindings(listArg);110}111}112113114