author | lmesnik |
Tue, 02 Apr 2019 17:11:04 -0700 | |
changeset 54389 | 772f62a13376 |
parent 51564 | 0f8e680269d4 |
permissions | -rw-r--r-- |
10324
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
1 |
/* |
51564
0f8e680269d4
8176553: LdapContext follows referrals infinitely ignoring set limit
vtewari
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. |
10324
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
4 |
* |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Oracle designates this |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
10 |
* |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
15 |
* accompanied this code). |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
16 |
* |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
20 |
* |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
22 |
* or visit www.oracle.com if you need additional information or have any |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
23 |
* questions. |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
24 |
*/ |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
25 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
26 |
package com.sun.jndi.ldap; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
27 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
28 |
import com.sun.jndi.toolkit.ctx.Continuation; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
29 |
import java.util.NoSuchElementException; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
30 |
import java.util.Vector; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
31 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
32 |
import javax.naming.*; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
33 |
import javax.naming.directory.Attributes; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
34 |
import javax.naming.ldap.Control; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
35 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
36 |
/** |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
37 |
* Basic enumeration for NameClassPair, Binding, and SearchResults. |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
38 |
*/ |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
39 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
40 |
abstract class AbstractLdapNamingEnumeration<T extends NameClassPair> |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
41 |
implements NamingEnumeration<T>, ReferralEnumeration<T> { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
42 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
43 |
protected Name listArg; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
44 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
45 |
private boolean cleaned = false; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
46 |
private LdapResult res; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
47 |
private LdapClient enumClnt; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
48 |
private Continuation cont; // used to fill in exceptions |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
49 |
private Vector<LdapEntry> entries = null; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
50 |
private int limit = 0; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
51 |
private int posn = 0; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
52 |
protected LdapCtx homeCtx; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
53 |
private LdapReferralException refEx = null; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
54 |
private NamingException errEx = null; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
55 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
56 |
/* |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
57 |
* Record the next set of entries and/or referrals. |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
58 |
*/ |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
59 |
AbstractLdapNamingEnumeration(LdapCtx homeCtx, LdapResult answer, Name listArg, |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
60 |
Continuation cont) throws NamingException { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
61 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
62 |
// These checks are to accommodate referrals and limit exceptions |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
63 |
// which will generate an enumeration and defer the exception |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
64 |
// to be thrown at the end of the enumeration. |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
65 |
// All other exceptions are thrown immediately. |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
66 |
// Exceptions shouldn't be thrown here anyhow because |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
67 |
// process_return_code() is called before the constructor |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
68 |
// is called, so these are just safety checks. |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
69 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
70 |
if ((answer.status != LdapClient.LDAP_SUCCESS) && |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
71 |
(answer.status != LdapClient.LDAP_SIZE_LIMIT_EXCEEDED) && |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
72 |
(answer.status != LdapClient.LDAP_TIME_LIMIT_EXCEEDED) && |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
73 |
(answer.status != LdapClient.LDAP_ADMIN_LIMIT_EXCEEDED) && |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
74 |
(answer.status != LdapClient.LDAP_REFERRAL) && |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
75 |
(answer.status != LdapClient.LDAP_PARTIAL_RESULTS)) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
76 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
77 |
// %%% need to deal with referral |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
78 |
NamingException e = new NamingException( |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
79 |
LdapClient.getErrorMessage( |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
80 |
answer.status, answer.errorMessage)); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
81 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
82 |
throw cont.fillInException(e); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
83 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
84 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
85 |
// otherwise continue |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
86 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
87 |
res = answer; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
88 |
entries = answer.entries; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
89 |
limit = (entries == null) ? 0 : entries.size(); // handle empty set |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
90 |
this.listArg = listArg; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
91 |
this.cont = cont; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
92 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
93 |
if (answer.refEx != null) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
94 |
refEx = answer.refEx; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
95 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
96 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
97 |
// Ensures that context won't get closed from underneath us |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
98 |
this.homeCtx = homeCtx; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
99 |
homeCtx.incEnumCount(); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
100 |
enumClnt = homeCtx.clnt; // remember |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
101 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
102 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
103 |
@Override |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
104 |
public final T nextElement() { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
105 |
try { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
106 |
return next(); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
107 |
} catch (NamingException e) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
108 |
// can't throw exception |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
109 |
cleanup(); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
110 |
return null; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
111 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
112 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
113 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
114 |
@Override |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
115 |
public final boolean hasMoreElements() { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
116 |
try { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
117 |
return hasMore(); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
118 |
} catch (NamingException e) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
119 |
// can't throw exception |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
120 |
cleanup(); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
121 |
return false; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
122 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
123 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
124 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
125 |
/* |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
126 |
* Retrieve the next set of entries and/or referrals. |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
127 |
*/ |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
128 |
private void getNextBatch() throws NamingException { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
129 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
130 |
res = homeCtx.getSearchReply(enumClnt, res); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
131 |
if (res == null) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
132 |
limit = posn = 0; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
133 |
return; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
134 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
135 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
136 |
entries = res.entries; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
137 |
limit = (entries == null) ? 0 : entries.size(); // handle empty set |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
138 |
posn = 0; // reset |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
139 |
|
25808 | 140 |
// minimize the number of calls to processReturnCode() |
10324
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
141 |
// (expensive when batchSize is small and there are many results) |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
142 |
if ((res.status != LdapClient.LDAP_SUCCESS) || |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
143 |
((res.status == LdapClient.LDAP_SUCCESS) && |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
144 |
(res.referrals != null))) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
145 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
146 |
try { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
147 |
// convert referrals into a chain of LdapReferralException |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
148 |
homeCtx.processReturnCode(res, listArg); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
149 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
150 |
} catch (LimitExceededException | PartialResultException e) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
151 |
setNamingException(e); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
152 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
153 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
154 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
155 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
156 |
// merge any newly received referrals with any current referrals |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
157 |
if (res.refEx != null) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
158 |
if (refEx == null) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
159 |
refEx = res.refEx; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
160 |
} else { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
161 |
refEx = refEx.appendUnprocessedReferrals(res.refEx); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
162 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
163 |
res.refEx = null; // reset |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
164 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
165 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
166 |
if (res.resControls != null) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
167 |
homeCtx.respCtls = res.resControls; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
168 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
169 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
170 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
171 |
private boolean more = true; // assume we have something to start with |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
172 |
private boolean hasMoreCalled = false; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
173 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
174 |
/* |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
175 |
* Test if unprocessed entries or referrals exist. |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
176 |
*/ |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
177 |
@Override |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
178 |
public final boolean hasMore() throws NamingException { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
179 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
180 |
if (hasMoreCalled) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
181 |
return more; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
182 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
183 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
184 |
hasMoreCalled = true; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
185 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
186 |
if (!more) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
187 |
return false; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
188 |
} else { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
189 |
return (more = hasMoreImpl()); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
190 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
191 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
192 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
193 |
/* |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
194 |
* Retrieve the next entry. |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
195 |
*/ |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
196 |
@Override |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
197 |
public final T next() throws NamingException { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
198 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
199 |
if (!hasMoreCalled) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
200 |
hasMore(); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
201 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
202 |
hasMoreCalled = false; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
203 |
return nextImpl(); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
204 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
205 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
206 |
/* |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
207 |
* Test if unprocessed entries or referrals exist. |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
208 |
*/ |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
209 |
private boolean hasMoreImpl() throws NamingException { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
210 |
// when page size is supported, this |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
211 |
// might generate an exception while attempting |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
212 |
// to fetch the next batch to determine |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
213 |
// whether there are any more elements |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
214 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
215 |
// test if the current set of entries has been processed |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
216 |
if (posn == limit) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
217 |
getNextBatch(); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
218 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
219 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
220 |
// test if any unprocessed entries exist |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
221 |
if (posn < limit) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
222 |
return true; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
223 |
} else { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
224 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
225 |
try { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
226 |
// try to process another referral |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
227 |
return hasMoreReferrals(); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
228 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
229 |
} catch (LdapReferralException | |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
230 |
LimitExceededException | |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
231 |
PartialResultException e) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
232 |
cleanup(); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
233 |
throw e; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
234 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
235 |
} catch (NamingException e) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
236 |
cleanup(); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
237 |
PartialResultException pre = new PartialResultException(); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
238 |
pre.setRootCause(e); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
239 |
throw pre; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
240 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
241 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
242 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
243 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
244 |
/* |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
245 |
* Retrieve the next entry. |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
246 |
*/ |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
247 |
private T nextImpl() throws NamingException { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
248 |
try { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
249 |
return nextAux(); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
250 |
} catch (NamingException e) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
251 |
cleanup(); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
252 |
throw cont.fillInException(e); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
253 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
254 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
255 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
256 |
private T nextAux() throws NamingException { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
257 |
if (posn == limit) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
258 |
getNextBatch(); // updates posn and limit |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
259 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
260 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
261 |
if (posn >= limit) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
262 |
cleanup(); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
263 |
throw new NoSuchElementException("invalid enumeration handle"); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
264 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
265 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
266 |
LdapEntry result = entries.elementAt(posn++); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
267 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
268 |
// gets and outputs DN from the entry |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
269 |
return createItem(result.DN, result.attributes, result.respCtls); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
270 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
271 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
272 |
protected final String getAtom(String dn) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
273 |
// need to strip off all but lowest component of dn |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
274 |
// so that is relative to current context (currentDN) |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
275 |
try { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
276 |
Name parsed = new LdapName(dn); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
277 |
return parsed.get(parsed.size() - 1); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
278 |
} catch (NamingException e) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
279 |
return dn; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
280 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
281 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
282 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
283 |
protected abstract T createItem(String dn, Attributes attrs, |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
284 |
Vector<Control> respCtls) throws NamingException; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
285 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
286 |
/* |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
287 |
* Append the supplied (chain of) referrals onto the |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
288 |
* end of the current (chain of) referrals. |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
289 |
*/ |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
290 |
@Override |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
291 |
public void appendUnprocessedReferrals(LdapReferralException ex) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
292 |
if (refEx != null) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
293 |
refEx = refEx.appendUnprocessedReferrals(ex); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
294 |
} else { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
295 |
refEx = ex.appendUnprocessedReferrals(refEx); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
296 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
297 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
298 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
299 |
final void setNamingException(NamingException e) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
300 |
errEx = e; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
301 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
302 |
|
39639
b2d7ac2be69e
8141148: LDAP "follow" throws ClassCastException with Java 8
robm
parents:
25859
diff
changeset
|
303 |
protected abstract AbstractLdapNamingEnumeration<? extends NameClassPair> getReferredResults( |
10324
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
304 |
LdapReferralContext refCtx) throws NamingException; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
305 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
306 |
/* |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
307 |
* Iterate through the URLs of a referral. If successful then perform |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
308 |
* a search operation and merge the received results with the current |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
309 |
* results. |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
310 |
*/ |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
311 |
protected final boolean hasMoreReferrals() throws NamingException { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
312 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
313 |
if ((refEx != null) && |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
314 |
(refEx.hasMoreReferrals() || |
51564
0f8e680269d4
8176553: LdapContext follows referrals infinitely ignoring set limit
vtewari
parents:
47216
diff
changeset
|
315 |
refEx.hasMoreReferralExceptions() |
0f8e680269d4
8176553: LdapContext follows referrals infinitely ignoring set limit
vtewari
parents:
47216
diff
changeset
|
316 |
&& !(errEx instanceof LimitExceededException))) { |
10324
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
317 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
318 |
if (homeCtx.handleReferrals == LdapClient.LDAP_REF_THROW) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
319 |
throw (NamingException)(refEx.fillInStackTrace()); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
320 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
321 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
322 |
// process the referrals sequentially |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
323 |
while (true) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
324 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
325 |
LdapReferralContext refCtx = |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
326 |
(LdapReferralContext)refEx.getReferralContext( |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
327 |
homeCtx.envprops, homeCtx.reqCtls); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
328 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
329 |
try { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
330 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
331 |
update(getReferredResults(refCtx)); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
332 |
break; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
333 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
334 |
} catch (LdapReferralException re) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
335 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
336 |
// record a previous exception |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
337 |
if (errEx == null) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
338 |
errEx = re.getNamingException(); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
339 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
340 |
refEx = re; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
341 |
continue; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
342 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
343 |
} finally { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
344 |
// Make sure we close referral context |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
345 |
refCtx.close(); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
346 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
347 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
348 |
return hasMoreImpl(); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
349 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
350 |
} else { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
351 |
cleanup(); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
352 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
353 |
if (errEx != null) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
354 |
throw errEx; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
355 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
356 |
return (false); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
357 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
358 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
359 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
360 |
/* |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
361 |
* Merge the entries and/or referrals from the supplied enumeration |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
362 |
* with those of the current enumeration. |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
363 |
*/ |
39639
b2d7ac2be69e
8141148: LDAP "follow" throws ClassCastException with Java 8
robm
parents:
25859
diff
changeset
|
364 |
protected void update(AbstractLdapNamingEnumeration<? extends NameClassPair> ne) { |
10324
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
365 |
// Cleanup previous context first |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
366 |
homeCtx.decEnumCount(); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
367 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
368 |
// New enum will have already incremented enum count and recorded clnt |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
369 |
homeCtx = ne.homeCtx; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
370 |
enumClnt = ne.enumClnt; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
371 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
372 |
// Do this to prevent referral enumeration (ne) from decrementing |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
373 |
// enum count because we'll be doing that here from this |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
374 |
// enumeration. |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
375 |
ne.homeCtx = null; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
376 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
377 |
// Record rest of information from new enum |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
378 |
posn = ne.posn; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
379 |
limit = ne.limit; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
380 |
res = ne.res; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
381 |
entries = ne.entries; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
382 |
refEx = ne.refEx; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
383 |
listArg = ne.listArg; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
384 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
385 |
|
44534 | 386 |
@SuppressWarnings("deprecation") |
10324
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
387 |
protected final void finalize() { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
388 |
cleanup(); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
389 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
390 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
391 |
protected final void cleanup() { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
392 |
if (cleaned) return; // been there; done that |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
393 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
394 |
if(enumClnt != null) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
395 |
enumClnt.clearSearchReply(res, homeCtx.reqCtls); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
396 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
397 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
398 |
enumClnt = null; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
399 |
cleaned = true; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
400 |
if (homeCtx != null) { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
401 |
homeCtx.decEnumCount(); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
402 |
homeCtx = null; |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
403 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
404 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
405 |
|
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
406 |
@Override |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
407 |
public final void close() { |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
408 |
cleanup(); |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
409 |
} |
e28265130e4f
7072353: JNDI libraries do not build with javac -Xlint:all -Werror
jjg
parents:
diff
changeset
|
410 |
} |