aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-web/archiva-rest
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2021-01-11 16:53:37 +0100
committerMartin Stockhammer <martin_s@apache.org>2021-01-11 16:57:13 +0100
commit0dc2e8fff6e21178b62d10982e34067655ff6524 (patch)
treeb4062e8967a6a5cac32f948c0aeb4023a4ad0ee2 /archiva-modules/archiva-web/archiva-rest
parent76985db7ffa4ecce1557444eb490f9bceb06fb1a (diff)
downloadarchiva-0dc2e8fff6e21178b62d10982e34067655ff6524.tar.gz
archiva-0dc2e8fff6e21178b62d10982e34067655ff6524.zip
Improving LDAP configuration
Diffstat (limited to 'archiva-modules/archiva-web/archiva-rest')
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/v2/LdapConfiguration.java1
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/v2/SecurityConfigurationService.java4
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/v2/DefaultSecurityConfigurationService.java29
3 files changed, 26 insertions, 8 deletions
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/v2/LdapConfiguration.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/v2/LdapConfiguration.java
index ae789a12f..d6802c6f2 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/v2/LdapConfiguration.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/v2/LdapConfiguration.java
@@ -64,6 +64,7 @@ public class LdapConfiguration implements Serializable
newCfg.setBindAuthenticatorEnabled( ldapConfiguration.isBindAuthenticatorEnabled() );
newCfg.setHostName( ldapConfiguration.getHostName( ) );
newCfg.setSslEnabled( ldapConfiguration.isSsl() );
+ newCfg.setContextFactory( ldapConfiguration.getContextFactory() );
if (ldapConfiguration.getPort()<=0) {
newCfg.setPort( newCfg.isSslEnabled() ? 636 : 389 );
} else
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/v2/SecurityConfigurationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/v2/SecurityConfigurationService.java
index aa02581c6..947164934 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/v2/SecurityConfigurationService.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/v2/SecurityConfigurationService.java
@@ -107,7 +107,7 @@ public interface SecurityConfigurationService
content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) )
}
)
- Response updateConfiguration( SecurityConfiguration newConfiguration)
+ SecurityConfiguration updateConfiguration( SecurityConfiguration newConfiguration)
throws ArchivaRestServiceException;
@@ -239,7 +239,7 @@ public interface SecurityConfigurationService
content = @Content(mediaType = APPLICATION_JSON, schema = @Schema(implementation = ArchivaRestError.class )) )
}
)
- Response updateLdapConfiguration( LdapConfiguration configuration ) throws ArchivaRestServiceException;
+ LdapConfiguration updateLdapConfiguration( LdapConfiguration configuration ) throws ArchivaRestServiceException;
@Path("config/ldap/verify")
@POST
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/v2/DefaultSecurityConfigurationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/v2/DefaultSecurityConfigurationService.java
index 80e65c2bc..3ecda4a06 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/v2/DefaultSecurityConfigurationService.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/v2/DefaultSecurityConfigurationService.java
@@ -182,6 +182,7 @@ public class DefaultSecurityConfigurationService implements SecurityConfiguratio
ldapConfig.setPassword( newConfig.getBindPassword( ) );
ldapConfig.setUseRoleNameAsGroup( newConfig.isUseRoleNameAsGroup( ) );
ldapConfig.setWritable( newConfig.isWritable( ) );
+ ldapConfig.setContextFactory( newConfig.getContextFactory( ) );
Map<String, String> props = ldapConfig.getExtraProperties( );
for ( Map.Entry<String, String> newProp : newConfig.getProperties( ).entrySet( ) )
@@ -200,7 +201,7 @@ public class DefaultSecurityConfigurationService implements SecurityConfiguratio
}
@Override
- public Response updateConfiguration( SecurityConfiguration newConfiguration ) throws ArchivaRestServiceException
+ public SecurityConfiguration updateConfiguration( SecurityConfiguration newConfiguration ) throws ArchivaRestServiceException
{
if ( newConfiguration == null )
{
@@ -308,7 +309,15 @@ public class DefaultSecurityConfigurationService implements SecurityConfiguratio
{
throw new ArchivaRestServiceException( ErrorMessage.of( REPOSITORY_ADMIN_ERROR, e.getMessage( ) ) );
}
- return Response.ok( ).build( );
+ try
+ {
+ return SecurityConfiguration.ofRedbackConfiguration( redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration( ) );
+ }
+ catch ( RepositoryAdminException e )
+ {
+ log.error( "Error while retrieve updated configuration: {}", e.getMessage( ) );
+ throw new ArchivaRestServiceException( ErrorMessage.of( REPOSITORY_ADMIN_ERROR, e.getMessage( ) ) );
+ }
}
@Override
@@ -414,7 +423,7 @@ public class DefaultSecurityConfigurationService implements SecurityConfiguratio
}
@Override
- public Response updateLdapConfiguration( LdapConfiguration configuration ) throws ArchivaRestServiceException
+ public LdapConfiguration updateLdapConfiguration( LdapConfiguration configuration ) throws ArchivaRestServiceException
{
try
{
@@ -426,14 +435,22 @@ public class DefaultSecurityConfigurationService implements SecurityConfiguratio
updateConfig( configuration, redbackRuntimeConfiguration );
redbackRuntimeConfigurationAdmin.updateRedbackRuntimeConfiguration( redbackRuntimeConfiguration );
-
- return Response.ok( ).build( );
-
}
catch ( RepositoryAdminException e )
{
throw new ArchivaRestServiceException( ErrorMessage.of( REPOSITORY_ADMIN_ERROR ) );
}
+
+ try
+ {
+ return LdapConfiguration.of( redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration( ).getLdapConfiguration() );
+ }
+ catch ( RepositoryAdminException e )
+ {
+ log.error( "Error while retrieve updated configuration: {}", e.getMessage( ) );
+ throw new ArchivaRestServiceException( ErrorMessage.of( REPOSITORY_ADMIN_ERROR, e.getMessage( ) ) );
+ }
+
}
static final Properties toProperties( Map<String, String> values )