mirror of https://github.com/apache/archiva.git
[MRM-1721] Chaining user manager
not yet complete but commit stuff to prevent compilation failure due to redback changes. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1418718 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6eea39fdd0
commit
017cb9625b
|
@ -1460,11 +1460,13 @@
|
|||
<defaultValue>false</defaultValue>
|
||||
</field>
|
||||
<field>
|
||||
<name>userManagerImpl</name>
|
||||
<description>The user manager impl to use.</description>
|
||||
<name>userManagerImpls</name>
|
||||
<description>The user manager impls to use.</description>
|
||||
<version>1.4.0+</version>
|
||||
<type>String</type>
|
||||
<defaultValue>jdo</defaultValue>
|
||||
<association>
|
||||
<type>String</type>
|
||||
<multiplicity>*</multiplicity>
|
||||
</association>
|
||||
</field>
|
||||
<field>
|
||||
<name>ldapConfiguration</name>
|
||||
|
|
|
@ -29,11 +29,15 @@ import java.util.Map;
|
|||
* @author Olivier Lamy
|
||||
* @since 1.4-M4
|
||||
*/
|
||||
@XmlRootElement( name = "redbackRuntimeConfiguration" )
|
||||
@XmlRootElement(name = "redbackRuntimeConfiguration")
|
||||
public class ArchivaRuntimeConfiguration
|
||||
implements Serializable
|
||||
{
|
||||
private String userManagerImpl = "jdo";
|
||||
|
||||
/**
|
||||
* Field userManagerImpls.
|
||||
*/
|
||||
private List<String> userManagerImpls = new ArrayList<String>();
|
||||
|
||||
private LdapConfiguration ldapConfiguration;
|
||||
|
||||
|
@ -54,14 +58,14 @@ public class ArchivaRuntimeConfiguration
|
|||
// no op
|
||||
}
|
||||
|
||||
public String getUserManagerImpl()
|
||||
public List<String> getUserManagerImpls()
|
||||
{
|
||||
return userManagerImpl;
|
||||
return userManagerImpls;
|
||||
}
|
||||
|
||||
public void setUserManagerImpl( String userManagerImpl )
|
||||
public void setUserManagerImpls( List<String> userManagerImpls )
|
||||
{
|
||||
this.userManagerImpl = userManagerImpl;
|
||||
this.userManagerImpls = userManagerImpls;
|
||||
}
|
||||
|
||||
public LdapConfiguration getLdapConfiguration()
|
||||
|
@ -125,10 +129,11 @@ public class ArchivaRuntimeConfiguration
|
|||
public String toString()
|
||||
{
|
||||
return "ArchivaRuntimeConfiguration{" +
|
||||
"userManagerImpl='" + userManagerImpl + '\'' +
|
||||
"userManagerImpls=" + userManagerImpls +
|
||||
", ldapConfiguration=" + ldapConfiguration +
|
||||
", migratedFromRedbackConfiguration=" + migratedFromRedbackConfiguration +
|
||||
", configurationProperties=" + configurationProperties +
|
||||
", configurationPropertiesEntries=" + configurationPropertiesEntries +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ public class DefaultArchivaRuntimeConfigurationAdmin
|
|||
String userManagerImpl = userConfiguration.getString( UserConfigurationKeys.USER_MANAGER_IMPL );
|
||||
if ( StringUtils.isNotEmpty( userManagerImpl ) )
|
||||
{
|
||||
archivaRuntimeConfiguration.setUserManagerImpl( userManagerImpl );
|
||||
archivaRuntimeConfiguration.getUserManagerImpls().add( userManagerImpl );
|
||||
}
|
||||
|
||||
// now ldap
|
||||
|
@ -177,7 +177,8 @@ public class DefaultArchivaRuntimeConfigurationAdmin
|
|||
{
|
||||
if ( UserConfigurationKeys.USER_MANAGER_IMPL.equals( key ) )
|
||||
{
|
||||
return getArchivaRuntimeConfiguration().getUserManagerImpl();
|
||||
// possible false for others than archiva user manager
|
||||
return getArchivaRuntimeConfiguration().getUserManagerImpls().get( 0 );
|
||||
}
|
||||
|
||||
ArchivaRuntimeConfiguration conf = getArchivaRuntimeConfiguration();
|
||||
|
|
|
@ -40,7 +40,7 @@ import java.util.Map;
|
|||
* @author Olivier Lamy
|
||||
* @since 1.4-M4
|
||||
*/
|
||||
@Service ("archivaRuntimeConfigurationService#rest")
|
||||
@Service( "archivaRuntimeConfigurationService#rest" )
|
||||
public class DefaultArchivaRuntimeConfigurationService
|
||||
extends AbstractRestService
|
||||
implements ArchivaRuntimeConfigurationService
|
||||
|
@ -49,7 +49,7 @@ public class DefaultArchivaRuntimeConfigurationService
|
|||
private ArchivaRuntimeConfigurationAdmin archivaRuntimeConfigurationAdmin;
|
||||
|
||||
@Inject
|
||||
@Named ( value = "userManager#configurable" )
|
||||
@Named( value = "userManager#configurable" )
|
||||
private UserManager userManager;
|
||||
|
||||
@Inject
|
||||
|
@ -74,14 +74,14 @@ public class DefaultArchivaRuntimeConfigurationService
|
|||
try
|
||||
{
|
||||
// has user manager impl changed ?
|
||||
boolean userManagerChanged = !StringUtils.equals( archivaRuntimeConfiguration.getUserManagerImpl(),
|
||||
archivaRuntimeConfigurationAdmin.getArchivaRuntimeConfiguration().getUserManagerImpl() );
|
||||
boolean userManagerChanged = archivaRuntimeConfiguration.getUserManagerImpls().size()
|
||||
!= archivaRuntimeConfigurationAdmin.getArchivaRuntimeConfiguration().getUserManagerImpls().size();
|
||||
archivaRuntimeConfigurationAdmin.updateArchivaRuntimeConfiguration( archivaRuntimeConfiguration );
|
||||
|
||||
if ( userManagerChanged )
|
||||
{
|
||||
log.info( "user manager impl changed to {} reload it",
|
||||
archivaRuntimeConfiguration.getUserManagerImpl() );
|
||||
log.info( "user managerImpls changed to {} so reload it",
|
||||
archivaRuntimeConfiguration.getUserManagerImpls() );
|
||||
userManager.initialize();
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.apache.archiva.rest.api.services.ArchivaRuntimeConfigurationService;
|
|||
import org.fest.assertions.api.Assertions;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -38,7 +39,7 @@ public class ArchivaRuntimeConfigurationServiceTest
|
|||
{
|
||||
ArchivaRuntimeConfiguration archivaRuntimeConfiguration =
|
||||
getArchivaRuntimeConfigurationService().getArchivaRuntimeConfigurationAdmin();
|
||||
assertEquals( "jdo", archivaRuntimeConfiguration.getUserManagerImpl() );
|
||||
assertEquals( "jdo", archivaRuntimeConfiguration.getUserManagerImpls().get( 0 ) );
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -47,14 +48,14 @@ public class ArchivaRuntimeConfigurationServiceTest
|
|||
{
|
||||
ArchivaRuntimeConfiguration archivaRuntimeConfiguration =
|
||||
getArchivaRuntimeConfigurationService().getArchivaRuntimeConfigurationAdmin();
|
||||
assertEquals( "jdo", archivaRuntimeConfiguration.getUserManagerImpl() );
|
||||
assertEquals( "jdo", archivaRuntimeConfiguration.getUserManagerImpls().get( 0 ) );
|
||||
|
||||
archivaRuntimeConfiguration.setUserManagerImpl( "foo" );
|
||||
archivaRuntimeConfiguration.setUserManagerImpls( Arrays.asList( "foo" ) );
|
||||
|
||||
getArchivaRuntimeConfigurationService().updateArchivaRuntimeConfiguration( archivaRuntimeConfiguration );
|
||||
|
||||
archivaRuntimeConfiguration = getArchivaRuntimeConfigurationService().getArchivaRuntimeConfigurationAdmin();
|
||||
assertEquals( "foo", archivaRuntimeConfiguration.getUserManagerImpl() );
|
||||
assertEquals( "foo", archivaRuntimeConfiguration.getUserManagerImpls().get( 0 ) );
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -20,18 +20,24 @@ package org.apache.archiva.web.security;
|
|||
|
||||
import org.apache.archiva.admin.model.RepositoryAdminException;
|
||||
import org.apache.archiva.admin.model.runtime.ArchivaRuntimeConfigurationAdmin;
|
||||
import org.apache.archiva.redback.users.User;
|
||||
import org.apache.archiva.redback.users.UserManager;
|
||||
import org.apache.archiva.redback.users.UserManagerListener;
|
||||
import org.apache.archiva.redback.users.UserNotFoundException;
|
||||
import org.apache.archiva.redback.users.UserQuery;
|
||||
import org.apache.archiva.redback.users.configurable.ConfigurableUserManager;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Olivier Lamy
|
||||
* @since 1.4-M4
|
||||
*/
|
||||
@Service ( "userManager#archiva" )
|
||||
@Service("userManager#archiva")
|
||||
public class ArchivaConfigurableUsersManager
|
||||
extends ConfigurableUserManager
|
||||
{
|
||||
|
@ -42,17 +48,24 @@ public class ArchivaConfigurableUsersManager
|
|||
@Inject
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
private List<UserManager> userManagers;
|
||||
|
||||
@Override
|
||||
public void initialize()
|
||||
{
|
||||
try
|
||||
{
|
||||
String userManagerImplStr =
|
||||
archivaRuntimeConfigurationAdmin.getArchivaRuntimeConfiguration().getUserManagerImpl();
|
||||
log.info( "use userManagerImpl: '{}'", userManagerImplStr );
|
||||
UserManager userManagerImpl =
|
||||
applicationContext.getBean( "userManager#" + userManagerImplStr, UserManager.class );
|
||||
setUserManagerImpl( userManagerImpl );
|
||||
List<String> userManagerImpls =
|
||||
archivaRuntimeConfigurationAdmin.getArchivaRuntimeConfiguration().getUserManagerImpls();
|
||||
log.info( "use userManagerImpls: '{}'", userManagerImpls );
|
||||
|
||||
userManagers = new ArrayList<UserManager>( userManagerImpls.size() );
|
||||
for ( String id : userManagerImpls )
|
||||
{
|
||||
UserManager userManagerImpl = applicationContext.getBean( "userManager#" + id, UserManager.class );
|
||||
setUserManagerImpl( userManagerImpl );
|
||||
userManagers.add( userManagerImpl );
|
||||
}
|
||||
}
|
||||
catch ( RepositoryAdminException e )
|
||||
{
|
||||
|
@ -62,8 +75,214 @@ public class ArchivaConfigurableUsersManager
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public User addUser( User user )
|
||||
{
|
||||
return super.addUser( user ); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addUserUnchecked( User user )
|
||||
{
|
||||
super.addUserUnchecked( user ); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public User createUser( String username, String fullName, String emailAddress )
|
||||
{
|
||||
return super.createUser( username, fullName,
|
||||
emailAddress ); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserQuery createUserQuery()
|
||||
{
|
||||
return super.createUserQuery(); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteUser( Object principal )
|
||||
throws UserNotFoundException
|
||||
{
|
||||
super.deleteUser( principal ); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteUser( String username )
|
||||
throws UserNotFoundException
|
||||
{
|
||||
super.deleteUser( username ); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eraseDatabase()
|
||||
{
|
||||
super.eraseDatabase(); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public User findUser( String username )
|
||||
throws UserNotFoundException
|
||||
{
|
||||
return super.findUser(
|
||||
username ); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public User findUser( Object principal )
|
||||
throws UserNotFoundException
|
||||
{
|
||||
return super.findUser(
|
||||
principal ); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getGuestUser()
|
||||
throws UserNotFoundException
|
||||
{
|
||||
return super.getGuestUser(); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> findUsersByEmailKey( String emailKey, boolean orderAscending )
|
||||
{
|
||||
return super.findUsersByEmailKey( emailKey,
|
||||
orderAscending ); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> findUsersByFullNameKey( String fullNameKey, boolean orderAscending )
|
||||
{
|
||||
return super.findUsersByFullNameKey( fullNameKey,
|
||||
orderAscending ); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> findUsersByQuery( UserQuery query )
|
||||
{
|
||||
return super.findUsersByQuery(
|
||||
query ); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> findUsersByUsernameKey( String usernameKey, boolean orderAscending )
|
||||
{
|
||||
return super.findUsersByUsernameKey( usernameKey,
|
||||
orderAscending ); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId()
|
||||
{
|
||||
return super.getId(); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> getUsers()
|
||||
{
|
||||
return super.getUsers(); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> getUsers( boolean orderAscending )
|
||||
{
|
||||
return super.getUsers(
|
||||
orderAscending ); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReadOnly()
|
||||
{
|
||||
return super.isReadOnly(); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public User updateUser( User user )
|
||||
throws UserNotFoundException
|
||||
{
|
||||
return super.updateUser( user ); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public User updateUser( User user, boolean passwordChangeRequired )
|
||||
throws UserNotFoundException
|
||||
{
|
||||
return super.updateUser( user,
|
||||
passwordChangeRequired ); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean userExists( Object principal )
|
||||
{
|
||||
return super.userExists(
|
||||
principal ); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUserManagerImpl( UserManager userManagerImpl )
|
||||
{
|
||||
super.setUserManagerImpl(
|
||||
userManagerImpl ); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addUserManagerListener( UserManagerListener listener )
|
||||
{
|
||||
super.addUserManagerListener(
|
||||
listener ); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUserManagerListener( UserManagerListener listener )
|
||||
{
|
||||
super.removeUserManagerListener(
|
||||
listener ); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fireUserManagerInit( boolean freshDatabase )
|
||||
{
|
||||
super.fireUserManagerInit(
|
||||
freshDatabase ); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fireUserManagerUserAdded( User addedUser )
|
||||
{
|
||||
super.fireUserManagerUserAdded(
|
||||
addedUser ); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fireUserManagerUserRemoved( User removedUser )
|
||||
{
|
||||
super.fireUserManagerUserRemoved(
|
||||
removedUser ); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void fireUserManagerUserUpdated( User updatedUser )
|
||||
{
|
||||
super.fireUserManagerUserUpdated(
|
||||
updatedUser ); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public User createGuestUser()
|
||||
{
|
||||
return super.createGuestUser(); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinalImplementation()
|
||||
{
|
||||
return super.isFinalImplementation(); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public String getDescriptionKey()
|
||||
{
|
||||
return "archiva.redback.usermanager.configurable.archiva";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -319,6 +319,11 @@ public class SecuritySystemStub
|
|||
{
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public String getUserManagerId()
|
||||
{
|
||||
return "mock";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -504,6 +509,11 @@ public class SecuritySystemStub
|
|||
{
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public String getUserManagerId()
|
||||
{
|
||||
return "mock";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1151,8 +1151,8 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
|
|||
}
|
||||
|
||||
|
||||
ArchivaRuntimeConfiguration=function(userManagerImpl,ldapConfiguration,migratedFromRedbackConfiguration,configurationPropertiesEntries){
|
||||
this.userManagerImpl=ko.observable(userManagerImpl);
|
||||
ArchivaRuntimeConfiguration=function(userManagerImpls,ldapConfiguration,migratedFromRedbackConfiguration,configurationPropertiesEntries){
|
||||
this.userManagerImpls=ko.observableArray(userManagerImpls);
|
||||
this.ldapConfiguration=ko.observable(ldapConfiguration);
|
||||
this.migratedFromRedbackConfiguration=ko.observable(migratedFromRedbackConfiguration);
|
||||
this.configurationPropertiesEntries=ko.observableArray(configurationPropertiesEntries?configurationPropertiesEntries:[]);
|
||||
|
|
|
@ -34,9 +34,11 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,purl) {
|
|||
* @param locked
|
||||
* @param passwordChangeRequired
|
||||
* @param ownerViewModel
|
||||
* @param readOnly
|
||||
* @param uuserManagerId
|
||||
*/
|
||||
User=function(username, password, confirmPassword,fullName,email,permanent,validated,timestampAccountCreation,
|
||||
timestampLastLogin,timestampLastPasswordChange,locked,passwordChangeRequired,ownerViewModel,readOnly) {
|
||||
timestampLastLogin,timestampLastPasswordChange,locked,passwordChangeRequired,ownerViewModel,readOnly,userManagerId) {
|
||||
var self=this;
|
||||
// Potentially Editable Field.
|
||||
this.username = ko.observable(username);
|
||||
|
@ -78,6 +80,8 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,purl) {
|
|||
|
||||
this.readOnly=readOnly;
|
||||
|
||||
this.userManagerId=userManagerId;
|
||||
|
||||
this.rememberme=false;
|
||||
|
||||
this.logged=false;
|
||||
|
@ -811,7 +815,7 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,purl) {
|
|||
mapUser=function(data) {
|
||||
return new User(data.username, data.password, null,data.fullName,data.email,data.permanent,data.validated,
|
||||
data.timestampAccountCreation,data.timestampLastLogin,data.timestampLastPasswordChange,
|
||||
data.locked,data.passwordChangeRequired,self,data.readOnly);
|
||||
data.locked,data.passwordChangeRequired,self,data.readOnly,data.userManagerId);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue