Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.naming/share/classes/com/sun/jndi/ldap/LdapBindingEnumeration.java
41161 views
1
/*
2
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22
* or visit www.oracle.com if you need additional information or have any
23
* questions.
24
*/
25
26
package com.sun.jndi.ldap;
27
28
import java.security.AccessControlContext;
29
import java.security.AccessController;
30
import java.security.PrivilegedActionException;
31
import java.security.PrivilegedExceptionAction;
32
import java.util.Vector;
33
import javax.naming.*;
34
import javax.naming.directory.*;
35
import javax.naming.ldap.Control;
36
import javax.naming.spi.*;
37
38
import com.sun.jndi.toolkit.ctx.Continuation;
39
40
final class LdapBindingEnumeration
41
extends AbstractLdapNamingEnumeration<Binding> {
42
43
@SuppressWarnings("removal")
44
private final AccessControlContext acc = AccessController.getContext();
45
46
LdapBindingEnumeration(LdapCtx homeCtx, LdapResult answer, Name remain,
47
Continuation cont) throws NamingException
48
{
49
super(homeCtx, answer, remain, cont);
50
}
51
52
@SuppressWarnings("removal")
53
@Override
54
protected Binding
55
createItem(String dn, Attributes attrs, Vector<Control> respCtls)
56
throws NamingException {
57
58
Object obj = null;
59
String atom = getAtom(dn);
60
61
if (attrs.get(Obj.JAVA_ATTRIBUTES[Obj.CLASSNAME]) != null) {
62
// serialized object or object reference
63
try {
64
PrivilegedExceptionAction<Object> pa = () -> Obj.decodeObject(attrs);
65
obj = AccessController.doPrivileged(pa, acc);
66
} catch (PrivilegedActionException e) {
67
throw (NamingException)e.getException();
68
}
69
}
70
if (obj == null) {
71
// DirContext object
72
obj = new LdapCtx(homeCtx, dn);
73
}
74
75
CompositeName cn = new CompositeName();
76
cn.add(atom);
77
78
try {
79
obj = DirectoryManager.getObjectInstance(obj, cn, homeCtx,
80
homeCtx.envprops, attrs);
81
82
} catch (NamingException e) {
83
throw e;
84
85
} catch (Exception e) {
86
NamingException ne =
87
new NamingException(
88
"problem generating object using object factory");
89
ne.setRootCause(e);
90
throw ne;
91
}
92
93
Binding binding;
94
if (respCtls != null) {
95
binding = new BindingWithControls(cn.toString(), obj,
96
homeCtx.convertControls(respCtls));
97
} else {
98
binding = new Binding(cn.toString(), obj);
99
}
100
binding.setNameInNamespace(dn);
101
return binding;
102
}
103
104
@Override
105
protected AbstractLdapNamingEnumeration<? extends NameClassPair> getReferredResults(
106
LdapReferralContext refCtx) throws NamingException{
107
// repeat the original operation at the new context
108
return (AbstractLdapNamingEnumeration<? extends NameClassPair>)refCtx.listBindings(listArg);
109
}
110
}
111
112