You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by el...@apache.org on 2015/01/10 10:28:14 UTC
svn commit: r1650728 - in /directory/apacheds/trunk:
http-integration/src/main/java/org/apache/directory/server/integration/http/
interceptors/authz/src/main/java/org/apache/directory/server/core/authz/
protocol-ldap/src/main/java/org/apache/directory/...
Author: elecharny
Date: Sat Jan 10 09:28:14 2015
New Revision: 1650728
URL: http://svn.apache.org/r1650728
Log:
Used LDAP constants instead of Strings
Modified:
directory/apacheds/trunk/http-integration/src/main/java/org/apache/directory/server/integration/http/HttpServer.java
directory/apacheds/trunk/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/GroupCache.java
directory/apacheds/trunk/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/TupleCache.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConfiguration.java
directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ReplicationConsumerImpl.java
directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/kerberos/StoreUtils.java
directory/apacheds/trunk/server-annotations/src/main/java/org/apache/directory/server/annotations/CreateConsumer.java
Modified: directory/apacheds/trunk/http-integration/src/main/java/org/apache/directory/server/integration/http/HttpServer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/http-integration/src/main/java/org/apache/directory/server/integration/http/HttpServer.java?rev=1650728&r1=1650727&r2=1650728&view=diff
==============================================================================
--- directory/apacheds/trunk/http-integration/src/main/java/org/apache/directory/server/integration/http/HttpServer.java (original)
+++ directory/apacheds/trunk/http-integration/src/main/java/org/apache/directory/server/integration/http/HttpServer.java Sat Jan 10 09:28:14 2015
@@ -36,6 +36,7 @@ import java.util.List;
import java.util.Set;
import java.util.UUID;
+import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.server.bridge.http.HttpDirectoryService;
@@ -178,7 +179,8 @@ public class HttpServer
{
// load the admin entry to get the private key and certificate
Dn adminDn = dirService.getDnFactory().create( ServerDNConstants.ADMIN_SYSTEM_DN );
- Entry adminEntry = dirService.getAdminSession().lookup( adminDn, "*", "+" );
+ Entry adminEntry = dirService.getAdminSession().lookup( adminDn, SchemaConstants.ALL_USER_ATTRIBUTES,
+ SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES );
File confDir = dirService.getInstanceLayout().getConfDirectory();
File ksFile = new File( confDir, "httpserver.generated.ks" );
Modified: directory/apacheds/trunk/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/GroupCache.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/GroupCache.java?rev=1650728&r1=1650727&r2=1650728&view=diff
==============================================================================
--- directory/apacheds/trunk/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/GroupCache.java (original)
+++ directory/apacheds/trunk/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/GroupCache.java Sat Jan 10 09:28:14 2015
@@ -152,7 +152,7 @@ public class GroupCache
SearchControls ctls = new SearchControls();
ctls.setSearchScope( SearchControls.SUBTREE_SCOPE );
ctls.setReturningAttributes( new String[]
- { "*", "+" } );
+ { SchemaConstants.ALL_USER_ATTRIBUTES, SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES } );
SearchOperationContext searchOperationContext = new SearchOperationContext( session,
baseDn, filter, ctls );
Modified: directory/apacheds/trunk/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/TupleCache.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/TupleCache.java?rev=1650728&r1=1650727&r2=1650728&view=diff
==============================================================================
--- directory/apacheds/trunk/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/TupleCache.java (original)
+++ directory/apacheds/trunk/interceptors/authz/src/main/java/org/apache/directory/server/core/authz/TupleCache.java Sat Jan 10 09:28:14 2015
@@ -133,7 +133,7 @@ public class TupleCache
SearchControls ctls = new SearchControls();
ctls.setSearchScope( SearchControls.SUBTREE_SCOPE );
ctls.setReturningAttributes( new String[]
- { "*", "+" } );
+ { SchemaConstants.ALL_USER_ATTRIBUTES, SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES } );
SearchOperationContext searchOperationContext = new SearchOperationContext( session,
baseDn, filter, ctls );
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConfiguration.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConfiguration.java?rev=1650728&r1=1650727&r2=1650728&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConfiguration.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/SyncReplConfiguration.java Sat Jan 10 09:28:14 2015
@@ -25,6 +25,7 @@ import java.util.Set;
import javax.net.ssl.X509TrustManager;
+import org.apache.directory.api.ldap.model.constants.LdapConstants;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.message.AliasDerefMode;
import org.apache.directory.api.ldap.model.message.SearchScope;
@@ -68,7 +69,7 @@ public class SyncReplConfiguration imple
/** port number of the syncrepl provider server, default is 10389 */
private int remotePort = 10389;
-
+
/** The producer, as <host>:<port> */
private String producer = remoteHost + ":" + remotePort;
@@ -88,7 +89,7 @@ public class SyncReplConfiguration imple
private String baseDn;
/** the ldap filter for fetching the entries, default value is (objectClass=*) */
- private String filter = "(objectClass=*)";
+ private String filter = LdapConstants.OBJECT_CLASS_STAR;
/** names of attributes to be replicated, default value is all user attributes */
private Set<String> attributes;
Modified: directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ReplicationConsumerImpl.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ReplicationConsumerImpl.java?rev=1650728&r1=1650727&r2=1650728&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ReplicationConsumerImpl.java (original)
+++ directory/apacheds/trunk/protocol-ldap/src/main/java/org/apache/directory/server/ldap/replication/consumer/ReplicationConsumerImpl.java Sat Jan 10 09:28:14 2015
@@ -147,7 +147,7 @@ public class ReplicationConsumerImpl imp
private byte[] lastSavedCookie;
private volatile boolean reload = false;
-
+
/** The (entrtyUuid=*) filter */
private static final PresenceNode ENTRY_UUID_PRESENCE_FILTER = new PresenceNode( SchemaConstants.ENTRY_UUID_AT );
@@ -223,7 +223,7 @@ public class ReplicationConsumerImpl imp
connection.getConfig().setTrustManagers( config.getTrustManager() );
connection.getConfig().setUseTls( true );
}
-
+
connection.addConnectionClosedEventListener( this );
}
@@ -259,7 +259,8 @@ public class ReplicationConsumerImpl imp
}
catch ( Exception e )
{
- CONSUMER_LOG.error( "Failed to connect to the producer {}, cause : {}", config.getProducer(), e.getMessage() );
+ CONSUMER_LOG.error( "Failed to connect to the producer {}, cause : {}", config.getProducer(),
+ e.getMessage() );
disconnected = true;
}
@@ -318,7 +319,7 @@ public class ReplicationConsumerImpl imp
CONSUMER_LOG.debug( "//////////////// END handleSearchDone//////////////////////" );
reload = false;
-
+
return searchDone.getLdapResult().getResultCode();
}
@@ -368,7 +369,6 @@ public class ReplicationConsumerImpl imp
SyncStateTypeEnum state = syncStateCtrl.getSyncStateType();
-
// check to avoid conversion of UUID from byte[] to String
if ( CONSUMER_LOG.isDebugEnabled() )
{
@@ -428,9 +428,10 @@ public class ReplicationConsumerImpl imp
if ( !session.exists( remoteDn ) )
{
- CONSUMER_LOG.debug(
- "looks like entry {} was already deleted in a prior update (possibly from another provider), skipping delete",
- remoteDn );
+ CONSUMER_LOG
+ .debug(
+ "looks like entry {} was already deleted in a prior update (possibly from another provider), skipping delete",
+ remoteDn );
}
else
{
@@ -587,7 +588,8 @@ public class ReplicationConsumerImpl imp
{
doSyncSearch( SynchronizationModeEnum.REFRESH_ONLY, reload );
- CONSUMER_LOG.debug( "--------------------- Sleep for {} seconds ------------------", ( config.getRefreshInterval() / 1000 ) );
+ CONSUMER_LOG.debug( "--------------------- Sleep for {} seconds ------------------",
+ ( config.getRefreshInterval() / 1000 ) );
Thread.sleep( config.getRefreshInterval() );
CONSUMER_LOG.debug( "--------------------- syncing again ------------------" );
@@ -664,7 +666,7 @@ public class ReplicationConsumerImpl imp
boolean connected = !disconnected;
boolean restartSync = false;
-
+
if ( disconnected )
{
connected = connect();
@@ -815,14 +817,14 @@ public class ReplicationConsumerImpl imp
CONSUMER_LOG.warn( "Full SYNC_REFRESH required from {}", config.getProducer() );
reload = true;
-
+
try
{
CONSUMER_LOG.debug( "Deleting baseDN {}", config.getBaseDn() );
-
+
// FIXME taking a backup right before deleting might be a good thing, just to be safe.
// the backup file can be deleted after reload completes successfully
-
+
// the 'rid' value is not taken into consideration when 'reload' is set
// so any dummy value is fine
deleteRecursive( new Dn( config.getBaseDn() ), -1000 );
@@ -974,7 +976,8 @@ public class ReplicationConsumerImpl imp
{
// can be ignored, most likely happens if there is no entry with the given Dn
// log in debug mode
- CONSUMER_LOG.debug( "Failed to read the cookie, cannot find the entry '{}' in the DIT for consumer {}", config.getConfigEntryDn(),
+ CONSUMER_LOG.debug( "Failed to read the cookie, cannot find the entry '{}' in the DIT for consumer {}",
+ config.getConfigEntryDn(),
config.getReplicaId() );
}
}
@@ -991,11 +994,13 @@ public class ReplicationConsumerImpl imp
Modification deleteCookieMod = new DefaultModification( ModificationOperation.REMOVE_ATTRIBUTE,
cookieAttr );
session.modify( config.getConfigEntryDn(), deleteCookieMod );
- CONSUMER_LOG.info( "resetting sync cookie of the consumer with config entry Dn {}", config.getConfigEntryDn() );
+ CONSUMER_LOG.info( "resetting sync cookie of the consumer with config entry Dn {}",
+ config.getConfigEntryDn() );
}
catch ( Exception e )
{
- CONSUMER_LOG.warn( "Failed to delete the cookie from the consumer with config entry Dn {}", config.getConfigEntryDn() );
+ CONSUMER_LOG.warn( "Failed to delete the cookie from the consumer with config entry Dn {}",
+ config.getConfigEntryDn() );
CONSUMER_LOG.warn( "{}", e );
}
@@ -1019,7 +1024,8 @@ public class ReplicationConsumerImpl imp
searchRequest.setBase( new Dn( schemaManager, config.getBaseDn() ) );
searchRequest.setFilter( filter );
searchRequest.setScope( SearchScope.SUBTREE );
- searchRequest.addAttributes( "entryUuid", "entryCsn", "*" );
+ searchRequest.addAttributes( SchemaConstants.ENTRY_UUID_AT, SchemaConstants.ENTRY_CSN_AT,
+ SchemaConstants.ALL_USER_ATTRIBUTES );
Cursor<Entry> cursor = session.search( searchRequest );
cursor.beforeFirst();
@@ -1094,7 +1100,8 @@ public class ReplicationConsumerImpl imp
break;
case RENAME:
- CONSUMER_LOG.debug( "renaming the Dn {} with new Rdn {} and deleteOldRdn flag set to {}", localDn.getName(), remoteRdn.getName(), String.valueOf( deleteOldRdn ) );
+ CONSUMER_LOG.debug( "renaming the Dn {} with new Rdn {} and deleteOldRdn flag set to {}",
+ localDn.getName(), remoteRdn.getName(), String.valueOf( deleteOldRdn ) );
RenameOperationContext renCtx = new RenameOperationContext( session, localDn, remoteRdn,
deleteOldRdn );
@@ -1105,12 +1112,13 @@ public class ReplicationConsumerImpl imp
break;
case MOVE_AND_RENAME:
- CONSUMER_LOG.debug(
- "moveAndRename on the Dn {} with new newParent Dn {}, new Rdn {} and deleteOldRdn flag set to {}",
- localDn.getName(),
- remoteParentDn.getName(),
- remoteRdn.getName(),
- String.valueOf( deleteOldRdn ) );
+ CONSUMER_LOG
+ .debug(
+ "moveAndRename on the Dn {} with new newParent Dn {}, new Rdn {} and deleteOldRdn flag set to {}",
+ localDn.getName(),
+ remoteParentDn.getName(),
+ remoteRdn.getName(),
+ String.valueOf( deleteOldRdn ) );
MoveAndRenameOperationContext movRenCtx = new MoveAndRenameOperationContext( session, localDn,
remoteParentDn, remoteRdn, deleteOldRdn );
@@ -1147,7 +1155,8 @@ public class ReplicationConsumerImpl imp
if ( localCsn.compareTo( remoteCsn ) >= 0 )
{
// just discard the received modified entry, that is old
- CONSUMER_LOG.debug( "local modification is latest, discarding the modification of dn {}", remoteEntry.getDn() );
+ CONSUMER_LOG.debug( "local modification is latest, discarding the modification of dn {}",
+ remoteEntry.getDn() );
return;
}
}
@@ -1305,7 +1314,7 @@ public class ReplicationConsumerImpl imp
if ( size == 1 )
{
String uuid = Strings.uuidToString( limitedUuidList.get( 0 ) );
-
+
filter = new EqualityNode<String>( SchemaConstants.ENTRY_UUID_AT,
new org.apache.directory.api.ldap.model.entry.StringValue( uuid ) );
if ( isRefreshPresent )
@@ -1345,7 +1354,7 @@ public class ReplicationConsumerImpl imp
Dn dn = new Dn( schemaManager, config.getBaseDn() );
CONSUMER_LOG.debug( "selecting entries to be deleted using filter {}", filter.toString() );
-
+
SearchRequest req = new SearchRequestImpl();
req.setBase( dn );
req.setFilter( filter );
@@ -1367,14 +1376,14 @@ public class ReplicationConsumerImpl imp
while ( cursor.next() )
{
Entry entry = cursor.get();
-
+
DeleteOperationContext ctx = new DeleteOperationContext( session );
ctx.setReplEvent( true );
ctx.setRid( replicaId );
// DO NOT generate replication event if this is being deleted as part of
// e_sync_refresh_required
- if( reload )
+ if ( reload )
{
ctx.setGenerateNoReplEvt( true );
}
@@ -1431,27 +1440,26 @@ public class ReplicationConsumerImpl imp
cursor = session.search( req );
cursor.beforeFirst();
-
-
+
OperationManager operationManager = directoryService.getOperationManager();
-
- while( cursor.next() )
+
+ while ( cursor.next() )
{
Entry e = cursor.get();
DeleteOperationContext ctx = new DeleteOperationContext( session );
ctx.setReplEvent( true );
ctx.setRid( rid );
-
+
// DO NOT generate replication event if this is being deleted as part of
// e_sync_refresh_required
- if( reload )
+ if ( reload )
{
ctx.setGenerateNoReplEvt( true );
}
ctx.setDn( e.getDn() );
-
+
operationManager.delete( ctx );
}
}
@@ -1463,7 +1471,7 @@ public class ReplicationConsumerImpl imp
}
finally
{
- if( cursor != null )
+ if ( cursor != null )
{
cursor.close();
}
Modified: directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/kerberos/StoreUtils.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/kerberos/StoreUtils.java?rev=1650728&r1=1650727&r2=1650728&view=diff
==============================================================================
--- directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/kerberos/StoreUtils.java (original)
+++ directory/apacheds/trunk/protocol-shared/src/main/java/org/apache/directory/server/protocol/shared/kerberos/StoreUtils.java Sat Jan 10 09:28:14 2015
@@ -36,7 +36,6 @@ import org.apache.directory.api.ldap.mod
import org.apache.directory.api.ldap.model.schema.AttributeType;
import org.apache.directory.api.ldap.model.schema.SchemaManager;
import org.apache.directory.server.core.api.CoreSession;
-import org.apache.directory.server.core.api.filtering.EntryFilteringCursor;
import org.apache.directory.server.i18n.I18n;
import org.apache.directory.server.kerberos.shared.store.PrincipalStoreEntry;
import org.apache.directory.shared.kerberos.KerberosAttribute;
@@ -135,8 +134,10 @@ public class StoreUtils
try
{
SchemaManager schemaManager = session.getDirectoryService().getSchemaManager();
- cursor = session.search( searchBaseDn, SearchScope.SUBTREE,
- getFilter( schemaManager, principal ), AliasDerefMode.DEREF_ALWAYS, "*" );
+ cursor = session
+ .search( searchBaseDn, SearchScope.SUBTREE,
+ getFilter( schemaManager, principal ), AliasDerefMode.DEREF_ALWAYS,
+ SchemaConstants.ALL_USER_ATTRIBUTES );
cursor.beforeFirst();
Modified: directory/apacheds/trunk/server-annotations/src/main/java/org/apache/directory/server/annotations/CreateConsumer.java
URL: http://svn.apache.org/viewvc/directory/apacheds/trunk/server-annotations/src/main/java/org/apache/directory/server/annotations/CreateConsumer.java?rev=1650728&r1=1650727&r2=1650728&view=diff
==============================================================================
--- directory/apacheds/trunk/server-annotations/src/main/java/org/apache/directory/server/annotations/CreateConsumer.java (original)
+++ directory/apacheds/trunk/server-annotations/src/main/java/org/apache/directory/server/annotations/CreateConsumer.java Sat Jan 10 09:28:14 2015
@@ -27,6 +27,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
+import org.apache.directory.api.ldap.model.constants.LdapConstants;
import org.apache.directory.api.ldap.model.message.AliasDerefMode;
import org.apache.directory.api.ldap.model.message.SearchScope;
import org.apache.directory.ldap.client.api.NoVerificationTrustManager;
@@ -94,7 +95,7 @@ public @interface CreateConsumer
/** the ldap filter for fetching the entries, default value is (objectClass=*) */
- String filter() default "(objectClass=*)";
+ String filter() default LdapConstants.OBJECT_CLASS_STAR;
/** names of attributes to be replicated, default value is all user attributes */