mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 08:55:44 +01:00
Implemented namespace feature
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2010, Sebastian Sdorra
|
* Copyright (c) 2010, Sebastian Sdorra
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
* <p>
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
*
|
* <p>
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
* this list of conditions and the following disclaimer.
|
* this list of conditions and the following disclaimer.
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
* 3. Neither the name of SCM-Manager; nor the names of its
|
* 3. Neither the name of SCM-Manager; nor the names of its
|
||||||
* contributors may be used to endorse or promote products derived from this
|
* contributors may be used to endorse or promote products derived from this
|
||||||
* software without specific prior written permission.
|
* software without specific prior written permission.
|
||||||
*
|
* <p>
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
@@ -24,39 +24,32 @@
|
|||||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
* <p>
|
||||||
* http://bitbucket.org/sdorra/scm-manager
|
* http://bitbucket.org/sdorra/scm-manager
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
package sonia.scm.config;
|
package sonia.scm.config;
|
||||||
|
|
||||||
//~--- non-JDK imports --------------------------------------------------------
|
|
||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.inject.Singleton;
|
import com.google.inject.Singleton;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import sonia.scm.event.ScmEventBus;
|
import sonia.scm.event.ScmEventBus;
|
||||||
import sonia.scm.util.HttpUtil;
|
import sonia.scm.util.HttpUtil;
|
||||||
import sonia.scm.xml.XmlSetStringAdapter;
|
import sonia.scm.xml.XmlSetStringAdapter;
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
import javax.xml.bind.annotation.XmlAccessType;
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
import javax.xml.bind.annotation.XmlAccessorType;
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main configuration object for SCM-Manager.
|
* The main configuration object for SCM-Manager.
|
||||||
@@ -67,38 +60,137 @@ import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
|
|||||||
@Singleton
|
@Singleton
|
||||||
@XmlRootElement(name = "scm-config")
|
@XmlRootElement(name = "scm-config")
|
||||||
@XmlAccessorType(XmlAccessType.FIELD)
|
@XmlAccessorType(XmlAccessType.FIELD)
|
||||||
public class ScmConfiguration
|
public class ScmConfiguration {
|
||||||
{
|
|
||||||
|
|
||||||
/** Default JavaScript date format */
|
/**
|
||||||
|
* Default JavaScript date format
|
||||||
|
*/
|
||||||
public static final String DEFAULT_DATEFORMAT = "YYYY-MM-DD HH:mm:ss";
|
public static final String DEFAULT_DATEFORMAT = "YYYY-MM-DD HH:mm:ss";
|
||||||
|
|
||||||
/** Default plugin url */
|
/**
|
||||||
|
* Default plugin url
|
||||||
|
*/
|
||||||
public static final String DEFAULT_PLUGINURL =
|
public static final String DEFAULT_PLUGINURL =
|
||||||
"http://plugins.scm-manager.org/scm-plugin-backend/api/{version}/plugins?os={os}&arch={arch}&snapshot=false";
|
"http://plugins.scm-manager.org/scm-plugin-backend/api/{version}/plugins?os={os}&arch={arch}&snapshot=false";
|
||||||
|
|
||||||
/** Default plugin url from version 1.0 */
|
/**
|
||||||
|
* Default plugin url from version 1.0
|
||||||
|
*/
|
||||||
public static final String OLD_PLUGINURL =
|
public static final String OLD_PLUGINURL =
|
||||||
"http://plugins.scm-manager.org/plugins.xml.gz";
|
"http://plugins.scm-manager.org/plugins.xml.gz";
|
||||||
|
|
||||||
/** Path to the configuration file */
|
/**
|
||||||
|
* Path to the configuration file
|
||||||
|
*/
|
||||||
public static final String PATH =
|
public static final String PATH =
|
||||||
"config".concat(File.separator).concat("config.xml");
|
"config".concat(File.separator).concat("config.xml");
|
||||||
|
|
||||||
/** the logger for ScmConfiguration */
|
/**
|
||||||
|
* the logger for ScmConfiguration
|
||||||
|
*/
|
||||||
private static final Logger logger =
|
private static final Logger logger =
|
||||||
LoggerFactory.getLogger(ScmConfiguration.class);
|
LoggerFactory.getLogger(ScmConfiguration.class);
|
||||||
|
|
||||||
//~--- methods --------------------------------------------------------------
|
|
||||||
|
@XmlElement(name = "admin-groups")
|
||||||
|
@XmlJavaTypeAdapter(XmlSetStringAdapter.class)
|
||||||
|
private Set<String> adminGroups;
|
||||||
|
|
||||||
|
|
||||||
|
@XmlElement(name = "admin-users")
|
||||||
|
@XmlJavaTypeAdapter(XmlSetStringAdapter.class)
|
||||||
|
private Set<String> adminUsers;
|
||||||
|
|
||||||
|
|
||||||
|
@XmlElement(name = "base-url")
|
||||||
|
private String baseUrl;
|
||||||
|
|
||||||
|
|
||||||
|
@XmlElement(name = "force-base-url")
|
||||||
|
private boolean forceBaseUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maximum allowed login attempts.
|
||||||
|
*
|
||||||
|
* @since 1.34
|
||||||
|
*/
|
||||||
|
@XmlElement(name = "login-attempt-limit")
|
||||||
|
private int loginAttemptLimit = -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* glob patterns for urls which are excluded from proxy
|
||||||
|
*/
|
||||||
|
@XmlElement(name = "proxy-excludes")
|
||||||
|
@XmlJavaTypeAdapter(XmlSetStringAdapter.class)
|
||||||
|
private Set<String> proxyExcludes;
|
||||||
|
|
||||||
|
|
||||||
|
private String proxyPassword;
|
||||||
|
|
||||||
|
|
||||||
|
private int proxyPort = 8080;
|
||||||
|
|
||||||
|
|
||||||
|
private String proxyServer = "proxy.mydomain.com";
|
||||||
|
|
||||||
|
|
||||||
|
private String proxyUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skip failed authenticators.
|
||||||
|
*
|
||||||
|
* @since 1.36
|
||||||
|
*/
|
||||||
|
@XmlElement(name = "skip-failed-authenticators")
|
||||||
|
private boolean skipFailedAuthenticators = false;
|
||||||
|
|
||||||
|
|
||||||
|
@XmlElement(name = "plugin-url")
|
||||||
|
private String pluginUrl = DEFAULT_PLUGINURL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Login attempt timeout.
|
||||||
|
*
|
||||||
|
* @since 1.34
|
||||||
|
*/
|
||||||
|
@XmlElement(name = "login-attempt-limit-timeout")
|
||||||
|
private long loginAttemptLimitTimeout = TimeUnit.MINUTES.toSeconds(5l);
|
||||||
|
|
||||||
|
|
||||||
|
private boolean enableProxy = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Authentication realm for basic authentication.
|
||||||
|
*/
|
||||||
|
private String realmDescription = HttpUtil.AUTHENTICATION_REALM;
|
||||||
|
private boolean enableRepositoryArchive = false;
|
||||||
|
private boolean disableGroupingGrid = false;
|
||||||
|
/**
|
||||||
|
* JavaScript date format from moment.js
|
||||||
|
*
|
||||||
|
* @see <a href="http://momentjs.com/docs/#/parsing/" target="_blank">http://momentjs.com/docs/#/parsing/</a>
|
||||||
|
*/
|
||||||
|
private String dateFormat = DEFAULT_DATEFORMAT;
|
||||||
|
private boolean anonymousAccessEnabled = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables xsrf cookie protection.
|
||||||
|
*
|
||||||
|
* @since 1.47
|
||||||
|
*/
|
||||||
|
@XmlElement(name = "xsrf-protection")
|
||||||
|
private boolean enabledXsrfProtection = true;
|
||||||
|
|
||||||
|
@XmlElement(name = "default-namespace-strategy")
|
||||||
|
private String defaultNamespaceStrategy = "sonia.scm.repository.DefaultNamespaceStrategy";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls the {@link sonia.scm.ConfigChangedListener#configChanged(Object)}
|
* Calls the {@link sonia.scm.ConfigChangedListener#configChanged(Object)}
|
||||||
* method of all registered listeners.
|
* method of all registered listeners.
|
||||||
*/
|
*/
|
||||||
public void fireChangeEvent()
|
public void fireChangeEvent() {
|
||||||
{
|
if (logger.isDebugEnabled()) {
|
||||||
if (logger.isDebugEnabled())
|
|
||||||
{
|
|
||||||
logger.debug("fire config changed event");
|
logger.debug("fire config changed event");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,12 +201,9 @@ public class ScmConfiguration
|
|||||||
/**
|
/**
|
||||||
* Load all properties from another {@link ScmConfiguration} object.
|
* Load all properties from another {@link ScmConfiguration} object.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param other
|
* @param other
|
||||||
*/
|
*/
|
||||||
public void load(ScmConfiguration other)
|
public void load(ScmConfiguration other) {
|
||||||
{
|
|
||||||
this.realmDescription = other.realmDescription;
|
this.realmDescription = other.realmDescription;
|
||||||
this.dateFormat = other.dateFormat;
|
this.dateFormat = other.dateFormat;
|
||||||
this.pluginUrl = other.pluginUrl;
|
this.pluginUrl = other.pluginUrl;
|
||||||
@@ -135,29 +224,14 @@ public class ScmConfiguration
|
|||||||
this.loginAttemptLimit = other.loginAttemptLimit;
|
this.loginAttemptLimit = other.loginAttemptLimit;
|
||||||
this.loginAttemptLimitTimeout = other.loginAttemptLimitTimeout;
|
this.loginAttemptLimitTimeout = other.loginAttemptLimitTimeout;
|
||||||
this.enabledXsrfProtection = other.enabledXsrfProtection;
|
this.enabledXsrfProtection = other.enabledXsrfProtection;
|
||||||
|
this.defaultNamespaceStrategy = other.defaultNamespaceStrategy;
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- get methods ----------------------------------------------------------
|
public Set<String> getAdminGroups() {
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a set of admin group names.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @return set of admin group names
|
|
||||||
*/
|
|
||||||
public Set<String> getAdminGroups()
|
|
||||||
{
|
|
||||||
return adminGroups;
|
return adminGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public Set<String> getAdminUsers() {
|
||||||
* Returns a set of admin user names.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @return set of admin user names
|
|
||||||
*/
|
|
||||||
public Set<String> getAdminUsers()
|
|
||||||
{
|
|
||||||
return adminUsers;
|
return adminUsers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,11 +239,10 @@ public class ScmConfiguration
|
|||||||
* Returns the complete base url of the scm-manager including the context path.
|
* Returns the complete base url of the scm-manager including the context path.
|
||||||
* For example http://localhost:8080/scm
|
* For example http://localhost:8080/scm
|
||||||
*
|
*
|
||||||
* @since 1.5
|
|
||||||
* @return complete base url of the scm-manager
|
* @return complete base url of the scm-manager
|
||||||
|
* @since 1.5
|
||||||
*/
|
*/
|
||||||
public String getBaseUrl()
|
public String getBaseUrl() {
|
||||||
{
|
|
||||||
return baseUrl;
|
return baseUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -177,23 +250,14 @@ public class ScmConfiguration
|
|||||||
* Returns the date format for the user interface. This format is a
|
* Returns the date format for the user interface. This format is a
|
||||||
* JavaScript date format, from the library moment.js.
|
* JavaScript date format, from the library moment.js.
|
||||||
*
|
*
|
||||||
* @see <a href="http://momentjs.com/docs/#/parsing/" target="_blank">http://momentjs.com/docs/#/parsing/</a>
|
|
||||||
* @return moment.js date format
|
* @return moment.js date format
|
||||||
|
* @see <a href="http://momentjs.com/docs/#/parsing/" target="_blank">http://momentjs.com/docs/#/parsing/</a>
|
||||||
*/
|
*/
|
||||||
public String getDateFormat()
|
public String getDateFormat() {
|
||||||
{
|
|
||||||
return dateFormat;
|
return dateFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public int getLoginAttemptLimit() {
|
||||||
* Returns maximum allowed login attempts.
|
|
||||||
*
|
|
||||||
* @return maximum allowed login attempts
|
|
||||||
*
|
|
||||||
* @since 1.34
|
|
||||||
*/
|
|
||||||
public int getLoginAttemptLimit()
|
|
||||||
{
|
|
||||||
return loginAttemptLimit;
|
return loginAttemptLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,11 +266,9 @@ public class ScmConfiguration
|
|||||||
* because of too many failed login attempts.
|
* because of too many failed login attempts.
|
||||||
*
|
*
|
||||||
* @return login attempt timeout in seconds
|
* @return login attempt timeout in seconds
|
||||||
*
|
|
||||||
* @since 1.34
|
* @since 1.34
|
||||||
*/
|
*/
|
||||||
public long getLoginAttemptLimitTimeout()
|
public long getLoginAttemptLimitTimeout() {
|
||||||
{
|
|
||||||
return loginAttemptLimitTimeout;
|
return loginAttemptLimitTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,8 +284,7 @@ public class ScmConfiguration
|
|||||||
*
|
*
|
||||||
* @return the complete plugin url.
|
* @return the complete plugin url.
|
||||||
*/
|
*/
|
||||||
public String getPluginUrl()
|
public String getPluginUrl() {
|
||||||
{
|
|
||||||
return pluginUrl;
|
return pluginUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,289 +292,141 @@ public class ScmConfiguration
|
|||||||
* Returns a set of glob patterns for urls which should excluded from
|
* Returns a set of glob patterns for urls which should excluded from
|
||||||
* proxy settings.
|
* proxy settings.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @return set of glob patterns
|
* @return set of glob patterns
|
||||||
* @since 1.23
|
* @since 1.23
|
||||||
*/
|
*/
|
||||||
public Set<String> getProxyExcludes()
|
public Set<String> getProxyExcludes() {
|
||||||
{
|
if (proxyExcludes == null) {
|
||||||
if (proxyExcludes == null)
|
|
||||||
{
|
|
||||||
proxyExcludes = Sets.newHashSet();
|
proxyExcludes = Sets.newHashSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
return proxyExcludes;
|
return proxyExcludes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public String getProxyPassword() {
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* @since 1.7
|
|
||||||
*/
|
|
||||||
public String getProxyPassword()
|
|
||||||
{
|
|
||||||
return proxyPassword;
|
return proxyPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public int getProxyPort() {
|
||||||
* Returns the proxy port.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @return proxy port
|
|
||||||
*/
|
|
||||||
public int getProxyPort()
|
|
||||||
{
|
|
||||||
return proxyPort;
|
return proxyPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the servername or ip of the proxyserver.
|
* Returns the servername or ip of the proxyserver.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @return servername or ip of the proxyserver
|
* @return servername or ip of the proxyserver
|
||||||
*/
|
*/
|
||||||
public String getProxyServer()
|
public String getProxyServer() {
|
||||||
{
|
|
||||||
return proxyServer;
|
return proxyServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public String getProxyUser() {
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* @since 1.7
|
|
||||||
*/
|
|
||||||
public String getProxyUser()
|
|
||||||
{
|
|
||||||
return proxyUser;
|
return proxyUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public String getRealmDescription() {
|
||||||
* Returns the realm description.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @return realm description
|
|
||||||
* @since 1.36
|
|
||||||
*/
|
|
||||||
public String getRealmDescription()
|
|
||||||
{
|
|
||||||
return realmDescription;
|
return realmDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAnonymousAccessEnabled() {
|
||||||
/**
|
|
||||||
* Returns true if the anonymous access to the SCM-Manager is enabled.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @return true if the anonymous access to the SCM-Manager is enabled
|
|
||||||
*/
|
|
||||||
public boolean isAnonymousAccessEnabled()
|
|
||||||
{
|
|
||||||
return anonymousAccessEnabled;
|
return anonymousAccessEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public boolean isDisableGroupingGrid() {
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
* @since 1.9
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean isDisableGroupingGrid()
|
|
||||||
{
|
|
||||||
return disableGroupingGrid;
|
return disableGroupingGrid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns {@code true} if the cookie xsrf protection is enabled.
|
* Returns {@code true} if the cookie xsrf protection is enabled.
|
||||||
*
|
*
|
||||||
* @see <a href="https://goo.gl/s67xO3">Issue 793</a>
|
|
||||||
* @return {@code true} if the cookie xsrf protection is enabled
|
* @return {@code true} if the cookie xsrf protection is enabled
|
||||||
*
|
* @see <a href="https://goo.gl/s67xO3">Issue 793</a>
|
||||||
* @since 1.47
|
* @since 1.47
|
||||||
*/
|
*/
|
||||||
public boolean isEnabledXsrfProtection()
|
public boolean isEnabledXsrfProtection() {
|
||||||
{
|
|
||||||
return enabledXsrfProtection;
|
return enabledXsrfProtection;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public boolean isEnableProxy() {
|
||||||
* Returns true if proxy is enabled.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @return true if proxy is enabled
|
|
||||||
*/
|
|
||||||
public boolean isEnableProxy()
|
|
||||||
{
|
|
||||||
return enableProxy;
|
return enableProxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public boolean isEnableRepositoryArchive() {
|
||||||
* Returns true if the repository archive is enabled.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @return true if the repository archive is enabled
|
|
||||||
* @since 1.14
|
|
||||||
*/
|
|
||||||
public boolean isEnableRepositoryArchive()
|
|
||||||
{
|
|
||||||
return enableRepositoryArchive;
|
return enableRepositoryArchive;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public boolean isForceBaseUrl() {
|
||||||
* Returns true if force base url is enabled.
|
|
||||||
*
|
|
||||||
* @since 1.5
|
|
||||||
* @return true if force base url is enabled
|
|
||||||
*/
|
|
||||||
public boolean isForceBaseUrl()
|
|
||||||
{
|
|
||||||
return forceBaseUrl;
|
return forceBaseUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public boolean isLoginAttemptLimitEnabled() {
|
||||||
* Returns true if the login attempt limit is enabled.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @return true if login attempt limit is enabled
|
|
||||||
*
|
|
||||||
* @since 1.37
|
|
||||||
*/
|
|
||||||
public boolean isLoginAttemptLimitEnabled()
|
|
||||||
{
|
|
||||||
return loginAttemptLimit > 0;
|
return loginAttemptLimit > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDefaultNamespaceStrategy() {
|
||||||
|
return defaultNamespaceStrategy;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if failed authenticators are skipped.
|
* Returns true if failed authenticators are skipped.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @return true if failed authenticators are skipped
|
* @return true if failed authenticators are skipped
|
||||||
*
|
|
||||||
* @since 1.36
|
* @since 1.36
|
||||||
*/
|
*/
|
||||||
public boolean isSkipFailedAuthenticators()
|
public boolean isSkipFailedAuthenticators() {
|
||||||
{
|
|
||||||
return skipFailedAuthenticators;
|
return skipFailedAuthenticators;
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- set methods ----------------------------------------------------------
|
public void setAdminGroups(Set<String> adminGroups) {
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param adminGroups
|
|
||||||
*/
|
|
||||||
public void setAdminGroups(Set<String> adminGroups)
|
|
||||||
{
|
|
||||||
this.adminGroups = adminGroups;
|
this.adminGroups = adminGroups;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setAdminUsers(Set<String> adminUsers) {
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param adminUsers
|
|
||||||
*/
|
|
||||||
public void setAdminUsers(Set<String> adminUsers)
|
|
||||||
{
|
|
||||||
this.adminUsers = adminUsers;
|
this.adminUsers = adminUsers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setAnonymousAccessEnabled(boolean anonymousAccessEnabled) {
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param anonymousAccessEnabled
|
|
||||||
*/
|
|
||||||
public void setAnonymousAccessEnabled(boolean anonymousAccessEnabled)
|
|
||||||
{
|
|
||||||
this.anonymousAccessEnabled = anonymousAccessEnabled;
|
this.anonymousAccessEnabled = anonymousAccessEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setBaseUrl(String baseUrl) {
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param baseUrl
|
|
||||||
* @since 1.5
|
|
||||||
*/
|
|
||||||
public void setBaseUrl(String baseUrl)
|
|
||||||
{
|
|
||||||
this.baseUrl = baseUrl;
|
this.baseUrl = baseUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setDateFormat(String dateFormat) {
|
||||||
* Sets the date format for the ui.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param dateFormat date format for ui
|
|
||||||
*/
|
|
||||||
public void setDateFormat(String dateFormat)
|
|
||||||
{
|
|
||||||
this.dateFormat = dateFormat;
|
this.dateFormat = dateFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setDisableGroupingGrid(boolean disableGroupingGrid) {
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
* @since 1.9
|
|
||||||
*
|
|
||||||
* @param disableGroupingGrid
|
|
||||||
*/
|
|
||||||
public void setDisableGroupingGrid(boolean disableGroupingGrid)
|
|
||||||
{
|
|
||||||
this.disableGroupingGrid = disableGroupingGrid;
|
this.disableGroupingGrid = disableGroupingGrid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setEnableProxy(boolean enableProxy) {
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param enableProxy
|
|
||||||
*/
|
|
||||||
public void setEnableProxy(boolean enableProxy)
|
|
||||||
{
|
|
||||||
this.enableProxy = enableProxy;
|
this.enableProxy = enableProxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable or disable the repository archive. Default is disabled.
|
* Enable or disable the repository archive. Default is disabled.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @param enableRepositoryArchive true to disable the repository archive
|
* @param enableRepositoryArchive true to disable the repository archive
|
||||||
* @since 1.14
|
* @since 1.14
|
||||||
*/
|
*/
|
||||||
public void setEnableRepositoryArchive(boolean enableRepositoryArchive)
|
public void setEnableRepositoryArchive(boolean enableRepositoryArchive) {
|
||||||
{
|
|
||||||
this.enableRepositoryArchive = enableRepositoryArchive;
|
this.enableRepositoryArchive = enableRepositoryArchive;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setForceBaseUrl(boolean forceBaseUrl) {
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param forceBaseUrl
|
|
||||||
* @since 1.5
|
|
||||||
*/
|
|
||||||
public void setForceBaseUrl(boolean forceBaseUrl)
|
|
||||||
{
|
|
||||||
this.forceBaseUrl = forceBaseUrl;
|
this.forceBaseUrl = forceBaseUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set maximum allowed login attempts.
|
* Set maximum allowed login attempts.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @param loginAttemptLimit login attempt limit
|
* @param loginAttemptLimit login attempt limit
|
||||||
*
|
|
||||||
* @since 1.34
|
* @since 1.34
|
||||||
*/
|
*/
|
||||||
public void setLoginAttemptLimit(int loginAttemptLimit)
|
public void setLoginAttemptLimit(int loginAttemptLimit) {
|
||||||
{
|
|
||||||
this.loginAttemptLimit = loginAttemptLimit;
|
this.loginAttemptLimit = loginAttemptLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -522,22 +435,13 @@ public class ScmConfiguration
|
|||||||
* because of too many failed login attempts.
|
* because of too many failed login attempts.
|
||||||
*
|
*
|
||||||
* @param loginAttemptLimitTimeout login attempt timeout in seconds
|
* @param loginAttemptLimitTimeout login attempt timeout in seconds
|
||||||
*
|
|
||||||
* @since 1.34
|
* @since 1.34
|
||||||
*/
|
*/
|
||||||
public void setLoginAttemptLimitTimeout(long loginAttemptLimitTimeout)
|
public void setLoginAttemptLimitTimeout(long loginAttemptLimitTimeout) {
|
||||||
{
|
|
||||||
this.loginAttemptLimitTimeout = loginAttemptLimitTimeout;
|
this.loginAttemptLimitTimeout = loginAttemptLimitTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setPluginUrl(String pluginUrl) {
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param pluginUrl
|
|
||||||
*/
|
|
||||||
public void setPluginUrl(String pluginUrl)
|
|
||||||
{
|
|
||||||
this.pluginUrl = pluginUrl;
|
this.pluginUrl = pluginUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -545,70 +449,30 @@ public class ScmConfiguration
|
|||||||
* Set glob patterns for urls which are should be excluded from proxy
|
* Set glob patterns for urls which are should be excluded from proxy
|
||||||
* settings.
|
* settings.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* @param proxyExcludes glob patterns
|
* @param proxyExcludes glob patterns
|
||||||
* @since 1.23
|
* @since 1.23
|
||||||
*/
|
*/
|
||||||
public void setProxyExcludes(Set<String> proxyExcludes)
|
public void setProxyExcludes(Set<String> proxyExcludes) {
|
||||||
{
|
|
||||||
this.proxyExcludes = proxyExcludes;
|
this.proxyExcludes = proxyExcludes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setProxyPassword(String proxyPassword) {
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param proxyPassword
|
|
||||||
* @since 1.7
|
|
||||||
*/
|
|
||||||
public void setProxyPassword(String proxyPassword)
|
|
||||||
{
|
|
||||||
this.proxyPassword = proxyPassword;
|
this.proxyPassword = proxyPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setProxyPort(int proxyPort) {
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param proxyPort
|
|
||||||
*/
|
|
||||||
public void setProxyPort(int proxyPort)
|
|
||||||
{
|
|
||||||
this.proxyPort = proxyPort;
|
this.proxyPort = proxyPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setProxyServer(String proxyServer) {
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param proxyServer
|
|
||||||
*/
|
|
||||||
public void setProxyServer(String proxyServer)
|
|
||||||
{
|
|
||||||
this.proxyServer = proxyServer;
|
this.proxyServer = proxyServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setProxyUser(String proxyUser) {
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param proxyUser
|
|
||||||
* @since 1.7
|
|
||||||
*/
|
|
||||||
public void setProxyUser(String proxyUser)
|
|
||||||
{
|
|
||||||
this.proxyUser = proxyUser;
|
this.proxyUser = proxyUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setRealmDescription(String realmDescription) {
|
||||||
* Sets the realm description.
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param realmDescription
|
|
||||||
* @since 1.36
|
|
||||||
*/
|
|
||||||
public void setRealmDescription(String realmDescription)
|
|
||||||
{
|
|
||||||
this.realmDescription = realmDescription;
|
this.realmDescription = realmDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -617,11 +481,9 @@ public class ScmConfiguration
|
|||||||
* authenticator finds the user but fails to authenticate the user.
|
* authenticator finds the user but fails to authenticate the user.
|
||||||
*
|
*
|
||||||
* @param skipFailedAuthenticators true to skip failed authenticators
|
* @param skipFailedAuthenticators true to skip failed authenticators
|
||||||
*
|
|
||||||
* @since 1.36
|
* @since 1.36
|
||||||
*/
|
*/
|
||||||
public void setSkipFailedAuthenticators(boolean skipFailedAuthenticators)
|
public void setSkipFailedAuthenticators(boolean skipFailedAuthenticators) {
|
||||||
{
|
|
||||||
this.skipFailedAuthenticators = skipFailedAuthenticators;
|
this.skipFailedAuthenticators = skipFailedAuthenticators;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -630,109 +492,13 @@ public class ScmConfiguration
|
|||||||
*
|
*
|
||||||
* @param enabledXsrfProtection {@code true} to enable xsrf protection
|
* @param enabledXsrfProtection {@code true} to enable xsrf protection
|
||||||
* @see <a href="https://goo.gl/s67xO3">Issue 793</a>
|
* @see <a href="https://goo.gl/s67xO3">Issue 793</a>
|
||||||
*
|
|
||||||
* @since 1.47
|
* @since 1.47
|
||||||
*/
|
*/
|
||||||
public void setEnabledXsrfProtection(boolean enabledXsrfProtection)
|
public void setEnabledXsrfProtection(boolean enabledXsrfProtection) {
|
||||||
{
|
|
||||||
this.enabledXsrfProtection = enabledXsrfProtection;
|
this.enabledXsrfProtection = enabledXsrfProtection;
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- fields ---------------------------------------------------------------
|
public void setDefaultNamespaceStrategy(String defaultNamespaceStrategy) {
|
||||||
|
this.defaultNamespaceStrategy = defaultNamespaceStrategy;
|
||||||
/** Field description */
|
}
|
||||||
@XmlElement(name = "admin-groups")
|
|
||||||
@XmlJavaTypeAdapter(XmlSetStringAdapter.class)
|
|
||||||
private Set<String> adminGroups;
|
|
||||||
|
|
||||||
/** Field description */
|
|
||||||
@XmlElement(name = "admin-users")
|
|
||||||
@XmlJavaTypeAdapter(XmlSetStringAdapter.class)
|
|
||||||
private Set<String> adminUsers;
|
|
||||||
|
|
||||||
/** Field description */
|
|
||||||
@XmlElement(name = "base-url")
|
|
||||||
private String baseUrl;
|
|
||||||
|
|
||||||
/** Field description */
|
|
||||||
@XmlElement(name = "force-base-url")
|
|
||||||
private boolean forceBaseUrl;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Maximum allowed login attempts.
|
|
||||||
*
|
|
||||||
* @since 1.34
|
|
||||||
*/
|
|
||||||
@XmlElement(name = "login-attempt-limit")
|
|
||||||
private int loginAttemptLimit = -1;
|
|
||||||
|
|
||||||
/** glob patterns for urls which are excluded from proxy */
|
|
||||||
@XmlElement(name = "proxy-excludes")
|
|
||||||
@XmlJavaTypeAdapter(XmlSetStringAdapter.class)
|
|
||||||
private Set<String> proxyExcludes;
|
|
||||||
|
|
||||||
/** Field description */
|
|
||||||
private String proxyPassword;
|
|
||||||
|
|
||||||
/** Field description */
|
|
||||||
private int proxyPort = 8080;
|
|
||||||
|
|
||||||
/** Field description */
|
|
||||||
private String proxyServer = "proxy.mydomain.com";
|
|
||||||
|
|
||||||
/** Field description */
|
|
||||||
private String proxyUser;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Skip failed authenticators.
|
|
||||||
*
|
|
||||||
* @since 1.36
|
|
||||||
*/
|
|
||||||
@XmlElement(name = "skip-failed-authenticators")
|
|
||||||
private boolean skipFailedAuthenticators = false;
|
|
||||||
|
|
||||||
/** Field description */
|
|
||||||
@XmlElement(name = "plugin-url")
|
|
||||||
private String pluginUrl = DEFAULT_PLUGINURL;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Login attempt timeout.
|
|
||||||
*
|
|
||||||
* @since 1.34
|
|
||||||
*/
|
|
||||||
@XmlElement(name = "login-attempt-limit-timeout")
|
|
||||||
private long loginAttemptLimitTimeout = TimeUnit.MINUTES.toSeconds(5l);
|
|
||||||
|
|
||||||
/** Field description */
|
|
||||||
private boolean enableProxy = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Authentication realm for basic authentication.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private String realmDescription = HttpUtil.AUTHENTICATION_REALM;
|
|
||||||
|
|
||||||
/** Field description */
|
|
||||||
private boolean enableRepositoryArchive = false;
|
|
||||||
|
|
||||||
/** Field description */
|
|
||||||
private boolean disableGroupingGrid = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JavaScript date format from moment.js
|
|
||||||
* @see <a href="http://momentjs.com/docs/#/parsing/" target="_blank">http://momentjs.com/docs/#/parsing/</a>
|
|
||||||
*/
|
|
||||||
private String dateFormat = DEFAULT_DATEFORMAT;
|
|
||||||
|
|
||||||
/** Field description */
|
|
||||||
private boolean anonymousAccessEnabled = false;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Enables xsrf cookie protection.
|
|
||||||
*
|
|
||||||
* @since 1.47
|
|
||||||
*/
|
|
||||||
@XmlElement(name = "xsrf-protection")
|
|
||||||
private boolean enabledXsrfProtection = true;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package sonia.scm.repository;
|
||||||
|
|
||||||
|
import sonia.scm.config.ScmConfiguration;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Provider;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class NamespaceStrategyProvider implements Provider<NamespaceStrategy> {
|
||||||
|
|
||||||
|
private final Set<NamespaceStrategy> strategies;
|
||||||
|
private final ScmConfiguration scmConfiguration;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public NamespaceStrategyProvider(Set<NamespaceStrategy> strategies, ScmConfiguration scmConfiguration) {
|
||||||
|
this.strategies = strategies;
|
||||||
|
this.scmConfiguration = scmConfiguration;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NamespaceStrategy get() {
|
||||||
|
String namespaceStrategy = scmConfiguration.getDefaultNamespaceStrategy();
|
||||||
|
|
||||||
|
for (NamespaceStrategy s : this.strategies) {
|
||||||
|
if (s.getClass().getCanonicalName().equals(namespaceStrategy)) {
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -37,23 +37,17 @@ import com.github.sdorra.ssp.PermissionObject;
|
|||||||
import com.github.sdorra.ssp.StaticPermissions;
|
import com.github.sdorra.ssp.StaticPermissions;
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import sonia.scm.BasicPropertiesAware;
|
import sonia.scm.BasicPropertiesAware;
|
||||||
import sonia.scm.ModelObject;
|
import sonia.scm.ModelObject;
|
||||||
import sonia.scm.util.HttpUtil;
|
import sonia.scm.util.HttpUtil;
|
||||||
import sonia.scm.util.Util;
|
import sonia.scm.util.Util;
|
||||||
import sonia.scm.util.ValidationUtil;
|
import sonia.scm.util.ValidationUtil;
|
||||||
|
|
||||||
|
import javax.xml.bind.annotation.*;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
|
||||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Source code repository.
|
* Source code repository.
|
||||||
*
|
*
|
||||||
@@ -178,40 +172,23 @@ public class Repository extends BasicPropertiesAware implements ModelObject, Per
|
|||||||
return healthCheckFailures;
|
return healthCheckFailures;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the unique id of the {@link Repository}.
|
|
||||||
*
|
|
||||||
* @return unique id
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the timestamp of the last modified date of the {@link Repository}.
|
|
||||||
*
|
|
||||||
* @return timestamp of the last modified date
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Long getLastModified() {
|
public Long getLastModified() {
|
||||||
return lastModified;
|
return lastModified;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the name of the {@link Repository}.
|
|
||||||
*
|
|
||||||
* @return name of the {@link Repository}
|
|
||||||
*/
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public String getNamespace() { return namespace; }
|
||||||
* Returns the access permissions of the {@link Repository}.
|
|
||||||
*
|
|
||||||
* @return access permissions
|
|
||||||
*/
|
|
||||||
public List<Permission> getPermissions() {
|
public List<Permission> getPermissions() {
|
||||||
if (permissions == null) {
|
if (permissions == null) {
|
||||||
permissions = Lists.newArrayList();
|
permissions = Lists.newArrayList();
|
||||||
|
|||||||
@@ -57,16 +57,8 @@ import sonia.scm.group.xml.XmlGroupDAO;
|
|||||||
import sonia.scm.io.DefaultFileSystem;
|
import sonia.scm.io.DefaultFileSystem;
|
||||||
import sonia.scm.io.FileSystem;
|
import sonia.scm.io.FileSystem;
|
||||||
import sonia.scm.net.SSLContextProvider;
|
import sonia.scm.net.SSLContextProvider;
|
||||||
import sonia.scm.net.ahc.AdvancedHttpClient;
|
import sonia.scm.net.ahc.*;
|
||||||
import sonia.scm.net.ahc.ContentTransformer;
|
import sonia.scm.plugin.*;
|
||||||
import sonia.scm.net.ahc.DefaultAdvancedHttpClient;
|
|
||||||
import sonia.scm.net.ahc.JsonContentTransformer;
|
|
||||||
import sonia.scm.net.ahc.XmlContentTransformer;
|
|
||||||
import sonia.scm.plugin.DefaultPluginLoader;
|
|
||||||
import sonia.scm.plugin.DefaultPluginManager;
|
|
||||||
import sonia.scm.plugin.ExtensionProcessor;
|
|
||||||
import sonia.scm.plugin.PluginLoader;
|
|
||||||
import sonia.scm.plugin.PluginManager;
|
|
||||||
import sonia.scm.repository.*;
|
import sonia.scm.repository.*;
|
||||||
import sonia.scm.repository.api.HookContextFactory;
|
import sonia.scm.repository.api.HookContextFactory;
|
||||||
import sonia.scm.repository.api.RepositoryServiceFactory;
|
import sonia.scm.repository.api.RepositoryServiceFactory;
|
||||||
@@ -78,32 +70,13 @@ import sonia.scm.resources.ResourceManager;
|
|||||||
import sonia.scm.resources.ScriptResourceServlet;
|
import sonia.scm.resources.ScriptResourceServlet;
|
||||||
import sonia.scm.schedule.QuartzScheduler;
|
import sonia.scm.schedule.QuartzScheduler;
|
||||||
import sonia.scm.schedule.Scheduler;
|
import sonia.scm.schedule.Scheduler;
|
||||||
import sonia.scm.security.AuthorizationChangedEventProducer;
|
import sonia.scm.security.*;
|
||||||
import sonia.scm.security.CipherHandler;
|
import sonia.scm.store.*;
|
||||||
import sonia.scm.security.CipherUtil;
|
|
||||||
import sonia.scm.security.ConfigurableLoginAttemptHandler;
|
|
||||||
import sonia.scm.security.DefaultKeyGenerator;
|
|
||||||
import sonia.scm.security.DefaultSecuritySystem;
|
|
||||||
import sonia.scm.security.KeyGenerator;
|
|
||||||
import sonia.scm.security.LoginAttemptHandler;
|
|
||||||
import sonia.scm.security.SecuritySystem;
|
|
||||||
import sonia.scm.store.BlobStoreFactory;
|
|
||||||
import sonia.scm.store.ConfigurationEntryStoreFactory;
|
|
||||||
import sonia.scm.store.ConfigurationStoreFactory;
|
|
||||||
import sonia.scm.store.DataStoreFactory;
|
|
||||||
import sonia.scm.store.FileBlobStoreFactory;
|
|
||||||
import sonia.scm.store.JAXBConfigurationEntryStoreFactory;
|
|
||||||
import sonia.scm.store.JAXBConfigurationStoreFactory;
|
|
||||||
import sonia.scm.store.JAXBDataStoreFactory;
|
|
||||||
import sonia.scm.template.MustacheTemplateEngine;
|
import sonia.scm.template.MustacheTemplateEngine;
|
||||||
import sonia.scm.template.TemplateEngine;
|
import sonia.scm.template.TemplateEngine;
|
||||||
import sonia.scm.template.TemplateEngineFactory;
|
import sonia.scm.template.TemplateEngineFactory;
|
||||||
import sonia.scm.template.TemplateServlet;
|
import sonia.scm.template.TemplateServlet;
|
||||||
import sonia.scm.url.RestJsonUrlProvider;
|
import sonia.scm.url.*;
|
||||||
import sonia.scm.url.RestXmlUrlProvider;
|
|
||||||
import sonia.scm.url.UrlProvider;
|
|
||||||
import sonia.scm.url.UrlProviderFactory;
|
|
||||||
import sonia.scm.url.WebUIUrlProvider;
|
|
||||||
import sonia.scm.user.DefaultUserManager;
|
import sonia.scm.user.DefaultUserManager;
|
||||||
import sonia.scm.user.UserDAO;
|
import sonia.scm.user.UserDAO;
|
||||||
import sonia.scm.user.UserManager;
|
import sonia.scm.user.UserManager;
|
||||||
@@ -224,6 +197,8 @@ public class ScmServletModule extends ServletModule
|
|||||||
ScmConfiguration config = getScmConfiguration();
|
ScmConfiguration config = getScmConfiguration();
|
||||||
CipherUtil cu = CipherUtil.getInstance();
|
CipherUtil cu = CipherUtil.getInstance();
|
||||||
|
|
||||||
|
bind(NamespaceStrategy.class).toProvider(NamespaceStrategyProvider.class);
|
||||||
|
|
||||||
// bind repository provider
|
// bind repository provider
|
||||||
ThrowingProviderBinder.create(binder()).bind(
|
ThrowingProviderBinder.create(binder()).bind(
|
||||||
RepositoryProvider.class, Repository.class).to(
|
RepositoryProvider.class, Repository.class).to(
|
||||||
@@ -351,10 +326,10 @@ public class ScmServletModule extends ServletModule
|
|||||||
// bind events
|
// bind events
|
||||||
// bind(LastModifiedUpdateListener.class);
|
// bind(LastModifiedUpdateListener.class);
|
||||||
|
|
||||||
Class<? extends NamespaceStrategy> namespaceStrategy = extensionProcessor.byExtensionPoint(NamespaceStrategy.class).iterator().next();
|
|
||||||
bind(NamespaceStrategy.class, namespaceStrategy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method description
|
* Method description
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,11 +1,18 @@
|
|||||||
package sonia.scm.repository;
|
package sonia.scm.repository;
|
||||||
|
|
||||||
|
import org.apache.shiro.SecurityUtils;
|
||||||
|
import org.apache.shiro.subject.Subject;
|
||||||
import sonia.scm.plugin.Extension;
|
import sonia.scm.plugin.Extension;
|
||||||
|
import sonia.scm.user.User;
|
||||||
|
|
||||||
|
|
||||||
@Extension
|
@Extension
|
||||||
public class DefaultNamespaceStrategy implements NamespaceStrategy {
|
public class DefaultNamespaceStrategy implements NamespaceStrategy {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNamespace() {
|
public String getNamespace() {
|
||||||
return "42";
|
Subject subject = SecurityUtils.getSubject();
|
||||||
|
String displayName = subject.getPrincipals().oneByType(User.class).getName();
|
||||||
|
return displayName;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,29 +42,14 @@ import com.google.inject.Singleton;
|
|||||||
import org.apache.shiro.concurrent.SubjectAwareExecutorService;
|
import org.apache.shiro.concurrent.SubjectAwareExecutorService;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import sonia.scm.ArgumentIsInvalidException;
|
import sonia.scm.*;
|
||||||
import sonia.scm.ConfigurationException;
|
|
||||||
import sonia.scm.HandlerEventType;
|
|
||||||
import sonia.scm.SCMContextProvider;
|
|
||||||
import sonia.scm.Type;
|
|
||||||
import sonia.scm.config.ScmConfiguration;
|
import sonia.scm.config.ScmConfiguration;
|
||||||
import sonia.scm.security.KeyGenerator;
|
import sonia.scm.security.KeyGenerator;
|
||||||
import sonia.scm.util.AssertUtil;
|
import sonia.scm.util.*;
|
||||||
import sonia.scm.util.CollectionAppender;
|
|
||||||
import sonia.scm.util.HttpUtil;
|
|
||||||
import sonia.scm.util.IOUtil;
|
|
||||||
import sonia.scm.util.Util;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ThreadFactory;
|
import java.util.concurrent.ThreadFactory;
|
||||||
@@ -128,16 +113,6 @@ public class DefaultRepositoryManager extends AbstractRepositoryManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param repository
|
|
||||||
* @param initRepository
|
|
||||||
*
|
|
||||||
* @throws IOException
|
|
||||||
* @throws RepositoryException
|
|
||||||
*/
|
|
||||||
public void create(Repository repository, boolean initRepository)
|
public void create(Repository repository, boolean initRepository)
|
||||||
throws RepositoryException, IOException {
|
throws RepositoryException, IOException {
|
||||||
logger.info("create repository {} of type {}", repository.getName(),
|
logger.info("create repository {} of type {}", repository.getName(),
|
||||||
@@ -163,30 +138,12 @@ public class DefaultRepositoryManager extends AbstractRepositoryManager {
|
|||||||
fireEvent(HandlerEventType.CREATE, repository);
|
fireEvent(HandlerEventType.CREATE, repository);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param repository
|
|
||||||
*
|
|
||||||
* @throws IOException
|
|
||||||
* @throws RepositoryException
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void create(Repository repository)
|
public void create(Repository repository)
|
||||||
throws RepositoryException, IOException {
|
throws RepositoryException, IOException {
|
||||||
create(repository, true);
|
create(repository, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param repository
|
|
||||||
*
|
|
||||||
* @throws IOException
|
|
||||||
* @throws RepositoryException
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(Repository repository)
|
public void delete(Repository repository)
|
||||||
throws RepositoryException, IOException {
|
throws RepositoryException, IOException {
|
||||||
@@ -213,40 +170,16 @@ public class DefaultRepositoryManager extends AbstractRepositoryManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param repository
|
|
||||||
*
|
|
||||||
* @throws IOException
|
|
||||||
* @throws RepositoryException
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void importRepository(Repository repository)
|
public void importRepository(Repository repository)
|
||||||
throws RepositoryException, IOException {
|
throws RepositoryException, IOException {
|
||||||
create(repository, false);
|
create(repository, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param context
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void init(SCMContextProvider context) {
|
public void init(SCMContextProvider context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param repository
|
|
||||||
*
|
|
||||||
* @throws IOException
|
|
||||||
* @throws RepositoryException
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void modify(Repository repository)
|
public void modify(Repository repository)
|
||||||
throws RepositoryException, IOException {
|
throws RepositoryException, IOException {
|
||||||
@@ -273,15 +206,6 @@ public class DefaultRepositoryManager extends AbstractRepositoryManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param repository
|
|
||||||
*
|
|
||||||
* @throws IOException
|
|
||||||
* @throws RepositoryException
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void refresh(Repository repository)
|
public void refresh(Repository repository)
|
||||||
throws RepositoryException, IOException {
|
throws RepositoryException, IOException {
|
||||||
@@ -299,16 +223,7 @@ public class DefaultRepositoryManager extends AbstractRepositoryManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- get methods ----------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param id
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Repository get(String id) {
|
public Repository get(String id) {
|
||||||
AssertUtil.assertIsNotEmpty(id);
|
AssertUtil.assertIsNotEmpty(id);
|
||||||
@@ -324,15 +239,6 @@ public class DefaultRepositoryManager extends AbstractRepositoryManager {
|
|||||||
return repository;
|
return repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param type
|
|
||||||
* @param name
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Repository get(String type, String name) {
|
public Repository get(String type, String name) {
|
||||||
AssertUtil.assertIsNotEmpty(type);
|
AssertUtil.assertIsNotEmpty(type);
|
||||||
@@ -348,14 +254,6 @@ public class DefaultRepositoryManager extends AbstractRepositoryManager {
|
|||||||
return repository;
|
return repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param comparator
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Repository> getAll(Comparator<Repository> comparator) {
|
public Collection<Repository> getAll(Comparator<Repository> comparator) {
|
||||||
List<Repository> repositories = Lists.newArrayList();
|
List<Repository> repositories = Lists.newArrayList();
|
||||||
@@ -378,28 +276,12 @@ public class DefaultRepositoryManager extends AbstractRepositoryManager {
|
|||||||
return repositories;
|
return repositories;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Repository> getAll() {
|
public Collection<Repository> getAll() {
|
||||||
return getAll(null);
|
return getAll(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param comparator
|
|
||||||
* @param start
|
|
||||||
* @param limit
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Repository> getAll(Comparator<Repository> comparator,
|
public Collection<Repository> getAll(Comparator<Repository> comparator,
|
||||||
int start, int limit) {
|
int start, int limit) {
|
||||||
@@ -417,26 +299,11 @@ public class DefaultRepositoryManager extends AbstractRepositoryManager {
|
|||||||
}, start, limit);
|
}, start, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param start
|
|
||||||
* @param limit
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Repository> getAll(int start, int limit) {
|
public Collection<Repository> getAll(int start, int limit) {
|
||||||
return getAll(null, start, limit);
|
return getAll(null, start, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Type> getConfiguredTypes() {
|
public Collection<Type> getConfiguredTypes() {
|
||||||
List<Type> validTypes = Lists.newArrayList();
|
List<Type> validTypes = Lists.newArrayList();
|
||||||
@@ -450,14 +317,6 @@ public class DefaultRepositoryManager extends AbstractRepositoryManager {
|
|||||||
return validTypes;
|
return validTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param request
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Repository getFromRequest(HttpServletRequest request) {
|
public Repository getFromRequest(HttpServletRequest request) {
|
||||||
AssertUtil.assertIsNotNull(request);
|
AssertUtil.assertIsNotNull(request);
|
||||||
@@ -465,15 +324,6 @@ public class DefaultRepositoryManager extends AbstractRepositoryManager {
|
|||||||
return getFromUri(HttpUtil.getStrippedURI(request));
|
return getFromUri(HttpUtil.getStrippedURI(request));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param type
|
|
||||||
* @param uri
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Repository getFromTypeAndUri(String type, String uri) {
|
public Repository getFromTypeAndUri(String type, String uri) {
|
||||||
if (Strings.isNullOrEmpty(type)) {
|
if (Strings.isNullOrEmpty(type)) {
|
||||||
@@ -512,14 +362,6 @@ public class DefaultRepositoryManager extends AbstractRepositoryManager {
|
|||||||
return repository;
|
return repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param uri
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Repository getFromUri(String uri) {
|
public Repository getFromUri(String uri) {
|
||||||
AssertUtil.assertIsNotEmpty(uri);
|
AssertUtil.assertIsNotEmpty(uri);
|
||||||
@@ -541,51 +383,21 @@ public class DefaultRepositoryManager extends AbstractRepositoryManager {
|
|||||||
return repository;
|
return repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param type
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public RepositoryHandler getHandler(String type) {
|
public RepositoryHandler getHandler(String type) {
|
||||||
return handlerMap.get(type);
|
return handlerMap.get(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Long getLastModified() {
|
public Long getLastModified() {
|
||||||
return repositoryDAO.getLastModified();
|
return repositoryDAO.getLastModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Type> getTypes() {
|
public Collection<Type> getTypes() {
|
||||||
return types;
|
return types;
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- methods --------------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param contextProvider
|
|
||||||
* @param handler
|
|
||||||
*/
|
|
||||||
private void addHandler(SCMContextProvider contextProvider,
|
private void addHandler(SCMContextProvider contextProvider,
|
||||||
RepositoryHandler handler) {
|
RepositoryHandler handler) {
|
||||||
AssertUtil.assertIsNotNull(handler);
|
AssertUtil.assertIsNotNull(handler);
|
||||||
@@ -609,19 +421,6 @@ public class DefaultRepositoryManager extends AbstractRepositoryManager {
|
|||||||
types.add(type);
|
types.add(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
//~--- get methods ----------------------------------------------------------
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method description
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @param repository
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @throws RepositoryException
|
|
||||||
*/
|
|
||||||
private RepositoryHandler getHandler(Repository repository)
|
private RepositoryHandler getHandler(Repository repository)
|
||||||
throws RepositoryException {
|
throws RepositoryException {
|
||||||
String type = repository.getType();
|
String type = repository.getType();
|
||||||
|
|||||||
@@ -34,11 +34,7 @@ import com.google.common.base.Stopwatch;
|
|||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
import org.apache.shiro.SecurityUtils;
|
import org.apache.shiro.SecurityUtils;
|
||||||
import org.apache.shiro.authc.AuthenticationException;
|
import org.apache.shiro.authc.*;
|
||||||
import org.apache.shiro.authc.AuthenticationInfo;
|
|
||||||
import org.apache.shiro.authc.AuthenticationToken;
|
|
||||||
import org.apache.shiro.authc.SimpleAuthenticationInfo;
|
|
||||||
import org.apache.shiro.authc.UsernamePasswordToken;
|
|
||||||
import org.apache.shiro.authc.credential.AllowAllCredentialsMatcher;
|
import org.apache.shiro.authc.credential.AllowAllCredentialsMatcher;
|
||||||
import org.apache.shiro.authz.AuthorizationInfo;
|
import org.apache.shiro.authz.AuthorizationInfo;
|
||||||
import org.apache.shiro.mgt.DefaultSecurityManager;
|
import org.apache.shiro.mgt.DefaultSecurityManager;
|
||||||
@@ -61,12 +57,7 @@ import sonia.scm.security.DefaultKeyGenerator;
|
|||||||
import sonia.scm.security.KeyGenerator;
|
import sonia.scm.security.KeyGenerator;
|
||||||
import sonia.scm.user.UserTestData;
|
import sonia.scm.user.UserTestData;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
@@ -96,8 +87,6 @@ public class DefaultRepositoryManagerPerfTest {
|
|||||||
|
|
||||||
private final KeyGenerator keyGenerator = new DefaultKeyGenerator();
|
private final KeyGenerator keyGenerator = new DefaultKeyGenerator();
|
||||||
|
|
||||||
private final NamespaceStrategy namespaceStrategy = new DefaultNamespaceStrategy();
|
|
||||||
|
|
||||||
@Mock
|
@Mock
|
||||||
private RepositoryHandler repositoryHandler;
|
private RepositoryHandler repositoryHandler;
|
||||||
|
|
||||||
@@ -114,7 +103,7 @@ public class DefaultRepositoryManagerPerfTest {
|
|||||||
when(repositoryHandler.getType()).thenReturn(new Type(REPOSITORY_TYPE, REPOSITORY_TYPE));
|
when(repositoryHandler.getType()).thenReturn(new Type(REPOSITORY_TYPE, REPOSITORY_TYPE));
|
||||||
Set<RepositoryHandler> handlerSet = ImmutableSet.of(repositoryHandler);
|
Set<RepositoryHandler> handlerSet = ImmutableSet.of(repositoryHandler);
|
||||||
RepositoryMatcher repositoryMatcher = new RepositoryMatcher(Collections.<RepositoryPathMatcher>emptySet());
|
RepositoryMatcher repositoryMatcher = new RepositoryMatcher(Collections.<RepositoryPathMatcher>emptySet());
|
||||||
|
NamespaceStrategy namespaceStrategy = mock(NamespaceStrategy.class);
|
||||||
repositoryManager = new DefaultRepositoryManager(
|
repositoryManager = new DefaultRepositoryManager(
|
||||||
configuration,
|
configuration,
|
||||||
contextProvider,
|
contextProvider,
|
||||||
@@ -133,9 +122,6 @@ public class DefaultRepositoryManagerPerfTest {
|
|||||||
ThreadContext.bind(securityManager);
|
ThreadContext.bind(securityManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Tear down test objects.
|
|
||||||
*/
|
|
||||||
@After
|
@After
|
||||||
public void tearDown(){
|
public void tearDown(){
|
||||||
ThreadContext.unbindSecurityManager();
|
ThreadContext.unbindSecurityManager();
|
||||||
|
|||||||
@@ -58,25 +58,11 @@ import sonia.scm.store.ConfigurationStoreFactory;
|
|||||||
import sonia.scm.store.JAXBConfigurationStoreFactory;
|
import sonia.scm.store.JAXBConfigurationStoreFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.Stack;
|
|
||||||
|
|
||||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
import static org.hamcrest.Matchers.*;
|
||||||
import static org.hamcrest.Matchers.hasProperty;
|
import static org.junit.Assert.*;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.mockito.Mockito.*;
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertNotNull;
|
|
||||||
import static org.junit.Assert.assertNotSame;
|
|
||||||
import static org.junit.Assert.assertNull;
|
|
||||||
import static org.junit.Assert.assertSame;
|
|
||||||
import static org.junit.Assert.assertThat;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
//~--- JDK imports ------------------------------------------------------------
|
//~--- JDK imports ------------------------------------------------------------
|
||||||
|
|
||||||
@@ -492,12 +478,15 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository, Re
|
|||||||
assertEquals(2, hook.eventsReceived);
|
assertEquals(2, hook.eventsReceived);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Test
|
||||||
* Tests {@link RepositoryManager#getFromTypeAndUri(String, String)}.
|
public void testNamespaceSet() throws Exception {
|
||||||
*
|
RepositoryManager repoManager = createRepositoryManager(false);
|
||||||
* @throws IOException
|
Repository repository = spy(createTestRepository());
|
||||||
* @throws RepositoryException
|
repository.setName("Testrepo");
|
||||||
*/
|
((DefaultRepositoryManager) repoManager).create(repository);
|
||||||
|
assertEquals("default_namespace", repository.getNamespace());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getRepositoryFromRequestUriTest() throws RepositoryException, IOException {
|
public void getRepositoryFromRequestUriTest() throws RepositoryException, IOException {
|
||||||
RepositoryManager m = createManager();
|
RepositoryManager m = createManager();
|
||||||
@@ -548,10 +537,11 @@ public class DefaultRepositoryManagerTest extends ManagerTestBase<Repository, Re
|
|||||||
|
|
||||||
ScmConfiguration configuration = new ScmConfiguration();
|
ScmConfiguration configuration = new ScmConfiguration();
|
||||||
|
|
||||||
NamespaceStrategy namespaceStrategy = new DefaultNamespaceStrategy();
|
|
||||||
|
|
||||||
configuration.setEnableRepositoryArchive(archiveEnabled);
|
configuration.setEnableRepositoryArchive(archiveEnabled);
|
||||||
|
|
||||||
|
NamespaceStrategy namespaceStrategy = mock(NamespaceStrategy.class);
|
||||||
|
when(namespaceStrategy.getNamespace()).thenReturn("default_namespace");
|
||||||
|
|
||||||
return new DefaultRepositoryManager(configuration, contextProvider,
|
return new DefaultRepositoryManager(configuration, contextProvider,
|
||||||
keyGenerator, repositoryDAO, handlerSet, createRepositoryMatcher(), namespaceStrategy);
|
keyGenerator, repositoryDAO, handlerSet, createRepositoryMatcher(), namespaceStrategy);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user