summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/UserManagerImplementationInformation.java15
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java1
-rw-r--r--archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaConfigurableUsersManager.java243
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js55
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors-rules.js1
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/general-admin.html41
6 files changed, 268 insertions, 88 deletions
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/UserManagerImplementationInformation.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/UserManagerImplementationInformation.java
index 1c4d94ae9..17ba2400d 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/UserManagerImplementationInformation.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/UserManagerImplementationInformation.java
@@ -33,15 +33,18 @@ public class UserManagerImplementationInformation
private String descriptionKey;
+ private boolean readOnly;
+
public UserManagerImplementationInformation()
{
// no op
}
- public UserManagerImplementationInformation( String beanId, String descriptionKey )
+ public UserManagerImplementationInformation( String beanId, String descriptionKey, boolean readOnly )
{
this.beanId = beanId;
this.descriptionKey = descriptionKey;
+ this.readOnly = readOnly;
}
public String getBeanId()
@@ -64,6 +67,16 @@ public class UserManagerImplementationInformation
this.descriptionKey = descriptionKey;
}
+ public boolean isReadOnly()
+ {
+ return readOnly;
+ }
+
+ public void setReadOnly( boolean readOnly )
+ {
+ this.readOnly = readOnly;
+ }
+
@Override
public String toString()
{
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java
index 9b45fc00b..2fa2a88a3 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java
@@ -116,6 +116,7 @@ public class DefaultArchivaRuntimeConfigurationService
UserManagerImplementationInformation information = new UserManagerImplementationInformation();
information.setBeanId( StringUtils.substringAfter( entry.getKey(), "#" ) );
information.setDescriptionKey( userManager.getDescriptionKey() );
+ information.setReadOnly( userManager.isReadOnly() );
informations.add( information );
}
}
diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaConfigurableUsersManager.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaConfigurableUsersManager.java
index 5270eaaa3..c572ced11 100644
--- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaConfigurableUsersManager.java
+++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaConfigurableUsersManager.java
@@ -31,13 +31,15 @@ import org.springframework.stereotype.Service;
import javax.inject.Inject;
import java.util.ArrayList;
+import java.util.LinkedHashMap;
import java.util.List;
+import java.util.Map;
/**
* @author Olivier Lamy
* @since 1.4-M4
*/
-@Service("userManager#archiva")
+@Service( "userManager#archiva" )
public class ArchivaConfigurableUsersManager
extends ConfigurableUserManager
{
@@ -48,7 +50,9 @@ public class ArchivaConfigurableUsersManager
@Inject
private ApplicationContext applicationContext;
- private List<UserManager> userManagers;
+ private Map<String, UserManager> userManagerPerId;
+
+ private List<UserManagerListener> listeners = new ArrayList<UserManagerListener>();
@Override
public void initialize()
@@ -59,12 +63,12 @@ public class ArchivaConfigurableUsersManager
archivaRuntimeConfigurationAdmin.getArchivaRuntimeConfiguration().getUserManagerImpls();
log.info( "use userManagerImpls: '{}'", userManagerImpls );
- userManagers = new ArrayList<UserManager>( userManagerImpls.size() );
+ userManagerPerId = new LinkedHashMap<String, UserManager>( userManagerImpls.size() );
for ( String id : userManagerImpls )
{
UserManager userManagerImpl = applicationContext.getBean( "userManager#" + id, UserManager.class );
setUserManagerImpl( userManagerImpl );
- userManagers.add( userManagerImpl );
+ userManagerPerId.put( id, userManagerImpl );
}
}
catch ( RepositoryAdminException e )
@@ -78,20 +82,36 @@ public class ArchivaConfigurableUsersManager
@Override
public User addUser( User user )
{
- return super.addUser( user ); //To change body of overridden methods use File | Settings | File Templates.
+ return userManagerPerId.get( user.getUserManagerId() ).addUser( user );
}
@Override
public void addUserUnchecked( User user )
{
- super.addUserUnchecked( user ); //To change body of overridden methods use File | Settings | File Templates.
+ userManagerPerId.get( user.getUserManagerId() ).addUserUnchecked( user );
+ }
+
+ protected UserManager findFirstWritable()
+ {
+ for ( UserManager userManager : userManagerPerId.values() )
+ {
+ if ( !userManager.isReadOnly() )
+ {
+ return userManager;
+ }
+ }
+ return null;
}
@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.
+ UserManager userManager = findFirstWritable();
+ if ( userManager == null )
+ {
+ throw new RuntimeException( "impossible to find a writable userManager" );
+ }
+ return userManager.createUser( username, fullName, emailAddress );
}
@Override
@@ -100,183 +120,276 @@ public class ArchivaConfigurableUsersManager
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.
+ UserManager userManager = findFirstWritable();
+ if ( userManager == null )
+ {
+ throw new RuntimeException( "impossible to find a writable userManager" );
+ }
+ userManager.deleteUser( username );
}
@Override
public void eraseDatabase()
{
- super.eraseDatabase(); //To change body of overridden methods use File | Settings | File Templates.
+ for ( UserManager userManager : userManagerPerId.values() )
+ {
+ userManager.eraseDatabase();
+ }
}
@Override
public User findUser( String username )
throws UserNotFoundException
{
- return super.findUser(
- username ); //To change body of overridden methods use File | Settings | File Templates.
- }
+ User user = null;
+ UserNotFoundException lastException = null;
+ for ( UserManager userManager : userManagerPerId.values() )
+ {
+ try
+ {
+ user = userManager.findUser( username );
+ if ( user != null )
+ {
+ return user;
+ }
+ }
+ catch ( UserNotFoundException e )
+ {
+ lastException = e;
+ }
+ }
- @Override
- public User findUser( Object principal )
- throws UserNotFoundException
- {
- return super.findUser(
- principal ); //To change body of overridden methods use File | Settings | File Templates.
+ if ( user == null )
+ {
+ throw lastException;
+ }
+
+ return user;
}
+
@Override
public User getGuestUser()
throws UserNotFoundException
{
- return super.getGuestUser(); //To change body of overridden methods use File | Settings | File Templates.
+ User user = null;
+ UserNotFoundException lastException = null;
+ for ( UserManager userManager : userManagerPerId.values() )
+ {
+ try
+ {
+ user = userManager.getGuestUser();
+ if ( user != null )
+ {
+ return user;
+ }
+ }
+ catch ( UserNotFoundException e )
+ {
+ lastException = e;
+ }
+ }
+
+ if ( user == null )
+ {
+ throw lastException;
+ }
+
+ return user;
}
@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.
+ List<User> users = new ArrayList<User>();
+
+ for ( UserManager userManager : userManagerPerId.values() )
+ {
+ List<User> found = userManager.findUsersByEmailKey( emailKey, orderAscending );
+ if ( found != null )
+ {
+ users.addAll( found );
+ }
+ }
+ return users;
}
@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.
+ List<User> users = new ArrayList<User>();
+
+ for ( UserManager userManager : userManagerPerId.values() )
+ {
+ List<User> found = userManager.findUsersByFullNameKey( fullNameKey, orderAscending );
+ if ( found != null )
+ {
+ users.addAll( found );
+ }
+ }
+ return users;
}
@Override
public List<User> findUsersByQuery( UserQuery query )
{
- return super.findUsersByQuery(
- query ); //To change body of overridden methods use File | Settings | File Templates.
+ List<User> users = new ArrayList<User>();
+
+ for ( UserManager userManager : userManagerPerId.values() )
+ {
+ List<User> found = userManager.findUsersByQuery( query );
+ if ( found != null )
+ {
+ users.addAll( found );
+ }
+ }
+ return users;
}
@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.
+ List<User> users = new ArrayList<User>();
+
+ for ( UserManager userManager : userManagerPerId.values() )
+ {
+ List<User> found = userManager.findUsersByUsernameKey( usernameKey, orderAscending );
+ if ( found != null )
+ {
+ users.addAll( found );
+ }
+ }
+ return users;
}
@Override
public String getId()
{
- return super.getId(); //To change body of overridden methods use File | Settings | File Templates.
+ return null;
}
@Override
public List<User> getUsers()
{
- return super.getUsers(); //To change body of overridden methods use File | Settings | File Templates.
+ List<User> users = new ArrayList<User>();
+
+ for ( UserManager userManager : userManagerPerId.values() )
+ {
+ List<User> found = userManager.getUsers();
+ if ( found != null )
+ {
+ users.addAll( found );
+ }
+ }
+ return users;
}
@Override
public List<User> getUsers( boolean orderAscending )
{
- return super.getUsers(
- orderAscending ); //To change body of overridden methods use File | Settings | File Templates.
+ List<User> users = new ArrayList<User>();
+
+ for ( UserManager userManager : userManagerPerId.values() )
+ {
+ List<User> found = userManager.getUsers( orderAscending );
+ if ( found != null )
+ {
+ users.addAll( found );
+ }
+ }
+ return users;
}
@Override
public boolean isReadOnly()
{
- return super.isReadOnly(); //To change body of overridden methods use File | Settings | File Templates.
+ //olamy: must be it depends :-)
+ return true;
}
@Override
public User updateUser( User user )
throws UserNotFoundException
{
- return super.updateUser( user ); //To change body of overridden methods use File | Settings | File Templates.
+ return userManagerPerId.get( user.getUserManagerId() ).updateUser( user );
}
@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.
+ return userManagerPerId.get( user.getUserManagerId() ).updateUser( user, passwordChangeRequired );
}
@Override
public void setUserManagerImpl( UserManager userManagerImpl )
{
- super.setUserManagerImpl(
- userManagerImpl ); //To change body of overridden methods use File | Settings | File Templates.
+ log.error( "setUserManagerImpl cannot be used in this implementation" );
}
@Override
public void addUserManagerListener( UserManagerListener listener )
{
- super.addUserManagerListener(
- listener ); //To change body of overridden methods use File | Settings | File Templates.
+ this.listeners.add( listener );
}
@Override
public void removeUserManagerListener( UserManagerListener listener )
{
- super.removeUserManagerListener(
- listener ); //To change body of overridden methods use File | Settings | File Templates.
+ this.listeners.remove( listener );
}
@Override
protected void fireUserManagerInit( boolean freshDatabase )
{
- super.fireUserManagerInit(
- freshDatabase ); //To change body of overridden methods use File | Settings | File Templates.
+ for ( UserManagerListener listener : listeners )
+ {
+ listener.userManagerInit( freshDatabase );
+ }
}
@Override
protected void fireUserManagerUserAdded( User addedUser )
{
- super.fireUserManagerUserAdded(
- addedUser ); //To change body of overridden methods use File | Settings | File Templates.
+ for ( UserManagerListener listener : listeners )
+ {
+ listener.userManagerUserAdded( addedUser );
+ }
}
@Override
protected void fireUserManagerUserRemoved( User removedUser )
{
- super.fireUserManagerUserRemoved(
- removedUser ); //To change body of overridden methods use File | Settings | File Templates.
+ for ( UserManagerListener listener : listeners )
+ {
+ listener.userManagerUserRemoved( removedUser );
+ }
}
@Override
protected void fireUserManagerUserUpdated( User updatedUser )
{
- super.fireUserManagerUserUpdated(
- updatedUser ); //To change body of overridden methods use File | Settings | File Templates.
+ for ( UserManagerListener listener : listeners )
+ {
+ listener.userManagerUserUpdated( updatedUser );
+ }
}
@Override
public User createGuestUser()
{
- return super.createGuestUser(); //To change body of overridden methods use File | Settings | File Templates.
+ return findFirstWritable().createGuestUser();
}
@Override
public boolean isFinalImplementation()
{
- return super.isFinalImplementation(); //To change body of overridden methods use File | Settings | File Templates.
+ return false;
}
public String getDescriptionKey()
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js
index fb3e2b441..70dd4c184 100644
--- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js
+++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js
@@ -1167,7 +1167,7 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
configurationPropertiesEntries=[];
}
- return new ArchivaRuntimeConfiguration(data.userManagerImpl,mapLdapConfiguration(data.ldapConfiguration),data.migratedFromRedbackConfiguration,
+ return new ArchivaRuntimeConfiguration(data.userManagerImpls,mapLdapConfiguration(data.ldapConfiguration),data.migratedFromRedbackConfiguration,
configurationPropertiesEntries);
}
@@ -1215,9 +1215,53 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
}
ArchivaRuntimeConfigurationViewModel=function(archivaRuntimeConfiguration,userManagerImplementationInformations){
+ var self=this;
this.archivaRuntimeConfiguration=ko.observable(archivaRuntimeConfiguration);
this.userManagerImplementationInformations=ko.observable(userManagerImplementationInformations);
- var self=this;
+
+ this.usedUserManagerImpls=ko.observableArray([]);
+
+ findUserManagerImplementationInformation=function(id){
+ for(var i= 0;i<self.userManagerImplementationInformations().length;i++){
+ $.log(id+""+self.userManagerImplementationInformations()[i].beanId);
+ if(id==self.userManagerImplementationInformations()[i].beanId){
+ return self.userManagerImplementationInformations()[i];
+ }
+ }
+ }
+
+ for(var i= 0;i<archivaRuntimeConfiguration.userManagerImpls().length;i++){
+ var id=archivaRuntimeConfiguration.userManagerImpls()[i];
+ $.log("id:"+id);
+ var userManagerImplementationInformation=findUserManagerImplementationInformation(id);
+
+ if(userManagerImplementationInformation!=null){
+ this.usedUserManagerImpls.push(userManagerImplementationInformation);
+ }
+ }
+
+ isUsedUserManagerImpl=function(userManagerImplementationInformation){
+ for(var i=0;i<self.usedUserManagerImpls().length;i++){
+ if(self.usedUserManagerImpls()[i].beanId==userManagerImplementationInformation.beanId){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ this.availableUserManagerImpls=ko.observableArray([]);
+
+ for(var i=0;i<self.userManagerImplementationInformations().length;i++){
+ if(!isUsedUserManagerImpl(self.userManagerImplementationInformations()[i])){
+ self.availableUserManagerImpls.push(self.userManagerImplementationInformations()[i]);
+ }
+
+ }
+
+ userManagerImplMoved=function(arg){
+ $.log("userManagerImplMoved:"+arg.sourceIndex+" to " + arg.targetIndex);
+ //self.usedUserManagerImpls().push(self.availableUserManagerImpls()[arg.sourceIndex]);
+ }
saveArchivaRuntimeConfiguration=function(){
$.log("saveArchivaRuntimeConfiguration");
@@ -1250,10 +1294,11 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
}
}
- UserManagerImplementationInformation=function(beanId,descriptionKey){
+ UserManagerImplementationInformation=function(beanId,descriptionKey,readOnly){
this.beanId=beanId;
this.descriptionKey=descriptionKey;
this.description= $.i18n.prop(descriptionKey);
+ this.readOnly=readOnly;
}
mapUserManagerImplementationInformations=function(data){
@@ -1266,7 +1311,7 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
if(data==null){
return null;
}
- return new UserManagerImplementationInformation(data.beanId,data.descriptionKey);
+ return new UserManagerImplementationInformation(data.beanId,data.descriptionKey,data.readOnly);
}
displayRuntimeConfiguration=function(){
@@ -1286,7 +1331,7 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
var archivaRuntimeConfiguration = mapArchivaRuntimeConfiguration(data);
var archivaRuntimeConfigurationViewModel =
new ArchivaRuntimeConfigurationViewModel(archivaRuntimeConfiguration,userManagerImplementationInformations);
- mainContent.html( $( "#runtime-configuration-main" ).tmpl( ) );
+ mainContent.html( $( "#runtime-configuration-main" ).tmpl() );
ko.applyBindings(archivaRuntimeConfigurationViewModel,$("#runtime-configuration-content" ).get(0));
activatePopoverDoc();
}
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors-rules.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors-rules.js
index 583fa43c9..e8b9ca74f 100644
--- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors-rules.js
+++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/proxy-connectors-rules.js
@@ -224,7 +224,6 @@ define("archiva.proxy-connectors-rules",["jquery","i18n","jquery.tmpl","bootstra
for(var i=0;i<self.proxyConnectorRule.proxyConnectors().length;i++){
if(self.proxyConnectorRule.proxyConnectors()[i].sourceRepoId()==sourceRepoId &&
self.proxyConnectorRule.proxyConnectors()[i].targetRepoId()==targetRepoId){
- $.log("found");
proxyConnectorToRemove=self.proxyConnectorRule.proxyConnectors()[i];
}
}
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/general-admin.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/general-admin.html
index cd1925f53..70de4ca4a 100644
--- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/general-admin.html
+++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/general-admin.html
@@ -744,7 +744,7 @@
<div style="min-height: 40px"
data-bind="sortable: {template: 'statistics-repositories-order-tmpl',data:availableRepositories}">
</div>
- </div>
+ </div>
</div>
</div>
<div class="span6 well">
@@ -842,9 +842,9 @@
</script>
<script id="statistics-repositories-order-tmpl" type="text/html">
- <div class="well draggable-item">
- ${$data}
- </div>
+ <div class="well draggable-item">
+ ${$data}
+ </div>
</script>
<script id="report-health" type="text/html">
@@ -904,20 +904,23 @@
<div class="tab-content">
<div class="tab-pane active" id="redback-runtime-general-content">
<div class="well">
- <form class="form-horizontal" id="runtime-configuration-form-id">
- <fieldset id="form-runtime-configuration">
- <div class="control-group">
- <label for="userManagerImpl" class="control-label">
- ${$.i18n.prop('runtime-configuration.usermanager.label')}
- </label>
+ <div class="row-fluid">
+ <div class="span4 dotted">
+ <h5></h5>
+ <hr/>
+ <div style="min-height: 40px" id="user-mananagers-sortables-choosed"
+ data-bind="sortable: { template: 'redback-runtime-general-content-usermanagers', data:usedUserManagerImpls}">
+ </div>
+ </div>
- <div class="controls">
- <select id="userManagerImpl"
- data-bind="options: userManagerImplementationInformations,optionsValue: 'beanId', optionsText: 'description', value: archivaRuntimeConfiguration().userManagerImpl, optionsCaption: 'Choose...'"></select>
- </div>
+ <div class="span4 dotted">
+ <h5></h5>
+ <hr/>
+ <div style="min-height: 40px"id="user-mananagers-sortables-availables"
+ data-bind="sortable: {template: 'redback-runtime-general-content-usermanagers',data:availableUserManagerImpls}">
</div>
- </fieldset>
- </form>
+ </div>
+ </div>
</div>
</div>
@@ -1033,3 +1036,9 @@
</div>
</script>
+
+<script id="redback-runtime-general-content-usermanagers" type="text/html">
+ <div class="well draggable-item">
+ ${$data.description}
+ </div>
+</script>