1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 * 19 */ 20 package org.apache.directory.api.ldap.model.message; 21 22 23 import java.util.Collection; 24 25 26 /** 27 * Represents a referral which is a set of alternative locations where an entry 28 * can be found. Here's what <a href="http://www.faqs.org/rfcs/rfc2251.html"> 29 * RFC 2251 </a> has to say about it: 30 * 31 * <pre> 32 * 4.1.11. Referral 33 * 34 * The referral error indicates that the contacted server does not hold 35 * the target entry of the request. The referral field is present in an 36 * LDAPResult if the LDAPResult.resultCode field value is referral, and 37 * absent with all other result codes. It contains a reference to 38 * another server (or set of servers) which may be accessed via LDAP or 39 * other protocols. Referrals can be returned in response to any 40 * operation request (except unbind and abandon which do not have 41 * responses). At least one URL MUST be present in the Referral. 42 * 43 * The referral is not returned for a singleLevel or wholeSubtree search 44 * in which the search scope spans multiple naming contexts, and several 45 * different servers would need to be contacted to complete the 46 * operation. Instead, continuation references, described in section 47 * 4.5.3, are returned. 48 * 49 * Referral ::= SEQUENCE OF LDAPURL -- one or more 50 * 51 * LDAPURL ::= LDAPString -- limited to characters permitted in URLs 52 * 53 * If the client wishes to progress the operation, it MUST follow the 54 * referral by contacting any one of servers. All the URLs MUST be 55 * equally capable of being used to progress the operation. (The 56 * mechanisms for how this is achieved by multiple servers are outside 57 * the scope of this document.) 58 * 59 * URLs for servers implementing the LDAP protocol are written according 60 * to <a href="http://www.faqs.org/rfcs/rfc2255.html">[9]</a>. If an alias 61 * was dereferenced, the <dn> part of the URL MUST be present, with the new 62 * target object name. If the <dn> part is present, the client MUST use this 63 * name in its next request to progress the operation, and if it is not present 64 * the client will use the same name as in the original request. Some servers 65 * (e.g. participating in distributed indexing) may provide a different filter 66 * in a referral for a search operation. If the filter part of the URL 67 * is present in an LDAPURL, the client MUST use this filter in its next 68 * request to progress this search, and if it is not present the client 69 * MUST use the same filter as it used for that search. Other aspects 70 * of the new request may be the same or different as the request which 71 * generated the referral. 72 * 73 * Note that UTF-8 characters appearing in a Dn or search filter may not 74 * be legal for URLs (e.g. spaces) and MUST be escaped using the % 75 * method in RFC 1738 <a href="http://www.faqs.org/rfcs/rfc1738.html">[7]</a>. 76 * 77 * Other kinds of URLs may be returned, so long as the operation could 78 * be performed using that protocol. 79 * </pre> 80 * 81 * @author <a href="mailto:dev@directory.apache.org"> Apache Directory Project</a> 82 * TODO This interface should be located in a url package under common to be 83 * constructed from a LDAPv3 URL parser. The interface will eventually 84 * look very different once url support is added: for one it will add and 85 * remove LdapUrl objects instead of strings or provide both string and 86 * LdapUrl add/remove methods. 87 */ 88 public interface Referral 89 { 90 /** 91 * Gets an unmodifiable set of alternative referral urls. 92 * 93 * @return the alternative url objects. 94 */ 95 Collection<String> getLdapUrls(); 96 97 98 /** 99 * Gets an unmodifiable set of encoded referral urls. 100 * 101 * @return the encoded url objects. 102 */ 103 Collection<byte[]> getLdapUrlsBytes(); 104 105 106 /** 107 * Adds an LDAPv3 URL to this Referral. 108 * 109 * @param url 110 * the LDAPv3 URL to add 111 */ 112 void addLdapUrl( String url ); 113 114 115 /** 116 * Adds an encoded LDAPv3 URL to this Referral. 117 * 118 * @param urlBytes the encoded LDAPv3 URL to add 119 */ 120 void addLdapUrlBytes( byte[] urlBytes ); 121 122 123 /** 124 * Removes an LDAPv3 URL to this Referral. 125 * 126 * @param url 127 * the LDAPv3 URL to remove 128 */ 129 void removeLdapUrl( String url ); 130 131 132 /** 133 * @return The total length of the Referral 134 */ 135 int getReferralLength(); 136 137 138 /** 139 * Set the length of the referral 140 * @param referralLength The total length of the Referral 141 */ 142 void setReferralLength( int referralLength ); 143 }