remove deprecated stuff

This commit is contained in:
Sebastian Sdorra
2014-01-03 10:34:34 +01:00
parent 39ad99f5e9
commit aec7773239
82 changed files with 168 additions and 10455 deletions

View File

@@ -37,7 +37,6 @@ package sonia.scm;
import sonia.scm.security.PermissionDescriptor;
import sonia.scm.user.User;
import sonia.scm.web.security.WebSecurityContext;
//~--- JDK imports ------------------------------------------------------------
@@ -66,48 +65,6 @@ public class ScmState
*/
public ScmState() {}
/**
* Constructs {@link ScmState} object.
*
*
* @param provider - context provider
* @param securityContext - security context of the current user
* @param repositoryTypes - available repository types
* @param clientConfig - client configuration
*/
@Deprecated
public ScmState(SCMContextProvider provider,
WebSecurityContext securityContext, Collection<Type> repositoryTypes,
ScmClientConfig clientConfig)
{
this(provider, securityContext, repositoryTypes, null, clientConfig);
}
/**
* Constructs {@link ScmState} object.
*
*
* @param provider - context provider
* @param securityContext - security context of the current user
* @param repositoryTypes - available repository types
* @param clientConfig - client configuration
* @param defaultUserType = Default user type
*
* @since 1.14
*/
@Deprecated
public ScmState(SCMContextProvider provider,
WebSecurityContext securityContext, Collection<Type> repositoryTypes,
String defaultUserType, ScmClientConfig clientConfig)
{
this.version = provider.getVersion();
this.user = securityContext.getUser();
this.groups = securityContext.getGroups();
this.repositoryTypes = repositoryTypes;
this.clientConfig = clientConfig;
this.defaultUserType = defaultUserType;
}
/**
* Constructs {@link ScmState} object.
*

View File

@@ -59,13 +59,6 @@ public class ServletContainerDetector
//~--- constructors ---------------------------------------------------------
/**
* Constructs a new ServletContainerDetector.
* @deprecated Use {@link ServletContainerDetector#detect(HttpServletRequest)} instead.
*/
@Deprecated
public ServletContainerDetector() {}
/**
* Constructs a new ServletContainerDetector depending on the ServletRequest.
* @param req The ServletRequest.
@@ -80,18 +73,6 @@ public class ServletContainerDetector
/**
* Detects the ServletContainer.
*
* @deprecated Use {@link ServletContainerDetector#detect(HttpServletRequest)} instead.
* @return the detected ServletContainer
*/
@Deprecated
public static ServletContainer detect()
{
return new ServletContainerDetector().detectContainer();
}
/**
* Alternate detection of ServletContainer using DefaultServletDetection.
*
* @param req The used Servlet instance.
* @return the detected ServletContainer.
* @since 1.32
@@ -211,14 +192,7 @@ public class ServletContainerDetector
{
final String value = System.getProperty("com.sun.aas.instanceRoot");
if (value != null)
{
return true;
}
else
{
return false;
}
return value != null;
}
/**
@@ -348,13 +322,14 @@ public class ServletContainerDetector
*/
private boolean detect(final String clazz)
{
boolean result = false;
try
{
final ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
systemClassLoader.loadClass(clazz);
return true;
result = true;
}
catch (final ClassNotFoundException cnfe)
{
@@ -362,13 +337,10 @@ public class ServletContainerDetector
if (classObj.getResource(clazz) != null)
{
return true;
}
else
{
return false;
result = true;
}
}
return result;
}
/**

View File

@@ -174,13 +174,6 @@ public class ScmConfiguration
this.enableRepositoryArchive = other.enableRepositoryArchive;
this.loginAttemptLimit = other.loginAttemptLimit;
this.loginAttemptLimitTimeout = other.loginAttemptLimitTimeout;
// deprecated fields
this.servername = other.servername;
this.sslPort = other.sslPort;
this.enableSSL = other.enableSSL;
this.enablePortForward = other.enablePortForward;
this.forwardPort = other.forwardPort;
}
/**
@@ -243,19 +236,6 @@ public class ScmConfiguration
return dateFormat;
}
/**
* Returns the forwarding port.
*
*
* @return forwarding port
* @deprecated use {@link #getBaseUrl()}
*/
@Deprecated
public int getForwardPort()
{
return forwardPort;
}
/**
* Returns maximum allowed login attempts.
*
@@ -362,31 +342,6 @@ public class ScmConfiguration
return proxyUser;
}
/**
* Returns the servername of the SCM-Manager host.
*
*
* @return servername of the SCM-Manager host
* @deprecated use {@link #getBaseUrl()}
*/
public String getServername()
{
return servername;
}
/**
* Returns the ssl port.
*
*
* @return ssl port
* @deprecated use {@link #getBaseUrl()} and {@link #isForceBaseUrl()}
*/
@Deprecated
public int getSslPort()
{
return sslPort;
}
/**
* Returns true if the anonymous access to the SCM-Manager is enabled.
*
@@ -409,19 +364,6 @@ public class ScmConfiguration
return disableGroupingGrid;
}
/**
* Returns true if port forwarding is enabled.
*
*
* @return true if port forwarding is enabled
* @deprecated use {@link #getBaseUrl()}
*/
@Deprecated
public boolean isEnablePortForward()
{
return enablePortForward;
}
/**
* Returns true if proxy is enabled.
*
@@ -445,19 +387,6 @@ public class ScmConfiguration
return enableRepositoryArchive;
}
/**
* Returns true if ssl is enabled.
*
*
* @return true if ssl is enabled
* @deprecated use {@link #getBaseUrl()} and {@link #isForceBaseUrl()}
*/
@Deprecated
public boolean isEnableSSL()
{
return enableSSL;
}
/**
* Returns true if force base url is enabled.
*
@@ -539,19 +468,6 @@ public class ScmConfiguration
this.disableGroupingGrid = disableGroupingGrid;
}
/**
* Method description
*
*
* @param enablePortForward
* @deprecated use {@link #setBaseUrl(String)}
*/
@Deprecated
public void setEnablePortForward(boolean enablePortForward)
{
this.enablePortForward = enablePortForward;
}
/**
* Method description
*
@@ -575,19 +491,6 @@ public class ScmConfiguration
this.enableRepositoryArchive = enableRepositoryArchive;
}
/**
* Method description
*
*
* @param enableSSL
* @deprecated use {@link #setBaseUrl(String)} and {$link #setForceBaseUrl(boolean)}
*/
@Deprecated
public void setEnableSSL(boolean enableSSL)
{
this.enableSSL = enableSSL;
}
/**
* Method description
*
@@ -600,19 +503,6 @@ public class ScmConfiguration
this.forceBaseUrl = forceBaseUrl;
}
/**
* Method description
*
*
* @param forwardPort
* @deprecated use {@link #setBaseUrl(String)}
*/
@Deprecated
public void setForwardPort(int forwardPort)
{
this.forwardPort = forwardPort;
}
/**
* Set maximum allowed login attempts.
*
@@ -709,31 +599,6 @@ public class ScmConfiguration
this.proxyUser = proxyUser;
}
/**
* Method description
*
*
* @param servername
* @deprecated use {@link #setBaseUrl(String)}
*/
public void setServername(String servername)
{
this.servername = servername;
}
/**
* Method description
*
*
* @param sslPort
* @deprecated use {@link #setBaseUrl(String)} and {@link #setForceBaseUrl(boolean)}
*/
@Deprecated
public void setSslPort(int sslPort)
{
this.sslPort = sslPort;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@@ -754,10 +619,6 @@ public class ScmConfiguration
@XmlElement(name = "force-base-url")
private boolean forceBaseUrl;
/** @deprecated use {@link #baseUrl} */
@Deprecated
private int forwardPort = 80;
/**
* Maximum allowed login attempts.
*
@@ -798,21 +659,6 @@ public class ScmConfiguration
/** Field description */
private String proxyUser;
/** @deprecated use {@link #baseUrl} */
private String servername = "localhost";
/** @deprecated use {@link #baseUrl} and {@link #forceBaseUrl} */
@Deprecated
private boolean enableSSL = false;
/** @deprecated use {@link #baseUrl} */
@Deprecated
private boolean enablePortForward = false;
/** @deprecated use {@link #baseUrl} and {@link #forceBaseUrl} */
@Deprecated
private int sslPort = 8181;
/** Configuration change listeners */
@XmlTransient
private Set<ConfigChangedListener> listeners =

View File

@@ -42,18 +42,6 @@ package sonia.scm.filter;
public class GZipFilterConfig
{
/**
* Returns true if the response should be buffered.
*
*
* @return true if the response should be buffered
* @deprecated use {@link #isBufferResponse()} instead.
*/
@Deprecated
public boolean isBufferRequest()
{
return bufferResponse;
}
/**
* Returns true if the response should be buffered.
@@ -68,19 +56,6 @@ public class GZipFilterConfig
//~--- set methods ----------------------------------------------------------
/**
* Enables or disables response buffering. Default buffering is enabled.
*
* @param bufferResponse true to enabled response buffering.
*
* @deprecated use {@link #setBufferResponse(boolean)} instead.
*/
@Deprecated
public void setBufferRequest(boolean bufferResponse)
{
this.bufferResponse = bufferResponse;
}
/**
* Enables or disables response buffering. Default buffering is enabled.
*

View File

@@ -1,230 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.plugin.ext;
//~--- non-JDK imports --------------------------------------------------------
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.util.IOUtil;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
import java.util.jar.JarEntry;
import java.util.jar.JarInputStream;
/**
*
* @author Sebastian Sdorra
* @deprecated use {@link DefaultExtensionScanner} instead
*/
@Deprecated
public class JARExtensionScanner implements ExtensionScanner
{
/** the logger for JARExtensionScanner */
private static final Logger logger =
LoggerFactory.getLogger(JARExtensionScanner.class);
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
*
* @param classLoader
* @param extensionObjects
* @param inputStream
* @param packages
*
* @throws IOException
*/
@Override
public void processExtensions(ClassLoader classLoader,
Collection<ExtensionObject> extensionObjects,
InputStream inputStream,
Collection<String> packages)
throws IOException
{
JarInputStream input = null;
try
{
input = new JarInputStream(inputStream);
JarEntry entry = input.getNextJarEntry();
while (entry != null)
{
if (!entry.isDirectory())
{
processEntry(classLoader, extensionObjects, packages, entry);
}
entry = input.getNextJarEntry();
}
}
finally
{
IOUtil.close(input);
}
}
/**
* Method description
*
*
* @param classLoader
* @param name
*
* @return
*/
private Class<?> createClass(ClassLoader classLoader, String name)
{
Class<?> clazz = null;
try
{
clazz = classLoader.loadClass(name);
}
catch (Exception ex)
{
logger.error(ex.getMessage(), ex);
}
return clazz;
}
/**
* Method description
*
*
*
* @param classLoader
* @param extensionObjects
* @param packages
* @param entry
*/
private void processEntry(ClassLoader classLoader,
Collection<ExtensionObject> extensionObjects,
Collection<String> packages, JarEntry entry)
{
String name = entry.getName();
if (name.endsWith(".class"))
{
name = getClassName(name);
if (isManagedClass(packages, name))
{
Class<?> managedClass = createClass(classLoader, name);
if (managedClass != null)
{
processManagedClass(extensionObjects, managedClass);
}
}
}
}
/**
* Method description
*
*
* @param extensionObjects
* @param managedClass
*/
private void processManagedClass(
Collection<ExtensionObject> extensionObjects, Class<?> managedClass)
{
Extension extension = managedClass.getAnnotation(Extension.class);
if (extension != null)
{
if (logger.isDebugEnabled())
{
logger.debug("found extension class {}", managedClass.getName());
}
extensionObjects.add(new ExtensionObject(extension, managedClass));
}
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param name
*
* @return
*/
private String getClassName(String name)
{
return name.replaceAll("/", ".").substring(0, name.length() - 6);
}
/**
* Method description
*
*
* @param packages
* @param name
*
* @return
*/
private boolean isManagedClass(Collection<String> packages, String name)
{
boolean result = false;
for (String pkg : packages)
{
if (name.startsWith(pkg))
{
result = true;
break;
}
}
return result;
}
}

View File

@@ -187,35 +187,6 @@ public abstract class AbstractRepositoryHandler<C extends SimpleRepositoryConfig
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param repository
*
* @return
* @since 1.8
*/
@Override
public BlameViewer getBlameViewer(Repository repository)
{
return null;
}
/**
* Method description
*
*
*
* @param repository
* @return
*/
@Override
public ChangesetViewer getChangesetViewer(Repository repository)
{
return null;
}
/**
* Method description
*
@@ -227,22 +198,6 @@ public abstract class AbstractRepositoryHandler<C extends SimpleRepositoryConfig
return config;
}
/**
* Method description
*
*
* @param repository
*
* @return
*
* @throws RepositoryException
*/
@Override
public DiffViewer getDiffViewer(Repository repository)
throws RepositoryException
{
return null;
}
/**
* Method description
@@ -259,21 +214,6 @@ public abstract class AbstractRepositoryHandler<C extends SimpleRepositoryConfig
"import handler is not supported by this repository handler");
}
/**
* Method description
*
*
* @param repository
*
* @return
* @since 1.5
*/
@Override
public RepositoryBrowser getRepositoryBrowser(Repository repository)
{
return null;
}
/**
* Returns true if the plugin is configured and enabled.
*

View File

@@ -1,162 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.SCMContextProvider;
import sonia.scm.Type;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.util.Collection;
/**
*
* @author Sebastian Sdorra
* @deprecated use {@link RepositoryManagerDecorator} instead.
*/
@Deprecated
public abstract class AbstractRepositoryManagerDecorator
implements RepositoryManager
{
/**
* Constructs ...
*
*
* @param orginal
*/
public AbstractRepositoryManagerDecorator(RepositoryManager orginal)
{
this.orginal = orginal;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param listener
*/
@Override
public void addListener(RepositoryListener listener)
{
orginal.addListener(listener);
}
/**
* Method description
*
*
* @param listeners
*/
@Override
public void addListeners(Collection<RepositoryListener> listeners)
{
orginal.addListeners(listeners);
}
/**
* Method description
*
*
* @throws IOException
*/
@Override
public void close() throws IOException
{
orginal.close();
}
/**
* Method description
*
*
* @param context
*/
@Override
public void init(SCMContextProvider context)
{
orginal.init(context);
}
/**
* Method description
*
*
* @param listener
*/
@Override
public void removeListener(RepositoryListener listener)
{
orginal.addListener(listener);
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param type
*
* @return
*/
@Override
public RepositoryHandler getHandler(String type)
{
return orginal.getHandler(type);
}
/**
* Method description
*
*
* @return
*/
@Override
public Collection<Type> getTypes()
{
return orginal.getTypes();
}
//~--- fields ---------------------------------------------------------------
/** Field description */
protected RepositoryManager orginal;
}

View File

@@ -1,71 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.api.RepositoryService;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
/**
* Interface description
*
*
* @author Sebastian Sdorra
* @since 1.8
*
* @deprecated use {@link RepositoryService#getBlameCommand()} instead.
*/
@Deprecated
public interface BlameViewer
{
/**
* Method description
*
*
* @param revision
* @param path
*
* @return
*
* @throws IOException
* @throws RepositoryException
*/
public BlameResult getBlame(String revision, String path)
throws IOException, RepositoryException;
}

View File

@@ -1,63 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.api.RepositoryService;
/**
*
* @author Sebastian Sdorra
* @since 1.8
*
* @deprecated use {@link RepositoryService#getBlameCommand()} instead.
*/
@Deprecated
public interface BlameViewerProvider
{
/**
* Method description
*
*
*
* @param repository
* @return null if BlameViewer is not supported
*
* @throws RepositoryException
*/
public BlameViewer getBlameViewer(Repository repository)
throws RepositoryException;
}

View File

@@ -1,308 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import com.google.inject.Inject;
import com.google.inject.Singleton;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.NotSupportedFeatuerException;
import sonia.scm.cache.Cache;
import sonia.scm.cache.CacheManager;
import sonia.scm.repository.api.RepositoryService;
import sonia.scm.util.AssertUtil;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
/**
* Class description
*
* @author Sebastian Sdorra
* @since 1.8
*
* @deprecated use {@link RepositoryService#getBlameCommand()} instead.
*/
@Singleton
@Deprecated
public class BlameViewerUtil extends PartCacheClearHook
{
/** Field description */
public static final String CACHE_NAME = "sonia.cache.repository.blame";
/** the logger for BlameViewerUtil */
private static final Logger logger =
LoggerFactory.getLogger(BlameViewerUtil.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*
* @param repositoryManager
* @param cacheManager
*/
@Inject
public BlameViewerUtil(RepositoryManager repositoryManager,
CacheManager cacheManager)
{
this.repositoryManager = repositoryManager;
this.cache = cacheManager.getCache(BlameViewerCacheKey.class,
BlameResult.class, CACHE_NAME);
init(repositoryManager, cache);
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param repositoryId
* @param revision
* @param path
*
* @return
*
*
* @throws IOException
* @throws NotSupportedFeatuerException
* @throws RepositoryException
*/
public BlameResult getBlame(String repositoryId, String revision, String path)
throws RepositoryException, NotSupportedFeatuerException, IOException
{
AssertUtil.assertIsNotEmpty(repositoryId);
Repository repository = repositoryManager.get(repositoryId);
if (repository == null)
{
throw new RepositoryNotFoundException(
"could not find repository with id ".concat(repositoryId));
}
return getBlame(repository, revision, path);
}
/**
* Method description
*
*
* @param repository
* @param revision
* @param path
*
* @return
*
*
* @throws IOException
* @throws NotSupportedFeatuerException
* @throws RepositoryException
*/
public BlameResult getBlame(Repository repository, String revision,
String path)
throws RepositoryException, NotSupportedFeatuerException, IOException
{
AssertUtil.assertIsNotNull(repository);
BlameViewer viewer = repositoryManager.getBlameViewer(repository);
if (viewer == null)
{
throw new NotSupportedFeatuerException(
"BlameViewer is not supported for type ".concat(
repository.getType()));
}
BlameViewerCacheKey key = new BlameViewerCacheKey(repository.getId(),
revision, path);
BlameResult result = cache.get(key);
if (result == null)
{
result = viewer.getBlame(revision, path);
cache.put(key, result);
}
else if (logger.isDebugEnabled())
{
logger.debug("fetch blameviewer results from cache");
}
return result;
}
//~--- inner classes --------------------------------------------------------
/**
* Class description
*
*
* @version Enter version here...
* @author Enter your name here...
*/
private static class BlameViewerCacheKey implements RepositoryCacheKey
{
/**
* Constructs ...
*
*
* @param repositoryId
* @param revision
* @param path
*/
public BlameViewerCacheKey(String repositoryId, String revision,
String path)
{
this.repositoryId = repositoryId;
this.revision = revision;
this.path = path;
}
//~--- methods ------------------------------------------------------------
/**
* Method description
*
*
* @param obj
*
* @return
*/
@Override
public boolean equals(Object obj)
{
if (obj == null)
{
return false;
}
if (getClass() != obj.getClass())
{
return false;
}
final BlameViewerCacheKey other = (BlameViewerCacheKey) obj;
if ((this.repositoryId == null)
? (other.repositoryId != null)
: !this.repositoryId.equals(other.repositoryId))
{
return false;
}
if ((this.revision == null)
? (other.revision != null)
: !this.revision.equals(other.revision))
{
return false;
}
if ((this.path == null)
? (other.path != null)
: !this.path.equals(other.path))
{
return false;
}
return true;
}
/**
* Method description
*
*
* @return
*/
@Override
public int hashCode()
{
int hash = 3;
hash = 53 * hash + ((this.repositoryId != null)
? this.repositoryId.hashCode()
: 0);
hash = 53 * hash + ((this.revision != null)
? this.revision.hashCode()
: 0);
hash = 53 * hash + ((this.path != null)
? this.path.hashCode()
: 0);
return hash;
}
//~--- get methods --------------------------------------------------------
/**
* Method description
*
*
* @return
*/
@Override
public String getRepositoryId()
{
return repositoryId;
}
//~--- fields -------------------------------------------------------------
/** Field description */
private String path;
/** Field description */
private String repositoryId;
/** Field description */
private String revision;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private Cache<BlameViewerCacheKey, BlameResult> cache;
/** Field description */
private RepositoryManager repositoryManager;
}

View File

@@ -1,106 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.api.RepositoryService;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
/**
*
* @author Sebastian Sdorra
*
* @deprecated use {@link RepositoryService#getLogCommand()} instead.
*/
@Deprecated
public interface ChangesetViewer
{
/**
* Method description
*
*
* @param revision
*
* @return
*
* @since 1.12
*
* @throws IOException
* @throws RepositoryException
*/
public Changeset getChangeset(String revision)
throws IOException, RepositoryException;
/**
* Method description
*
*
*
*
* @param start
* @param max
*
* @return
*
* @throws IOException
* @throws RepositoryException
*/
public ChangesetPagingResult getChangesets(int start, int max)
throws IOException, RepositoryException;
/**
* Method description
*
*
*
*
* @param path
* @param revision
* @param start
* @param max
*
* @return
*
* @throws IOException
* @throws RepositoryException
*/
public ChangesetPagingResult getChangesets(String path, String revision,
int start, int max)
throws IOException, RepositoryException;
}

View File

@@ -1,63 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.api.RepositoryService;
/**
*
* @author Sebastian Sdorra
* @since 1.8
*
* @deprecated use {@link RepositoryService#getLogCommand()} instead.
*/
@Deprecated
public interface ChangesetViewerProvider
{
/**
* Method description
*
*
*
* @param repository
* @return null if ChangesetViewer is not supported
*
* @throws RepositoryException
*/
public ChangesetViewer getChangesetViewer(Repository repository)
throws RepositoryException;
}

View File

@@ -1,679 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import com.google.inject.Inject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.NotSupportedFeatuerException;
import sonia.scm.cache.Cache;
import sonia.scm.cache.CacheManager;
import sonia.scm.repository.api.RepositoryService;
import sonia.scm.util.AssertUtil;
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.util.Arrays;
import java.util.Set;
/**
*
* @author Sebastian Sdorra
* @since 1.6
*
* @deprecated use {@link RepositoryService#getLogCommand()} instead.
*/
@Deprecated
public class ChangesetViewerUtil extends PartCacheClearHook
{
/** Field description */
public static final String CACHE_NAME = "sonia.cache.repository.changesets";
/** the logger for ChangesetViewerUtil */
private static final Logger logger =
LoggerFactory.getLogger(ChangesetViewerUtil.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*
* @param repositoryManager
* @param cacheManager
* @param changesetPreProcessorSet
* @param changesetPreProcessorFactorySet
*/
@Inject
public ChangesetViewerUtil(
RepositoryManager repositoryManager, CacheManager cacheManager,
Set<ChangesetPreProcessor> changesetPreProcessorSet,
Set<ChangesetPreProcessorFactory> changesetPreProcessorFactorySet)
{
this.repositoryManager = repositoryManager;
this.changesetPreProcessorSet = changesetPreProcessorSet;
this.changesetPreProcessorFactorySet = changesetPreProcessorFactorySet;
cache = cacheManager.getCache(ChangesetViewerCacheKey.class,
ChangesetPagingResult.class, CACHE_NAME);
init(repositoryManager, cache);
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param repository
* @param revision
*
* @return
*
* @since 1.12
*
*
* @throws IOException
* @throws NotSupportedFeatuerException
* @throws RepositoryException
*/
public Changeset getChangeset(Repository repository, String revision)
throws RepositoryException, IOException, NotSupportedFeatuerException
{
AssertUtil.assertIsNotNull(repository);
ChangesetViewer viewer = repositoryManager.getChangesetViewer(repository);
if (viewer == null)
{
throw new NotSupportedFeatuerException(
"ChangesetViewer is not supported for type ".concat(
repository.getType()));
}
Changeset changeset = null;
ChangesetViewerCacheKey key =
new ChangesetViewerCacheKey(repository.getId(), null, revision, -1, -1);
ChangesetPagingResult result = cache.get(key);
if (result == null)
{
changeset = viewer.getChangeset(revision);
if (changeset != null)
{
prepareForReturn(repository, changeset);
result = new ChangesetPagingResult(1, Arrays.asList(changeset));
cache.put(key, result);
}
else
{
throw new RepositoryException("could not find changeset");
}
}
else
{
if (logger.isDebugEnabled())
{
logger.debug("fetch changesetviewer result from cache");
}
changeset = result.getChangesets().get(0);
}
return changeset;
}
/**
* Method description
*
*
* @param repositoryId
* @param revision
*
* @return
*
* @since 1.12
*
*
* @throws IOException
* @throws NotSupportedFeatuerException
* @throws RepositoryException
* @throws RepositoryNotFoundException
*/
public Changeset getChangeset(String repositoryId, String revision)
throws RepositoryNotFoundException, IOException, RepositoryException,
NotSupportedFeatuerException
{
AssertUtil.assertIsNotEmpty(repositoryId);
Repository repository = repositoryManager.get(repositoryId);
if (repository == null)
{
throw new RepositoryNotFoundException(
"could not find repository with id ".concat(repositoryId));
}
return getChangeset(repository, revision);
}
/**
* Method description
*
*
* @param repositoryId
* @param start
* @param max
*
* @return
*
*
* @throws IOException
* @throws NotSupportedFeatuerException
* @throws RepositoryException
*/
public ChangesetPagingResult getChangesets(String repositoryId, int start,
int max)
throws IOException, RepositoryException, NotSupportedFeatuerException
{
AssertUtil.assertIsNotEmpty(repositoryId);
Repository repository = repositoryManager.get(repositoryId);
if (repository == null)
{
throw new RepositoryNotFoundException(
"could not find repository with id ".concat(repositoryId));
}
return getChangesets(repository, start, max);
}
/**
* Method description
*
*
* @param repositoryId
* @param path
* @param revision
* @param start
* @param max
*
* @return
*
*
* @throws IOException
* @throws NotSupportedFeatuerException
* @throws RepositoryException
*/
public ChangesetPagingResult getChangesets(String repositoryId, String path,
String revision, int start, int max)
throws IOException, RepositoryException, NotSupportedFeatuerException
{
AssertUtil.assertIsNotEmpty(repositoryId);
Repository repository = repositoryManager.get(repositoryId);
if (repository == null)
{
throw new RepositoryNotFoundException(
"could not find repository with id ".concat(repositoryId));
}
return getChangesets(repository, path, revision, start, max);
}
/**
* Method description
*
*
* @param repository
* @param start
* @param max
*
* @return
*
*
* @throws IOException
* @throws NotSupportedFeatuerException
* @throws RepositoryException
*/
public ChangesetPagingResult getChangesets(Repository repository, int start,
int max)
throws IOException, RepositoryException, NotSupportedFeatuerException
{
AssertUtil.assertIsNotNull(repository);
ChangesetViewer viewer = repositoryManager.getChangesetViewer(repository);
if (viewer == null)
{
throw new NotSupportedFeatuerException(
"ChangesetViewer is not supported for type ".concat(
repository.getType()));
}
ChangesetViewerCacheKey key =
new ChangesetViewerCacheKey(repository.getId(), start, max);
ChangesetPagingResult result = cache.get(key);
if (result == null)
{
result = viewer.getChangesets(start, max);
if (result != null)
{
if (Util.isNotEmpty(result.getChangesets()))
{
prepareForReturn(repository, result);
}
cache.put(key, result);
}
else
{
throw new RepositoryException("could not fetch changesets");
}
}
else if (logger.isDebugEnabled())
{
logger.debug("fetch changesetviewer results from cache");
}
return result;
}
/**
* Method description
*
*
* @param repository
* @param path
* @param revision
* @param start
* @param max
*
* @return
*
*
* @throws IOException
* @throws NotSupportedFeatuerException
* @throws RepositoryException
*/
public ChangesetPagingResult getChangesets(Repository repository,
String path, String revision, int start, int max)
throws IOException, RepositoryException, NotSupportedFeatuerException
{
AssertUtil.assertIsNotNull(repository);
ChangesetViewer viewer = repositoryManager.getChangesetViewer(repository);
if (viewer == null)
{
throw new NotSupportedFeatuerException(
"ChangesetViewer is not supported for type ".concat(
repository.getType()));
}
ChangesetViewerCacheKey key =
new ChangesetViewerCacheKey(repository.getId(), path, revision, start,
max);
ChangesetPagingResult result = cache.get(key);
if (result == null)
{
result = viewer.getChangesets(path, revision, start, max);
if (result != null)
{
if (Util.isNotEmpty(result.getChangesets()))
{
prepareForReturn(repository, result);
}
cache.put(key, result);
}
else
{
throw new RepositoryException("could not fetch changesets");
}
}
else if (logger.isDebugEnabled())
{
logger.debug("fetch changesetviewer results from cache");
}
return result;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
*
* @param repository
* @param changesets
*/
private void callPreProcessorFactories(Repository repository,
ChangesetPagingResult changesets)
{
if (Util.isNotEmpty(changesetPreProcessorFactorySet))
{
for (ChangesetPreProcessorFactory factory :
changesetPreProcessorFactorySet)
{
ChangesetPreProcessor cpp = factory.createPreProcessor(repository);
if (cpp != null)
{
for (Changeset c : changesets.getChangesets())
{
cpp.process(c);
}
}
}
}
}
/**
* Method description
*
*
* @param repository
* @param c
*/
private void callPreProcessorFactories(Repository repository, Changeset c)
{
if (Util.isNotEmpty(changesetPreProcessorFactorySet))
{
for (ChangesetPreProcessorFactory factory :
changesetPreProcessorFactorySet)
{
ChangesetPreProcessor cpp = factory.createPreProcessor(repository);
if (cpp != null)
{
cpp.process(c);
}
}
}
}
/**
* Method description
*
*
* @param changesets
*/
private void callPreProcessors(ChangesetPagingResult changesets)
{
if (Util.isNotEmpty(changesetPreProcessorSet))
{
for (Changeset c : changesets.getChangesets())
{
callPreProcessors(c);
}
}
}
/**
* Method description
*
*
* @param c
*/
private void callPreProcessors(Changeset c)
{
for (ChangesetPreProcessor cpp : changesetPreProcessorSet)
{
cpp.process(c);
}
}
/**
* Method description
*
*
* @param repository
* @param result
*/
private void prepareForReturn(Repository repository,
ChangesetPagingResult result)
{
EscapeUtil.escape(result);
callPreProcessors(result);
callPreProcessorFactories(repository, result);
}
/**
* Method description
*
*
* @param repository
* @param changeset
*/
private void prepareForReturn(Repository repository, Changeset changeset)
{
EscapeUtil.escape(changeset);
callPreProcessors(changeset);
callPreProcessorFactories(repository, changeset);
}
//~--- inner classes --------------------------------------------------------
/**
* Class description
*
*
* @version Enter version here..., 11/07/24
* @author Enter your name here...
*/
private class ChangesetViewerCacheKey implements RepositoryCacheKey
{
/**
* Constructs ...
*
*
* @param repository
* @param start
* @param max
*/
public ChangesetViewerCacheKey(String repository, int start, int max)
{
this(repository, null, null, start, max);
}
/**
* Constructs ...
*
*
* @param repository
* @param path
* @param revision
* @param start
* @param max
*/
public ChangesetViewerCacheKey(String repository, String path,
String revision, int start, int max)
{
this.repository = repository;
this.path = path;
this.revision = revision;
this.start = start;
this.max = max;
}
//~--- methods ------------------------------------------------------------
/**
* Method description
*
*
* @param obj
*
* @return
*/
@Override
public boolean equals(Object obj)
{
if (obj == null)
{
return false;
}
if (getClass() != obj.getClass())
{
return false;
}
final ChangesetViewerCacheKey other = (ChangesetViewerCacheKey) obj;
if ((this.revision == null)
? (other.revision != null)
: !this.revision.equals(other.revision))
{
return false;
}
if (this.max != other.max)
{
return false;
}
if ((this.path == null)
? (other.path != null)
: !this.path.equals(other.path))
{
return false;
}
if ((this.repository == null)
? (other.repository != null)
: !this.repository.equals(other.repository))
{
return false;
}
if (this.start != other.start)
{
return false;
}
return true;
}
/**
* Method description
*
*
* @return
*/
@Override
public int hashCode()
{
int hash = 5;
hash = 47 * hash + ((this.revision != null)
? this.revision.hashCode()
: 0);
hash = 47 * hash + this.max;
hash = 47 * hash + ((this.path != null)
? this.path.hashCode()
: 0);
hash = 47 * hash + ((this.repository != null)
? this.repository.hashCode()
: 0);
hash = 47 * hash + this.start;
return hash;
}
//~--- get methods --------------------------------------------------------
/**
* Method description
*
*
* @return
*/
@Override
public String getRepositoryId()
{
return repository;
}
//~--- fields -------------------------------------------------------------
/** Field description */
private int max;
/** Field description */
private String path;
/** Field description */
private String repository;
/** Field description */
private String revision;
/** Field description */
private int start;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private Cache<ChangesetViewerCacheKey, ChangesetPagingResult> cache;
/** Field description */
private Set<ChangesetPreProcessorFactory> changesetPreProcessorFactorySet;
/** Field description */
private Set<ChangesetPreProcessor> changesetPreProcessorSet;
/** Field description */
private RepositoryManager repositoryManager;
}

View File

@@ -1,66 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.repository;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.io.OutputStream;
import sonia.scm.repository.api.RepositoryService;
/**
*
* @author Sebastian Sdorra
* @since 1.8
*
* @deprecated use {@link RepositoryService#getDiffCommand()} instead.
*/
@Deprecated
public interface DiffViewer
{
/**
* Method description
*
*
* @param revision
* @param path
* @param output
*
* @throws IOException
* @throws RepositoryException
*/
public void getDiff(String revision, String path, OutputStream output)
throws IOException, RepositoryException;
}

View File

@@ -1,63 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.api.RepositoryService;
/**
*
* @author Sebastian Sdorra
* @since 1.8
*
* @deprecated use {@link RepositoryService#getDiffCommand()} instead.
*/
@Deprecated
public interface DiffViewerProvider
{
/**
* Method description
*
*
*
* @param repository
* @return null if DiffViewer is not supported
*
* @throws RepositoryException
*/
public DiffViewer getDiffViewer(Repository repository)
throws RepositoryException;
}

View File

@@ -48,7 +48,6 @@ import sonia.scm.security.RepositoryPermission;
import sonia.scm.security.Role;
import sonia.scm.security.ScmSecurityException;
import sonia.scm.util.AssertUtil;
import sonia.scm.web.security.WebSecurityContext;
/**
*
@@ -73,93 +72,6 @@ public final class PermissionUtil
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param repository
* @param securityContext
* @param pt
* @deprecated
*/
@Deprecated
public static void assertPermission(Repository repository,
WebSecurityContext securityContext, PermissionType pt)
{
assertPermission(repository, pt);
}
/**
* Method description
*
*
* @param repository
* @param securityContextProvider
* @param pt
*/
@Deprecated
public static void assertPermission(Repository repository,
Provider<WebSecurityContext> securityContextProvider, PermissionType pt)
{
assertPermission(repository, securityContextProvider.get(), pt);
}
/**
* Method description
*
*
* @param repository
* @param pt
*
* @since 1.21
*/
@Deprecated
public static void assertPermission(Repository repository, PermissionType pt)
{
if (!hasPermission(null, repository, pt))
{
throw new ScmSecurityException("action denied");
}
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param repository
* @param securityContextProvider
* @param pt
*
* @return
* @deprecated
*/
@Deprecated
public static boolean hasPermission(Repository repository,
Provider<WebSecurityContext> securityContextProvider, PermissionType pt)
{
return hasPermission(null, repository, pt);
}
/**
* Method description
*
*
* @param repository
* @param securityContext
* @param pt
*
* @return
* @deprecated use {@link #hasPermission(ScmConfiguration, Repository, PermissionType)} instead
*/
@Deprecated
public static boolean hasPermission(Repository repository,
WebSecurityContext securityContext, PermissionType pt)
{
return hasPermission(null, repository, pt);
}
/**
* Method description
*
@@ -207,25 +119,6 @@ public final class PermissionUtil
return result;
}
/**
* Returns true if the repository is writable.
*
*
* @param configuration SCM-Manager main configuration
* @param repository repository to check
* @param securityContext current user security context
*
* @return true if the repository is writable
* @since 1.14
* @deprecated use {@link #isWritable(ScmConfiguration, Repository)} instead
*/
@Deprecated
public static boolean isWritable(ScmConfiguration configuration,
Repository repository, WebSecurityContext securityContext)
{
return isWritable(configuration, repository);
}
/**
* Returns true if the repository is writable.
*

View File

@@ -160,7 +160,6 @@ public class Repository extends BasicPropertiesAware implements ModelObject
repository.setLastModified(lastModified);
repository.setDescription(description);
repository.setPermissions(permissions);
repository.setUrl(url);
repository.setPublicReadable(publicReadable);
repository.setArchived(archived);
}
@@ -213,7 +212,6 @@ public class Repository extends BasicPropertiesAware implements ModelObject
&& Objects.equal(archived, other.archived)
&& Objects.equal(permissions, other.permissions)
&& Objects.equal(type, other.type)
&& Objects.equal(url, other.url)
&& Objects.equal(creationDate, other.creationDate)
&& Objects.equal(lastModified, other.lastModified)
&& Objects.equal(properties, other.properties);
@@ -230,7 +228,7 @@ public class Repository extends BasicPropertiesAware implements ModelObject
public int hashCode()
{
return Objects.hashCode(id, name, contact, description, publicReadable,
archived, permissions, type, url, creationDate, lastModified, properties);
archived, permissions, type, creationDate, lastModified, properties);
}
/**
@@ -252,7 +250,6 @@ public class Repository extends BasicPropertiesAware implements ModelObject
.add("archived", archived)
.add("permissions", permissions)
.add("type", type)
.add("url", url)
.add("lastModified", lastModified)
.add("creationDate", creationDate)
.add("properties", properties)
@@ -359,19 +356,6 @@ public class Repository extends BasicPropertiesAware implements ModelObject
return type;
}
/**
* Returns the base url of the {@link Repository}.
*
*
* @return base url
* @deprecated use {@link #createUrl(String)}
*/
@Deprecated
public String getUrl()
{
return url;
}
/**
* Returns true if the repository is archived.
*
@@ -529,19 +513,6 @@ public class Repository extends BasicPropertiesAware implements ModelObject
this.type = type;
}
/**
* Sets the base url of the {@link Repository}
*
*
* @param url base url
* @deprecated
*/
@Deprecated
public void setUrl(String url)
{
this.url = url;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
@@ -574,9 +545,4 @@ public class Repository extends BasicPropertiesAware implements ModelObject
/** Field description */
private String type;
/**
* @deprecated use {@link #createUrl(java.lang.String)} instead
*/
private String url;
}

View File

@@ -1,85 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.api.RepositoryService;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.io.OutputStream;
/**
*
* @author Sebastian Sdorra
* @since 1.5
*
* @deprecated use {@link RepositoryService#getBrowseCommand()} instead.
*/
@Deprecated
public interface RepositoryBrowser
{
/**
* Method description
*
*
* @param revision
* @param path
* @param output
*
*
* @throws IOException
* @throws RepositoryException
*/
public void getContent(String revision, String path, OutputStream output)
throws IOException, RepositoryException;
/**
* Method description
*
*
* @param revision
* @param path
*
* @return
*
* @throws IOException
* @throws RepositoryException
*/
public BrowserResult getResult(String revision, String path)
throws IOException, RepositoryException;
}

View File

@@ -1,63 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.repository.api.RepositoryService;
/**
*
* @author Sebastian Sdorra
* @since 1.5
*
* @deprecated use {@link RepositoryService#getBrowseCommand()} instead.
*/
@Deprecated
public interface RepositoryBrowserProvider
{
/**
* Method description
*
*
* @param repository
*
* @return null if RepositoryBrowser is not supported
*
* @throws RepositoryException
*/
public RepositoryBrowser getRepositoryBrowser(Repository repository)
throws RepositoryException;
}

View File

@@ -1,419 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import com.google.inject.Inject;
import com.google.inject.Singleton;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.NotSupportedFeatuerException;
import sonia.scm.cache.Cache;
import sonia.scm.cache.CacheManager;
import sonia.scm.repository.api.RepositoryService;
import sonia.scm.util.AssertUtil;
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Set;
/**
*
* @author Sebastian Sdorra
* @since 1.6
*
* @deprecated use {@link RepositoryService#getBrowseCommand()} instead.
*/
@Singleton
@Deprecated
public class RepositoryBrowserUtil extends PartCacheClearHook
{
/** Field description */
public static final String CACHE_NAME = "sonia.cache.repository.browser";
/** the logger for RepositoryBrowserUtil */
private static final Logger logger =
LoggerFactory.getLogger(RepositoryBrowserUtil.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*
* @param repositoryManager
* @param cacheManager
* @param preProcessorSet
* @param preProcessorFactorySet
*/
@Inject
public RepositoryBrowserUtil(
RepositoryManager repositoryManager, CacheManager cacheManager,
Set<FileObjectPreProcessor> preProcessorSet,
Set<FileObjectPreProcessorFactory> preProcessorFactorySet)
{
this.repositoryManager = repositoryManager;
this.cache = cacheManager.getCache(RepositoryBrowserCacheKey.class,
BrowserResult.class, CACHE_NAME);
this.preProcessorSet = preProcessorSet;
this.preProcessorFactorySet = preProcessorFactorySet;
init(repositoryManager, cache);
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param repositoryId
* @param revision
* @param path
*
* @return
*
* @throws IOException
* @throws NotSupportedFeatuerException
* @throws RepositoryException
*/
public BrowserResult getResult(String repositoryId, String revision,
String path)
throws RepositoryException, NotSupportedFeatuerException, IOException
{
AssertUtil.assertIsNotEmpty(repositoryId);
Repository repository = repositoryManager.get(repositoryId);
if (repository == null)
{
throw new RepositoryNotFoundException(
"could not find repository with id ".concat(repositoryId));
}
return getResult(repository, revision, path);
}
/**
* Method description
*
*
* @param repository
* @param revision
* @param path
*
* @return
*
* @throws IOException
* @throws NotSupportedFeatuerException
* @throws RepositoryException
*/
public BrowserResult getResult(Repository repository, String revision,
String path)
throws RepositoryException, NotSupportedFeatuerException, IOException
{
AssertUtil.assertIsNotNull(repository);
RepositoryBrowser browser =
repositoryManager.getRepositoryBrowser(repository);
if (browser == null)
{
throw new NotSupportedFeatuerException(
"RepositoryBrowser is not supported for type ".concat(
repository.getType()));
}
RepositoryBrowserCacheKey key =
new RepositoryBrowserCacheKey(repository.getId(), revision, path);
BrowserResult result = cache.get(key);
if (result == null)
{
result = browser.getResult(revision, path);
if (result != null)
{
sort(result);
EscapeUtil.escape(result);
callPreProcessors(result);
callPreProcessorFactories(repository, result);
}
else
{
result = new BrowserResult();
}
cache.put(key, result);
}
else if (logger.isDebugEnabled())
{
logger.debug("fetch repositorybrowser results from cache");
}
return result;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param fopp
* @param result
*/
private void callPreProcessor(FileObjectPreProcessor fopp,
BrowserResult result)
{
if (fopp != null)
{
List<FileObject> foList = result.getFiles();
if (Util.isNotEmpty(foList))
{
for (FileObject fo : foList)
{
fopp.process(fo);
}
}
}
}
/**
* Method description
*
*
*
* @param repository
* @param result
*/
private void callPreProcessorFactories(Repository repository,
BrowserResult result)
{
if (Util.isNotEmpty(preProcessorFactorySet))
{
for (FileObjectPreProcessorFactory factory : preProcessorFactorySet)
{
FileObjectPreProcessor fopp = factory.createPreProcessor(repository);
callPreProcessor(fopp, result);
}
}
}
/**
* Method description
*
*
*
* @param result
*/
private void callPreProcessors(BrowserResult result)
{
if (Util.isNotEmpty(preProcessorSet))
{
for (FileObjectPreProcessor fopp : preProcessorSet)
{
callPreProcessor(fopp, result);
}
}
}
/**
* Method description
*
*
* @param result
*/
private void sort(BrowserResult result)
{
List<FileObject> files = result.getFiles();
if (files != null)
{
Collections.sort(files, FileObjectNameComparator.instance);
}
}
//~--- inner classes --------------------------------------------------------
/**
* Class description
*
*
* @version Enter version here..., 11/08/03
* @author Enter your name here...
*/
private static class RepositoryBrowserCacheKey implements RepositoryCacheKey
{
/**
* Constructs ...
*
*
* @param repositoryId
* @param revision
* @param path
*/
public RepositoryBrowserCacheKey(String repositoryId, String revision,
String path)
{
this.repositoryId = repositoryId;
this.revision = revision;
this.path = path;
}
//~--- methods ------------------------------------------------------------
/**
* Method description
*
*
* @param obj
*
* @return
*/
@Override
public boolean equals(Object obj)
{
if (obj == null)
{
return false;
}
if (getClass() != obj.getClass())
{
return false;
}
final RepositoryBrowserCacheKey other = (RepositoryBrowserCacheKey) obj;
if ((this.repositoryId == null)
? (other.repositoryId != null)
: !this.repositoryId.equals(other.repositoryId))
{
return false;
}
if ((this.revision == null)
? (other.revision != null)
: !this.revision.equals(other.revision))
{
return false;
}
if ((this.path == null)
? (other.path != null)
: !this.path.equals(other.path))
{
return false;
}
return true;
}
/**
* Method description
*
*
* @return
*/
@Override
public int hashCode()
{
int hash = 3;
hash = 53 * hash + ((this.repositoryId != null)
? this.repositoryId.hashCode()
: 0);
hash = 53 * hash + ((this.revision != null)
? this.revision.hashCode()
: 0);
hash = 53 * hash + ((this.path != null)
? this.path.hashCode()
: 0);
return hash;
}
//~--- get methods --------------------------------------------------------
/**
* Method description
*
*
* @return
*/
@Override
public String getRepositoryId()
{
return repositoryId;
}
//~--- fields -------------------------------------------------------------
/** Field description */
private String path;
/** Field description */
private String repositoryId;
/** Field description */
private String revision;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private Cache<RepositoryBrowserCacheKey, BrowserResult> cache;
/** Field description */
private Set<FileObjectPreProcessorFactory> preProcessorFactorySet;
/** Field description */
private Set<FileObjectPreProcessor> preProcessorSet;
/** Field description */
private RepositoryManager repositoryManager;
}

View File

@@ -50,9 +50,7 @@ import sonia.scm.plugin.ExtensionPoint;
@ExtensionPoint
public interface RepositoryHandler
extends Handler<Repository, RepositoryException>,
ListenerSupport<ConfigChangedListener>,
RepositoryBrowserProvider, ChangesetViewerProvider,
DiffViewerProvider, BlameViewerProvider
ListenerSupport<ConfigChangedListener>
{
/**

View File

@@ -57,9 +57,8 @@ import javax.servlet.http.HttpServletRequest;
*/
public interface RepositoryManager
extends TypeManager<Repository, RepositoryException>,
ListenerSupport<RepositoryListener>, RepositoryBrowserProvider,
RepositoryHookSupport, ChangesetViewerProvider,
BlameViewerProvider, DiffViewerProvider
ListenerSupport<RepositoryListener>,
RepositoryHookSupport
{
/**

View File

@@ -37,7 +37,6 @@ package sonia.scm.repository;
import sonia.scm.ManagerDecorator;
import sonia.scm.Type;
import sonia.scm.group.GroupManager;
//~--- JDK imports ------------------------------------------------------------
@@ -223,39 +222,6 @@ public class RepositoryManagerDecorator
return decorated.get(type, name);
}
/**
* {@inheritDoc}
*
*
* @param repository
*
* @return
*
* @throws RepositoryException
*/
@Override
public BlameViewer getBlameViewer(Repository repository)
throws RepositoryException
{
return decorated.getBlameViewer(repository);
}
/**
* {@inheritDoc}
*
*
* @param repository
*
* @return
*
* @throws RepositoryException
*/
@Override
public ChangesetViewer getChangesetViewer(Repository repository)
throws RepositoryException
{
return decorated.getChangesetViewer(repository);
}
/**
* {@inheritDoc}
@@ -282,22 +248,6 @@ public class RepositoryManagerDecorator
return decorated;
}
/**
* {@inheritDoc}
*
*
* @param repository
*
* @return
*
* @throws RepositoryException
*/
@Override
public DiffViewer getDiffViewer(Repository repository)
throws RepositoryException
{
return decorated.getDiffViewer(repository);
}
/**
* {@inheritDoc}
@@ -356,22 +306,6 @@ public class RepositoryManagerDecorator
return decorated.getHandler(type);
}
/**
* {@inheritDoc}
*
*
* @param repository
*
* @return
*
* @throws RepositoryException
*/
@Override
public RepositoryBrowser getRepositoryBrowser(Repository repository)
throws RepositoryException
{
return decorated.getRepositoryBrowser(repository);
}
/**
* {@inheritDoc}
@@ -388,5 +322,5 @@ public class RepositoryManagerDecorator
//~--- fields ---------------------------------------------------------------
/** Field description */
private RepositoryManager decorated;
private final RepositoryManager decorated;
}

View File

@@ -76,57 +76,6 @@ public final class RepositoryUtil
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param configuration
* @param repositoryManager
* @param repository
*
* @since 1.16
*/
public static void appendUrl(ScmConfiguration configuration,
RepositoryManager repositoryManager, Repository repository)
{
RepositoryHandler handler =
repositoryManager.getHandler(repository.getType());
if (handler != null)
{
String url = handler.createResourcePath(repository);
url = HttpUtil.getCompleteUrl(configuration, url);
repository.setUrl(url);
}
}
/**
* Method description
*
*
*
* @param request
* @param repositoryManager
* @param repository
*
* @since 1.16
*/
public static void appendUrl(HttpServletRequest request,
RepositoryManager repositoryManager, Repository repository)
{
RepositoryHandler handler =
repositoryManager.getHandler(repository.getType());
if (handler != null)
{
String url = handler.createResourcePath(repository);
url = HttpUtil.getCompleteUrl(request, url);
repository.setUrl(url);
}
}
/**
* Method description
*

View File

@@ -123,26 +123,6 @@ public final class RepositoryServiceFactory
//~--- constructors ---------------------------------------------------------
/**
* Constructs a new {@link RepositoryServiceFactory}. This constructor
* should not be called manually, it should only be used by the injection
* container.
*
* @param cacheManager cache manager
* @param repositoryManager manager for repositories
* @param resolvers a set of {@link RepositoryServiceResolver}
* @param preProcessorUtil helper object for pre processor handling
*
* @deprecated
*/
@Deprecated
public RepositoryServiceFactory(CacheManager cacheManager,
RepositoryManager repositoryManager,
Set<RepositoryServiceResolver> resolvers, PreProcessorUtil preProcessorUtil)
{
this(null, cacheManager, repositoryManager, resolvers, preProcessorUtil);
}
/**
* Constructs a new {@link RepositoryServiceFactory}. This constructor
* should not be called manually, it should only be used by the injection

View File

@@ -1,149 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.security;
//~--- non-JDK imports --------------------------------------------------------
import org.apache.shiro.crypto.hash.SimpleHash;
/**
*
* @author Sebastian Sdorra
* @since 1.13
* @deprecated use {@link SimpleHash} instead.
*/
@Deprecated
public interface HashBuilder
{
/**
* Method description
*
*
* @return
*/
public HashBuilder appendSalt();
/**
* Method description
*
*
* @return
*/
public HashBuilder createSalt();
/**
* Method description
*
*
* @param length
*
* @return
*/
public HashBuilder createSalt(int length);
/**
* Method description
*
*
* @return
*/
public HashBuilder enableLabel();
/**
* Method description
*
*
* @return
*/
public byte[] toByteArray();
/**
* Method description
*
*
* @return
*/
public String toHexString();
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public String getHexSalt();
/**
* Method description
*
*
* @return
*/
public byte[] getSalt();
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param iterations
*
* @return
*/
public HashBuilder setIterations(int iterations);
/**
* Method description
*
*
* @param salt
*
* @return
*/
public HashBuilder setSalt(byte[] salt);
/**
* Method description
*
*
* @param value
*
* @return
*/
public HashBuilder setValue(String value);
}

View File

@@ -1,130 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.security;
//~--- non-JDK imports --------------------------------------------------------
import org.apache.shiro.crypto.hash.Md5Hash;
/**
*
* @author Sebastian Sdorra
* @since 1.13
* @deprecated use {@link Md5Hash} instead.
*/
@Deprecated
public class MD5HashBuilder extends MessageDigestHashBuilder
{
/** Field description */
public static final String DIGEST = "MD5";
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
public MD5HashBuilder()
{
super(DIGEST, null, null, 0, false, false);
}
/**
* Constructs ...
*
*
* @param value
*/
public MD5HashBuilder(String value)
{
super(DIGEST, value, null, 0, false, false);
}
/**
* Constructs ...
*
*
* @param value
* @param salt
*/
public MD5HashBuilder(String value, byte[] salt)
{
super(DIGEST, value, salt, 0, false, false);
}
/**
* Constructs ...
*
*
* @param value
* @param salt
* @param iterations
*/
public MD5HashBuilder(String value, byte[] salt, int iterations)
{
super(DIGEST, value, salt, iterations, false, false);
}
/**
* Constructs ...
*
*
* @param value
* @param salt
* @param iterations
* @param appendSalt
*/
public MD5HashBuilder(String value, byte[] salt, int iterations,
boolean appendSalt)
{
super(DIGEST, value, salt, iterations, appendSalt, false);
}
/**
* Constructs ...
*
*
* @param value
* @param salt
* @param iterations
* @param appendSalt
* @param enableLabel
*/
public MD5HashBuilder(String value, byte[] salt, int iterations,
boolean appendSalt, boolean enableLabel)
{
super(DIGEST, value, salt, iterations, appendSalt, enableLabel);
}
}

View File

@@ -1,501 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.security;
//~--- non-JDK imports --------------------------------------------------------
import org.apache.shiro.crypto.hash.SimpleHash;
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*
* @author Sebastian Sdorra
* @since 1.13
* @deprecated use {@link SimpleHash} instead.
*/
@Deprecated
public class MessageDigestHashBuilder implements HashBuilder
{
/** Field description */
public static final int DEFAULT_SALT_LENGTH = 8;
/** Field description */
public static final String ENCODING = "UTF-8";
/** Field description */
public static final String RANDOM_INSTANCE = "SHA1PRNG";
/** Field description */
private static Pattern PATTERN = Pattern.compile("\\{([^\\}]+)\\}(.*)");
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*
* @param digest
* @param value
* @param salt
* @param iterations
* @param appendSalt
* @param enableLabel
*/
public MessageDigestHashBuilder(String digest, String value, byte[] salt,
int iterations, boolean appendSalt, boolean enableLabel)
{
this.digest = digest;
this.value = value;
this.salt = salt;
this.iterations = iterations;
this.appendSalt = appendSalt;
this.enableLable = enableLabel;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param hash
*
* @return
*/
public static Extractor createExtractor(String hash)
{
return new Extractor(hash);
}
/**
* Method description
*
*
* @return
*/
@Override
public HashBuilder appendSalt()
{
this.appendSalt = true;
return this;
}
/**
* Method description
*
*
* @return
*/
@Override
public HashBuilder createSalt()
{
return createSalt(DEFAULT_SALT_LENGTH);
}
/**
* Method description
*
*
* @param length
*
* @return
*/
@Override
public HashBuilder createSalt(int length)
{
try
{
SecureRandom random = SecureRandom.getInstance(RANDOM_INSTANCE);
this.salt = new byte[length];
random.nextBytes(salt);
}
catch (NoSuchAlgorithmException ex)
{
throw new SecurityException("could not find secure random instance");
}
return this;
}
/**
* Method description
*
*
* @return
*/
@Override
public HashBuilder enableLabel()
{
this.enableLable = true;
return this;
}
/**
* Method description
*
*
* @return
*/
@Override
public byte[] toByteArray()
{
byte[] input = null;
try
{
MessageDigest md = MessageDigest.getInstance(digest);
md.reset();
if (salt != null)
{
md.update(salt);
}
input = md.digest(value.getBytes(ENCODING));
if (iterations > 0)
{
for (int i = 0; i < iterations; i++)
{
md.reset();
input = md.digest(input);
}
}
if ((salt != null) && appendSalt)
{
byte[] content = new byte[input.length + salt.length];
System.arraycopy(input, 0, content, 0, input.length);
System.arraycopy(salt, 0, content, input.length, salt.length);
input = content;
}
}
catch (UnsupportedEncodingException ex)
{
throw new SecurityException("unknown encoding", ex);
}
catch (NoSuchAlgorithmException ex)
{
throw new SecurityException("unknown digest", ex);
}
return input;
}
/**
* Method description
*
*
* @return
*/
@Override
public String toHexString()
{
String hexString = null;
if (enableLable)
{
StringBuilder buffer = new StringBuilder();
buffer.append("{").append(digest).append("}");
buffer.append(Util.toString(toByteArray()));
hexString = buffer.toString();
}
else
{
hexString = Util.toString(toByteArray());
}
return hexString;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
@Override
public String getHexSalt()
{
String hexSalt = null;
if (salt != null)
{
hexSalt = Util.toString(salt);
}
return hexSalt;
}
/**
* Method description
*
*
* @return
*/
@Override
public byte[] getSalt()
{
return salt;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param iterations
*
* @return
*/
@Override
public HashBuilder setIterations(int iterations)
{
this.iterations = iterations;
return this;
}
/**
* Method description
*
*
* @param salt
*
* @return
*/
@Override
public HashBuilder setSalt(byte[] salt)
{
this.salt = salt;
return this;
}
/**
* Method description
*
*
* @param value
*
* @return
*/
@Override
public HashBuilder setValue(String value)
{
this.value = value;
return this;
}
//~--- inner classes --------------------------------------------------------
/**
* Class description
*
*
* @version Enter version here..., 12/02/17
* @author Enter your name here...
*/
public static class Extractor
{
/**
* Constructs ...
*
*
* @param hash
*/
public Extractor(String hash)
{
this.hash = hash;
}
//~--- get methods --------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public MessageDigestHashBuilder getHashBuilder()
{
return getHashBuilder(-1);
}
/**
* Method description
*
*
* @param saltLength
*
* @return
*/
public MessageDigestHashBuilder getHashBuilder(int saltLength)
{
MessageDigestHashBuilder hashBuilder = null;
Matcher m = PATTERN.matcher(hash);
if (m.matches())
{
String digest = m.group(1);
if (digest != null)
{
byte[] salt = null;
if (saltLength > 0)
{
String hashWithoutPrefix = m.group(2);
salt = getSalt(hashWithoutPrefix, saltLength);
}
hashBuilder = new MessageDigestHashBuilder(digest, null, salt, 0,
salt != null, true);
}
}
return hashBuilder;
}
/**
* Method description
*
*
* @return
*/
public String getLabel()
{
String label = null;
Matcher m = PATTERN.matcher(hash);
if (m.matches())
{
label = m.group(1);
}
return label;
}
/**
* Method description
*
*
* @param length
*
* @return
*/
public byte[] getSalt(int length)
{
Matcher m = PATTERN.matcher(hash);
String hashWithoutPrefix = hash;
if (m.matches())
{
hashWithoutPrefix = m.group(2);
}
return getSalt(hashWithoutPrefix, length);
}
/**
* Method description
*
*
* @param hashWithoutPrefix
* @param length
*
* @return
*/
private byte[] getSalt(String hashWithoutPrefix, int length)
{
byte[] content = Util.fromHexString(hashWithoutPrefix);
byte[] salt = new byte[length];
System.arraycopy(content, content.length - length, salt, 0, length);
return salt;
}
//~--- fields -------------------------------------------------------------
/** Field description */
private String hash;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private boolean appendSalt;
/** Field description */
private String digest;
/** Field description */
private boolean enableLable;
/** Field description */
private int iterations;
/** Field description */
private byte[] salt;
/** Field description */
private String value;
}

View File

@@ -1,130 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.security;
//~--- non-JDK imports --------------------------------------------------------
import org.apache.shiro.crypto.hash.Sha1Hash;
/**
*
* @author Sebastian Sdorra
* @since 1.13
* @deprecated use {@link Sha1Hash} instead.
*/
@Deprecated
public class SHA1HashBuilder extends MessageDigestHashBuilder
{
/** Field description */
public static final String DIGEST = "SHA-1";
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
public SHA1HashBuilder()
{
super(DIGEST, null, null, 0, false, false);
}
/**
* Constructs ...
*
*
* @param value
*/
public SHA1HashBuilder(String value)
{
super(DIGEST, value, null, 0, false, false);
}
/**
* Constructs ...
*
*
* @param value
* @param salt
*/
public SHA1HashBuilder(String value, byte[] salt)
{
super(DIGEST, value, salt, 0, false, false);
}
/**
* Constructs ...
*
*
* @param value
* @param salt
* @param iterations
*/
public SHA1HashBuilder(String value, byte[] salt, int iterations)
{
super(DIGEST, value, salt, iterations, false, false);
}
/**
* Constructs ...
*
*
* @param value
* @param salt
* @param iterations
* @param appendSalt
*/
public SHA1HashBuilder(String value, byte[] salt, int iterations,
boolean appendSalt)
{
super(DIGEST, value, salt, iterations, appendSalt, false);
}
/**
* Constructs ...
*
*
* @param value
* @param salt
* @param iterations
* @param appendSalt
* @param enableLabel
*/
public SHA1HashBuilder(String value, byte[] salt, int iterations,
boolean appendSalt, boolean enableLabel)
{
super(DIGEST, value, salt, iterations, appendSalt, enableLabel);
}
}

View File

@@ -1,130 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.security;
//~--- non-JDK imports --------------------------------------------------------
import org.apache.shiro.crypto.hash.Sha512Hash;
/**
*
* @author Sebastian Sdorra
* @since 1.13
* @deprecated use {@link Sha512Hash} instead.
*/
@Deprecated
public class SHA512HashBuilder extends MessageDigestHashBuilder
{
/** Field description */
public static final String DIGEST = "SHA-512";
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*/
public SHA512HashBuilder()
{
super(DIGEST, null, null, 0, false, false);
}
/**
* Constructs ...
*
*
* @param value
*/
public SHA512HashBuilder(String value)
{
super(DIGEST, value, null, 0, false, false);
}
/**
* Constructs ...
*
*
* @param value
* @param salt
*/
public SHA512HashBuilder(String value, byte[] salt)
{
super(DIGEST, value, salt, 0, false, false);
}
/**
* Constructs ...
*
*
* @param value
* @param salt
* @param iterations
*/
public SHA512HashBuilder(String value, byte[] salt, int iterations)
{
super(DIGEST, value, salt, iterations, false, false);
}
/**
* Constructs ...
*
*
* @param value
* @param salt
* @param iterations
* @param appendSalt
*/
public SHA512HashBuilder(String value, byte[] salt, int iterations,
boolean appendSalt)
{
super(DIGEST, value, salt, iterations, appendSalt, false);
}
/**
* Constructs ...
*
*
* @param value
* @param salt
* @param iterations
* @param appendSalt
* @param enableLabel
*/
public SHA512HashBuilder(String value, byte[] salt, int iterations,
boolean appendSalt, boolean enableLabel)
{
super(DIGEST, value, salt, iterations, appendSalt, enableLabel);
}
}

View File

@@ -1,58 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.security;
//~--- non-JDK imports --------------------------------------------------------
import org.apache.shiro.SecurityUtils;
import sonia.scm.user.User;
/**
*
* @author Sebastian Sdorra
* @deprecated use {@link SecurityUtils#getSubject()} instead.
*/
@Deprecated
public interface SecurityContext
{
/**
* Method description
*
*
* @return
*/
public User getUser();
}

View File

@@ -1,65 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.template;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.io.Writer;
import java.util.Map;
/**
*
* @author Sebastian Sdorra
* @deprecated use {@link TemplateEngineFactory}
*/
@Deprecated
public interface TemplateHandler
{
/**
* Method description
*
*
* @param templateName
* @param writer
* @param params
*
* @throws IOException
*/
public void render(String templateName, Writer writer,
Map<String, ? extends Object> params)
throws IOException;
}

View File

@@ -397,7 +397,7 @@ public class User extends BasicPropertiesAware implements Principal, ModelObject
@Override
public boolean isValid()
{
return ValidationUtil.isUsernameValid(name) && Util.isNotEmpty(displayName)
return ValidationUtil.isNameValid(name) && Util.isNotEmpty(displayName)
&& Util.isNotEmpty(type)
&& ((Util.isEmpty(mail)) || ValidationUtil.isMailAddressValid(mail));
}

View File

@@ -35,16 +35,11 @@ package sonia.scm.util;
//~--- non-JDK imports --------------------------------------------------------
import com.google.inject.Provider;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import sonia.scm.SCMContext;
import sonia.scm.security.Role;
import sonia.scm.security.ScmSecurityException;
import sonia.scm.security.SecurityContext;
import sonia.scm.user.User;
/**
*
@@ -61,21 +56,6 @@ public final class SecurityUtil
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param contextProvider
* @deprecated use {@link Subject#checkRole(java.lang.String)} with {
* @link Role#ADMIN} instead.
*/
@Deprecated
public static void assertIsAdmin(
Provider<? extends SecurityContext> contextProvider)
{
assertIsAdmin();
}
/**
* This method is only present for compatibility reasons.
* Use {@link Subject#checkRole(java.lang.String)} with {
@@ -96,133 +76,4 @@ public final class SecurityUtil
throw new ScmSecurityException("admin account is required");
}
}
/**
* Method description
*
*
* @param context
* @deprecated use {@link Subject#checkRole(java.lang.String)} with {
* @link Role#ADMIN} instead.
*/
@Deprecated
public static void assertIsAdmin(SecurityContext context)
{
assertIsAdmin();
}
/**
* Method description
*
*
* @param contextProvider
*/
public static void assertIsNotAnonymous(
Provider<? extends SecurityContext> contextProvider)
{
if (isAnonymous(contextProvider))
{
throw new ScmSecurityException("anonymous is not allowed here");
}
}
/**
* Method description
*
*
* @param context
*/
public static void assertIsNotAnonymous(SecurityContext context)
{
if (isAnonymous(context))
{
throw new ScmSecurityException("anonymous is not allowed here");
}
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param contextProvider
*
* @return
*/
public static User getCurrentUser(
Provider<? extends SecurityContext> contextProvider)
{
AssertUtil.assertIsNotNull(contextProvider);
SecurityContext context = contextProvider.get();
AssertUtil.assertIsNotNull(context);
User user = context.getUser();
if (user == null)
{
throw new ScmSecurityException("user is not authenticated");
}
return user;
}
/**
* Method description
*
*
* @param contextProvider
*
* @return
*/
public static boolean isAdmin(
Provider<? extends SecurityContext> contextProvider)
{
return isAdmin(contextProvider.get());
}
/**
* Method description
*
*
* @param contextProvider
*
* @return
*/
public static boolean isAdmin(SecurityContext contextProvider)
{
AssertUtil.assertIsNotNull(contextProvider);
return (contextProvider.getUser() != null)
&& contextProvider.getUser().isAdmin();
}
/**
* Method description
*
*
* @param contextProvider
*
* @return
*/
public static boolean isAnonymous(
Provider<? extends SecurityContext> contextProvider)
{
return isAnonymous(contextProvider.get());
}
/**
* Method description
*
*
* @param context
*
* @return
*/
public static boolean isAnonymous(SecurityContext context)
{
return SCMContext.USER_ANONYMOUS.equals(context.getUser().getName());
}
}

View File

@@ -36,8 +36,6 @@ package sonia.scm.util;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.Platform;
import sonia.scm.ServletContainer;
import sonia.scm.ServletContainerDetector;
/**
*
@@ -116,19 +114,6 @@ public final class SystemUtil
return platform;
}
/**
* Method description
*
*
* @return
* @deprecated use {@link ServletContainerDetector#detect(javax.servlet.http.HttpServletRequest)) instead
*/
@Deprecated
public static ServletContainer getServletContainer()
{
return ServletContainerDetector.detect();
}
/**
* Method description
*

View File

@@ -175,21 +175,6 @@ public final class ValidationUtil
return result;
}
/**
* Method description
*
*
* @param username
*
* @return
* @deprecated use {@link #isNameValid(String)}
*/
@Deprecated
public static boolean isUsernameValid(String username)
{
return isNameValid(username);
}
/**
* Method description
*

View File

@@ -1,219 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.web.cgi;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.config.ScmConfiguration;
import sonia.scm.util.HttpUtil;
//~--- JDK imports ------------------------------------------------------------
import java.io.File;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Locale;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* @author Sebastian Sdorra
* @deprecated use {@link CGIExecutorFactory}
*/
@Deprecated
public abstract class AbstractCGIServlet extends HttpServlet
{
/** Field description */
private static final long serialVersionUID = -8638099037069714140L;
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*
* @param configuration
*/
public AbstractCGIServlet(ScmConfiguration configuration)
{
this.configuration = configuration;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param req
*
* @return
*
* @throws IOException
* @throws ServletException
*/
protected abstract File getCommand(HttpServletRequest req)
throws ServletException, IOException;
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @throws ServletException
*/
@Override
public void init() throws ServletException
{
cgiRunner = new CGIRunner(getServletContext(), null, isExitStateIgnored());
baseEnvironment = createBaseEnvironment();
}
/**
* Method description
*
*
* @return
*
* @throws ServletException
*/
protected EnvList createBaseEnvironment() throws ServletException
{
EnvList env = new EnvList();
Enumeration e = getInitParameterNames();
while (e.hasMoreElements())
{
String n = (String) e.nextElement();
if ((n != null) && n.startsWith("ENV_"))
{
env.set(n.substring(4), getInitParameter(n));
}
}
if (!env.containsKey("SystemRoot"))
{
String os = System.getProperty("os.name");
if ((os != null)
&& (os.toLowerCase(Locale.ENGLISH).indexOf("windows") != -1))
{
env.set("SystemRoot", "C:\\WINDOWS");
}
}
return env;
}
/**
* Method description
*
*
*
* @param request
* @param baseEnvironment
*
* @return
*
* @throws ServletException
*/
protected EnvList createRequestEnvironment(HttpServletRequest request,
EnvList baseEnvironment)
throws ServletException
{
return new EnvList(baseEnvironment);
}
/**
* Method description
*
*
* @param req
* @param resp
*
* @throws IOException
* @throws ServletException
*/
@Override
protected void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException
{
cgiRunner.exec(createRequestEnvironment(req, baseEnvironment),
getCmdPrefix(), getCommand(req), req.getPathInfo(), req, resp,
HttpUtil.getServerPort(configuration, req));
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
protected String getCmdPrefix()
{
return null;
}
/**
* Method description
*
*
* @return
*/
protected boolean isExitStateIgnored()
{
return false;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private EnvList baseEnvironment;
/** Field description */
private CGIRunner cgiRunner;
/** Field description */
private ScmConfiguration configuration;
}

View File

@@ -1,573 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.web.cgi;
//~--- non-JDK imports --------------------------------------------------------
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.logging.LoggingOutputStream;
import sonia.scm.util.IOUtil;
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Enumeration;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Based on org.eclipse.jetty.servlets.CGI
*
* @author Sebastian Sdorra
* @deprecated use {@link CGIExecutorFactory}
*/
@Deprecated
public class CGIRunner
{
/** Field description */
public static final int BUFFERSIZE = 2 * 8192;
/** Field description */
private static final Logger logger = LoggerFactory.getLogger(CGIRunner.class);
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*
* @param context
* @param defaultCmdPrefix
* @param ignoreExitState
*/
public CGIRunner(ServletContext context, String defaultCmdPrefix,
boolean ignoreExitState)
{
this(context, defaultCmdPrefix, ignoreExitState, false);
}
/**
* Constructs ...
*
*
* @param context
* @param defaultCmdPrefix
* @param ignoreExitState
* @param asyncRequestInput
*/
public CGIRunner(ServletContext context, String defaultCmdPrefix,
boolean ignoreExitState, boolean asyncRequestInput)
{
this.context = context;
this.defaultCmdPrefix = defaultCmdPrefix;
this.ignoreExitState = ignoreExitState;
this.asyncRequestInput = asyncRequestInput;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param environment
* @param command
* @param pathInfo
* @param req
* @param res
* @param serverPort
*
* @throws IOException
*/
public void exec(EnvList environment, File command, String pathInfo,
HttpServletRequest req, HttpServletResponse res,
int serverPort)
throws IOException
{
exec(environment, defaultCmdPrefix, command, pathInfo, req, res,
serverPort);
}
/**
* Method description
*
*
*
* @param environment
* @param cmdPrefix
* @param command
* @param pathInfo
* @param req
* @param res
* @param serverPort
*
* @throws IOException
*/
public void exec(EnvList environment, String cmdPrefix, File command,
String pathInfo, HttpServletRequest req,
HttpServletResponse res, int serverPort)
throws IOException
{
String path = command.getAbsolutePath();
File dir = command.getParentFile();
String scriptName = req.getRequestURI().substring(0,
req.getRequestURI().length() - pathInfo.length());
String scriptPath = context.getRealPath(scriptName);
String pathTranslated = req.getPathTranslated();
int len = req.getContentLength();
if (len < 0)
{
len = 0;
}
if (Util.isEmpty(pathTranslated))
{
pathTranslated = path;
}
// these ones are from "The WWW Common Gateway Interface Version 1.1"
// look at :
// http://Web.Golux.Com/coar/cgi/draft-coar-cgi-v11-03-clean.html#6.1.1
environment.set("AUTH_TYPE", req.getAuthType());
environment.set("CONTENT_LENGTH", Integer.toString(len));
environment.set("CONTENT_TYPE", req.getContentType());
environment.set("GATEWAY_INTERFACE", "CGI/1.1");
environment.set("PATH_INFO", pathInfo);
environment.set("PATH_TRANSLATED", pathTranslated);
environment.set("QUERY_STRING", req.getQueryString());
environment.set("REMOTE_ADDR", req.getRemoteAddr());
environment.set("REMOTE_HOST", req.getRemoteHost());
// The identity information reported about the connection by a
// RFC 1413 [11] request to the remote agent, if
// available. Servers MAY choose not to support this feature, or
// not to request the data for efficiency reasons.
// "REMOTE_IDENT" => "NYI"
environment.set("REMOTE_USER", req.getRemoteUser());
environment.set("REQUEST_METHOD", req.getMethod());
environment.set("SCRIPT_NAME", scriptName);
environment.set("SCRIPT_FILENAME", scriptPath);
environment.set("SERVER_NAME", req.getServerName());
environment.set("SERVER_PORT", Integer.toString(serverPort));
environment.set("SERVER_PROTOCOL", req.getProtocol());
environment.set("SERVER_SOFTWARE", context.getServerInfo());
Enumeration enm = req.getHeaderNames();
while (enm.hasMoreElements())
{
String name = (String) enm.nextElement();
String value = req.getHeader(name);
environment.set("HTTP_" + name.toUpperCase().replace('-', '_'), value);
}
// these extra ones were from printenv on www.dev.nomura.co.uk
environment.set("HTTPS", (req.isSecure()
? "ON"
: "OFF"));
// "DOCUMENT_ROOT" => root + "/docs",
// "SERVER_URL" => "NYI - http://us0245",
// "TZ" => System.getProperty("user.timezone"),
// are we meant to decode args here ? or does the script get them
// via PATH_INFO ? if we are, they should be decoded and passed
// into exec here...
String execCmd = path;
if ((execCmd.charAt(0) != '"') && (execCmd.indexOf(' ') >= 0))
{
execCmd = "\"" + execCmd + "\"";
}
if (cmdPrefix != null)
{
execCmd = cmdPrefix + " " + execCmd;
}
if (logger.isDebugEnabled())
{
logger.debug("execute cgi: ".concat(execCmd));
if (logger.isTraceEnabled())
{
logger.trace(environment.toString());
}
}
Process p = (dir == null)
? Runtime.getRuntime().exec(execCmd, environment.getEnvArray())
: Runtime.getRuntime().exec(execCmd, environment.getEnvArray(),
dir);
passRequestInputToProcess(req, p, len);
// hook processes output to browser's input (sync)
// if browser closes stream, we should detect it and kill process...
OutputStream os = null;
try
{
// read any headers off the top of our input stream
// NOTE: Multiline header items not supported!
String line = null;
InputStream inFromCgi = p.getInputStream();
if (logger.isTraceEnabled())
{
logger.trace("CGI-Response Header:");
}
// br=new BufferedReader(new InputStreamReader(inFromCgi));
// while ((line=br.readLine())!=null)
while ((line = getTextLineFromStream(inFromCgi)).length() > 0)
{
if (logger.isTraceEnabled())
{
logger.trace(" ".concat(line));
}
if (!line.startsWith("HTTP"))
{
int k = line.indexOf(':');
if (k > 0)
{
String key = line.substring(0, k).trim();
String value = line.substring(k + 1).trim();
if ("Location".equals(key))
{
res.sendRedirect(res.encodeRedirectURL(value));
}
else if ("Status".equals(key))
{
String[] token = value.split(" ");
int status = Integer.parseInt(token[0]);
res.setStatus(status);
}
else
{
// add remaining header items to our response header
res.addHeader(key, value);
}
}
}
}
// copy cgi content to response stream...
os = res.getOutputStream();
IOUtil.copy(inFromCgi, os);
p.waitFor();
if (!ignoreExitState)
{
int exitValue = p.exitValue();
if (0 != exitValue)
{
StringBuilder msg = new StringBuilder("Non-zero exit status (");
msg.append(exitValue).append(") from CGI program: ").append(path);
logger.warn(msg.toString());
if (!res.isCommitted())
{
res.sendError(500, "Failed to exec CGI");
}
}
}
}
catch (IOException e)
{
// browser has probably closed its input stream - we
// terminate and clean up...
logger.debug("CGI: Client closed connection!");
}
catch (InterruptedException ie)
{
logger.debug("CGI: interrupted!");
}
finally
{
IOUtil.close(os);
os = null;
p.destroy();
// Log.debug("CGI: terminated!");
}
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public String getCmdPrefix()
{
return defaultCmdPrefix;
}
/**
* Method description
*
*
* @return
*/
public ServletContext getContext()
{
return context;
}
/**
* Method description
*
*
* @return
*/
public boolean isIgnoreExitState()
{
return ignoreExitState;
}
//~--- set methods ----------------------------------------------------------
/**
* Method description
*
*
* @param cmdPrefix
*/
public void setCmdPrefix(String cmdPrefix)
{
this.defaultCmdPrefix = cmdPrefix;
}
/**
* Method description
*
*
* @param context
*/
public void setContext(ServletContext context)
{
this.context = context;
}
/**
* Method description
*
*
* @param ignoreExitState
*/
public void setIgnoreExitState(boolean ignoreExitState)
{
this.ignoreExitState = ignoreExitState;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param in
* @param out
* @param byteCount
*
* @throws IOException
*/
private void copy(InputStream in, OutputStream out, long byteCount)
throws IOException
{
byte buffer[] = new byte[BUFFERSIZE];
int len = BUFFERSIZE;
if (byteCount >= 0)
{
while (byteCount > 0)
{
int max = (byteCount < BUFFERSIZE)
? (int) byteCount
: BUFFERSIZE;
len = in.read(buffer, 0, max);
if (len == -1)
{
break;
}
byteCount -= len;
out.write(buffer, 0, len);
}
}
else
{
while (true)
{
len = in.read(buffer, 0, BUFFERSIZE);
if (len < 0)
{
break;
}
out.write(buffer, 0, len);
}
}
}
/**
* Method description
*
*
* @param request
* @param p
* @param length
*
* @throws IOException
*/
private void passRequestInputToProcess(HttpServletRequest request, Process p,
int length)
throws IOException
{
final InputStream inFromReq = request.getInputStream();
final OutputStream outToCgi = p.getOutputStream();
final int inLength = length;
IOUtil.copyThread(p.getErrorStream(),
new LoggingOutputStream(logger,
LoggingOutputStream.LEVEL_ERROR));
if (asyncRequestInput)
{
new Thread(new Runnable()
{
@Override
public void run()
{
try
{
if (inLength > 0)
{
copy(inFromReq, outToCgi, inLength);
}
}
catch (IOException ex)
{
logger.debug(ex.getMessage(), ex);
}
finally
{
IOUtil.close(inFromReq);
IOUtil.close(outToCgi);
}
}
}).start();
}
else
{
try
{
if (inLength > 0)
{
copy(inFromReq, outToCgi, inLength);
}
}
finally
{
IOUtil.close(inFromReq);
IOUtil.close(outToCgi);
}
}
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param is
*
* @return
*
* @throws IOException
*/
private String getTextLineFromStream(InputStream is) throws IOException
{
StringBuilder buffer = new StringBuilder();
int b;
while ((b = is.read()) != -1 && (b != (int) '\n'))
{
buffer.append((char) b);
}
return buffer.toString().trim();
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private boolean asyncRequestInput = false;
/** Field description */
private ServletContext context;
/** Field description */
private String defaultCmdPrefix;
/** Field description */
private boolean ignoreExitState;
}

View File

@@ -26,9 +26,28 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package sonia.scm.web.filter;
//~--- non-JDK imports --------------------------------------------------------
import com.google.inject.Inject;
import com.google.inject.Singleton;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.user.User;
//~--- JDK imports ------------------------------------------------------------
import java.io.IOException;
import java.util.Set;
import javax.servlet.FilterChain;
@@ -36,102 +55,122 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.user.User;
import com.google.inject.Inject;
import com.google.inject.Singleton;
/**
* This filter calls all AutoLoginModule objects to try an auto-login. It can be
* used on its own, usually at the global context ('/*') or as a base class like
* BasicAuthenticationFilter.
*
*
* @author Clemens Rabe
*/
@Singleton
public class AutoLoginFilter extends HttpFilter {
public class AutoLoginFilter extends HttpFilter
{
/** the logger for AutoLoginFilter */
private static final Logger logger = LoggerFactory
.getLogger(AutoLoginFilter.class);
/** the logger for AutoLoginFilter */
private static final Logger logger =
LoggerFactory.getLogger(AutoLoginFilter.class);
@Deprecated
public AutoLoginFilter() {
}
//~--- constructors ---------------------------------------------------------
/**
* Constructor.
*
* @param autoLoginModules
* - The auto-login modules.
*/
@Inject
public AutoLoginFilter(Set<AutoLoginModule> autoLoginModules) {
this.autoLoginModules = autoLoginModules;
}
/**
* Constructor.
*
* @param autoLoginModules
* - The auto-login modules.
*/
@Inject
public AutoLoginFilter(Set<AutoLoginModule> autoLoginModules)
{
this.autoLoginModules = autoLoginModules;
}
@Override
protected void doFilter(HttpServletRequest request,
HttpServletResponse response, FilterChain chain)
throws IOException, ServletException {
User user = getAuthenticatedUser(request, response);
//~--- methods --------------------------------------------------------------
if (user == null)
chain.doFilter(request, response);
else
chain.doFilter(
new SecurityHttpServletRequestWrapper(request, user),
response);
}
/**
* Method description
*
*
* @param request
* @param response
* @param chain
*
* @throws IOException
* @throws ServletException
*/
@Override
protected void doFilter(HttpServletRequest request,
HttpServletResponse response, FilterChain chain)
throws IOException, ServletException
{
User user = getAuthenticatedUser(request, response);
/**
* Check all known AutoLoginModule objects to authenticate the user using
* the current request.
*
* @param request
* - The servlet request.
* @param response
* - The servlet response.
* @return The user or null if no user was found.
*/
protected User getAuthenticatedUser(HttpServletRequest request,
HttpServletResponse response) {
Subject subject = SecurityUtils.getSubject();
User user = null;
if (user == null)
{
chain.doFilter(request, response);
}
else
{
chain.doFilter(new SecurityHttpServletRequestWrapper(request, user),
response);
}
}
if (subject.isAuthenticated() || subject.isRemembered()) {
if (logger.isTraceEnabled()) {
logger.trace("user is allready authenticated");
}
//~--- get methods ----------------------------------------------------------
user = subject.getPrincipals().oneByType(User.class);
} else {
// Try the known filters first
for (AutoLoginModule filter : autoLoginModules) {
user = filter.authenticate(request, response, subject);
/**
* Check all known AutoLoginModule objects to authenticate the user using
* the current request.
*
* @param request
* - The servlet request.
* @param response
* - The servlet response.
* @return The user or null if no user was found.
*/
protected User getAuthenticatedUser(HttpServletRequest request,
HttpServletResponse response)
{
Subject subject = SecurityUtils.getSubject();
User user = null;
if (user != null) {
if (logger.isTraceEnabled()) {
logger.trace(
"user {} successfully authenticated by authentication filter",
user.getName());
}
break;
}
}
}
if (subject.isAuthenticated() || subject.isRemembered())
{
if (logger.isTraceEnabled())
{
logger.trace("user is allready authenticated");
}
return user;
}
user = subject.getPrincipals().oneByType(User.class);
}
else
{
/**
* Set of AutoLoginModule objects.
*/
private Set<AutoLoginModule> autoLoginModules;
// Try the known filters first
for (AutoLoginModule filter : autoLoginModules)
{
user = filter.authenticate(request, response, subject);
if (user != null)
{
if (logger.isTraceEnabled())
{
logger.trace(
"user {} successfully authenticated by authentication filter",
user.getName());
}
break;
}
}
}
return user;
}
//~--- fields ---------------------------------------------------------------
/**
* Set of AutoLoginModule objects.
*/
private final Set<AutoLoginModule> autoLoginModules;
}

View File

@@ -52,8 +52,6 @@ import sonia.scm.config.ScmConfiguration;
import sonia.scm.user.User;
import sonia.scm.util.HttpUtil;
import sonia.scm.util.Util;
import sonia.scm.web.security.AuthenticationHandler;
import sonia.scm.web.security.WebSecurityContext;
//~--- JDK imports ------------------------------------------------------------
@@ -90,16 +88,6 @@ public class BasicAuthenticationFilter extends AutoLoginFilter
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*
* @param securityContextProvider
* @deprecated use the constructor with out arguments instead.
*/
@Deprecated
public BasicAuthenticationFilter(
Provider<WebSecurityContext> securityContextProvider) {}
/**
* Constructs a new basic authenticaton filter
@@ -281,5 +269,5 @@ public class BasicAuthenticationFilter extends AutoLoginFilter
//~--- fields ---------------------------------------------------------------
/** Field description */
private ScmConfiguration configuration;
private final ScmConfiguration configuration;
}

View File

@@ -53,7 +53,6 @@ import sonia.scm.repository.Repository;
import sonia.scm.security.ScmSecurityException;
import sonia.scm.util.HttpUtil;
import sonia.scm.util.Util;
import sonia.scm.web.security.WebSecurityContext;
//~--- JDK imports ------------------------------------------------------------
@@ -93,21 +92,6 @@ public abstract class PermissionFilter extends HttpFilter
this.configuration = configuration;
}
/**
* Constructs a new permission filter
*
* @param configuration global scm-manager configuration
* @param securityContextProvider security context provider
*
* @deprecated {@link #PermissionFilter(ScmConfiguration)} instead
*/
@Deprecated
public PermissionFilter(ScmConfiguration configuration,
Provider<WebSecurityContext> securityContextProvider)
{
this.configuration = configuration;
}
//~--- get methods ----------------------------------------------------------
/**

View File

@@ -45,7 +45,6 @@ import org.slf4j.LoggerFactory;
import sonia.scm.config.ScmConfiguration;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryProvider;
import sonia.scm.web.security.WebSecurityContext;
//~--- JDK imports ------------------------------------------------------------
@@ -82,24 +81,6 @@ public abstract class ProviderPermissionFilter extends PermissionFilter
this.repositoryProvider = repositoryProvider;
}
/**
* Constructs ...
*
*
*
* @param configuration
* @param securityContextProvider
* @param repositoryProvider
* @deprecated
*/
@Deprecated
public ProviderPermissionFilter(ScmConfiguration configuration,
Provider<WebSecurityContext> securityContextProvider,
RepositoryProvider repositoryProvider)
{
this(configuration, repositoryProvider);
}
//~--- get methods ----------------------------------------------------------
/**
@@ -136,5 +117,5 @@ public abstract class ProviderPermissionFilter extends PermissionFilter
//~--- fields ---------------------------------------------------------------
/** Field description */
private RepositoryProvider repositoryProvider;
private final RepositoryProvider repositoryProvider;
}

View File

@@ -35,12 +35,10 @@ package sonia.scm.web.filter;
//~--- non-JDK imports --------------------------------------------------------
import com.google.inject.Provider;
import sonia.scm.config.ScmConfiguration;
import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryManager;
import sonia.scm.web.security.WebSecurityContext;
//~--- JDK imports ------------------------------------------------------------
@@ -77,24 +75,6 @@ public abstract class RegexPermissionFilter extends PermissionFilter
this.repositoryManager = repositoryManager;
}
/**
* Constructs ...
*
*
*
* @param configuration
* @param securityContextProvider
* @param repositoryManager
* @deprecated
*/
@Deprecated
public RegexPermissionFilter(ScmConfiguration configuration,
Provider<WebSecurityContext> securityContextProvider,
RepositoryManager repositoryManager)
{
this(configuration, repositoryManager);
}
//~--- get methods ----------------------------------------------------------
/**

View File

@@ -1,79 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.web.proxy;
//~--- JDK imports ------------------------------------------------------------
import java.net.URL;
/**
*
* @author Sebastian Sdorra
* @since 1.8
* @deprecated use {@link ProxyConfigurationProvider} instead.
*/
@Deprecated
public class BasicProxyURLProvider implements ProxyURLProvider
{
/**
* Constructs ...
*
*
* @param url
*/
public BasicProxyURLProvider(URL url)
{
this.url = url;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
@Override
public URL getProxyURL()
{
return url;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private URL url;
}

View File

@@ -1,190 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.web.proxy;
//~--- non-JDK imports --------------------------------------------------------
import com.google.inject.Inject;
import com.google.inject.Singleton;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.util.AssertUtil;
import sonia.scm.util.IOUtil;
//~--- JDK imports ------------------------------------------------------------
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* @author Sebastian Sdorra
* @since 1.8
* @deprecated use {@link ProxyServlet} instead
*/
@Singleton
@Deprecated
public class ProxyServet extends HttpServlet
{
/** the logger for MyProxy */
private static final Logger logger =
LoggerFactory.getLogger(ProxyServet.class);
/** Field description */
private static final long serialVersionUID = -8069773175342430809L;
//~--- constructors ---------------------------------------------------------
/**
* Constructs ...
*
*
* @param urlProvider
*/
@Inject
public ProxyServet(ProxyURLProvider urlProvider)
{
this.urlProvider = urlProvider;
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param request
* @param response
*/
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
{
doPost(request, response);
}
/**
* Method description
*
*
* @param request
* @param response
*/
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
{
BufferedInputStream webToProxyBuf = null;
BufferedOutputStream proxyToClientBuf = null;
HttpURLConnection con;
try
{
URL url = urlProvider.getProxyURL();
AssertUtil.assertIsNotNull(url);
if (logger.isInfoEnabled())
{
logger.info("proxy request for {}", url.toString());
}
con = (HttpURLConnection) url.openConnection();
con.setDoOutput(true);
con.setDoInput(true);
con.setUseCaches(true);
for (Enumeration e = request.getHeaderNames(); e.hasMoreElements(); )
{
String headerName = e.nextElement().toString();
con.setRequestProperty(headerName, request.getHeader(headerName));
}
con.connect();
response.setStatus(con.getResponseCode());
for (Iterator i = con.getHeaderFields().entrySet().iterator();
i.hasNext(); )
{
Map.Entry mapEntry = (Map.Entry) i.next();
if (mapEntry.getKey() != null)
{
response.setHeader(mapEntry.getKey().toString(),
((List) mapEntry.getValue()).get(0).toString());
}
}
webToProxyBuf = new BufferedInputStream(con.getInputStream());
proxyToClientBuf = new BufferedOutputStream(response.getOutputStream());
int oneByte;
while ((oneByte = webToProxyBuf.read()) != -1)
{
proxyToClientBuf.write(oneByte);
}
con.disconnect();
}
catch (Exception ex)
{
logger.error("could not proxy request", ex);
}
finally
{
IOUtil.close(webToProxyBuf);
IOUtil.close(proxyToClientBuf);
}
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private ProxyURLProvider urlProvider;
}

View File

@@ -1,57 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.web.proxy;
//~--- JDK imports ------------------------------------------------------------
import java.net.URL;
/**
*
* @author Sebastian Sdorra
* @since 1.8
* @deprecated use {@link ProxyConfigurationProvider} instead.
*/
@Deprecated
public interface ProxyURLProvider
{
/**
* Method description
*
*
* @return
*/
public URL getProxyURL();
}

View File

@@ -1,99 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.web.security;
//~--- non-JDK imports --------------------------------------------------------
import sonia.scm.security.SecurityContext;
import sonia.scm.user.User;
//~--- JDK imports ------------------------------------------------------------
import java.util.Collection;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.shiro.SecurityUtils;
/**
*
* @author Sebastian Sdorra
* @deprecated use {@link SecurityUtils#getSecurityManager()} instead.
*/
@Deprecated
public interface WebSecurityContext extends SecurityContext
{
/**
* Method description
*
*
* @param request
* @param response
* @param username
* @param password
*
* @return
*/
public User authenticate(HttpServletRequest request,
HttpServletResponse response, String username,
String password);
/**
* Method description
*
*
* @param request
* @param response
*/
public void logout(HttpServletRequest request, HttpServletResponse response);
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
public Collection<String> getGroups();
/**
* Method description
*
*
* @return
*/
public boolean isAuthenticated();
}

View File

@@ -1,300 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import sonia.scm.config.ScmConfiguration;
import sonia.scm.security.ScmSecurityException;
import sonia.scm.user.User;
import sonia.scm.web.security.WebSecurityContext;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
//~--- JDK imports ------------------------------------------------------------
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
/**
*
* @author Sebastian Sdorra
*/
@Ignore
public class PermissionUtilTest
{
/**
* Constructs ...
*
*/
public PermissionUtilTest()
{
admams.getUser().setAdmin(true);
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*/
@Test(expected = ScmSecurityException.class)
public void assertFailedPermissionTest()
{
PermissionUtil.assertPermission(repository, dent, PermissionType.WRITE);
}
/**
* Method description
*
*/
@Test
public void assertPermissionTest()
{
PermissionUtil.assertPermission(repository, dent, PermissionType.READ);
PermissionUtil.assertPermission(repository, perfect, PermissionType.READ);
PermissionUtil.assertPermission(repository, perfect, PermissionType.WRITE);
PermissionUtil.assertPermission(repository, marvin, PermissionType.READ);
PermissionUtil.assertPermission(repository, marvin, PermissionType.WRITE);
PermissionUtil.assertPermission(repository, marvin, PermissionType.OWNER);
PermissionUtil.assertPermission(repository, admams, PermissionType.READ);
PermissionUtil.assertPermission(repository, admams, PermissionType.WRITE);
PermissionUtil.assertPermission(repository, admams, PermissionType.OWNER);
}
/**
* Method description
*
*/
@Before
public void before()
{
repository = new Repository();
Permission[] permissions = new Permission[] {
new Permission("dent", PermissionType.READ),
new Permission("perfect", PermissionType.WRITE),
new Permission("marvin", PermissionType.OWNER) };
repository.setPermissions(Arrays.asList(permissions));
}
/**
* Method description
*
*/
@Test
public void testGroupPermissions()
{
WebSecurityContext dent = mockGroupCtx(new User("dent", "Arthur Dent",
"arthur.dent@hitchhiker.com"), "devel", "qa");
WebSecurityContext ford = mockGroupCtx(new User("ford", "Ford Prefect",
"ford.prefect@hitchhiker.com"), "devel");
WebSecurityContext zaphod = mockGroupCtx(new User("zaphod",
"Zaphod Beeblebrox",
"zaphod.beeblebrox@hitchhiker.com"), "qa");
WebSecurityContext trillian = mockGroupCtx(new User("trillian",
"Trillian Astra",
"trillian.astra@hitchhiker.com"));
Repository r = new Repository();
r.setPermissions(
new ArrayList<Permission>(
Arrays.asList(
new Permission("dent"),
new Permission("devel", PermissionType.WRITE, true),
new Permission("qa", PermissionType.READ, true))));
// member of both devel and qa
assertTrue(PermissionUtil.hasPermission(r, dent, PermissionType.READ));
assertTrue(PermissionUtil.hasPermission(r, dent, PermissionType.WRITE));
assertFalse(PermissionUtil.hasPermission(r, dent, PermissionType.OWNER));
// now, additionally the owner
r.getPermissions().add(new Permission("dent", PermissionType.OWNER));
assertTrue(PermissionUtil.hasPermission(r, dent, PermissionType.OWNER));
// member of just devel
assertTrue(PermissionUtil.hasPermission(r, ford, PermissionType.READ));
assertTrue(PermissionUtil.hasPermission(r, ford, PermissionType.WRITE));
assertFalse(PermissionUtil.hasPermission(r, ford, PermissionType.OWNER));
// member of just qa
assertTrue(PermissionUtil.hasPermission(r, zaphod, PermissionType.READ));
assertFalse(PermissionUtil.hasPermission(r, zaphod, PermissionType.WRITE));
assertFalse(PermissionUtil.hasPermission(r, zaphod, PermissionType.OWNER));
// member of no groups
assertFalse(PermissionUtil.hasPermission(r, trillian, PermissionType.READ));
assertFalse(PermissionUtil.hasPermission(r, trillian,
PermissionType.WRITE));
assertFalse(PermissionUtil.hasPermission(r, trillian,
PermissionType.OWNER));
}
/**
* Method description
*
*/
@Test
public void testIsWritable()
{
ScmConfiguration configuration = new ScmConfiguration();
configuration.setEnableRepositoryArchive(true);
assertTrue(PermissionUtil.isWritable(configuration, repository, perfect));
repository.setArchived(true);
assertFalse(PermissionUtil.isWritable(configuration, repository, perfect));
assertFalse(PermissionUtil.isWritable(configuration, repository, admams));
configuration.setEnableRepositoryArchive(false);
assertTrue(PermissionUtil.isWritable(configuration, repository, perfect));
assertTrue(PermissionUtil.isWritable(configuration, repository, admams));
assertFalse(PermissionUtil.isWritable(configuration, repository, dent));
configuration.setEnableRepositoryArchive(true);
repository.setArchived(false);
assertTrue(PermissionUtil.isWritable(configuration, repository, perfect));
assertTrue(PermissionUtil.isWritable(configuration, repository, admams));
assertFalse(PermissionUtil.isWritable(configuration, repository, dent));
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*/
@Test
public void hasPermissionTest()
{
assertTrue(PermissionUtil.hasPermission(repository, dent,
PermissionType.READ));
assertTrue(PermissionUtil.hasPermission(repository, perfect,
PermissionType.READ));
assertTrue(PermissionUtil.hasPermission(repository, perfect,
PermissionType.WRITE));
assertFalse(PermissionUtil.hasPermission(repository, dent,
PermissionType.WRITE));
assertFalse(PermissionUtil.hasPermission(repository, slarti,
PermissionType.WRITE));
assertFalse(PermissionUtil.hasPermission(repository, slarti,
PermissionType.READ));
assertTrue(PermissionUtil.hasPermission(repository, marvin,
PermissionType.READ));
assertTrue(PermissionUtil.hasPermission(repository, marvin,
PermissionType.WRITE));
assertTrue(PermissionUtil.hasPermission(repository, marvin,
PermissionType.OWNER));
assertTrue(PermissionUtil.hasPermission(repository, admams,
PermissionType.READ));
assertTrue(PermissionUtil.hasPermission(repository, admams,
PermissionType.WRITE));
assertTrue(PermissionUtil.hasPermission(repository, admams,
PermissionType.OWNER));
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param user
*
* @return
*/
private WebSecurityContext mockCtx(User user)
{
WebSecurityContext context = mock(WebSecurityContext.class);
when(context.getUser()).thenReturn(user);
return context;
}
/**
* Method description
*
*
* @param user
* @param groups
*
* @return
*/
private WebSecurityContext mockGroupCtx(User user, String... groups)
{
WebSecurityContext context = mockCtx(user);
Set<String> groupSet = new HashSet<String>(Arrays.asList(groups));
when(context.getGroups()).thenReturn(groupSet);
return context;
}
//~--- fields ---------------------------------------------------------------
/** Field description */
private WebSecurityContext dent = mockCtx(new User("dent", "Arthur Dent",
"arthur.dent@hitchhiker.com"));
/** Field description */
private WebSecurityContext perfect = mockCtx(new User("perfect",
"Ford Prefect",
"ford.perfect@hitchhiker.com"));
/** Field description */
private Repository repository;
/** Field description */
private WebSecurityContext slarti = mockCtx(new User("slarti",
"Slartibartfaß",
"slartibartfass@hitchhiker.com"));
/** Field description */
private WebSecurityContext marvin = mockCtx(new User("marvin", "Marvin",
"paranoid.android@hitchhiker.com"));
/** Field description */
private WebSecurityContext admams = mockCtx(new User("adams",
"Douglas Adams",
"douglas.adams@hitchhiker.com"));
}

View File

@@ -1,207 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.security;
//~--- non-JDK imports --------------------------------------------------------
import org.junit.Test;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
//~--- JDK imports ------------------------------------------------------------
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*
* @author Sebastian Sdorra
*/
public abstract class HashBuilderTestBase
{
/**
* Method description
*
*
* @return
*/
public abstract HashBuilder createHashBuilder();
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
protected abstract String getLable();
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*/
@Test
public void testCreateIteratedSaltedHash()
{
HashBuilder hashBuilder = createHashBuilder();
String hash = hashBuilder.setIterations(1000).createSalt().setValue(
"hitcheker").toHexString();
byte[] salt = hashBuilder.getSalt();
hashBuilder = createHashBuilder();
String otherHash = hashBuilder.setIterations(1000).setSalt(salt).setValue(
"hitcheker").toHexString();
checkHash("hitcheker", hash, otherHash);
}
/**
* Method description
*
*/
@Test
public void testCreateLabledHash()
{
HashBuilder hashBuilder = createHashBuilder();
String hash = hashBuilder.enableLabel().setValue("hitcheker").toHexString();
System.out.println(hash);
checkHash("hitcheker", hash);
Pattern p = Pattern.compile("\\{([^\\}]+)\\}.*");
Matcher m = p.matcher(hash);
assertTrue(m.matches());
String lable = m.group(1);
assertNotNull(lable);
assertEquals(getLable(), lable);
}
/**
* Method description
*
*/
@Test
public void testCreateSalt()
{
HashBuilder hashBuilder = createHashBuilder();
assertNotNull(hashBuilder);
byte[] salt = hashBuilder.createSalt().getSalt();
assertNotNull(salt);
byte[] otherSalt = hashBuilder.createSalt().getSalt();
assertNotNull(otherSalt);
assertEquals(salt.length, otherSalt.length);
assertThat(salt, not(equalTo(otherSalt)));
salt = hashBuilder.createSalt(4).getSalt();
assertEquals(4, salt.length);
}
/**
* Method description
*
*/
@Test
public void testCreateSaltedHash()
{
HashBuilder hashBuilder = createHashBuilder();
String hash = hashBuilder.createSalt().setValue("hitcheker").toHexString();
byte[] salt = hashBuilder.getSalt();
hashBuilder = createHashBuilder();
String otherHash =
hashBuilder.setSalt(salt).setValue("hitcheker").toHexString();
checkHash("hitcheker", hash, otherHash);
}
/**
* Method description
*
*/
@Test
public void testCreateSimpleHash()
{
HashBuilder hashBuilder = createHashBuilder();
String hash = hashBuilder.setValue("hitcheker").toHexString();
hashBuilder = createHashBuilder();
String otherHash = hashBuilder.setValue("hitcheker").toHexString();
checkHash("hitcheker", hash, otherHash);
}
/**
* Method description
*
*
* @param plain
* @param hash
*/
private void checkHash(String plain, String hash)
{
assertNotNull(hash);
assertThat(hash, not(equalTo(plain)));
}
/**
* Method description
*
*
* @param plain
* @param hash
* @param otherHash
*/
private void checkHash(String plain, String hash, String otherHash)
{
checkHash(plain, hash);
assertNotNull(otherHash);
assertThat(otherHash, not(equalTo("hitcheker")));
assertEquals(hash, otherHash);
}
}

View File

@@ -1,67 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.security;
/**
*
* @author Sebastian Sdorra
*/
public class MD5HashBuilderTest extends HashBuilderTestBase
{
/**
* Method description
*
*
* @return
*/
@Override
public HashBuilder createHashBuilder()
{
return new MD5HashBuilder();
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
@Override
protected String getLable()
{
return MD5HashBuilder.DIGEST;
}
}

View File

@@ -1,64 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.security;
//~--- non-JDK imports --------------------------------------------------------
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author Sebastian Sdorra
*/
public class MessageDigestHashBuilderTest
{
/**
* Method description
*
*/
@Test
public void testExtractor()
{
MessageDigestHashBuilder hashBuilder = new SHA1HashBuilder("hitcheker");
String hash =
hashBuilder.enableLabel().createSalt().appendSalt().toHexString();
assertNotNull(hash);
hashBuilder =
MessageDigestHashBuilder.createExtractor(hash).getHashBuilder(8);
assertEquals(hash, hashBuilder.setValue("hitcheker").toHexString());
}
}

View File

@@ -1,87 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.security;
//~--- non-JDK imports --------------------------------------------------------
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author Sebastian Sdorra
*/
public class SHA1HashBuilderTest extends HashBuilderTestBase
{
/**
* Method description
*
*
* @return
*/
@Override
public HashBuilder createHashBuilder()
{
return new SHA1HashBuilder();
}
/**
* Method description
*
*/
@Test
public void testCompatibility()
{
MessageDigestEncryptionHandler mdeh = new MessageDigestEncryptionHandler();
String hash = mdeh.encrypt("trillian123");
String newHash = createHashBuilder().setValue("trillian123").toHexString();
assertEquals(hash, newHash);
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
@Override
protected String getLable()
{
return SHA1HashBuilder.DIGEST;
}
}

View File

@@ -1,67 +0,0 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.security;
/**
*
* @author Sebastian Sdorra
*/
public class SHA512HashBuilderTest extends HashBuilderTestBase
{
/**
* Method description
*
*
* @return
*/
@Override
public HashBuilder createHashBuilder()
{
return new SHA512HashBuilder();
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
@Override
protected String getLable()
{
return SHA512HashBuilder.DIGEST;
}
}