aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2012-12-04 18:22:28 +0000
committerOlivier Lamy <olamy@apache.org>2012-12-04 18:22:28 +0000
commit19e9ca8bb5f73d7ce644b4112eb4458ea23af96e (patch)
tree903a8bed0d27f13efa994bfeebf25e5b8fcada6d
parentd354911bba3bd54da92fd6c00ec92fbf8db347dc (diff)
downloadarchiva-19e9ca8bb5f73d7ce644b4112eb4458ea23af96e.tar.gz
archiva-19e9ca8bb5f73d7ce644b4112eb4458ea23af96e.zip
[MRM-1718] ldap configuration editable with the ui.
WORK IN PROGRESS ! git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1417093 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ArchivaLdapConfiguration.java23
-rw-r--r--archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ArchivaRuntimeConfiguration.java27
-rw-r--r--archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/runtime/ArchivaRuntimeConfigurationAdmin.java2
-rw-r--r--archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultArchivaRuntimeConfigurationAdmin.java66
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaRuntimeConfigurationService.java4
-rw-r--r--archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaConfigurableUsersManager.java2
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js16
7 files changed, 120 insertions, 20 deletions
diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ArchivaLdapConfiguration.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ArchivaLdapConfiguration.java
index ee9ff6d4b..a66d8d6bb 100644
--- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ArchivaLdapConfiguration.java
+++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ArchivaLdapConfiguration.java
@@ -26,7 +26,7 @@ import java.util.Map;
* @author Olivier Lamy
* @since 1.4-M4
*/
-@XmlRootElement ( name = "archivaLdapConfiguration" )
+@XmlRootElement( name = "archivaLdapConfiguration" )
public class ArchivaLdapConfiguration
{
@@ -39,7 +39,7 @@ public class ArchivaLdapConfiguration
/**
* The LDAP port.
*/
- private String port;
+ private int port;
/**
* ssl LDAP connection.
@@ -72,6 +72,11 @@ public class ArchivaLdapConfiguration
private String authenticationMethod;
/**
+ *
+ */
+ private boolean bindAuthenticatorEnabled;
+
+ /**
* Field extraProperties.
*/
private Map<String, String> extraProperties = new HashMap<String, String>();
@@ -91,12 +96,12 @@ public class ArchivaLdapConfiguration
this.hostName = hostName;
}
- public String getPort()
+ public int getPort()
{
return port;
}
- public void setPort( String port )
+ public void setPort( int port )
{
this.port = port;
}
@@ -170,4 +175,14 @@ public class ArchivaLdapConfiguration
{
this.extraProperties = extraProperties;
}
+
+ public boolean isBindAuthenticatorEnabled()
+ {
+ return bindAuthenticatorEnabled;
+ }
+
+ public void setBindAuthenticatorEnabled( boolean bindAuthenticatorEnabled )
+ {
+ this.bindAuthenticatorEnabled = bindAuthenticatorEnabled;
+ }
}
diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ArchivaRuntimeConfiguration.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ArchivaRuntimeConfiguration.java
index f100d3c04..426b9b603 100644
--- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ArchivaRuntimeConfiguration.java
+++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/ArchivaRuntimeConfiguration.java
@@ -25,7 +25,7 @@ import java.io.Serializable;
* @author Olivier Lamy
* @since 1.4-M4
*/
-@XmlRootElement (name = "archivaRuntimeConfiguration")
+@XmlRootElement(name = "archivaRuntimeConfiguration")
public class ArchivaRuntimeConfiguration
implements Serializable
{
@@ -33,6 +33,11 @@ public class ArchivaRuntimeConfiguration
private ArchivaLdapConfiguration archivaLdapConfiguration;
+ /**
+ * flag to know if redback configuration has been checked/migrated.
+ */
+ private boolean migratedFromRedbackConfiguration = false;
+
public ArchivaRuntimeConfiguration()
{
// no op
@@ -57,4 +62,24 @@ public class ArchivaRuntimeConfiguration
{
this.archivaLdapConfiguration = archivaLdapConfiguration;
}
+
+ public boolean isMigratedFromRedbackConfiguration()
+ {
+ return migratedFromRedbackConfiguration;
+ }
+
+ public void setMigratedFromRedbackConfiguration( boolean migratedFromRedbackConfiguration )
+ {
+ this.migratedFromRedbackConfiguration = migratedFromRedbackConfiguration;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "ArchivaRuntimeConfiguration{" +
+ "userManagerImpl='" + userManagerImpl + '\'' +
+ ", archivaLdapConfiguration=" + archivaLdapConfiguration +
+ ", migratedFromRedbackConfiguration=" + migratedFromRedbackConfiguration +
+ '}';
+ }
}
diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/runtime/ArchivaRuntimeConfigurationAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/runtime/ArchivaRuntimeConfigurationAdmin.java
index 5139f974d..9cf37ee56 100644
--- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/runtime/ArchivaRuntimeConfigurationAdmin.java
+++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/runtime/ArchivaRuntimeConfigurationAdmin.java
@@ -27,7 +27,7 @@ import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration;
*/
public interface ArchivaRuntimeConfigurationAdmin
{
- ArchivaRuntimeConfiguration getArchivaRuntimeConfigurationAdmin()
+ ArchivaRuntimeConfiguration getArchivaRuntimeConfiguration()
throws RepositoryAdminException;
void updateArchivaRuntimeConfiguration( ArchivaRuntimeConfiguration archivaRuntimeConfiguration )
diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultArchivaRuntimeConfigurationAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultArchivaRuntimeConfigurationAdmin.java
index 76e33f990..aada4b2f2 100644
--- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultArchivaRuntimeConfigurationAdmin.java
+++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultArchivaRuntimeConfigurationAdmin.java
@@ -18,7 +18,9 @@ package org.apache.archiva.admin.repository.runtime;
* under the License.
*/
+import net.sf.beanlib.provider.replicator.BeanReplicator;
import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.beans.ArchivaLdapConfiguration;
import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration;
import org.apache.archiva.admin.model.runtime.ArchivaRuntimeConfigurationAdmin;
import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
@@ -26,20 +28,72 @@ import org.apache.archiva.configuration.Configuration;
import org.apache.archiva.configuration.IndeterminateConfigurationException;
import org.apache.archiva.configuration.RuntimeConfiguration;
import org.apache.archiva.redback.components.registry.RegistryException;
+import org.apache.archiva.redback.configuration.UserConfiguration;
+import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
+import javax.annotation.PostConstruct;
+import javax.inject.Inject;
+import javax.inject.Named;
+
/**
* @author Olivier Lamy
* @since 1.4-M4
*/
-@Service ( "archivaRuntimeConfigurationAdmin#default" )
+@Service( "archivaRuntimeConfigurationAdmin#default" )
public class DefaultArchivaRuntimeConfigurationAdmin
extends AbstractRepositoryAdmin
implements ArchivaRuntimeConfigurationAdmin
{
+ @Inject
+ @Named( value = "userConfiguration" )
+ UserConfiguration userConfiguration;
+
+ @PostConstruct
+ public void initialize()
+ throws RepositoryAdminException
+ {
+ ArchivaRuntimeConfiguration archivaRuntimeConfiguration = getArchivaRuntimeConfiguration();
+ // migrate or not data from redback
+ if ( !archivaRuntimeConfiguration.isMigratedFromRedbackConfiguration() )
+ {
+ // so migrate if available
+ String userManagerImpl = userConfiguration.getString( "user.manager.impl" );
+ if ( StringUtils.isNotEmpty( userManagerImpl ) )
+ {
+ archivaRuntimeConfiguration.setUserManagerImpl( userManagerImpl );
+ }
+
+ // now ldap
+
+ ArchivaLdapConfiguration archivaLdapConfiguration =
+ archivaRuntimeConfiguration.getArchivaLdapConfiguration();
+ if ( archivaLdapConfiguration == null )
+ {
+ archivaLdapConfiguration = new ArchivaLdapConfiguration();
+ archivaRuntimeConfiguration.setArchivaLdapConfiguration( archivaLdapConfiguration );
+ }
+
+ archivaLdapConfiguration.setHostName( userConfiguration.getString( "ldap.config.hostname", null ) );
+ archivaLdapConfiguration.setPort( userConfiguration.getInt( "ldap.config.port", -1 ) );
+ archivaLdapConfiguration.setSsl( userConfiguration.getBoolean( "ldap.config.ssl", false ) );
+ archivaLdapConfiguration.setBaseDn( userConfiguration.getConcatenatedList( "ldap.config.base.dn", null ) );
+ archivaLdapConfiguration.setContextFactory(
+ userConfiguration.getString( "ldap.config.context.factory", null ) );
+ archivaLdapConfiguration.setBindDn( userConfiguration.getConcatenatedList( "ldap.config.bind.dn", null ) );
+ archivaLdapConfiguration.setPassword( userConfiguration.getString( "ldap.config.password", null ) );
+ archivaLdapConfiguration.setAuthenticationMethod(
+ userConfiguration.getString( "ldap.config.authentication.method", null ) );
+
+ archivaRuntimeConfiguration.setMigratedFromRedbackConfiguration( true );
+
+ updateArchivaRuntimeConfiguration( archivaRuntimeConfiguration );
+ }
+
+ }
- public ArchivaRuntimeConfiguration getArchivaRuntimeConfigurationAdmin()
+ public ArchivaRuntimeConfiguration getArchivaRuntimeConfiguration()
throws RepositoryAdminException
{
return build( getArchivaConfiguration().getConfiguration().getRuntimeConfiguration() );
@@ -67,15 +121,11 @@ public class DefaultArchivaRuntimeConfigurationAdmin
private ArchivaRuntimeConfiguration build( RuntimeConfiguration runtimeConfiguration )
{
- ArchivaRuntimeConfiguration archivaRuntimeConfiguration = new ArchivaRuntimeConfiguration();
- archivaRuntimeConfiguration.setUserManagerImpl( runtimeConfiguration.getUserManagerImpl() );
- return archivaRuntimeConfiguration;
+ return new BeanReplicator().replicateBean( runtimeConfiguration, ArchivaRuntimeConfiguration.class );
}
private RuntimeConfiguration build( ArchivaRuntimeConfiguration archivaRuntimeConfiguration )
{
- RuntimeConfiguration runtimeConfiguration = new RuntimeConfiguration();
- runtimeConfiguration.setUserManagerImpl( archivaRuntimeConfiguration.getUserManagerImpl() );
- return runtimeConfiguration;
+ return new BeanReplicator().replicateBean( archivaRuntimeConfiguration, RuntimeConfiguration.class );
}
}
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 df0b6eeb7..88a7d51d8 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
@@ -60,7 +60,7 @@ public class DefaultArchivaRuntimeConfigurationService
{
try
{
- return archivaRuntimeConfigurationAdmin.getArchivaRuntimeConfigurationAdmin();
+ return archivaRuntimeConfigurationAdmin.getArchivaRuntimeConfiguration();
}
catch ( RepositoryAdminException e )
{
@@ -75,7 +75,7 @@ public class DefaultArchivaRuntimeConfigurationService
{
// has user manager impl changed ?
boolean userManagerChanged = !StringUtils.equals( archivaRuntimeConfiguration.getUserManagerImpl(),
- archivaRuntimeConfigurationAdmin.getArchivaRuntimeConfigurationAdmin().getUserManagerImpl() );
+ archivaRuntimeConfigurationAdmin.getArchivaRuntimeConfiguration().getUserManagerImpl() );
archivaRuntimeConfigurationAdmin.updateArchivaRuntimeConfiguration( archivaRuntimeConfiguration );
if ( userManagerChanged )
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 5a2a08e9b..c6ef0b600 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
@@ -48,7 +48,7 @@ public class ArchivaConfigurableUsersManager
try
{
String userManagerImplStr =
- archivaRuntimeConfigurationAdmin.getArchivaRuntimeConfigurationAdmin().getUserManagerImpl();
+ archivaRuntimeConfigurationAdmin.getArchivaRuntimeConfiguration().getUserManagerImpl();
log.info( "use userManagerImpl: '{}'", userManagerImplStr );
UserManager userManagerImpl =
applicationContext.getBean( "userManager#" + userManagerImplStr, UserManager.class );
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js
index 6a2378e0b..343ddef07 100644
--- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js
+++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js
@@ -253,12 +253,13 @@ require(["jquery","jquery.tmpl","i18n","knockout"], function(jquery,jqueryTmpl,i
$.log("displayRedbackError with array");
for(var i=0; i<obj.errorMessages.length; i++ ) {
if(obj.errorMessages[i].errorKey) {
- $.log("displayRedbackError with array loop");
displayErrorMessage($.i18n.prop( obj.errorMessages[i].errorKey, obj.errorMessages[i].args ),idToAppend);
}
+ if(obj.errorMessages[i].message) {
+ displayErrorMessage(obj.errorMessages[i].message,idToAppend);
+ }
}
} else {
- $.log("displayRedbackError no array");
displayErrorMessage($.i18n.prop( obj.errorMessages.errorKey, obj.errorMessages.args ),idToAppend);
}
}
@@ -301,7 +302,9 @@ require(["jquery","jquery.tmpl","i18n","knockout"], function(jquery,jqueryTmpl,i
displayErrorMessage($.i18n.prop( data.errorKey ),idToAppend);
} else if (data.errorMessages){
$.each(data.errorMessages, function(index, value) {
- displayErrorMessage( $.i18n.prop(data.errorMessages[index].errorKey,data.errorMessages[index].args?data.errorMessages[index].args:null),idToAppend);
+ if(data.errorMessages[index].errorKey) {
+ displayErrorMessage( $.i18n.prop(data.errorMessages[index].errorKey,data.errorMessages[index].args?data.errorMessages[index].args:null),idToAppend);
+ }
});
} else {
$.log("print data.errorMessage:"+data.errorMessage);
@@ -396,6 +399,13 @@ require(["jquery","jquery.tmpl","i18n","knockout"], function(jquery,jqueryTmpl,i
// utils javascript string extensions
//------------------------------------
+ String.prototype.isEmpty = function(str) {
+ return ($.trim(this ).length < 1);
+ }
+ String.prototype.isNotEmpty = function(str) {
+ return ($.trim(this ).length > 0);
+ }
+
String.prototype.endsWith = function(str) {
return (this.match(str+"$")==str)
}