001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one
003 *  or more contributor license agreements.  See the NOTICE file
004 *  distributed with this work for additional information
005 *  regarding copyright ownership.  The ASF licenses this file
006 *  to you under the Apache License, Version 2.0 (the
007 *  "License"); you may not use this file except in compliance
008 *  with the License.  You may obtain a copy of the License at
009 *
010 *    http://www.apache.org/licenses/LICENSE-2.0
011 *
012 *  Unless required by applicable law or agreed to in writing,
013 *  software distributed under the License is distributed on an
014 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *  KIND, either express or implied.  See the License for the
016 *  specific language governing permissions and limitations
017 *  under the License.
018 *
019 */
020package org.apache.directory.server.annotations;
021
022
023import java.lang.annotation.Documented;
024import java.lang.annotation.ElementType;
025import java.lang.annotation.Inherited;
026import java.lang.annotation.Retention;
027import java.lang.annotation.RetentionPolicy;
028import java.lang.annotation.Target;
029
030import org.apache.directory.api.ldap.model.constants.LdapConstants;
031import org.apache.directory.api.ldap.model.message.AliasDerefMode;
032import org.apache.directory.api.ldap.model.message.SearchScope;
033import org.apache.directory.ldap.client.api.NoVerificationTrustManager;
034
035
036/**
037 * A annotation used to define a replication consumer configuration. Many elements can be configured :
038 * <ul>
039 *   <li>remoteHost : the remote server's name, defaults to 'localhost'</li>
040 *   <li>remotePort : the remote server's LDAP port, defaults to 389</li>
041 *   <li>replUserDn : The replication User's DN</li>
042 *   <li>replUserPassword : The replication User's password</li>
043 *   <li>refreshNPersist : the replication mode, defaults to 'true'</li>
044 *   <li>refreshInterval : the interval between replications when in refreshOnly mode, defaults to 60s</li>
045 *   <li>baseDn : the base from which to fetch entries on the remote server</li>
046 *   <li>filter : the filter to select entries,defaults to (ObjectClass=*)</li>
047 *   <li>attributes : the list of attributes to replicate, defaults to all</li>
048 *   <li>searchSizeLimit : the maximum number of entries to fetch, defaults to no limit</li>
049 *   <li>searchTimeout : the maximum delay to wait for entries, defaults to no limit</li>
050 *   <li>searchScope : the scope, defaults to SUBTREE</li>
051 *   <li>aliasDerefMode : set the aliss derefence policy, defaults to NEVER </li>
052 *   <li>cookie : the replication cookie</li>
053 *   <li>replicaId : the replica identifier</li>
054 *   <li>configEntryDn : the configuration entry's DN</li>
055 *   <li>chaseReferrals : tells if we chase referrals, defaults to false</li>
056 *   <li>useTls : the connection uses TLS, defaults to true</li>
057 *   <li>strictCertVerification : strictly verify the certificate, defaults to true</li>
058 *   <li>trustManager : the trustManager to use, defaults to @link{NoVerificationTrustManager}</li>
059 * </ul>
060 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
061 */
062@Documented
063@Inherited
064@Retention(RetentionPolicy.RUNTIME)
065@Target(
066    { ElementType.METHOD, ElementType.TYPE })
067public @interface CreateConsumer
068{
069    /** 
070     * Host name of the syncrepl remote server, default value is ""
071     * 
072     *  @return The remote host
073     */
074    String remoteHost() default "";
075
076
077    /** 
078     * Port number of the syncrepl provider server, default is 389 
079     * 
080     * @return The remote port
081     */
082    int remotePort() default 389;
083
084
085    /** 
086     * Replication user's Dn 
087     * 
088     * @return the replication user's Dn
089     */
090    String replUserDn();
091
092
093    /** 
094     * Password for binding with replication user dn 
095     * 
096     * @return the replication user credentials
097     */
098    String replUserPassword();
099
100
101    /** 
102     * flag to represent refresh and persist or refresh only mode, defaults to true
103     *  
104     * @return <tt>true</tt> if replication is done with a refresh and persist
105     */
106    boolean refreshNPersist() default true;
107
108
109    /** 
110     * Time interval for successive sync requests, default is 60 seconds 
111     * 
112     * @return The refresh interval
113     */
114    long refreshInterval() default 60 * 1000;
115
116
117    /** 
118     * The base Dn whose content will be searched for replicating
119     * 
120     * @return The replication Base DN 
121     */
122    String baseDn();
123
124
125    /** 
126     * The ldap filter for fetching the entries, default value is (objectClass=*)
127     * 
128     *  @return The filter
129     */
130    String filter() default LdapConstants.OBJECT_CLASS_STAR;
131
132
133    /** 
134     * Names of attributes to be replicated, default value is all user attributes
135     * 
136     * @return The replicated attributes
137     */
138    String[] attributes() default "";
139
140
141    /** 
142     * The maximum number of search results to be fetched
143     * default value is 0 (i.e no limit) 
144     * 
145     * @return The search size limit
146     */
147    int searchSizeLimit() default 0;
148
149
150    /** 
151     * The timeout value to be used while doing a search 
152     * default value is 0 (i.e no limit)
153     * 
154     * @return The search time limit
155     */
156    int searchTimeout() default 0;
157
158
159    /** 
160     * The search scope, default is sub tree level 
161     * 
162     * @return the Search scope
163     */
164    SearchScope searchScope() default SearchScope.SUBTREE;
165
166
167    /** 
168     * Alias dereferencing mode, default is set to 'never deref aliases' 
169     * 
170     * @return the Deref Alias mode
171     */
172    AliasDerefMode aliasDerefMode() default AliasDerefMode.NEVER_DEREF_ALIASES;
173
174
175    /**
176     * @return The replica's id
177     */
178    int replicaId();
179
180
181    /** 
182     * @return The configuration entry DN
183     */
184    String configEntryDn() default "";
185
186
187    /** 
188     * flag to indicate whether to chase referrals or not, default is false hence passes ManageDsaITControl 
189     * with syncsearch request
190     * 
191     * @return <tt>true</tt> if referals are chased
192     */
193    boolean chaseReferrals() default false;
194
195
196    /** 
197     * flag to indicate the use of TLS, default is true
198     * 
199     * @return <tt>true</tt> if Tls is in use
200     */
201    boolean useTls() default true;
202
203
204    /** 
205     * flag to indicate the use of strict certificate verification, default is true
206     *  
207     * @return <tt>true</tt> if a strict certificate validation is done
208     */
209    boolean strictCertVerification() default true;
210
211
212    /** 
213     * The X509 certificate trust manager used, default value set to {@link NoVerificationTrustManager}
214     * 
215     *  @return The trust manager class
216     */
217    Class<?> trustManager() default NoVerificationTrustManager.class;
218}