Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ILdapLogger.java « core « connection « studio « directory « apache « org « java « main « src « connection.core « plugins - github.com/apache/directory-studio.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d9adcbb73333d90709a32b17228695bba4cd28c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
/*
 *  Licensed to the Apache Software Foundation (ASF) under one
 *  or more contributor license agreements.  See the NOTICE file
 *  distributed with this work for additional information
 *  regarding copyright ownership.  The ASF licenses this file
 *  to you under the Apache License, Version 2.0 (the
 *  "License"); you may not use this file except in compliance
 *  with the License.  You may obtain a copy of the License at
 *  
 *    http://www.apache.org/licenses/LICENSE-2.0
 *  
 *  Unless required by applicable law or agreed to in writing,
 *  software distributed under the License is distributed on an
 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 *  KIND, either express or implied.  See the License for the
 *  specific language governing permissions and limitations
 *  under the License. 
 *  
 */
package org.apache.directory.studio.connection.core;


import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import javax.naming.directory.SearchControls;

import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.entry.Modification;
import org.apache.directory.api.ldap.model.message.Control;
import org.apache.directory.api.ldap.model.message.Referral;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.api.util.Strings;
import org.apache.directory.studio.connection.core.Connection.AliasDereferencingMethod;
import org.apache.directory.studio.connection.core.io.StudioLdapException;
import org.apache.directory.studio.connection.core.io.api.StudioSearchResult;


/**
 * Callback interface to log modifications.
 *
 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
 */
public interface ILdapLogger
{

    /**
     * Logs a changetype:add.
     * 
     * @param connection the connection
     * @param entry the entry
     * @param controls the controls
     * @param ex the LDAP exception if an error occurred, null otherwise
     */
    default void logChangetypeAdd( Connection connection, final Entry entry, final Control[] controls,
        StudioLdapException ex )
    {
    }


    /**
     * Logs a changetype:delete.
     * 
     * @param connection the connection
     * @param dn the Dn
     * @param controls the controls
     * @param ex the LDAP exception if an error occurred, null otherwise
     * 
     */
    default void logChangetypeDelete( Connection connection, final Dn dn, final Control[] controls,
        StudioLdapException ex )
    {

    }


    /**
     * Logs a changetype:modify.
     * 
     * @param connection the connection
     * @param dn the Dn
     * @param modifications the modification items
     * @param ex the LDAP exception if an error occurred, null otherwise
     * @param controls the controls
     */
    default void logChangetypeModify( Connection connection, final Dn dn,
        final Collection<Modification> modifications, final Control[] controls, StudioLdapException ex )
    {
    }


    /**
     * Logs a changetype:moddn.
     * 
     * @param connection the connection
     * @param oldDn the old Dn
     * @param newDn the new Dn
     * @param deleteOldRdn the delete old Rdn
     * @param controls the controls
     * @param ex the LDAP exception if an error occurred, null otherwise
     */
    default void logChangetypeModDn( Connection connection, final Dn oldDn, final Dn newDn,
        final boolean deleteOldRdn, final Control[] controls, StudioLdapException ex )
    {
    }


    /**
     * Sets the logger ID.
     * 
     * @param id the new logger ID
     */
    void setId( String id );


    /**
     * Gets the logger ID.
     * 
     * @return the logger ID
     */
    String getId();


    /**
     * Sets the logger name.
     * 
     * @param name the new logger name
     */
    void setName( String name );


    /**
     * Gets the logger name.
     * 
     * @return the logger name
     */
    String getName();


    /**
     * Sets the logger description.
     * 
     * @param description the new logger description
     */
    void setDescription( String description );


    /**
     * Gets the logger description.
     * 
     * @return the logger description
     */
    String getDescription();


    /**
     * Logs a search request.
     *
     * @param connection the connection
     * @param searchBase the search base
     * @param filter the filter
     * @param searchControls the search controls
     * @param aliasesDereferencingMethod the aliases dereferncing method
     * @param controls the LDAP controls 
     * @param requestNum the request number
     * @param ex the LDAP exception if an error occurred, null otherwise
     */
    default void logSearchRequest( Connection connection, String searchBase, String filter,
        SearchControls searchControls, AliasDereferencingMethod aliasesDereferencingMethod,
        Control[] controls, long requestNum, StudioLdapException ex )
    {
    }


    /**
     * Logs a search result entry.
     * 
     * @param connection the connection
     * @param studioSearchResult the search result entry
     * @param requestNum the request number
     * @param ex the LDAP exception if an error occurred, null otherwise
     */
    default void logSearchResultEntry( Connection connection, StudioSearchResult studioSearchResult, long requestNum,
        StudioLdapException ex )
    {
    }


    /**
     * Logs a search result reference.
     *
     * @param connection the connection
     * @param referral the referral
     * @param referralsInfo the referrals info containing further URLs and DNs
     * @param requestNum the request number
     * @param ex the LDAP exception if an error occurred, null otherwise
     */
    default void logSearchResultReference( Connection connection, Referral referral,
        ReferralsInfo referralsInfo, long requestNum, StudioLdapException ex )
    {
    }


    /**
     * Logs a search result done.
     *
     * @param connection the connection
     * @param count the number of received entries
     * @param requestNum the request number
     * @param ex the LDAP exception if an error occurred, null otherwise
     */
    default void logSearchResultDone( Connection connection, long count, long requestNum, StudioLdapException ex )
    {
    }

    /**
     * Gets the masked attributes.
     * 
     * @return the masked attributes
     */
    default Set<String> getMaskedAttributes()
    {
        Set<String> maskedAttributes = new HashSet<String>();

        String maskedAttributeString = ConnectionCorePlugin.getDefault().getPluginPreferences().getString(
            ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_MASKED_ATTRIBUTES );
        String[] splitted = maskedAttributeString.split( "," ); //$NON-NLS-1$

        for ( String s : splitted )
        {
            maskedAttributes.add( Strings.toLowerCase( s ) );
        }

        return maskedAttributes;
    }

}