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 2006/12/03 12:40:21 UTC
svn commit: r481754 - in /directory/trunks:
apacheds/core/src/main/java/org/apache/directory/server/core/authn/
apacheds/core/src/main/java/org/apache/directory/server/core/authz/
apacheds/core/src/main/java/org/apache/directory/server/core/interceptor...
Author: elecharny
Date: Sun Dec 3 03:40:18 2006
New Revision: 481754
URL: http://svn.apache.org/viewvc?view=rev&rev=481754
Log:
Removed a few tens of warning by replacing a class by an enum (MicroOperation)
and by using Generics
Modified:
directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java
directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java
directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/authz/AuthorizationService.java
directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/interceptor/BaseInterceptor.java
directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/interceptor/Interceptor.java
directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java
directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/interceptor/NextInterceptor.java
directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/aci/MicroOperation.java
Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java?view=diff&rev=481754&r1=481753&r2=481754
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java (original)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/authn/AuthenticationService.java Sun Dec 3 03:40:18 2006
@@ -66,7 +66,7 @@
private static final boolean IS_DEBUG = log.isDebugEnabled();
/** authenticators **/
- public Map authenticators = new HashMap();
+ public Map<String, Collection<Authenticator>> authenticators = new HashMap<String, Collection<Authenticator>>();
private DirectoryServiceConfiguration factoryCfg;
@@ -107,13 +107,11 @@
*/
public void destroy()
{
- Iterator i = new ArrayList( authenticators.values() ).iterator();
- while ( i.hasNext() )
+ for ( Collection<Authenticator> collection:authenticators.values() )
{
- Iterator j = new ArrayList( ( Collection ) i.next() ).iterator();
- while ( j.hasNext() )
+ for ( Authenticator authenticator:collection )
{
- unregister( ( Authenticator ) j.next() );
+ unregister( authenticator );
}
}
@@ -129,10 +127,10 @@
{
cfg.getAuthenticator().init( factoryCfg, cfg );
- Collection authenticatorList = getAuthenticators( cfg.getAuthenticator().getAuthenticatorType() );
+ Collection<Authenticator> authenticatorList = getAuthenticators( cfg.getAuthenticator().getAuthenticatorType() );
if ( authenticatorList == null )
{
- authenticatorList = new ArrayList();
+ authenticatorList = new ArrayList<Authenticator>();
authenticators.put( cfg.getAuthenticator().getAuthenticatorType(), authenticatorList );
}
@@ -171,10 +169,11 @@
*
* @return <tt>null</tt> if no authenticator is found.
*/
- private Collection getAuthenticators( String type )
+ private Collection<Authenticator> getAuthenticators( String type )
{
- Collection result = ( Collection ) authenticators.get( type );
- if ( result != null && result.size() > 0 )
+ Collection<Authenticator> result = authenticators.get( type );
+
+ if ( ( result != null ) && ( result.size() > 0 ) )
{
return result;
}
@@ -321,16 +320,13 @@
private void invalidateAuthenticatorCaches( LdapDN principalDn )
{
- for ( Iterator jj = this.authenticators.keySet().iterator(); jj.hasNext(); /**/ )
+ for ( String authMech:authenticators.keySet() )
{
- String authMech = ( String ) jj.next();
-
- Collection authenticators = getAuthenticators( authMech );
+ Collection<Authenticator> authenticators = getAuthenticators( authMech );
// try each authenticator
- for ( Iterator ii = authenticators.iterator(); ii.hasNext(); /**/ )
+ for ( Authenticator authenticator:authenticators )
{
- Authenticator authenticator = ( Authenticator ) ii.next();
authenticator.invalidateCache( getPrincipal().getJndiName() );
}
}
@@ -435,7 +431,7 @@
}
- public void bind( NextInterceptor next, LdapDN bindDn, byte[] credentials, List mechanisms, String saslAuthId )
+ public void bind( NextInterceptor next, LdapDN bindDn, byte[] credentials, List<String> mechanisms, String saslAuthId )
throws NamingException
{
@@ -457,10 +453,11 @@
}
// pick the first matching authenticator type
- Collection authenticators = null;
- for ( int ii = 0; ii < mechanisms.size(); ii++ )
+ Collection<Authenticator> authenticators = null;
+
+ for ( String mechanism:mechanisms )
{
- authenticators = getAuthenticators( ( String ) mechanisms.get( ii ) );
+ authenticators = getAuthenticators( mechanism );
if ( authenticators != null )
{
@@ -484,9 +481,8 @@
// TODO : we should refactor that.
// try each authenticators
- for ( Iterator i = authenticators.iterator(); i.hasNext(); )
+ for ( Authenticator authenticator:authenticators )
{
- Authenticator authenticator = ( Authenticator ) i.next();
try
{
// perform the authentication
Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java?view=diff&rev=481754&r1=481753&r2=481754
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java (original)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/authn/SimpleAuthenticator.java Sun Dec 3 03:40:18 2006
@@ -62,11 +62,11 @@
private static final Logger log = LoggerFactory.getLogger( SimpleAuthenticator.class );
private static final Collection USERLOOKUP_BYPASS;
- private WeakHashMap credentialCache = new WeakHashMap( 1000 );
+ private WeakHashMap<String, byte[]> credentialCache = new WeakHashMap<String, byte[]>( 1000 );
static
{
- Set c = new HashSet();
+ Set<String> c = new HashSet<String>();
c.add( "normalizationService" );
c.add( "collectiveAttributeService" );
c.add( "authenticationService" );
Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/authz/AuthorizationService.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/authz/AuthorizationService.java?view=diff&rev=481754&r1=481753&r2=481754
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/authz/AuthorizationService.java (original)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/authz/AuthorizationService.java Sun Dec 3 03:40:18 2006
@@ -96,22 +96,22 @@
static
{
- HashSet set = new HashSet( 2 );
+ Set<MicroOperation> set = new HashSet<MicroOperation>( 2 );
set.add( MicroOperation.BROWSE );
set.add( MicroOperation.RETURN_DN );
SEARCH_ENTRY_PERMS = Collections.unmodifiableCollection( set );
- set = new HashSet( 2 );
+ set = new HashSet<MicroOperation>( 2 );
set.add( MicroOperation.READ );
set.add( MicroOperation.BROWSE );
LOOKUP_PERMS = Collections.unmodifiableCollection( set );
- set = new HashSet( 2 );
+ set = new HashSet<MicroOperation>( 2 );
set.add( MicroOperation.ADD );
set.add( MicroOperation.REMOVE );
REPLACE_PERMS = Collections.unmodifiableCollection( set );
- set = new HashSet( 2 );
+ set = new HashSet<MicroOperation>( 2 );
set.add( MicroOperation.EXPORT );
set.add( MicroOperation.RENAME );
MOVERENAME_PERMS = Collections.unmodifiableCollection( set );
Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/interceptor/BaseInterceptor.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/interceptor/BaseInterceptor.java?view=diff&rev=481754&r1=481753&r2=481754
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/interceptor/BaseInterceptor.java (original)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/interceptor/BaseInterceptor.java Sun Dec 3 03:40:18 2006
@@ -221,7 +221,7 @@
}
- public void bind( NextInterceptor next, LdapDN bindDn, byte[] credentials, List mechanisms, String saslAuthId )
+ public void bind( NextInterceptor next, LdapDN bindDn, byte[] credentials, List<String> mechanisms, String saslAuthId )
throws NamingException
{
next.bind( bindDn, credentials, mechanisms, saslAuthId );
Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/interceptor/Interceptor.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/interceptor/Interceptor.java?view=diff&rev=481754&r1=481753&r2=481754
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/interceptor/Interceptor.java (original)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/interceptor/Interceptor.java Sun Dec 3 03:40:18 2006
@@ -243,7 +243,7 @@
/**
* Filters {@link Partition#bind(org.apache.directory.shared.ldap.name.LdapDN,byte[],java.util.List,String)} call.
*/
- void bind( NextInterceptor next, LdapDN bindDn, byte[] credentials, List mechanisms, String saslAuthId )
+ void bind( NextInterceptor next, LdapDN bindDn, byte[] credentials, List<String> mechanisms, String saslAuthId )
throws NamingException;
Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java?view=diff&rev=481754&r1=481753&r2=481754
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java (original)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/interceptor/InterceptorChain.java Sun Dec 3 03:40:18 2006
@@ -210,7 +210,7 @@
}
};
- private final Map name2entry = new HashMap();
+ private final Map<String, Entry> name2entry = new HashMap<String, Entry>();
private final Entry tail;
@@ -282,8 +282,9 @@
*/
public synchronized void destroy()
{
- List entries = new ArrayList();
+ List<Entry> entries = new ArrayList<Entry>();
Entry e = tail;
+
do
{
entries.add( e );
@@ -291,19 +292,17 @@
}
while ( e != null );
- Iterator i = entries.iterator();
- while ( i.hasNext() )
+ for ( Entry entry:entries )
{
- e = ( Entry ) i.next();
- if ( e != tail )
+ if ( entry != tail )
{
try
{
- deregister( e.configuration.getName() );
+ deregister( entry.configuration.getName() );
}
catch ( Throwable t )
{
- log.warn( "Failed to deregister an interceptor: " + e.configuration.getName(), t );
+ log.warn( "Failed to deregister an interceptor: " + entry.configuration.getName(), t );
}
}
}
@@ -316,7 +315,7 @@
*/
public Interceptor get( String interceptorName )
{
- Entry e = ( Entry ) name2entry.get( interceptorName );
+ Entry e = name2entry.get( interceptorName );
if ( e == null )
{
return null;
@@ -331,8 +330,9 @@
*/
public synchronized List getAll()
{
- List result = new ArrayList();
+ List<Interceptor> result = new ArrayList<Interceptor>();
Entry e = head;
+
do
{
result.add( e.configuration.getInterceptor() );
@@ -359,7 +359,7 @@
public synchronized void addBefore( String nextInterceptorName, InterceptorConfiguration cfg )
throws NamingException
{
- Entry e = ( Entry ) name2entry.get( nextInterceptorName );
+ Entry e = name2entry.get( nextInterceptorName );
if ( e == null )
{
throw new ConfigurationException( "Interceptor not found: " + nextInterceptorName );
@@ -377,7 +377,7 @@
public synchronized void addAfter( String prevInterceptorName, InterceptorConfiguration cfg )
throws NamingException
{
- Entry e = ( Entry ) name2entry.get( prevInterceptorName );
+ Entry e = name2entry.get( prevInterceptorName );
if ( e == null )
{
throw new ConfigurationException( "Interceptor not found: " + prevInterceptorName );
@@ -466,7 +466,7 @@
*/
private Entry checkOldName( String baseName ) throws ConfigurationException
{
- Entry e = ( Entry ) name2entry.get( baseName );
+ Entry e = name2entry.get( baseName );
if ( e == null )
{
@@ -716,7 +716,7 @@
}
- public void bind( LdapDN bindDn, byte[] credentials, List mechanisms, String saslAuthId ) throws NamingException
+ public void bind( LdapDN bindDn, byte[] credentials, List<String> mechanisms, String saslAuthId ) throws NamingException
{
Entry node = getStartingEntry();
Interceptor head = node.configuration.getInterceptor();
@@ -1419,7 +1419,7 @@
}
- public void bind( LdapDN bindDn, byte[] credentials, List mechanisms, String saslAuthId )
+ public void bind( LdapDN bindDn, byte[] credentials, List<String> mechanisms, String saslAuthId )
throws NamingException
{
Entry next = getNextEntry();
Modified: directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/interceptor/NextInterceptor.java
URL: http://svn.apache.org/viewvc/directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/interceptor/NextInterceptor.java?view=diff&rev=481754&r1=481753&r2=481754
==============================================================================
--- directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/interceptor/NextInterceptor.java (original)
+++ directory/trunks/apacheds/core/src/main/java/org/apache/directory/server/core/interceptor/NextInterceptor.java Sun Dec 3 03:40:18 2006
@@ -170,7 +170,7 @@
/**
* Calls the next interceptor's {@link Interceptor#bind(NextInterceptor,org.apache.directory.shared.ldap.name.LdapDN,byte[],java.util.List,String)
*/
- void bind( LdapDN bindDn, byte[] credentials, List mechanisms, String saslAuthId ) throws NamingException;
+ void bind( LdapDN bindDn, byte[] credentials, List<String> mechanisms, String saslAuthId ) throws NamingException;
/**
Modified: directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/aci/MicroOperation.java
URL: http://svn.apache.org/viewvc/directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/aci/MicroOperation.java?view=diff&rev=481754&r1=481753&r2=481754
==============================================================================
--- directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/aci/MicroOperation.java (original)
+++ directory/trunks/shared/ldap/src/main/java/org/apache/directory/shared/ldap/aci/MicroOperation.java Sun Dec 3 03:40:18 2006
@@ -27,39 +27,39 @@
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
-public class MicroOperation
+public enum MicroOperation
{
// Permissions that may be used in conjunction with any component of
// <tt>ProtectedItem</tt>s.
- public static final MicroOperation ADD = new MicroOperation( "Add" );
+ ADD( "Add" ),
- public static final MicroOperation DISCLOSE_ON_ERROR = new MicroOperation( "DiscloseOnError" );
+ DISCLOSE_ON_ERROR( "DiscloseOnError" ),
- public static final MicroOperation READ = new MicroOperation( "Read" );
+ READ( "Read" ),
- public static final MicroOperation REMOVE = new MicroOperation( "Remove" );
+ REMOVE( "Remove" ),
// Permissions that may be used only in conjunction with the entry
// component.
- public static final MicroOperation BROWSE = new MicroOperation( "Browse" );
+ BROWSE( "Browse" ),
- public static final MicroOperation EXPORT = new MicroOperation( "Export" );
+ EXPORT( "Export" ),
- public static final MicroOperation IMPORT = new MicroOperation( "Import" );
+ IMPORT( "Import" ),
- public static final MicroOperation MODIFY = new MicroOperation( "Modify" );
+ MODIFY( "Modify" ),
- public static final MicroOperation RENAME = new MicroOperation( "Rename" );
+ RENAME ( "Rename" ),
- public static final MicroOperation RETURN_DN = new MicroOperation( "ReturnDN" );
+ RETURN_DN( "ReturnDN" ),
// Permissions that may be used in conjunction with any component,
// except entry, of <tt>ProtectedItem</tt>s.
- public static final MicroOperation COMPARE = new MicroOperation( "Compare" );
+ COMPARE( "Compare" ),
- public static final MicroOperation FILTER_MATCH = new MicroOperation( "FilterMatch" );
+ FILTER_MATCH( "FilterMatch" ),
- public static final MicroOperation INVOKE = new MicroOperation( "Invoke" );
+ INVOKE( "Invoke" );
private final String name;