165 urlScope = url.getScope();
166 urlFilter = url.getFilter();
167
168 } catch (NamingException e) {
169 // Not an LDAP URL; use original URL
170 urlString = referral;
171 urlAttrs = urlScope = urlFilter = null;
172 }
173
174 // reuse original name if URL DN is absent
175 if (urlString == null) {
176 urlString = nextName;
177 } else {
178 // concatenate with remaining name if URL DN is present
179 urlString = "";
180 }
181
182 if (urlString == null) {
183 urlName = null;
184 } else {
185 urlName = urlString.equals("") ? new CompositeName() :
186 new CompositeName().add(urlString);
187 }
188 }
189
190
191 public void close() throws NamingException {
192 if (refCtx != null) {
193 refCtx.close();
194 refCtx = null;
195 }
196 refEx = null;
197 }
198
199 void setHopCount(int hopCount) {
200 this.hopCount = hopCount;
201 if ((refCtx != null) && (refCtx instanceof LdapCtx)) {
202 ((LdapCtx)refCtx).setHopCount(hopCount);
203 }
204 }
205
871 "Referral context not an instance of LdapContext");
872 }
873 return ((LdapContext)refCtx).getRequestControls();
874 }
875
876 public Control[] getResponseControls() throws NamingException {
877 if (skipThisReferral) {
878 throw (NamingException)
879 ((refEx.appendUnprocessedReferrals(null)).fillInStackTrace());
880 }
881
882 if (!(refCtx instanceof LdapContext)) {
883 throw new NotContextException(
884 "Referral context not an instance of LdapContext");
885 }
886 return ((LdapContext)refCtx).getResponseControls();
887 }
888
889 // ---------------------- Private methods ---------------------
890 private Name toName(String name) throws InvalidNameException {
891 return name.equals("") ? new CompositeName() :
892 new CompositeName().add(name);
893 }
894
895 /*
896 * Use the DN component from the LDAP URL (if present) to override the
897 * supplied DN.
898 */
899 private Name overrideName(Name name) throws InvalidNameException {
900 return (urlName == null ? name : urlName);
901 }
902
903 /*
904 * Use the attributes and scope components from the LDAP URL (if present)
905 * to override the corresponding components supplied in SearchControls.
906 */
907 private SearchControls overrideAttributesAndScope(SearchControls cons) {
908 SearchControls urlCons;
909
910 if ((urlScope != null) || (urlAttrs != null)) {
911 urlCons = new SearchControls(cons.getSearchScope(),
|
165 urlScope = url.getScope();
166 urlFilter = url.getFilter();
167
168 } catch (NamingException e) {
169 // Not an LDAP URL; use original URL
170 urlString = referral;
171 urlAttrs = urlScope = urlFilter = null;
172 }
173
174 // reuse original name if URL DN is absent
175 if (urlString == null) {
176 urlString = nextName;
177 } else {
178 // concatenate with remaining name if URL DN is present
179 urlString = "";
180 }
181
182 if (urlString == null) {
183 urlName = null;
184 } else {
185 urlName = urlString.isEmpty() ? new CompositeName() :
186 new CompositeName().add(urlString);
187 }
188 }
189
190
191 public void close() throws NamingException {
192 if (refCtx != null) {
193 refCtx.close();
194 refCtx = null;
195 }
196 refEx = null;
197 }
198
199 void setHopCount(int hopCount) {
200 this.hopCount = hopCount;
201 if ((refCtx != null) && (refCtx instanceof LdapCtx)) {
202 ((LdapCtx)refCtx).setHopCount(hopCount);
203 }
204 }
205
871 "Referral context not an instance of LdapContext");
872 }
873 return ((LdapContext)refCtx).getRequestControls();
874 }
875
876 public Control[] getResponseControls() throws NamingException {
877 if (skipThisReferral) {
878 throw (NamingException)
879 ((refEx.appendUnprocessedReferrals(null)).fillInStackTrace());
880 }
881
882 if (!(refCtx instanceof LdapContext)) {
883 throw new NotContextException(
884 "Referral context not an instance of LdapContext");
885 }
886 return ((LdapContext)refCtx).getResponseControls();
887 }
888
889 // ---------------------- Private methods ---------------------
890 private Name toName(String name) throws InvalidNameException {
891 return name.isEmpty() ? new CompositeName() :
892 new CompositeName().add(name);
893 }
894
895 /*
896 * Use the DN component from the LDAP URL (if present) to override the
897 * supplied DN.
898 */
899 private Name overrideName(Name name) throws InvalidNameException {
900 return (urlName == null ? name : urlName);
901 }
902
903 /*
904 * Use the attributes and scope components from the LDAP URL (if present)
905 * to override the corresponding components supplied in SearchControls.
906 */
907 private SearchControls overrideAttributesAndScope(SearchControls cons) {
908 SearchControls urlCons;
909
910 if ((urlScope != null) || (urlAttrs != null)) {
911 urlCons = new SearchControls(cons.getSearchScope(),
|