From b8fcef8f78e3bff24cc077f5ad1e98e521a667ad Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Thu, 22 Jun 2023 16:53:40 +1000 Subject: [PATCH] disable registration link should disable registration for real Signed-off-by: Olivier Lamy --- .../admin/DefaultArchivaAdministration.java | 12 +++++++++++- .../DefaultArchivaAdministrationService.java | 5 +++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java index 3be9f58dd..57d0ce6f6 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java @@ -27,6 +27,7 @@ import org.apache.archiva.configuration.Configuration; import org.apache.archiva.configuration.UserInterfaceOptions; import org.apache.archiva.configuration.WebappConfiguration; import org.apache.archiva.metadata.model.facets.AuditEvent; +import org.apache.archiva.redback.configuration.UserConfiguration; import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; @@ -60,6 +61,7 @@ public class DefaultArchivaAdministration // setup wagon on start with initial values NetworkConfiguration networkConfiguration = getNetworkConfiguration(); setupWagon( networkConfiguration ); + System.setProperty(UserConfiguration.USER_REGISTRATION_DISABLE_KEY, Boolean.toString(getUiConfiguration().isDisableRegistration())); } @PreDestroy @@ -389,7 +391,6 @@ public class DefaultArchivaAdministration Configuration configuration = getArchivaConfiguration().getConfiguration(); if ( uiConfiguration != null ) { - UserInterfaceOptions userInterfaceOptions = getModelMapper().map( uiConfiguration, UserInterfaceOptions.class ); configuration.getWebapp().setUi( userInterfaceOptions ); @@ -398,6 +399,15 @@ public class DefaultArchivaAdministration { configuration.getWebapp().setUi( null ); } + + if( uiConfiguration != null && uiConfiguration.isDisableRegistration() ) + { + System.setProperty(UserConfiguration.USER_REGISTRATION_DISABLE_KEY, Boolean.TRUE.toString()); + } + if( uiConfiguration != null && !uiConfiguration.isDisableRegistration() ) + { + System.setProperty(UserConfiguration.USER_REGISTRATION_DISABLE_KEY, Boolean.FALSE.toString()); + } saveConfiguration( configuration ); } diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaAdministrationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaAdministrationService.java index 51144e87a..295c85227 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaAdministrationService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultArchivaAdministrationService.java @@ -269,7 +269,7 @@ public class DefaultArchivaAdministrationService { try { - return new ArrayList( archivaAdministration.getKnownContentConsumers() ); + return new ArrayList<>( archivaAdministration.getKnownContentConsumers() ); } catch ( RepositoryAdminException e ) { @@ -283,7 +283,7 @@ public class DefaultArchivaAdministrationService { try { - return new ArrayList( archivaAdministration.getInvalidContentConsumers() ); + return new ArrayList<>( archivaAdministration.getInvalidContentConsumers() ); } catch ( RepositoryAdminException e ) { @@ -351,6 +351,7 @@ public class DefaultArchivaAdministrationService uiConfiguration.setApplicationUrl(StringUtils.stripEnd(uiConfiguration.getApplicationUrl(), "/")); archivaAdministration.updateUiConfiguration( uiConfiguration ); + } catch ( RepositoryAdminException e ) {