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.api.ldap.extras.controls.ad;
021
022
023import org.apache.directory.api.ldap.model.message.Control;
024
025import java.util.EnumSet;
026import java.util.Set;
027
028/**
029 * The DirSync control, as described in http://tools.ietf.org/html/draft-armijo-ldap-dirsync-00.
030 * We use the same control for both the SearchRequest and the SearchResultDone. Here is the
031 * ASN/1 description of the SearchRequest control :
032 * 
033 * <pre>
034 * Repl    Control ::= SEQUENCE {
035 *     controlType             1.2.840.113556.1.4.841
036 *     controlValue            replControlValue
037 *     criticality             TRUE
038 * }
039 * 
040 * the control value can be one of the two structures :
041 * 
042 * Client side :
043 * realReplControlValue ::= SEQUENCE {
044 *     flags                 integer
045 *     maxBytes              integer
046 *     cookie                OCTET STRING
047 * }
048 * 
049 * or
050 * 
051 * server side :
052 * realReplControlValue ::= SEQUENCE {
053 *     flag                  integer
054 *     maxBytes              integer
055 *     cookie                OCTET STRING
056 * }
057 * </pre> 
058 *
059 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
060 *
061 */
062public interface AdDirSync extends Control
063{
064    /** This control OID */
065    String OID = "1.2.840.113556.1.4.841";
066
067    /**
068     * @return The maximum length of attributes to be returned
069     */
070    int getMaxReturnLength();
071
072
073    /**
074     * @param maxReturnLength The maximum length of attributes to be returned
075     */
076    void setMaxReturnLength( int maxReturnLength );
077
078
079    /**
080     * @return The cookie used while processing the successive DirSync operations
081     */
082    byte[] getCookie();
083
084
085    /**
086     * @param cookie The cookie to send to the server. It's the value found in the response control. Should be null
087     * for the first control.
088     */
089    void setCookie( byte[] cookie );
090
091
092    /**
093     * @return The flags returned by the server. Zero or more of :
094     * <ul>
095     * <li>LDAP_DIRSYNC_OBJECT_SECURITY (0x0001)</li>
096     * <li>LDAP_DIRSYNC_ANCESTORS_FIRST_ORDER (0x0800)</li>
097     * <li>LDAP_DIRSYNC_PUBLIC_DATA_ONLY (0x2000)(</li>
098     * <li>LDAP_DIRSYNC_INCREMENTAL_VALUES (0x7FFFFFFF)</li>
099     * </ul>
100     */
101    Set<AdDirSyncFlag> getFlags();
102
103
104    /**
105     * @param flags The flags to be set. See {@link EnumSet} for how to generate EnumSets.
106     */
107    void setFlags( Set<AdDirSyncFlag> flags );
108
109
110    /**
111     * @param flag The flag to be added to the current collection of flags.
112     */
113    void addFlag( AdDirSyncFlag flag );
114
115
116    /**
117     * @param flag The flag to be removed from the current collection of flags. 
118     */
119    void removeFlag( AdDirSyncFlag flag );
120}