rename to default to have an interface
git-svn-id: https://svn.apache.org/repos/asf/archiva/redback/redback-core/trunk@1477968 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
29ab886c64
commit
4ecba94f20
|
@ -20,6 +20,7 @@ package org.apache.archiva.redback.authentication.ldap;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.archiva.redback.authentication.AbstractAuthenticator;
|
import org.apache.archiva.redback.authentication.AbstractAuthenticator;
|
||||||
|
import org.apache.archiva.redback.common.ldap.connection.DefaultLdapConnection;
|
||||||
import org.apache.archiva.redback.common.ldap.user.UserMapper;
|
import org.apache.archiva.redback.common.ldap.user.UserMapper;
|
||||||
import org.apache.archiva.redback.common.ldap.connection.LdapConnectionFactory;
|
import org.apache.archiva.redback.common.ldap.connection.LdapConnectionFactory;
|
||||||
import org.apache.archiva.redback.configuration.UserConfiguration;
|
import org.apache.archiva.redback.configuration.UserConfiguration;
|
||||||
|
@ -30,7 +31,6 @@ import org.apache.archiva.redback.authentication.AuthenticationException;
|
||||||
import org.apache.archiva.redback.authentication.AuthenticationResult;
|
import org.apache.archiva.redback.authentication.AuthenticationResult;
|
||||||
import org.apache.archiva.redback.authentication.Authenticator;
|
import org.apache.archiva.redback.authentication.Authenticator;
|
||||||
import org.apache.archiva.redback.authentication.PasswordBasedAuthenticationDataSource;
|
import org.apache.archiva.redback.authentication.PasswordBasedAuthenticationDataSource;
|
||||||
import org.apache.archiva.redback.common.ldap.connection.LdapConnection;
|
|
||||||
import org.apache.archiva.redback.common.ldap.connection.LdapException;
|
import org.apache.archiva.redback.common.ldap.connection.LdapException;
|
||||||
import org.apache.archiva.redback.users.ldap.service.LdapCacheService;
|
import org.apache.archiva.redback.users.ldap.service.LdapCacheService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -103,8 +103,8 @@ public class LdapBindAuthenticator
|
||||||
|
|
||||||
log.debug( "Searching for users with filter: '{}' from base dn: {}", filter, mapper.getUserBaseDn() );
|
log.debug( "Searching for users with filter: '{}' from base dn: {}", filter, mapper.getUserBaseDn() );
|
||||||
|
|
||||||
LdapConnection ldapConnection = null;
|
DefaultLdapConnection ldapConnection = null;
|
||||||
LdapConnection authLdapConnection = null;
|
DefaultLdapConnection authLdapConnection = null;
|
||||||
NamingEnumeration<SearchResult> results = null;
|
NamingEnumeration<SearchResult> results = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -172,13 +172,13 @@ public class LdapBindAuthenticator
|
||||||
return ( source instanceof PasswordBasedAuthenticationDataSource );
|
return ( source instanceof PasswordBasedAuthenticationDataSource );
|
||||||
}
|
}
|
||||||
|
|
||||||
private LdapConnection getLdapConnection()
|
private DefaultLdapConnection getLdapConnection()
|
||||||
throws LdapException
|
throws LdapException
|
||||||
{
|
{
|
||||||
return connectionFactory.getConnection();
|
return connectionFactory.getConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void closeLdapConnection( LdapConnection ldapConnection )
|
private void closeLdapConnection( DefaultLdapConnection ldapConnection )
|
||||||
{
|
{
|
||||||
if ( ldapConnection != null )
|
if ( ldapConnection != null )
|
||||||
{
|
{
|
||||||
|
|
|
@ -101,28 +101,28 @@ public class ConfigurableLdapConnectionFactory
|
||||||
// LdapConnectionFactory Implementation
|
// LdapConnectionFactory Implementation
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
public LdapConnection getConnection()
|
public DefaultLdapConnection getConnection()
|
||||||
throws LdapException
|
throws LdapException
|
||||||
{
|
{
|
||||||
return new LdapConnection( getLdapConnectionConfiguration(), null );
|
return new DefaultLdapConnection( getLdapConnectionConfiguration(), null );
|
||||||
}
|
}
|
||||||
|
|
||||||
public LdapConnection getConnection( Rdn subRdn )
|
public DefaultLdapConnection getConnection( Rdn subRdn )
|
||||||
throws LdapException
|
throws LdapException
|
||||||
{
|
{
|
||||||
return new LdapConnection( getLdapConnectionConfiguration(), subRdn );
|
return new DefaultLdapConnection( getLdapConnectionConfiguration(), subRdn );
|
||||||
}
|
}
|
||||||
|
|
||||||
public LdapConnection getConnection( String bindDn, String password )
|
public DefaultLdapConnection getConnection( String bindDn, String password )
|
||||||
throws LdapException
|
throws LdapException
|
||||||
{
|
{
|
||||||
return new LdapConnection( getLdapConnectionConfiguration(), bindDn, password );
|
return new DefaultLdapConnection( getLdapConnectionConfiguration(), bindDn, password );
|
||||||
}
|
}
|
||||||
|
|
||||||
public LdapConnection getConnection( LdapConnectionConfiguration ldapConnectionConfiguration )
|
public DefaultLdapConnection getConnection( LdapConnectionConfiguration ldapConnectionConfiguration )
|
||||||
throws LdapException
|
throws LdapException
|
||||||
{
|
{
|
||||||
return new LdapConnection( ldapConnectionConfiguration, null );
|
return new DefaultLdapConnection( ldapConnectionConfiguration, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
public LdapName getBaseDnLdapName()
|
public LdapName getBaseDnLdapName()
|
||||||
|
|
|
@ -1,276 +0,0 @@
|
||||||
package org.apache.archiva.redback.common.ldap.connection;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import com.sun.jndi.ldap.LdapCtxFactory;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import javax.naming.Context;
|
|
||||||
import javax.naming.NamingException;
|
|
||||||
import javax.naming.directory.DirContext;
|
|
||||||
import javax.naming.directory.InitialDirContext;
|
|
||||||
import javax.naming.ldap.LdapName;
|
|
||||||
import javax.naming.ldap.Rdn;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Hashtable;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The configuration for a connection will not change.
|
|
||||||
*
|
|
||||||
* @author <a href="mailto:trygvis@inamo.no">trygvis</a>
|
|
||||||
*/
|
|
||||||
public class LdapConnection
|
|
||||||
{
|
|
||||||
|
|
||||||
private static LdapCtxFactory ctxFactory;// = new LdapCtxFactory();
|
|
||||||
|
|
||||||
|
|
||||||
static
|
|
||||||
{
|
|
||||||
initCtxFactory();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private Logger log = LoggerFactory.getLogger( getClass() );
|
|
||||||
|
|
||||||
private LdapConnectionConfiguration config;
|
|
||||||
|
|
||||||
private DirContext context;
|
|
||||||
|
|
||||||
private List<Rdn> baseDnRdns;
|
|
||||||
|
|
||||||
private static void initCtxFactory()
|
|
||||||
{
|
|
||||||
ctxFactory = new LdapCtxFactory();
|
|
||||||
}
|
|
||||||
|
|
||||||
public LdapConnection( LdapConnectionConfiguration config, Rdn subRdn )
|
|
||||||
throws LdapException
|
|
||||||
{
|
|
||||||
this.config = config;
|
|
||||||
|
|
||||||
LdapName baseDn = new LdapName( config.getBaseDn().getRdns() );
|
|
||||||
|
|
||||||
if ( subRdn != null )
|
|
||||||
{
|
|
||||||
baseDn.add( subRdn );
|
|
||||||
}
|
|
||||||
|
|
||||||
log.debug( "baseDn: {}", baseDn );
|
|
||||||
|
|
||||||
baseDnRdns = Collections.unmodifiableList( baseDn.getRdns() );
|
|
||||||
|
|
||||||
if ( context != null )
|
|
||||||
{
|
|
||||||
throw new LdapException( "Already connected." );
|
|
||||||
}
|
|
||||||
|
|
||||||
log.debug( "baseDnRdns: {}", baseDnRdns );
|
|
||||||
|
|
||||||
Hashtable<Object, Object> e = getEnvironment();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
context = (DirContext) ctxFactory.getInitialContext( e );
|
|
||||||
}
|
|
||||||
catch ( NamingException ex )
|
|
||||||
{
|
|
||||||
throw new LdapException( "Could not connect to the server.", ex );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This ldap connection will attempt to establish a connection using the configuration,
|
|
||||||
* replacing the principal and the password
|
|
||||||
*
|
|
||||||
* @param config
|
|
||||||
* @param bindDn
|
|
||||||
* @param password
|
|
||||||
* @throws LdapException
|
|
||||||
*/
|
|
||||||
public LdapConnection( LdapConnectionConfiguration config, String bindDn, String password )
|
|
||||||
throws LdapException
|
|
||||||
{
|
|
||||||
this.config = config;
|
|
||||||
|
|
||||||
Hashtable<Object, Object> e = getEnvironment();
|
|
||||||
|
|
||||||
e.put( Context.SECURITY_PRINCIPAL, bindDn );
|
|
||||||
e.put( Context.SECURITY_CREDENTIALS, password );
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
context = (DirContext) ctxFactory.getInitialContext( e );
|
|
||||||
}
|
|
||||||
catch ( NamingException ex )
|
|
||||||
{
|
|
||||||
throw new LdapException( "Could not connect to the server.", ex );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Connection Managment
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
public Hashtable<Object, Object> getEnvironment()
|
|
||||||
throws LdapException
|
|
||||||
{
|
|
||||||
Properties env = new Properties();
|
|
||||||
|
|
||||||
env.putAll( config.getExtraProperties() );
|
|
||||||
|
|
||||||
config.check();
|
|
||||||
|
|
||||||
env.put( Context.INITIAL_CONTEXT_FACTORY, config.getContextFactory() );
|
|
||||||
|
|
||||||
// REDBACK-289/MRM-1488
|
|
||||||
// enable connection pooling when using Sun's LDAP context factory
|
|
||||||
if ( config.getContextFactory().equals( "com.sun.jndi.ldap.LdapCtxFactory" ) )
|
|
||||||
{
|
|
||||||
env.put( "com.sun.jndi.ldap.connect.pool", "true" );
|
|
||||||
|
|
||||||
env.put( "com.sun.jndi.ldap.connect.pool.timeout", "3600" );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( config.getHostname() != null )
|
|
||||||
{
|
|
||||||
String protocol = "ldap";// config.isSsl() ? "ldaps" : "ldap";
|
|
||||||
if ( config.getPort() != 0 )
|
|
||||||
{
|
|
||||||
env.put( Context.PROVIDER_URL, protocol + "://" + config.getHostname() + ":" + config.getPort() + "/" );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
env.put( Context.PROVIDER_URL, protocol + "://" + config.getHostname() + "/" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( config.isSsl() )
|
|
||||||
{
|
|
||||||
env.put( Context.SECURITY_PROTOCOL, "ssl" );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( config.getAuthenticationMethod() != null )
|
|
||||||
{
|
|
||||||
env.put( Context.SECURITY_AUTHENTICATION, config.getAuthenticationMethod() );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( config.getBindDn() != null )
|
|
||||||
{
|
|
||||||
env.put( Context.SECURITY_PRINCIPAL, config.getBindDn().toString() );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( config.getPassword() != null )
|
|
||||||
{
|
|
||||||
env.put( Context.SECURITY_CREDENTIALS, config.getPassword() );
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Object Factories
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
String objectFactories = null;
|
|
||||||
|
|
||||||
for ( Class<?> objectFactoryClass : config.getObjectFactories() )
|
|
||||||
{
|
|
||||||
if ( objectFactories == null )
|
|
||||||
{
|
|
||||||
objectFactories = objectFactoryClass.getName();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
objectFactories += ":" + objectFactoryClass.getName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( objectFactories != null )
|
|
||||||
{
|
|
||||||
env.setProperty( Context.OBJECT_FACTORIES, objectFactories );
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// State Factories
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
String stateFactories = null;
|
|
||||||
|
|
||||||
for ( Class<?> stateFactoryClass : config.getStateFactories() )
|
|
||||||
{
|
|
||||||
if ( stateFactories == null )
|
|
||||||
{
|
|
||||||
stateFactories = stateFactoryClass.getName();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
stateFactories += ":" + stateFactoryClass.getName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( stateFactories != null )
|
|
||||||
{
|
|
||||||
env.setProperty( Context.STATE_FACTORIES, stateFactories );
|
|
||||||
}
|
|
||||||
|
|
||||||
log.debug( "env properties: {}", env );
|
|
||||||
|
|
||||||
return env;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void close()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if ( context != null )
|
|
||||||
{
|
|
||||||
context.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch ( NamingException ex )
|
|
||||||
{
|
|
||||||
log.info( "skip error closing ldap connection {}", ex.getMessage() );
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
context = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
// Utils
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
public LdapConnectionConfiguration getConfiguration()
|
|
||||||
{
|
|
||||||
return config;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Rdn> getBaseDnRdns()
|
|
||||||
{
|
|
||||||
return baseDnRdns;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DirContext getDirContext()
|
|
||||||
{
|
|
||||||
return context;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -30,16 +30,16 @@ import javax.naming.spi.StateFactory;
|
||||||
*/
|
*/
|
||||||
public interface LdapConnectionFactory
|
public interface LdapConnectionFactory
|
||||||
{
|
{
|
||||||
LdapConnection getConnection()
|
DefaultLdapConnection getConnection()
|
||||||
throws LdapException;
|
throws LdapException;
|
||||||
|
|
||||||
LdapConnection getConnection( LdapConnectionConfiguration ldapConnectionConfiguration )
|
DefaultLdapConnection getConnection( LdapConnectionConfiguration ldapConnectionConfiguration )
|
||||||
throws LdapException;
|
throws LdapException;
|
||||||
|
|
||||||
LdapConnection getConnection( Rdn subRdn )
|
DefaultLdapConnection getConnection( Rdn subRdn )
|
||||||
throws LdapException;
|
throws LdapException;
|
||||||
|
|
||||||
LdapConnection getConnection( String bindDn, String password )
|
DefaultLdapConnection getConnection( String bindDn, String password )
|
||||||
throws LdapException;
|
throws LdapException;
|
||||||
|
|
||||||
LdapName getBaseDnLdapName()
|
LdapName getBaseDnLdapName()
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.archiva.redback.common.ldap.role;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import org.apache.archiva.redback.common.ldap.connection.LdapConnection;
|
import org.apache.archiva.redback.common.ldap.connection.DefaultLdapConnection;
|
||||||
import org.apache.archiva.redback.common.ldap.connection.LdapConnectionFactory;
|
import org.apache.archiva.redback.common.ldap.connection.LdapConnectionFactory;
|
||||||
import org.apache.archiva.redback.components.apacheds.ApacheDs;
|
import org.apache.archiva.redback.components.apacheds.ApacheDs;
|
||||||
import org.apache.archiva.redback.policy.PasswordEncoder;
|
import org.apache.archiva.redback.policy.PasswordEncoder;
|
||||||
|
@ -89,7 +89,7 @@ public class TestLdapRoleMapper
|
||||||
List<String> roleNames =
|
List<String> roleNames =
|
||||||
Arrays.asList( "Archiva System Administrator", "Internal Repo Manager", "Internal Repo Observer" );
|
Arrays.asList( "Archiva System Administrator", "Internal Repo Manager", "Internal Repo Observer" );
|
||||||
|
|
||||||
LdapConnection ldapConnection;
|
DefaultLdapConnection ldapConnection;
|
||||||
|
|
||||||
DirContext context;
|
DirContext context;
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ package org.apache.archiva.redback.rest.services;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.archiva.redback.common.ldap.MappingException;
|
import org.apache.archiva.redback.common.ldap.MappingException;
|
||||||
import org.apache.archiva.redback.common.ldap.connection.LdapConnection;
|
import org.apache.archiva.redback.common.ldap.connection.DefaultLdapConnection;
|
||||||
import org.apache.archiva.redback.common.ldap.connection.LdapConnectionFactory;
|
import org.apache.archiva.redback.common.ldap.connection.LdapConnectionFactory;
|
||||||
import org.apache.archiva.redback.common.ldap.connection.LdapException;
|
import org.apache.archiva.redback.common.ldap.connection.LdapException;
|
||||||
import org.apache.archiva.redback.common.ldap.role.LdapRoleMapper;
|
import org.apache.archiva.redback.common.ldap.role.LdapRoleMapper;
|
||||||
|
@ -67,7 +67,7 @@ public class DefaultLdapGroupMappingService
|
||||||
public StringList getLdapGroups()
|
public StringList getLdapGroups()
|
||||||
throws RedbackServiceException
|
throws RedbackServiceException
|
||||||
{
|
{
|
||||||
LdapConnection ldapConnection = null;
|
DefaultLdapConnection ldapConnection = null;
|
||||||
|
|
||||||
DirContext context = null;
|
DirContext context = null;
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ public class DefaultLdapGroupMappingService
|
||||||
// utils
|
// utils
|
||||||
//------------------
|
//------------------
|
||||||
|
|
||||||
protected void closeLdapConnection( LdapConnection ldapConnection )
|
protected void closeLdapConnection( DefaultLdapConnection ldapConnection )
|
||||||
{
|
{
|
||||||
if ( ldapConnection != null )
|
if ( ldapConnection != null )
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,10 +19,8 @@ package org.apache.archiva.redback.rbac.ldap;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import org.apache.archiva.redback.common.ldap.MappingException;
|
import org.apache.archiva.redback.common.ldap.MappingException;
|
||||||
import org.apache.archiva.redback.common.ldap.connection.LdapConnection;
|
import org.apache.archiva.redback.common.ldap.connection.DefaultLdapConnection;
|
||||||
import org.apache.archiva.redback.common.ldap.connection.LdapConnectionFactory;
|
import org.apache.archiva.redback.common.ldap.connection.LdapConnectionFactory;
|
||||||
import org.apache.archiva.redback.common.ldap.connection.LdapException;
|
import org.apache.archiva.redback.common.ldap.connection.LdapException;
|
||||||
import org.apache.archiva.redback.common.ldap.role.LdapRoleMapper;
|
import org.apache.archiva.redback.common.ldap.role.LdapRoleMapper;
|
||||||
|
@ -176,7 +174,7 @@ public class LdapRbacManager
|
||||||
{
|
{
|
||||||
if ( writableLdap )
|
if ( writableLdap )
|
||||||
{
|
{
|
||||||
LdapConnection ldapConnection = null;
|
DefaultLdapConnection ldapConnection = null;
|
||||||
DirContext context = null;
|
DirContext context = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -252,7 +250,7 @@ public class LdapRbacManager
|
||||||
public List<Role> getAllRoles()
|
public List<Role> getAllRoles()
|
||||||
throws RbacManagerException
|
throws RbacManagerException
|
||||||
{
|
{
|
||||||
LdapConnection ldapConnection = null;
|
DefaultLdapConnection ldapConnection = null;
|
||||||
DirContext context = null;
|
DirContext context = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -282,7 +280,7 @@ public class LdapRbacManager
|
||||||
public List<UserAssignment> getAllUserAssignments()
|
public List<UserAssignment> getAllUserAssignments()
|
||||||
throws RbacManagerException
|
throws RbacManagerException
|
||||||
{
|
{
|
||||||
LdapConnection ldapConnection = null;
|
DefaultLdapConnection ldapConnection = null;
|
||||||
DirContext context = null;
|
DirContext context = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -315,7 +313,7 @@ public class LdapRbacManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void closeLdapConnection( LdapConnection ldapConnection )
|
protected void closeLdapConnection( DefaultLdapConnection ldapConnection )
|
||||||
{
|
{
|
||||||
if ( ldapConnection != null )
|
if ( ldapConnection != null )
|
||||||
{
|
{
|
||||||
|
@ -422,7 +420,7 @@ public class LdapRbacManager
|
||||||
throws RbacManagerException
|
throws RbacManagerException
|
||||||
{
|
{
|
||||||
|
|
||||||
LdapConnection ldapConnection = null;
|
DefaultLdapConnection ldapConnection = null;
|
||||||
DirContext context = null;
|
DirContext context = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -530,7 +528,7 @@ public class LdapRbacManager
|
||||||
{
|
{
|
||||||
return role;
|
return role;
|
||||||
}
|
}
|
||||||
LdapConnection ldapConnection = null;
|
DefaultLdapConnection ldapConnection = null;
|
||||||
DirContext context = null;
|
DirContext context = null;
|
||||||
//verify it's a ldap group
|
//verify it's a ldap group
|
||||||
try
|
try
|
||||||
|
@ -567,7 +565,7 @@ public class LdapRbacManager
|
||||||
public Collection<Role> getUnassignedRoles( String username )
|
public Collection<Role> getUnassignedRoles( String username )
|
||||||
throws RbacManagerException
|
throws RbacManagerException
|
||||||
{
|
{
|
||||||
LdapConnection ldapConnection = null;
|
DefaultLdapConnection ldapConnection = null;
|
||||||
|
|
||||||
DirContext context = null;
|
DirContext context = null;
|
||||||
|
|
||||||
|
@ -615,7 +613,7 @@ public class LdapRbacManager
|
||||||
{
|
{
|
||||||
return ua;
|
return ua;
|
||||||
}
|
}
|
||||||
LdapConnection ldapConnection = null;
|
DefaultLdapConnection ldapConnection = null;
|
||||||
DirContext context = null;
|
DirContext context = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -788,7 +786,7 @@ public class LdapRbacManager
|
||||||
rolesCache.remove( role.getName() );
|
rolesCache.remove( role.getName() );
|
||||||
if ( writableLdap )
|
if ( writableLdap )
|
||||||
{
|
{
|
||||||
LdapConnection ldapConnection = null;
|
DefaultLdapConnection ldapConnection = null;
|
||||||
DirContext context = null;
|
DirContext context = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -870,7 +868,7 @@ public class LdapRbacManager
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
LdapConnection ldapConnection = null;
|
DefaultLdapConnection ldapConnection = null;
|
||||||
DirContext context = null;
|
DirContext context = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -920,7 +918,7 @@ public class LdapRbacManager
|
||||||
{
|
{
|
||||||
if ( writableLdap )
|
if ( writableLdap )
|
||||||
{
|
{
|
||||||
LdapConnection ldapConnection = null;
|
DefaultLdapConnection ldapConnection = null;
|
||||||
DirContext context = null;
|
DirContext context = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -958,7 +956,7 @@ public class LdapRbacManager
|
||||||
{
|
{
|
||||||
if ( writableLdap )
|
if ( writableLdap )
|
||||||
{
|
{
|
||||||
LdapConnection ldapConnection = null;
|
DefaultLdapConnection ldapConnection = null;
|
||||||
DirContext context = null;
|
DirContext context = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -987,7 +985,7 @@ public class LdapRbacManager
|
||||||
public UserAssignment saveUserAssignment( UserAssignment userAssignment )
|
public UserAssignment saveUserAssignment( UserAssignment userAssignment )
|
||||||
throws RbacManagerException
|
throws RbacManagerException
|
||||||
{
|
{
|
||||||
LdapConnection ldapConnection = null;
|
DefaultLdapConnection ldapConnection = null;
|
||||||
DirContext context = null;
|
DirContext context = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -1054,7 +1052,7 @@ public class LdapRbacManager
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
LdapConnection ldapConnection = null;
|
DefaultLdapConnection ldapConnection = null;
|
||||||
DirContext context = null;
|
DirContext context = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.archiva.redback.users.ldap;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
import org.apache.archiva.redback.common.ldap.role.LdapRoleMapper;
|
import org.apache.archiva.redback.common.ldap.connection.DefaultLdapConnection;
|
||||||
import org.apache.archiva.redback.common.ldap.user.LdapUser;
|
import org.apache.archiva.redback.common.ldap.user.LdapUser;
|
||||||
import org.apache.archiva.redback.common.ldap.user.UserMapper;
|
import org.apache.archiva.redback.common.ldap.user.UserMapper;
|
||||||
import org.apache.archiva.redback.configuration.UserConfiguration;
|
import org.apache.archiva.redback.configuration.UserConfiguration;
|
||||||
|
@ -31,7 +31,6 @@ import org.apache.archiva.redback.users.UserManager;
|
||||||
import org.apache.archiva.redback.users.UserManagerException;
|
import org.apache.archiva.redback.users.UserManagerException;
|
||||||
import org.apache.archiva.redback.users.UserNotFoundException;
|
import org.apache.archiva.redback.users.UserNotFoundException;
|
||||||
import org.apache.archiva.redback.common.ldap.MappingException;
|
import org.apache.archiva.redback.common.ldap.MappingException;
|
||||||
import org.apache.archiva.redback.common.ldap.connection.LdapConnection;
|
|
||||||
import org.apache.archiva.redback.common.ldap.connection.LdapConnectionFactory;
|
import org.apache.archiva.redback.common.ldap.connection.LdapConnectionFactory;
|
||||||
import org.apache.archiva.redback.common.ldap.connection.LdapException;
|
import org.apache.archiva.redback.common.ldap.connection.LdapException;
|
||||||
import org.apache.archiva.redback.users.UserQuery;
|
import org.apache.archiva.redback.users.UserQuery;
|
||||||
|
@ -130,7 +129,7 @@ public class LdapUserManager
|
||||||
return guestUser;
|
return guestUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
LdapConnection ldapConnection = getLdapConnection();
|
DefaultLdapConnection ldapConnection = getLdapConnection();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DirContext context = ldapConnection.getDirContext();
|
DirContext context = ldapConnection.getDirContext();
|
||||||
|
@ -169,7 +168,7 @@ public class LdapUserManager
|
||||||
{
|
{
|
||||||
clearFromCache( username );
|
clearFromCache( username );
|
||||||
}
|
}
|
||||||
LdapConnection ldapConnection = null;
|
DefaultLdapConnection ldapConnection = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ldapConnection = getLdapConnection();
|
ldapConnection = getLdapConnection();
|
||||||
|
@ -212,7 +211,7 @@ public class LdapUserManager
|
||||||
return ldapUser;
|
return ldapUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
LdapConnection ldapConnection = null;
|
DefaultLdapConnection ldapConnection = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -279,7 +278,7 @@ public class LdapUserManager
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
LdapConnection ldapConnection = null;
|
DefaultLdapConnection ldapConnection = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -330,7 +329,7 @@ public class LdapUserManager
|
||||||
*/
|
*/
|
||||||
public List<User> getUsers()
|
public List<User> getUsers()
|
||||||
{
|
{
|
||||||
LdapConnection ldapConnection = null;
|
DefaultLdapConnection ldapConnection = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -386,7 +385,7 @@ public class LdapUserManager
|
||||||
clearFromCache( user.getUsername() );
|
clearFromCache( user.getUsername() );
|
||||||
}
|
}
|
||||||
|
|
||||||
LdapConnection ldapConnection = null;
|
DefaultLdapConnection ldapConnection = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -430,7 +429,7 @@ public class LdapUserManager
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
LdapConnection ldapConnection = null;
|
DefaultLdapConnection ldapConnection = null;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -453,7 +452,7 @@ public class LdapUserManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private LdapConnection getLdapConnection()
|
private DefaultLdapConnection getLdapConnection()
|
||||||
throws LdapException
|
throws LdapException
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -467,7 +466,7 @@ public class LdapUserManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void closeLdapConnection( LdapConnection ldapConnection )
|
private void closeLdapConnection( DefaultLdapConnection ldapConnection )
|
||||||
{
|
{
|
||||||
if ( ldapConnection != null )
|
if ( ldapConnection != null )
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.archiva.redback.users.ldap.ctl;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -42,8 +41,6 @@ import javax.naming.directory.DirContext;
|
||||||
import javax.naming.directory.SearchControls;
|
import javax.naming.directory.SearchControls;
|
||||||
import javax.naming.directory.SearchResult;
|
import javax.naming.directory.SearchResult;
|
||||||
|
|
||||||
import org.apache.archiva.redback.common.ldap.connection.LdapConnection;
|
|
||||||
import org.apache.archiva.redback.common.ldap.connection.LdapException;
|
|
||||||
import org.apache.archiva.redback.common.ldap.user.LdapUser;
|
import org.apache.archiva.redback.common.ldap.user.LdapUser;
|
||||||
import org.apache.archiva.redback.common.ldap.user.LdapUserMapper;
|
import org.apache.archiva.redback.common.ldap.user.LdapUserMapper;
|
||||||
import org.apache.archiva.redback.common.ldap.user.UserMapper;
|
import org.apache.archiva.redback.common.ldap.user.UserMapper;
|
||||||
|
|
|
@ -22,7 +22,7 @@ package org.apache.archiva.redback.users.ldap;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import org.apache.archiva.redback.policy.PasswordEncoder;
|
import org.apache.archiva.redback.policy.PasswordEncoder;
|
||||||
import org.apache.archiva.redback.users.User;
|
import org.apache.archiva.redback.users.User;
|
||||||
import org.apache.archiva.redback.common.ldap.connection.LdapConnection;
|
import org.apache.archiva.redback.common.ldap.connection.DefaultLdapConnection;
|
||||||
import org.apache.archiva.redback.common.ldap.connection.LdapConnectionFactory;
|
import org.apache.archiva.redback.common.ldap.connection.LdapConnectionFactory;
|
||||||
import org.apache.archiva.redback.policy.encoders.SHA1PasswordEncoder;
|
import org.apache.archiva.redback.policy.encoders.SHA1PasswordEncoder;
|
||||||
import org.apache.archiva.redback.users.UserManager;
|
import org.apache.archiva.redback.users.UserManager;
|
||||||
|
@ -147,7 +147,7 @@ public class LdapUserManagerTest
|
||||||
{
|
{
|
||||||
assertNotNull( connectionFactory );
|
assertNotNull( connectionFactory );
|
||||||
|
|
||||||
LdapConnection connection = null;
|
DefaultLdapConnection connection = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
connection = connectionFactory.getConnection();
|
connection = connectionFactory.getConnection();
|
||||||
|
@ -168,7 +168,7 @@ public class LdapUserManagerTest
|
||||||
public void testDirectUsersExistence()
|
public void testDirectUsersExistence()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
LdapConnection connection = null;
|
DefaultLdapConnection connection = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
connection = connectionFactory.getConnection();
|
connection = connectionFactory.getConnection();
|
||||||
|
|
Loading…
Reference in New Issue