disable registration link should disable registration for real

Signed-off-by: Olivier Lamy <olamy@apache.org>
This commit is contained in:
Olivier Lamy 2023-06-22 16:53:40 +10:00
parent c07e1e37ef
commit b8fcef8f78
No known key found for this signature in database
GPG Key ID: 873A8E86B4372146
2 changed files with 14 additions and 3 deletions

View File

@ -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 );
}

View File

@ -269,7 +269,7 @@ public class DefaultArchivaAdministrationService
{
try
{
return new ArrayList<String>( archivaAdministration.getKnownContentConsumers() );
return new ArrayList<>( archivaAdministration.getKnownContentConsumers() );
}
catch ( RepositoryAdminException e )
{
@ -283,7 +283,7 @@ public class DefaultArchivaAdministrationService
{
try
{
return new ArrayList<String>( 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 )
{