summaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-web
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2012-11-23 18:35:43 +0000
committerOlivier Lamy <olamy@apache.org>2012-11-23 18:35:43 +0000
commit4affdc7bbd4ab04e7cf65287e009ee8e80ebdae8 (patch)
tree5f9f4bbc2746428700a28d2f9d9ee0b682921937 /archiva-modules/archiva-web
parent0144a7f6d72c9bc0fc4ab2b9489b0870e0cdac4b (diff)
downloadarchiva-4affdc7bbd4ab04e7cf65287e009ee8e80ebdae8.tar.gz
archiva-4affdc7bbd4ab04e7cf65287e009ee8e80ebdae8.zip
[MRM-1714] using LDAP can be configurable with the ui
add a rest service which return available userManager implementation. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1413021 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-web')
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaRuntimeConfigurationService.java9
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java42
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaRuntimeConfigurationServiceTest.java17
-rw-r--r--archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaConfigurableUsersManager.java6
4 files changed, 71 insertions, 3 deletions
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaRuntimeConfigurationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaRuntimeConfigurationService.java
index 1b3e6b356..f67f4aed8 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaRuntimeConfigurationService.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ArchivaRuntimeConfigurationService.java
@@ -20,6 +20,7 @@ package org.apache.archiva.rest.api.services;
import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration;
import org.apache.archiva.redback.authorization.RedbackAuthorization;
+import org.apache.archiva.rest.api.model.UserManagerImplementationInformation;
import org.apache.archiva.security.common.ArchivaRoleConstants;
import javax.ws.rs.Consumes;
@@ -28,6 +29,7 @@ import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
+import java.util.List;
/**
* @author Olivier Lamy
@@ -50,4 +52,11 @@ public interface ArchivaRuntimeConfigurationService
@RedbackAuthorization ( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
Boolean updateArchivaRuntimeConfiguration( ArchivaRuntimeConfiguration archivaRuntimeConfiguration )
throws ArchivaRestServiceException;
+
+ @Path ( "userManagerImplementationInformation" )
+ @GET
+ @Produces ( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+ @RedbackAuthorization ( permissions = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION )
+ List<UserManagerImplementationInformation> getUserManagerImplementationInformations()
+ throws ArchivaRestServiceException;
}
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 e8727f87b..df0b6eeb7 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
@@ -22,13 +22,19 @@ import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration;
import org.apache.archiva.admin.model.runtime.ArchivaRuntimeConfigurationAdmin;
import org.apache.archiva.redback.users.UserManager;
+import org.apache.archiva.rest.api.model.UserManagerImplementationInformation;
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
import org.apache.archiva.rest.api.services.ArchivaRuntimeConfigurationService;
import org.apache.commons.lang.StringUtils;
+import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import javax.inject.Inject;
import javax.inject.Named;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
/**
* @author Olivier Lamy
@@ -43,9 +49,12 @@ public class DefaultArchivaRuntimeConfigurationService
private ArchivaRuntimeConfigurationAdmin archivaRuntimeConfigurationAdmin;
@Inject
- @Named ( value = "userManager#archiva" )
+ @Named ( value = "userManager#configurable" )
private UserManager userManager;
+ @Inject
+ private ApplicationContext applicationContext;
+
public ArchivaRuntimeConfiguration getArchivaRuntimeConfigurationAdmin()
throws ArchivaRestServiceException
{
@@ -66,7 +75,7 @@ public class DefaultArchivaRuntimeConfigurationService
{
// has user manager impl changed ?
boolean userManagerChanged = !StringUtils.equals( archivaRuntimeConfiguration.getUserManagerImpl(),
- archivaRuntimeConfigurationAdmin.getArchivaRuntimeConfigurationAdmin().getUserManagerImpl() );
+ archivaRuntimeConfigurationAdmin.getArchivaRuntimeConfigurationAdmin().getUserManagerImpl() );
archivaRuntimeConfigurationAdmin.updateArchivaRuntimeConfiguration( archivaRuntimeConfiguration );
if ( userManagerChanged )
@@ -84,6 +93,35 @@ public class DefaultArchivaRuntimeConfigurationService
}
}
+
+ public List<UserManagerImplementationInformation> getUserManagerImplementationInformations()
+ throws ArchivaRestServiceException
+ {
+
+ Map<String, UserManager> beans = applicationContext.getBeansOfType( UserManager.class );
+
+ if ( beans.isEmpty() )
+ {
+ return Collections.emptyList();
+ }
+
+ List<UserManagerImplementationInformation> informations =
+ new ArrayList<UserManagerImplementationInformation>( beans.size() );
+
+ for ( Map.Entry<String, UserManager> entry : beans.entrySet() )
+ {
+ UserManager userManager = applicationContext.getBean( entry.getKey(), UserManager.class );
+ if ( userManager.isFinalImplementation() )
+ {
+ UserManagerImplementationInformation information = new UserManagerImplementationInformation();
+ information.setBeanId( StringUtils.substringAfter( entry.getKey(), "#" ) );
+ information.setDescriptionKey( userManager.getDescriptionKey() );
+ informations.add( information );
+ }
+ }
+
+ return informations;
+ }
}
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaRuntimeConfigurationServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaRuntimeConfigurationServiceTest.java
index 88225bf93..80d7f7931 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaRuntimeConfigurationServiceTest.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArchivaRuntimeConfigurationServiceTest.java
@@ -19,8 +19,13 @@ package org.apache.archiva.rest.services;
*/
import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration;
+import org.apache.archiva.rest.api.model.UserManagerImplementationInformation;
+import org.apache.archiva.rest.api.services.ArchivaRuntimeConfigurationService;
+import org.fest.assertions.api.Assertions;
import org.junit.Test;
+import java.util.List;
+
/**
* @author Olivier Lamy
*/
@@ -51,8 +56,18 @@ public class ArchivaRuntimeConfigurationServiceTest
archivaRuntimeConfiguration = getArchivaRuntimeConfigurationService().getArchivaRuntimeConfigurationAdmin();
assertEquals( "foo", archivaRuntimeConfiguration.getUserManagerImpl() );
-
}
+ @Test
+ public void usermanagersinformations()
+ throws Exception
+ {
+ ArchivaRuntimeConfigurationService service = getArchivaRuntimeConfigurationService();
+ List<UserManagerImplementationInformation> infos = service.getUserManagerImplementationInformations();
+ Assertions.assertThat( infos ).isNotNull().isNotEmpty().contains(
+ new UserManagerImplementationInformation( "jdo", null ) );
+
+ }
+
}
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 c12c13880..5a2a08e9b 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
@@ -29,6 +29,7 @@ import javax.inject.Inject;
/**
* @author Olivier Lamy
+ * @since 1.4-M4
*/
@Service ( "userManager#archiva" )
public class ArchivaConfigurableUsersManager
@@ -60,4 +61,9 @@ public class ArchivaConfigurableUsersManager
throw new RuntimeException( e.getMessage(), e );
}
}
+
+ public String getDescriptionKey()
+ {
+ return "archiva.redback.usermanager.configurable.archiva";
+ }
}