else if (resource.isSecurityAnonymousAccessEnabled()) {
// the supplied anon auth info is wrong/empty
getLogger().warn(
"Nexus refused to apply configuration, the supplied anonymous username/pwd information is empty.");
throw new PlexusResourceException(Status.CLIENT_ERROR_BAD_REQUEST, getNexusErrorResponse(
"securityAnonymousUsername", "Cannot be empty when Anonynous access is enabled"));
}
else {
getNexusConfiguration().setAnonymousAccess(false, null, null);
}
if (resource.getGlobalRestApiSettings() != null) {
RestApiSettings restApiSettings = resource.getGlobalRestApiSettings();
getGlobalRestApiSettings().setForceBaseUrl(restApiSettings.isForceBaseUrl());
if (StringUtils.isEmpty(resource.getGlobalRestApiSettings().getBaseUrl())) {
getGlobalRestApiSettings().setBaseUrl(null);
}
else {
getGlobalRestApiSettings().setBaseUrl(
new Reference(restApiSettings.getBaseUrl()).getTargetRef().toString());
}
getGlobalRestApiSettings().setUITimeout(restApiSettings.getUiTimeout() * 1000);
}
else {
getGlobalRestApiSettings().disable();
}
// NEXUS-3064: to "inform" global remote storage context (and hence, all affected proxy
// repositories) about the change, but only if config is saved okay
// TODO: this is wrong, the config framework should "tell" this changed, but we have some
// design flaw here: the globalRemoteStorageContext is NOT a component, while the settings are
boolean remoteConnectionSettingsIsDirty = ((DefaultGlobalRemoteConnectionSettings)getGlobalRemoteConnectionSettings()).isDirty();
boolean remoteProxySettingsIsDirty = ((DefaultGlobalRemoteProxySettings)getGlobalRemoteProxySettings()).isDirty();
getNexusConfiguration().saveConfiguration();
// NEXUS-3064: to "inform" global remote storage context (and hence, all affected proxy
// repositories) about the change, but only if config is saved okay
// TODO: this is wrong, the config framework should "tell" this changed, but we have some
// design flaw here: the globalRemoteStorageContext is NOT a component, while the settings are
if (remoteConnectionSettingsIsDirty) {
getNexusConfiguration().getGlobalRemoteStorageContext().setRemoteConnectionSettings(
getGlobalRemoteConnectionSettings());
}
if (remoteProxySettingsIsDirty) {
getNexusConfiguration().getGlobalRemoteStorageContext().setRemoteProxySettings(
getGlobalRemoteProxySettings()
);
}
}
catch (IOException e) {
getLogger().warn("Got IO Exception during update of Nexus configuration.", e);
throw new ResourceException(Status.SERVER_ERROR_INTERNAL);
}
catch (InvalidConfigurationException e) {
// TODO: this should be removed from the Global config, as it is NO longer part of the nexus.xml
getLogger().debug("Configuraiton Exception while setting security values", e);
this.handleInvalidConfigurationException(e);
}
catch (ConfigurationException e) {
getLogger().warn("Nexus refused to apply configuration.", e);
throw new PlexusResourceException(Status.CLIENT_ERROR_BAD_REQUEST, e.getMessage(),
getNexusErrorResponse("*", e.getMessage()));
}
}
}
// TODO: this method needs some serious cleaning up...