mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-02-26 16:30:50 +01:00
Cleanup Code
Pushed-by: Rene Pfeuffer<rene.pfeuffer@cloudogu.com> Co-authored-by: René Pfeuffer<rene.pfeuffer@cloudogu.com>
This commit is contained in:
@@ -24,21 +24,15 @@
|
||||
|
||||
package sonia.scm;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.BindingAnnotation;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
@BindingAnnotation
|
||||
@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.api.rest;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
@@ -35,11 +34,8 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import sonia.scm.security.Authentications;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Provider
|
||||
|
||||
@@ -24,25 +24,17 @@
|
||||
|
||||
package sonia.scm.api.rest;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import jakarta.ws.rs.ext.Provider;
|
||||
import org.apache.shiro.authc.DisabledAccountException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
@Provider
|
||||
public class DisabledAccountExceptionMapper
|
||||
extends StatusExceptionMapper<DisabledAccountException>
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
public DisabledAccountExceptionMapper()
|
||||
{
|
||||
super(DisabledAccountException.class, Response.Status.FORBIDDEN);
|
||||
|
||||
@@ -24,25 +24,17 @@
|
||||
|
||||
package sonia.scm.api.rest;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import jakarta.ws.rs.ext.Provider;
|
||||
import org.apache.shiro.authc.ExcessiveAttemptsException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
@Provider
|
||||
public class ExcessiveAttemptsExceptionMapper
|
||||
extends StatusExceptionMapper<ExcessiveAttemptsException>
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
public ExcessiveAttemptsExceptionMapper()
|
||||
{
|
||||
super(ExcessiveAttemptsException.class, Response.Status.FORBIDDEN);
|
||||
|
||||
@@ -33,7 +33,6 @@ import jakarta.ws.rs.ext.Provider;
|
||||
/**
|
||||
* Configures the way objects are marshaled to json.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Provider
|
||||
|
||||
@@ -24,63 +24,34 @@
|
||||
|
||||
package sonia.scm.api.rest;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
@XmlRootElement(name = "result")
|
||||
public class RestActionResult
|
||||
{
|
||||
private boolean success = false;
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
public RestActionResult() {}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param success
|
||||
*/
|
||||
|
||||
public RestActionResult(boolean success)
|
||||
{
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public boolean isSuccess()
|
||||
{
|
||||
return success;
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param success
|
||||
*/
|
||||
|
||||
public void setSuccess(boolean success)
|
||||
{
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private boolean success = false;
|
||||
}
|
||||
|
||||
@@ -24,33 +24,19 @@
|
||||
|
||||
package sonia.scm.api.rest;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
@XmlRootElement(name = "result")
|
||||
public class RestActionUploadResult extends RestActionResult
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
public RestActionUploadResult()
|
||||
{
|
||||
this(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param success
|
||||
*/
|
||||
|
||||
public RestActionUploadResult(boolean success)
|
||||
{
|
||||
super(success);
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.api.rest;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import jakarta.ws.rs.WebApplicationException;
|
||||
@@ -43,28 +42,11 @@ import java.lang.reflect.Type;
|
||||
* mimetype for uploads.
|
||||
*
|
||||
* TODO find a better way
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Provider
|
||||
public class RestActionUploadResultMessageWriter
|
||||
implements MessageBodyWriter<RestActionResult>
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param result
|
||||
* @param type
|
||||
* @param genericType
|
||||
* @param annotations
|
||||
* @param mediaType
|
||||
* @param httpHeaders
|
||||
* @param entityStream
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws WebApplicationException
|
||||
*/
|
||||
@Override
|
||||
public void writeTo(RestActionResult result, Class<?> type, Type genericType,
|
||||
Annotation[] annotations, MediaType mediaType,
|
||||
@@ -77,20 +59,6 @@ public class RestActionUploadResultMessageWriter
|
||||
entityStream.write(v.getBytes(Charsets.UTF_8));
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param result
|
||||
* @param type
|
||||
* @param genericType
|
||||
* @param annotations
|
||||
* @param mediaType
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public long getSize(RestActionResult result, Class<?> type, Type genericType,
|
||||
Annotation[] annotations, MediaType mediaType)
|
||||
@@ -98,17 +66,6 @@ public class RestActionUploadResultMessageWriter
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param type
|
||||
* @param genericType
|
||||
* @param annotations
|
||||
* @param mediaType
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean isWriteable(Class<?> type, Type genericType,
|
||||
Annotation[] annotations, MediaType mediaType)
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.api.rest;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Objects;
|
||||
@@ -33,69 +32,38 @@ import jakarta.xml.bind.annotation.XmlAccessType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlRootElement(name = "exception")
|
||||
public class RestExceptionResult
|
||||
{
|
||||
private String message;
|
||||
|
||||
private String stacktrace;
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
public RestExceptionResult() {}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param throwable
|
||||
*/
|
||||
|
||||
public RestExceptionResult(Throwable throwable)
|
||||
{
|
||||
this(throwable.getMessage(), throwable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param message
|
||||
* @param stacktrace
|
||||
*/
|
||||
|
||||
public RestExceptionResult(String message, String stacktrace)
|
||||
{
|
||||
this.message = message;
|
||||
this.stacktrace = stacktrace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param message
|
||||
* @param throwable
|
||||
*/
|
||||
|
||||
public RestExceptionResult(String message, Throwable throwable)
|
||||
{
|
||||
this(message, Throwables.getStackTraceAsString(throwable));
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param obj
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
@@ -115,24 +83,14 @@ public class RestExceptionResult
|
||||
&& Objects.equal(stacktrace, other.stacktrace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hashCode(message, stacktrace);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
@@ -144,59 +102,30 @@ public class RestExceptionResult
|
||||
//J+
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public String getMessage()
|
||||
{
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public String getStacktrace()
|
||||
{
|
||||
return stacktrace;
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
|
||||
public void setMessage(String message)
|
||||
{
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param stacktrace
|
||||
*/
|
||||
|
||||
public void setStacktrace(String stacktrace)
|
||||
{
|
||||
this.stacktrace = stacktrace;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private String message;
|
||||
|
||||
/** Field description */
|
||||
private String stacktrace;
|
||||
}
|
||||
|
||||
@@ -24,25 +24,17 @@
|
||||
|
||||
package sonia.scm.api.rest;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import jakarta.ws.rs.core.Response;
|
||||
import jakarta.ws.rs.ext.Provider;
|
||||
import sonia.scm.security.ScmSecurityException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
@Provider
|
||||
public class ScmSecurityExceptionMapper
|
||||
extends StatusExceptionMapper<ScmSecurityException>
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
public ScmSecurityExceptionMapper()
|
||||
{
|
||||
super(ScmSecurityException.class, Response.Status.FORBIDDEN);
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.api.rest;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
@@ -32,20 +31,11 @@ import jakarta.ws.rs.ext.ExceptionMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @param <E>
|
||||
*/
|
||||
public class StatusExceptionMapper<E extends Throwable>
|
||||
implements ExceptionMapper<E>
|
||||
{
|
||||
|
||||
/**
|
||||
* the logger for StatusExceptionMapper
|
||||
*/
|
||||
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(StatusExceptionMapper.class);
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.api.rest;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import jakarta.ws.rs.WebApplicationException;
|
||||
@@ -43,10 +42,7 @@ import java.io.PrintWriter;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
@Provider
|
||||
public class TemplateEngineViewable implements MessageBodyWriter<Viewable>
|
||||
{
|
||||
|
||||
@@ -64,8 +64,6 @@ public class AvailablePluginResource {
|
||||
|
||||
/**
|
||||
* Returns a collection of available plugins.
|
||||
*
|
||||
* @return collection of available plugins.
|
||||
*/
|
||||
@GET
|
||||
@Path("")
|
||||
@@ -107,8 +105,6 @@ public class AvailablePluginResource {
|
||||
|
||||
/**
|
||||
* Returns available plugin.
|
||||
*
|
||||
* @return available plugin.
|
||||
*/
|
||||
@GET
|
||||
@Path("/{name}")
|
||||
|
||||
@@ -64,8 +64,6 @@ public class InstalledPluginResource {
|
||||
|
||||
/**
|
||||
* Returns a collection of installed plugins.
|
||||
*
|
||||
* @return collection of installed plugins.
|
||||
*/
|
||||
@GET
|
||||
@Path("")
|
||||
@@ -129,7 +127,6 @@ public class InstalledPluginResource {
|
||||
* Returns the installed plugin with the given id.
|
||||
*
|
||||
* @param name name of plugin
|
||||
* @return installed plugin with specified id
|
||||
*/
|
||||
@GET
|
||||
@Path("/{name}")
|
||||
|
||||
@@ -62,7 +62,6 @@ public class NamespaceStrategyResource {
|
||||
*
|
||||
* @param uriInfo uri info
|
||||
*
|
||||
* @return available and current namespace strategies
|
||||
*/
|
||||
@GET
|
||||
@Path("")
|
||||
|
||||
@@ -368,13 +368,6 @@ public class RepositoryPermissionRootResource {
|
||||
.orElseThrow(() -> notFound(entity(namespaceAndName)));
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the permission already exists in the repository
|
||||
*
|
||||
* @param permission the searched permission
|
||||
* @param repository the repository to be inspected
|
||||
* @throws AlreadyExistsException if the permission already exists in the repository
|
||||
*/
|
||||
private void checkPermissionAlreadyExists(RepositoryPermissionDto permission, Repository repository) {
|
||||
if (isPermissionExist(permission, repository)) {
|
||||
throw alreadyExists(entity("Permission", permission.getName()).in(repository));
|
||||
|
||||
@@ -59,8 +59,6 @@ public class UIPluginResource {
|
||||
|
||||
/**
|
||||
* Returns a collection of installed plugins and their ui bundles.
|
||||
*
|
||||
* @return collection of installed plugins.
|
||||
*/
|
||||
@GET
|
||||
@Path("")
|
||||
@@ -95,7 +93,6 @@ public class UIPluginResource {
|
||||
*
|
||||
* @param id id of plugin
|
||||
*
|
||||
* @return installed plugin with specified id
|
||||
*/
|
||||
@GET
|
||||
@Path("{id}")
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
|
||||
package sonia.scm.cache;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
||||
import java.io.File;
|
||||
@@ -34,9 +32,7 @@ import java.net.URL;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
@ImplementedBy(DefaultCacheConfigurationLoader.class)
|
||||
public interface CacheConfigurationLoader {
|
||||
|
||||
|
||||
@@ -24,53 +24,28 @@
|
||||
|
||||
package sonia.scm.cache;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
public class CacheException extends RuntimeException
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
private static final long serialVersionUID = -1108209749696572319L;
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
public CacheException() {}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param message
|
||||
*/
|
||||
|
||||
public CacheException(String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param cause
|
||||
*/
|
||||
|
||||
public CacheException(Throwable cause)
|
||||
{
|
||||
super(cause);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param message
|
||||
* @param cause
|
||||
*/
|
||||
|
||||
public CacheException(String message, Throwable cause)
|
||||
{
|
||||
super(message, cause);
|
||||
|
||||
@@ -24,20 +24,14 @@
|
||||
|
||||
package sonia.scm.cache;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.io.DeepCopy;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
public enum CopyStrategy
|
||||
{
|
||||
|
||||
@@ -61,30 +55,14 @@ public enum CopyStrategy
|
||||
this.copyOnWrite = copyOnWrite;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param value
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public static CopyStrategy fromString(String value)
|
||||
{
|
||||
return valueOf(value.toUpperCase(Locale.ENGLISH).replace("-", ""));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param object
|
||||
* @param <T>
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public <T> T copyOnRead(T object)
|
||||
{
|
||||
return copyOnRead
|
||||
@@ -92,15 +70,7 @@ public enum CopyStrategy
|
||||
: object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param object
|
||||
* @param <T>
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public <T> T copyOnWrite(T object)
|
||||
{
|
||||
return copyOnWrite
|
||||
@@ -108,30 +78,15 @@ public enum CopyStrategy
|
||||
: object;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public String getConfigName()
|
||||
{
|
||||
return configName;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param object
|
||||
* @param <T>
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
private <T> T deepCopy(T object)
|
||||
{
|
||||
T copy = null;
|
||||
@@ -151,12 +106,9 @@ public enum CopyStrategy
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private String configName;
|
||||
|
||||
/** Field description */
|
||||
private boolean copyOnRead;
|
||||
|
||||
/** Field description */
|
||||
private boolean copyOnWrite;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.cache;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.collect.Iterators;
|
||||
import jakarta.inject.Inject;
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.cache;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Maps;
|
||||
@@ -42,24 +41,17 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
public class GuavaCacheConfigurationReader {
|
||||
|
||||
/**
|
||||
* the logger for CacheConfigurationReader
|
||||
*/
|
||||
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(GuavaCacheConfigurationReader.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
private JAXBContext context;
|
||||
|
||||
private CacheConfigurationLoader loader;
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
* @param loader
|
||||
*/
|
||||
@Inject
|
||||
public GuavaCacheConfigurationReader(CacheConfigurationLoader loader) {
|
||||
this.loader = loader;
|
||||
@@ -71,7 +63,6 @@ public class GuavaCacheConfigurationReader {
|
||||
}
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
public GuavaCacheManagerConfiguration read() {
|
||||
URL defaultConfigUrl = loader.getDefaultResource();
|
||||
@@ -127,13 +118,7 @@ public class GuavaCacheConfigurationReader {
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
* @param config
|
||||
* @param other
|
||||
* @return
|
||||
*/
|
||||
|
||||
private GuavaCacheManagerConfiguration merge(
|
||||
GuavaCacheManagerConfiguration config, GuavaCacheManagerConfiguration other) {
|
||||
GuavaCacheConfiguration defaultCache = config.getDefaultCache();
|
||||
@@ -154,13 +139,7 @@ public class GuavaCacheConfigurationReader {
|
||||
ImmutableList.copyOf(namedCaches.values()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
* @param url
|
||||
* @param fail
|
||||
* @return
|
||||
*/
|
||||
|
||||
private GuavaCacheManagerConfiguration readConfiguration(URL url, boolean fail) {
|
||||
logger.debug("read cache configuration from {}", url);
|
||||
|
||||
@@ -180,15 +159,4 @@ public class GuavaCacheConfigurationReader {
|
||||
return config;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Field description
|
||||
*/
|
||||
private JAXBContext context;
|
||||
|
||||
/**
|
||||
* Field description
|
||||
*/
|
||||
private CacheConfigurationLoader loader;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
/**
|
||||
* Guava based implementation of {@link CacheManager} and {@link org.apache.shiro.cache.CacheManager}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Singleton
|
||||
public class GuavaCacheManager implements CacheManager, org.apache.shiro.cache.CacheManager {
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
|
||||
package sonia.scm.cache;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||
import jakarta.xml.bind.annotation.XmlElement;
|
||||
@@ -34,28 +32,20 @@ import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
@XmlRootElement(name = "caches")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class GuavaCacheManagerConfiguration
|
||||
{
|
||||
@XmlElement(name = "cache")
|
||||
private List<GuavaNamedCacheConfiguration> caches;
|
||||
|
||||
@XmlElement(name = "defaultCache")
|
||||
private GuavaCacheConfiguration defaultCache;
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*/
|
||||
public GuavaCacheManagerConfiguration() {}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param defaultCache
|
||||
* @param caches
|
||||
*/
|
||||
|
||||
public GuavaCacheManagerConfiguration(GuavaCacheConfiguration defaultCache,
|
||||
List<GuavaNamedCacheConfiguration> caches)
|
||||
{
|
||||
@@ -63,14 +53,8 @@ public class GuavaCacheManagerConfiguration
|
||||
this.caches = caches;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<GuavaNamedCacheConfiguration> getCaches()
|
||||
{
|
||||
@@ -82,24 +66,10 @@ public class GuavaCacheManagerConfiguration
|
||||
return caches;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public GuavaCacheConfiguration getDefaultCache()
|
||||
{
|
||||
return defaultCache;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
@XmlElement(name = "cache")
|
||||
private List<GuavaNamedCacheConfiguration> caches;
|
||||
|
||||
/** Field description */
|
||||
@XmlElement(name = "defaultCache")
|
||||
private GuavaCacheConfiguration defaultCache;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
|
||||
package sonia.scm.cache;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||
import jakarta.xml.bind.annotation.XmlAttribute;
|
||||
|
||||
@@ -24,43 +24,20 @@
|
||||
|
||||
package sonia.scm.cache;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import jakarta.xml.bind.annotation.adapters.XmlAdapter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
public class XmlCopyStrategyAdapter extends XmlAdapter<String, CopyStrategy>
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param v
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
@Override
|
||||
public String marshal(CopyStrategy v) throws Exception
|
||||
{
|
||||
return v.getConfigName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param v
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
|
||||
@Override
|
||||
public CopyStrategy unmarshal(String v) throws Exception
|
||||
{
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.config;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import ch.qos.logback.core.PropertyDefinerBase;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
@@ -34,15 +33,12 @@ import sonia.scm.SCMContext;
|
||||
import sonia.scm.SCMContextProvider;
|
||||
import sonia.scm.util.SystemUtil;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Resolve directory path for SCM-Manager logs.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class ScmLogFilePropertyDefiner extends PropertyDefinerBase {
|
||||
|
||||
|
||||
@@ -38,23 +38,15 @@ import sonia.scm.repository.PostReceiveRepositoryHookEvent;
|
||||
/**
|
||||
* {@link PostReceiveRepositoryHookEvent} which stores receives data and passes it to the {@link DebugService}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@EagerSingleton
|
||||
public final class DebugHook
|
||||
{
|
||||
/**
|
||||
* the logger for DebugHook
|
||||
*/
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(DebugHook.class);
|
||||
|
||||
private final DebugService debugService;
|
||||
|
||||
/**
|
||||
* Constructs a new instance.
|
||||
*
|
||||
* @param debugService debug service
|
||||
*/
|
||||
@Inject
|
||||
public DebugHook(DebugService debugService)
|
||||
{
|
||||
|
||||
@@ -34,7 +34,6 @@ import java.util.Date;
|
||||
/**
|
||||
* Received data from repository hook event.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@XmlRootElement(name = "hook")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@@ -44,7 +43,7 @@ public class DebugHookData
|
||||
private Collection<String> changesets;
|
||||
|
||||
/**
|
||||
* Constructs a new instance. This constructor should only be used by JAXB.
|
||||
* This constructor should only be used by JAXB.
|
||||
*/
|
||||
public DebugHookData()
|
||||
{
|
||||
@@ -63,8 +62,6 @@ public class DebugHookData
|
||||
|
||||
/**
|
||||
* Returns the receiving date.
|
||||
*
|
||||
* @return receiving date
|
||||
*/
|
||||
public Date getDate()
|
||||
{
|
||||
@@ -73,8 +70,6 @@ public class DebugHookData
|
||||
|
||||
/**
|
||||
* Return collection of changeset ids.
|
||||
*
|
||||
* @return collection of changeset ids
|
||||
*/
|
||||
public Collection<String> getChangesets()
|
||||
{
|
||||
|
||||
@@ -30,7 +30,6 @@ import com.google.inject.AbstractModule;
|
||||
* DebugModule binds all required classes around the {@link DebugService}. The module will only be activated, if the
|
||||
* application was started in development stage.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public final class DebugModule extends AbstractModule
|
||||
{
|
||||
|
||||
@@ -37,18 +37,12 @@ import java.util.Collection;
|
||||
/**
|
||||
* Rest api resource for the {@link DebugService}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Path("debug/{namespace}/{name}/post-receive")
|
||||
public final class DebugResource
|
||||
{
|
||||
private final DebugService debugService;
|
||||
|
||||
/**
|
||||
* Constructs a new instance.
|
||||
*
|
||||
* @param debugService debug service
|
||||
*/
|
||||
@Inject
|
||||
public DebugResource(DebugService debugService)
|
||||
{
|
||||
|
||||
@@ -38,7 +38,6 @@ import java.util.Collection;
|
||||
/**
|
||||
* The DebugService stores and returns received data from repository hook events.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Singleton
|
||||
public final class DebugService
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.event;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.github.legman.EventBus;
|
||||
import com.github.legman.Subscribe;
|
||||
@@ -39,18 +38,13 @@ import sonia.scm.metrics.MeterRegistryProvider;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
public class LegmanScmEventBus extends ScmEventBus {
|
||||
|
||||
private static final AtomicLong INSTANCE_COUNTER = new AtomicLong();
|
||||
private static final String FORMAT_NAME = "ScmEventBus-%s";
|
||||
|
||||
/**
|
||||
* the logger for LegmanScmEventBus
|
||||
*/
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(LegmanScmEventBus.class);
|
||||
|
||||
private String name;
|
||||
|
||||
@@ -38,15 +38,11 @@ import sonia.scm.web.filter.HttpFilter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
@Priority(Filters.PRIORITY_BASEURL)
|
||||
@WebElement(Filters.PATTERN_ALL)
|
||||
public class BaseUrlFilter extends HttpFilter {
|
||||
|
||||
/** scm configuration */
|
||||
private final ScmConfiguration configuration;
|
||||
|
||||
@Inject
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.filter;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import jakarta.servlet.FilterChain;
|
||||
@@ -42,10 +41,7 @@ import sonia.scm.web.filter.HttpFilter;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
@Priority(Filters.PRIORITY_POST_AUTHENTICATION)
|
||||
@WebElement(Filters.PATTERN_ALL)
|
||||
public class MDCFilter extends HttpFilter
|
||||
@@ -67,19 +63,8 @@ public class MDCFilter extends HttpFilter
|
||||
@VisibleForTesting
|
||||
static final String MDC_USERNAME = "username";
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param chain
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws ServletException
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected void doFilter(HttpServletRequest request,
|
||||
HttpServletResponse response, FilterChain chain)
|
||||
@@ -107,14 +92,8 @@ public class MDCFilter extends HttpFilter
|
||||
}
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
private String getUsername()
|
||||
{
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.filter;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.inject.Inject;
|
||||
@@ -43,12 +42,7 @@ import sonia.scm.web.filter.PropagatePrincipleServletRequestWrapper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Priority(Filters.PRIORITY_AUTHORIZATION)
|
||||
public class PropagatePrincipleFilter extends HttpFilter
|
||||
{
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.filter;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.Singleton;
|
||||
import jakarta.servlet.FilterChain;
|
||||
@@ -41,47 +40,23 @@ import sonia.scm.web.filter.HttpFilter;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Singleton
|
||||
public class StaticResourceFilter extends HttpFilter
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(StaticResourceFilter.class);
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param filterConfig
|
||||
*
|
||||
* @throws ServletException
|
||||
*/
|
||||
private ServletContext context;
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException
|
||||
{
|
||||
this.context = filterConfig.getServletContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param chain
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws ServletException
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected void doFilter(HttpServletRequest request,
|
||||
HttpServletResponse response, FilterChain chain)
|
||||
@@ -115,17 +90,8 @@ public class StaticResourceFilter extends HttpFilter
|
||||
}
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param request
|
||||
* @param uri
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
private File getResourceFile(HttpServletRequest request, String uri)
|
||||
{
|
||||
String path = uri.substring(request.getContextPath().length());
|
||||
@@ -133,8 +99,4 @@ public class StaticResourceFilter extends HttpFilter
|
||||
return new File(context.getRealPath(path));
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private ServletContext context;
|
||||
}
|
||||
|
||||
@@ -28,9 +28,6 @@ import lombok.Value;
|
||||
import sonia.scm.plugin.WebElementDescriptor;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @param <T>
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Value
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.filter;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Ordering;
|
||||
@@ -40,27 +39,18 @@ import sonia.scm.plugin.WebElementExtension;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
public final class WebElementCollector
|
||||
{
|
||||
|
||||
/**
|
||||
* the logger for WebElementCollector
|
||||
*/
|
||||
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(WebElementCollector.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
private final Iterable<TypedWebElementDescriptor<Filter>> filters;
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param elements
|
||||
*/
|
||||
private final Iterable<TypedWebElementDescriptor<HttpServlet>> servlets;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private WebElementCollector(Iterable<WebElementExtension> elements)
|
||||
{
|
||||
@@ -95,68 +85,34 @@ public final class WebElementCollector
|
||||
servlets = ordering.immutableSortedCopy(sl);
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param loader
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public static WebElementCollector collect(PluginLoader loader)
|
||||
{
|
||||
return new WebElementCollector(
|
||||
loader.getExtensionProcessor().getWebElements());
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public Iterable<TypedWebElementDescriptor<Filter>> getFilters()
|
||||
{
|
||||
return filters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public Iterable<TypedWebElementDescriptor<HttpServlet>> getServlets()
|
||||
{
|
||||
return servlets;
|
||||
}
|
||||
|
||||
//~--- inner classes --------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Class description
|
||||
*
|
||||
*
|
||||
* @version Enter version here..., 15/02/01
|
||||
* @author Enter your name here...
|
||||
*/
|
||||
|
||||
|
||||
private static class TypedWebElementDescriptorOrdering
|
||||
extends Ordering<TypedWebElementDescriptor<?>>
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param left
|
||||
* @param right
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int compare(TypedWebElementDescriptor<?> left,
|
||||
TypedWebElementDescriptor<?> right)
|
||||
@@ -166,12 +122,4 @@ public final class WebElementCollector
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private final Iterable<TypedWebElementDescriptor<Filter>> filters;
|
||||
|
||||
/** Field description */
|
||||
private final Iterable<TypedWebElementDescriptor<HttpServlet>> servlets;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.filter;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.Scopes;
|
||||
import com.google.inject.servlet.ServletModule;
|
||||
@@ -35,17 +34,13 @@ import org.slf4j.LoggerFactory;
|
||||
import sonia.scm.plugin.PluginLoader;
|
||||
import sonia.scm.plugin.WebElementDescriptor;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
public class WebElementModule extends ServletModule {
|
||||
|
||||
/**
|
||||
* the logger for WebElementModule
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(WebElementModule.class);
|
||||
|
||||
private final WebElementCollector collector;
|
||||
|
||||
public WebElementModule(PluginLoader pluginLoader)
|
||||
{
|
||||
collector = WebElementCollector.collect(pluginLoader);
|
||||
@@ -113,8 +108,4 @@ public class WebElementModule extends ServletModule {
|
||||
builder.with(clazz);
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private final WebElementCollector collector;
|
||||
}
|
||||
|
||||
@@ -52,9 +52,7 @@ import java.util.function.Predicate;
|
||||
|
||||
import static java.util.stream.Collectors.toSet;
|
||||
|
||||
/**
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
@Singleton
|
||||
public class DefaultGroupManager extends AbstractGroupManager {
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.group;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
@@ -32,63 +31,37 @@ import com.google.inject.Provider;
|
||||
import sonia.scm.Undecorated;
|
||||
import sonia.scm.util.Decorators;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
public class GroupManagerProvider implements Provider<GroupManager>
|
||||
{
|
||||
@Inject(optional = true)
|
||||
private Set<GroupManagerDecoratorFactory> decoratorFactories;
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Inject
|
||||
@Undecorated
|
||||
private Provider<GroupManager> groupManagerProvider;
|
||||
|
||||
@Override
|
||||
public GroupManager get()
|
||||
{
|
||||
return Decorators.decorate(groupManagerProvider.get(), decoratorFactories);
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param decoratorFactories
|
||||
*/
|
||||
|
||||
public void setDecoratorFactories(
|
||||
Set<GroupManagerDecoratorFactory> decoratorFactories)
|
||||
{
|
||||
this.decoratorFactories = decoratorFactories;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param groupManagerProvider
|
||||
*/
|
||||
|
||||
public void setGroupManagerProvider(
|
||||
Provider<GroupManager> groupManagerProvider)
|
||||
{
|
||||
this.groupManagerProvider = groupManagerProvider;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
@Inject(optional = true)
|
||||
private Set<GroupManagerDecoratorFactory> decoratorFactories;
|
||||
|
||||
/** Field description */
|
||||
@Inject
|
||||
@Undecorated
|
||||
private Provider<GroupManager> groupManagerProvider;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ import sonia.scm.security.AccessToken;
|
||||
/**
|
||||
* Generates cookies and invalidates initialization token cookies.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.35.0
|
||||
*/
|
||||
public interface InitializationCookieIssuer {
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.lifecycle;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.github.legman.Subscribe;
|
||||
import com.google.inject.servlet.GuiceFilter;
|
||||
@@ -37,24 +36,16 @@ import sonia.scm.event.ScmEventBus;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class BootstrapContextFilter extends GuiceFilter {
|
||||
|
||||
/**
|
||||
* the logger for BootstrapContextFilter
|
||||
*/
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(BootstrapContextFilter.class);
|
||||
|
||||
private final BootstrapContextListener listener = new BootstrapContextListener();
|
||||
|
||||
private ClassLoader webAppClassLoader;
|
||||
|
||||
/** Field description */
|
||||
private FilterConfig filterConfig;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -56,9 +56,7 @@ import sonia.scm.update.UpdateEngine;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
public class BootstrapContextListener extends GuiceServletContextListener {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(BootstrapContextListener.class);
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.lifecycle.modules;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Objects;
|
||||
@@ -32,24 +31,14 @@ import jakarta.xml.bind.annotation.XmlAccessType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||
import sonia.scm.Validateable;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class ClassOverride implements Validateable
|
||||
{
|
||||
private Class<?> bind;
|
||||
|
||||
private Class<?> to;
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param obj
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
@@ -68,24 +57,14 @@ public class ClassOverride implements Validateable
|
||||
return Objects.equal(bind, other.bind) && Objects.equal(to, other.to);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hashCode(bind, to);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
@@ -97,71 +76,37 @@ public class ClassOverride implements Validateable
|
||||
//J+
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public Class<?> getBind()
|
||||
{
|
||||
return bind;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public Class<?> getTo()
|
||||
{
|
||||
return to;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean isValid()
|
||||
{
|
||||
return (bind != null) && (to != null);
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param bind
|
||||
*/
|
||||
|
||||
public void setBind(Class<?> bind)
|
||||
{
|
||||
this.bind = bind;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param to
|
||||
*/
|
||||
|
||||
public void setTo(Class<?> to)
|
||||
{
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private Class<?> bind;
|
||||
|
||||
/** Field description */
|
||||
private Class<?> to;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.lifecycle.modules;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Lists;
|
||||
@@ -48,35 +47,24 @@ import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
@XmlRootElement(name = "overrides")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class ClassOverrides implements Iterable<ClassOverride>
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
public static final String OVERRIDE_PATH = "META-INF/scm/override.xml";
|
||||
|
||||
/**
|
||||
* the logger for ClassOverrides
|
||||
*/
|
||||
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(ClassOverrides.class);
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
@XmlElement(name = "module")
|
||||
private List<Class<? extends Module>> moduleClasses;
|
||||
|
||||
@XmlElement(name = "override")
|
||||
private List<ClassOverride> overrides;
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param classLoader
|
||||
* @return
|
||||
*
|
||||
*/
|
||||
public static ClassOverrides findOverrides(ClassLoader classLoader)
|
||||
{
|
||||
final ClassOverrides overrides = new ClassOverrides();
|
||||
@@ -133,12 +121,7 @@ public class ClassOverrides implements Iterable<ClassOverride>
|
||||
return overrides;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param overrides
|
||||
*/
|
||||
|
||||
public void append(ClassOverrides overrides)
|
||||
{
|
||||
AssertUtil.assertIsNotNull(overrides);
|
||||
@@ -158,26 +141,15 @@ public class ClassOverrides implements Iterable<ClassOverride>
|
||||
getModuleClasses().addAll(overrides.getModuleClasses());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public Iterator<ClassOverride> iterator()
|
||||
{
|
||||
return getOverrides().iterator();
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public List<Class<? extends Module>> getModuleClasses()
|
||||
{
|
||||
if (moduleClasses == null)
|
||||
@@ -188,12 +160,7 @@ public class ClassOverrides implements Iterable<ClassOverride>
|
||||
return moduleClasses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<? extends Module> getModules()
|
||||
{
|
||||
@@ -232,15 +199,7 @@ public class ClassOverrides implements Iterable<ClassOverride>
|
||||
return modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param clazz
|
||||
* @param <T>
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> Class<T> getOverride(Class<T> clazz)
|
||||
{
|
||||
@@ -257,12 +216,7 @@ public class ClassOverrides implements Iterable<ClassOverride>
|
||||
return implementation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public List<ClassOverride> getOverrides()
|
||||
{
|
||||
if (overrides == null)
|
||||
@@ -273,38 +227,17 @@ public class ClassOverrides implements Iterable<ClassOverride>
|
||||
return overrides;
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param moduleClasses
|
||||
*/
|
||||
|
||||
public void setModuleClasses(List<Class<? extends Module>> moduleClasses)
|
||||
{
|
||||
this.moduleClasses = moduleClasses;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param overrides
|
||||
*/
|
||||
|
||||
public void setOverrides(List<ClassOverride> overrides)
|
||||
{
|
||||
this.overrides = overrides;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
@XmlElement(name = "module")
|
||||
private List<Class<? extends Module>> moduleClasses;
|
||||
|
||||
/** Field description */
|
||||
@XmlElement(name = "override")
|
||||
private List<ClassOverride> overrides;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ import java.util.concurrent.ConcurrentLinkedDeque;
|
||||
* Guice module which captures all classes which are implementing the {@link Closeable}. These classes can be later
|
||||
* closed, by injecting the {@link CloseableModule} and calling {@link #closeAll()}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public final class CloseableModule extends AbstractModule {
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.lifecycle.modules;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.inject.AbstractModule;
|
||||
@@ -38,13 +37,10 @@ import sonia.scm.EagerSingleton;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Guice module which captures all classes which are annotated with {@link EagerSingleton}. These classes can be later
|
||||
* initialized.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class EagerSingletonModule extends AbstractModule {
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.lifecycle.modules;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.inject.AbstractModule;
|
||||
@@ -38,7 +37,6 @@ import sonia.scm.event.ScmEventBus;
|
||||
/**
|
||||
* Registers every instance to the scm-manager event bus.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class ScmEventBusModule extends AbstractModule {
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.lifecycle.modules;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.TypeLiteral;
|
||||
@@ -39,7 +38,6 @@ import sonia.scm.SCMContext;
|
||||
/**
|
||||
* Initializes all instances which are implementing the {@link Initable} interface.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class ScmInitializerModule extends AbstractModule {
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.lifecycle.modules;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.name.Names;
|
||||
import jakarta.servlet.ServletContext;
|
||||
@@ -48,44 +47,25 @@ import sonia.scm.security.DisabledRememberMeManager;
|
||||
import sonia.scm.security.ScmAtLeastOneSuccessfulStrategy;
|
||||
import sonia.scm.security.ScmPermissionResolver;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
public class ScmSecurityModule extends ShiroWebModule
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
private static final int ITERATIONS = 8192;
|
||||
|
||||
/**
|
||||
* the logger for ScmSecurityModule
|
||||
*/
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(ScmSecurityModule.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param servletContext
|
||||
* @param extensionProcessor
|
||||
*/
|
||||
private final ExtensionProcessor extensionProcessor;
|
||||
|
||||
public ScmSecurityModule(ServletContext servletContext, ExtensionProcessor extensionProcessor)
|
||||
{
|
||||
super(servletContext);
|
||||
this.extensionProcessor = extensionProcessor;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void configureShiroWeb()
|
||||
{
|
||||
@@ -153,11 +133,6 @@ public class ScmSecurityModule extends ShiroWebModule
|
||||
return passwordService;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private final ExtensionProcessor extensionProcessor;
|
||||
|
||||
static class IdempotentPasswordService extends DefaultPasswordService {
|
||||
|
||||
private boolean isEncrypted(Object password) {
|
||||
|
||||
@@ -143,9 +143,7 @@ import sonia.scm.work.DefaultCentralWorkQueue;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.TrustManager;
|
||||
|
||||
/**
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
class ScmServletModule extends ServletModule {
|
||||
|
||||
private static final String PATTERN_ALL = "/*";
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.lifecycle.modules;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
@@ -34,10 +33,7 @@ import jakarta.servlet.ServletContextListener;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
@Singleton
|
||||
public class ServletContextListenerHolder implements ServletContextListener {
|
||||
|
||||
|
||||
@@ -38,14 +38,11 @@ import java.security.NoSuchAlgorithmException;
|
||||
* Provider for {@link SSLContext}. The provider will first try to retrieve the {@link SSLContext} from an "default"
|
||||
* named optional provider, if this fails the provider will return the jvm default context.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @version 1.47
|
||||
*/
|
||||
public final class SSLContextProvider implements Provider<SSLContext> {
|
||||
|
||||
/**
|
||||
* the logger for SSLContextProvider
|
||||
*/
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(SSLContextProvider.class);
|
||||
|
||||
@Named("default")
|
||||
|
||||
@@ -24,27 +24,14 @@
|
||||
|
||||
package sonia.scm.net;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.SSLSession;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
public class TrustAllHostnameVerifier implements HostnameVerifier
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param hostname
|
||||
* @param session
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean verify(String hostname, SSLSession session)
|
||||
{
|
||||
|
||||
@@ -24,53 +24,26 @@
|
||||
|
||||
package sonia.scm.net;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import javax.net.ssl.X509TrustManager;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
public class TrustAllTrustManager implements X509TrustManager
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param chain
|
||||
* @param authType
|
||||
*
|
||||
* @throws CertificateException
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void checkClientTrusted(X509Certificate[] chain, String authType)
|
||||
throws CertificateException {}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param chain
|
||||
* @param authType
|
||||
*
|
||||
* @throws CertificateException
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void checkServerTrusted(X509Certificate[] chain, String authType)
|
||||
throws CertificateException {}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public X509Certificate[] getAcceptedIssuers()
|
||||
{
|
||||
|
||||
@@ -49,14 +49,11 @@ import java.util.Set;
|
||||
* Default implementation of the {@link AdvancedHttpClient}. The default
|
||||
* implementation uses {@link HttpURLConnection}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.46
|
||||
*/
|
||||
public class DefaultAdvancedHttpClient extends AdvancedHttpClient {
|
||||
|
||||
/**
|
||||
* the logger for DefaultAdvancedHttpClient
|
||||
*/
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(DefaultAdvancedHttpClient.class);
|
||||
|
||||
private final HttpURLConnectionFactory connectionFactory;
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.net.ahc;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.collect.LinkedHashMultimap;
|
||||
import com.google.common.collect.Multimap;
|
||||
@@ -33,8 +32,6 @@ import com.google.common.io.ByteSource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
@@ -46,11 +43,22 @@ import java.util.Map.Entry;
|
||||
/**
|
||||
* Http server response object of {@link DefaultAdvancedHttpClient}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.46
|
||||
*/
|
||||
public class DefaultAdvancedHttpResponse extends AdvancedHttpResponse
|
||||
{
|
||||
private final DefaultAdvancedHttpClient client;
|
||||
|
||||
private final HttpURLConnection connection;
|
||||
|
||||
/** server response status */
|
||||
private final int status;
|
||||
|
||||
/** server response text */
|
||||
private final String statusText;
|
||||
|
||||
/** http headers */
|
||||
private Multimap<String, String> headers;
|
||||
|
||||
/**
|
||||
* Constructs a new {@link DefaultAdvancedHttpResponse}.
|
||||
@@ -69,22 +77,16 @@ HttpURLConnection connection, int status, String statusText)
|
||||
this.statusText = statusText;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public ByteSource contentAsByteSource() throws IOException
|
||||
{
|
||||
return new URLConnectionByteSource(connection);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public Multimap<String, String> getHeaders()
|
||||
{
|
||||
@@ -102,29 +104,22 @@ HttpURLConnection connection, int status, String statusText)
|
||||
return headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int getStatus()
|
||||
{
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public String getStatusText()
|
||||
{
|
||||
return statusText;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@Override
|
||||
protected ContentTransformer createTransformer(Class<?> type,
|
||||
String contentType)
|
||||
@@ -132,7 +127,7 @@ HttpURLConnection connection, int status, String statusText)
|
||||
return client.createTransformer(type, contentType);
|
||||
}
|
||||
|
||||
//~--- inner classes --------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* {@link ByteSource} implementation of a http connection.
|
||||
@@ -140,26 +135,17 @@ HttpURLConnection connection, int status, String statusText)
|
||||
private static class URLConnectionByteSource extends ByteSource
|
||||
{
|
||||
|
||||
/**
|
||||
* the logger for URLConnectionByteSource
|
||||
*/
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(URLConnectionByteSource.class);
|
||||
|
||||
//~--- constructors -------------------------------------------------------
|
||||
private final HttpURLConnection connection;
|
||||
|
||||
/**
|
||||
* Constructs a new {@link URLConnectionByteSource}.
|
||||
*
|
||||
*
|
||||
* @param connection http connection
|
||||
*/
|
||||
private URLConnectionByteSource(HttpURLConnection connection)
|
||||
{
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
//~--- methods ------------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* Opens the input stream of http connection, if an error occurs during
|
||||
@@ -193,27 +179,6 @@ HttpURLConnection connection, int status, String statusText)
|
||||
return stream;
|
||||
}
|
||||
|
||||
//~--- fields -------------------------------------------------------------
|
||||
|
||||
/** http connection */
|
||||
private final HttpURLConnection connection;
|
||||
}
|
||||
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private final DefaultAdvancedHttpClient client;
|
||||
|
||||
/** http connection */
|
||||
private final HttpURLConnection connection;
|
||||
|
||||
/** server response status */
|
||||
private final int status;
|
||||
|
||||
/** server response text */
|
||||
private final String statusText;
|
||||
|
||||
/** http headers */
|
||||
private Multimap<String, String> headers;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.net.ahc;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.fasterxml.jackson.databind.AnnotationIntrospector;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
@@ -46,17 +45,13 @@ import java.io.InputStream;
|
||||
* {@link ContentTransformer} for json. The {@link JsonContentTransformer} uses
|
||||
* jacksons {@link ObjectMapper} to marshalling/unmarshalling.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.46
|
||||
*/
|
||||
@Extension
|
||||
public class JsonContentTransformer implements ContentTransformer
|
||||
{
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
/**
|
||||
* Constructs a new {@link JsonContentTransformer}.
|
||||
*
|
||||
*/
|
||||
public JsonContentTransformer()
|
||||
{
|
||||
this.mapper = new ObjectMapper();
|
||||
@@ -71,11 +66,8 @@ public class JsonContentTransformer implements ContentTransformer
|
||||
this.mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public ByteSource marshall(Object object)
|
||||
{
|
||||
@@ -95,9 +87,7 @@ public class JsonContentTransformer implements ContentTransformer
|
||||
return source;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public <T> T unmarshall(Class<T> type, ByteSource content)
|
||||
{
|
||||
@@ -121,7 +111,6 @@ public class JsonContentTransformer implements ContentTransformer
|
||||
return object;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns {@code true}, if the content type is compatible with
|
||||
@@ -140,8 +129,4 @@ public class JsonContentTransformer implements ContentTransformer
|
||||
return MediaType.valueOf(contentType).isCompatible(MediaType.APPLICATION_JSON_TYPE);
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** object mapper */
|
||||
private final ObjectMapper mapper;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.net.ahc;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.io.ByteSource;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
@@ -37,22 +36,17 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* {@link ContentTransformer} for xml. The {@link XmlContentTransformer} uses
|
||||
* jaxb to marshalling/unmarshalling.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.46
|
||||
*/
|
||||
@Extension
|
||||
public class XmlContentTransformer implements ContentTransformer
|
||||
{
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public ByteSource marshall(Object object)
|
||||
{
|
||||
@@ -72,9 +66,7 @@ public class XmlContentTransformer implements ContentTransformer
|
||||
return source;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public <T> T unmarshall(Class<T> type, ByteSource content)
|
||||
{
|
||||
@@ -97,7 +89,6 @@ public class XmlContentTransformer implements ContentTransformer
|
||||
return object;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns {@code true}, if the content type is compatible with
|
||||
|
||||
@@ -24,18 +24,14 @@
|
||||
|
||||
package sonia.scm.plugin;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.net.ChildFirstURLClassLoader;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* Child first {@link ClassLoader} for SCM-Manager plugins.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class ChildFirstPluginClassLoader extends ChildFirstURLClassLoader
|
||||
implements PluginClassLoader
|
||||
@@ -43,13 +39,7 @@ public class ChildFirstPluginClassLoader extends ChildFirstURLClassLoader
|
||||
|
||||
private final String plugin;
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param urls
|
||||
* @param parent
|
||||
*/
|
||||
|
||||
public ChildFirstPluginClassLoader(URL[] urls, ClassLoader parent, String plugin)
|
||||
{
|
||||
super(urls, parent);
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.plugin;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.Stopwatch;
|
||||
import com.google.inject.Binder;
|
||||
@@ -35,25 +34,17 @@ import sonia.scm.config.ConfigBinding;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class DefaultExtensionProcessor implements ExtensionProcessor {
|
||||
|
||||
/**
|
||||
* the logger for DefaultExtensionProcessor
|
||||
*/
|
||||
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(DefaultExtensionProcessor.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
private final ExtensionCollector collector;
|
||||
private final Set<ConfigBinding> configBindings;
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
* @param collector
|
||||
*/
|
||||
public DefaultExtensionProcessor(ExtensionCollector collector, ConfigurationResolver configurationResolver) {
|
||||
this.collector = collector;
|
||||
this.configBindings = collector.getConfigElements().stream().map(configElement -> {
|
||||
@@ -63,35 +54,20 @@ public class DefaultExtensionProcessor implements ExtensionProcessor {
|
||||
}).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
* @param extensionPoint
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public Iterable<Class> byExtensionPoint(Class extensionPoint) {
|
||||
return collector.byExtensionPoint(extensionPoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
* @param extensionPoint
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public Class oneByExtensionPoint(Class extensionPoint) {
|
||||
return collector.oneByExtensionPoint(extensionPoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
* @param binder
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void processAutoBindExtensions(Binder binder) {
|
||||
logger.info("start processing extensions");
|
||||
@@ -102,13 +78,8 @@ public class DefaultExtensionProcessor implements ExtensionProcessor {
|
||||
logger.info("bound extensions in {}", sw.stop());
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public Iterable<WebElementExtension> getWebElements() {
|
||||
return collector.getWebElements();
|
||||
@@ -124,11 +95,4 @@ public class DefaultExtensionProcessor implements ExtensionProcessor {
|
||||
return configBindings;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Field description
|
||||
*/
|
||||
private final ExtensionCollector collector;
|
||||
private final Set<ConfigBinding> configBindings;
|
||||
}
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
|
||||
package sonia.scm.plugin;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
|
||||
@@ -33,7 +31,6 @@ import java.net.URLClassLoader;
|
||||
* Default {@link ClassLoader} for SCM-Manager plugins. This {@link ClassLoader}
|
||||
* uses the default parent first strategy.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class DefaultPluginClassLoader extends URLClassLoader
|
||||
implements PluginClassLoader
|
||||
@@ -41,13 +38,7 @@ public class DefaultPluginClassLoader extends URLClassLoader
|
||||
|
||||
private final String plugin;
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param urls
|
||||
* @param parent
|
||||
*/
|
||||
|
||||
public DefaultPluginClassLoader(URL[] urls, ClassLoader parent, String plugin)
|
||||
{
|
||||
super(urls, parent);
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.plugin;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -39,30 +38,24 @@ import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Set;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class DefaultPluginLoader implements PluginLoader
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
public static final String PATH_MODULECONFIG = "META-INF/scm/module.xml";
|
||||
|
||||
/** Field description */
|
||||
public static final String PATH_PLUGINCONFIG = "META-INF/scm/plugin.xml";
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
private final ExtensionProcessor extensionProcessor;
|
||||
|
||||
private final Set<InstalledPlugin> installedPlugins;
|
||||
|
||||
private final Set<ScmModule> modules;
|
||||
|
||||
private final ClassLoader uberClassLoader;
|
||||
|
||||
private final UberWebResourceLoader uberWebResourceLoader;
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
* @param servletContext
|
||||
* @param parent
|
||||
* @param installedPlugins
|
||||
*/
|
||||
public DefaultPluginLoader(ServletContext servletContext, ClassLoader parent,
|
||||
Set<InstalledPlugin> installedPlugins, ConfigurationResolver configurationResolver)
|
||||
{
|
||||
@@ -87,84 +80,43 @@ public class DefaultPluginLoader implements PluginLoader
|
||||
}
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public ExtensionProcessor getExtensionProcessor()
|
||||
{
|
||||
return extensionProcessor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public Collection<ScmModule> getInstalledModules()
|
||||
{
|
||||
return modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public Collection<InstalledPlugin> getInstalledPlugins()
|
||||
{
|
||||
return installedPlugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public ClassLoader getUberClassLoader()
|
||||
{
|
||||
return uberClassLoader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public UberWebResourceLoader getUberWebResourceLoader()
|
||||
{
|
||||
return uberWebResourceLoader;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param classLoader
|
||||
* @param context
|
||||
* @param path
|
||||
* @param <T>
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
* @throws JAXBException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private <T> Set<T> getInstalled(ClassLoader classLoader, JAXBContext context,
|
||||
String path)
|
||||
@@ -184,20 +136,4 @@ public class DefaultPluginLoader implements PluginLoader
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private final ExtensionProcessor extensionProcessor;
|
||||
|
||||
/** Field description */
|
||||
private final Set<InstalledPlugin> installedPlugins;
|
||||
|
||||
/** Field description */
|
||||
private final Set<ScmModule> modules;
|
||||
|
||||
/** Field description */
|
||||
private final ClassLoader uberClassLoader;
|
||||
|
||||
/** Field description */
|
||||
private final UberWebResourceLoader uberWebResourceLoader;
|
||||
}
|
||||
|
||||
@@ -51,11 +51,7 @@ import java.util.stream.Collectors;
|
||||
import static sonia.scm.ContextEntry.ContextBuilder.entity;
|
||||
import static sonia.scm.ScmConstraintViolationException.Builder.doThrow;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Singleton
|
||||
public class DefaultPluginManager implements PluginManager {
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.plugin;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Throwables;
|
||||
@@ -45,24 +44,23 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Default implementation of the {@link UberWebResourceLoader}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public class DefaultUberWebResourceLoader implements UberWebResourceLoader
|
||||
{
|
||||
|
||||
/**
|
||||
* the logger for DefaultUberWebResourceLoader
|
||||
*/
|
||||
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(DefaultUberWebResourceLoader.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
private final Cache<String, URL> cache;
|
||||
|
||||
private final Iterable<InstalledPlugin> plugins;
|
||||
|
||||
private final ServletContext servletContext;
|
||||
|
||||
public DefaultUberWebResourceLoader(ServletContext servletContext, Iterable<InstalledPlugin> plugins) {
|
||||
this(servletContext, plugins, SCMContext.getContext().getStage());
|
||||
@@ -81,16 +79,8 @@ public class DefaultUberWebResourceLoader implements UberWebResourceLoader
|
||||
return CacheBuilder.newBuilder().build();
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param path
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public URL getResource(String path)
|
||||
{
|
||||
@@ -121,14 +111,7 @@ public class DefaultUberWebResourceLoader implements UberWebResourceLoader
|
||||
cache.put(path, url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param path
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public List<URL> getResources(String path)
|
||||
{
|
||||
@@ -166,28 +149,15 @@ public class DefaultUberWebResourceLoader implements UberWebResourceLoader
|
||||
return resources.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@VisibleForTesting
|
||||
Cache<String, URL> getCache()
|
||||
{
|
||||
return cache;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param path
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
private URL find(String path)
|
||||
{
|
||||
URL resource;
|
||||
@@ -246,14 +216,4 @@ public class DefaultUberWebResourceLoader implements UberWebResourceLoader
|
||||
return false;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private final Cache<String, URL> cache;
|
||||
|
||||
/** Field description */
|
||||
private final Iterable<InstalledPlugin> plugins;
|
||||
|
||||
/** Field description */
|
||||
private final ServletContext servletContext;
|
||||
}
|
||||
|
||||
@@ -24,15 +24,12 @@
|
||||
|
||||
package sonia.scm.plugin;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* This {@link WebResourceLoader} is used, if the plugin does not contain a
|
||||
* webapp directory.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public class EmptyWebResourceLoader implements WebResourceLoader
|
||||
@@ -44,7 +41,6 @@ public class EmptyWebResourceLoader implements WebResourceLoader
|
||||
*
|
||||
* @param path resource path
|
||||
*
|
||||
* @return {@code null}
|
||||
*/
|
||||
@Override
|
||||
public URL getResource(String path)
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.plugin;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import org.slf4j.Logger;
|
||||
@@ -34,33 +33,33 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Objects;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The ExplodedSmp object represents an extracted SCM-Manager plugin. The object
|
||||
* contains the path to the plugin directory and loads the plugin descriptor.
|
||||
* The ExplodedSmp can be created with the {@link #create(java.nio.file.Path)}
|
||||
* method.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public final class ExplodedSmp {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ExplodedSmp.class);
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
* @param path
|
||||
* @param plugin
|
||||
* directory
|
||||
*/
|
||||
private final Path path;
|
||||
|
||||
/**
|
||||
* plugin object
|
||||
*/
|
||||
private final InstalledPluginDescriptor plugin;
|
||||
|
||||
ExplodedSmp(Path path, InstalledPluginDescriptor plugin) {
|
||||
logger.trace("create exploded scm for plugin {} and dependencies {}", plugin.getInformation().getName(), plugin.getDependencies());
|
||||
this.path = path;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Creates a new ExplodedSmp object.
|
||||
@@ -76,12 +75,10 @@ public final class ExplodedSmp {
|
||||
return new ExplodedSmp(directory, Plugins.parsePluginDescriptor(desc));
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the exploded smp contains a core plugin
|
||||
*
|
||||
* @return {@code true} for a core plugin
|
||||
* @since 2.30.0
|
||||
*/
|
||||
public boolean isCore() {
|
||||
@@ -92,7 +89,6 @@ public final class ExplodedSmp {
|
||||
/**
|
||||
* Returns the path to the plugin directory.
|
||||
*
|
||||
* @return to plugin directory
|
||||
*/
|
||||
public Path getPath() {
|
||||
return path;
|
||||
@@ -101,7 +97,6 @@ public final class ExplodedSmp {
|
||||
/**
|
||||
* Returns parsed plugin descriptor.
|
||||
*
|
||||
* @return plugin descriptor
|
||||
*/
|
||||
public InstalledPluginDescriptor getPlugin() {
|
||||
return plugin;
|
||||
@@ -126,7 +121,7 @@ public final class ExplodedSmp {
|
||||
return information.getName() + "@" + information.getVersion() + " (" + path + ")";
|
||||
}
|
||||
|
||||
//~--- inner classes --------------------------------------------------------
|
||||
|
||||
|
||||
/**
|
||||
* Transforms {@link Path} to {@link ExplodedSmp}.
|
||||
@@ -148,16 +143,4 @@ public final class ExplodedSmp {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* directory
|
||||
*/
|
||||
private final Path path;
|
||||
|
||||
/**
|
||||
* plugin object
|
||||
*/
|
||||
private final InstalledPluginDescriptor plugin;
|
||||
}
|
||||
|
||||
@@ -35,9 +35,7 @@ import org.slf4j.LoggerFactory;
|
||||
import sonia.scm.EagerSingleton;
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
/**
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
public final class ExtensionBinder {
|
||||
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
|
||||
package sonia.scm.plugin;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import java.net.URL;
|
||||
@@ -42,44 +40,25 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
/**
|
||||
* TODO add caching
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public class MultiParentClassLoader extends ClassLoader
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param parents
|
||||
*/
|
||||
private final List<ClassLoader> parents;
|
||||
|
||||
public MultiParentClassLoader(ClassLoader... parents)
|
||||
{
|
||||
this(Arrays.asList(parents));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param parents
|
||||
*/
|
||||
|
||||
public MultiParentClassLoader(Collection<? extends ClassLoader> parents)
|
||||
{
|
||||
super(null);
|
||||
this.parents = new CopyOnWriteArrayList<>(parents);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public URL getResource(String name)
|
||||
{
|
||||
@@ -96,16 +75,7 @@ public class MultiParentClassLoader extends ClassLoader
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
|
||||
@Override
|
||||
public Enumeration<URL> getResources(String name) throws IOException
|
||||
{
|
||||
@@ -124,19 +94,6 @@ public class MultiParentClassLoader extends ClassLoader
|
||||
return Collections.enumeration(resources);
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param name
|
||||
* @param resolve
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
@Override
|
||||
protected Class<?> loadClass(String name, boolean resolve)
|
||||
throws ClassNotFoundException
|
||||
@@ -157,8 +114,4 @@ public class MultiParentClassLoader extends ClassLoader
|
||||
throw new ClassNotFoundException(String.format("%s not found.", name));
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private final List<ClassLoader> parents;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ import java.nio.file.Path;
|
||||
/**
|
||||
* Load web resources from a plugin webapp directory.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public class PathWebResourceLoader implements WebResourceLoader {
|
||||
@@ -44,9 +43,7 @@ public class PathWebResourceLoader implements WebResourceLoader {
|
||||
|
||||
private final Path directory;
|
||||
|
||||
/**
|
||||
* the logger for PathWebResourceLoader
|
||||
*/
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(PathWebResourceLoader.class);
|
||||
|
||||
public PathWebResourceLoader(Path directory) {
|
||||
|
||||
@@ -28,6 +28,5 @@ package sonia.scm.plugin;
|
||||
* The PluginClassLoader interface is mainly a marker to find the class loader
|
||||
* in a memory dump. This should make it easier to find class loader leaks.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public interface PluginClassLoader {}
|
||||
|
||||
@@ -24,69 +24,39 @@
|
||||
|
||||
package sonia.scm.plugin;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
public final class PluginNode
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param plugin
|
||||
*/
|
||||
|
||||
public PluginNode(ExplodedSmp plugin)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param node
|
||||
*/
|
||||
|
||||
public void addChild(PluginNode node)
|
||||
{
|
||||
this.children.add(node);
|
||||
node.addParent(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param node
|
||||
*/
|
||||
|
||||
private void addParent(PluginNode node)
|
||||
{
|
||||
this.parents.add(node);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public PluginNode getChild(final String id)
|
||||
{
|
||||
return Iterables.find(children, new Predicate<PluginNode>()
|
||||
@@ -100,69 +70,38 @@ public final class PluginNode
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public List<PluginNode> getChildren()
|
||||
{
|
||||
return children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return plugin.getPlugin().getInformation().getName(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public List<PluginNode> getParents()
|
||||
{
|
||||
return parents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public ExplodedSmp getPlugin()
|
||||
{
|
||||
return plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
public InstalledPlugin getWrapper()
|
||||
{
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param wrapper
|
||||
*/
|
||||
|
||||
public void setWrapper(InstalledPlugin wrapper)
|
||||
{
|
||||
this.wrapper = wrapper;
|
||||
@@ -186,15 +125,11 @@ public final class PluginNode
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private final List<PluginNode> parents = Lists.newArrayList();
|
||||
|
||||
/** Field description */
|
||||
private final List<PluginNode> children = Lists.newArrayList();
|
||||
|
||||
/** Field description */
|
||||
private final ExplodedSmp plugin;
|
||||
|
||||
/** Field description */
|
||||
private InstalledPlugin wrapper;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.plugin;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
@@ -60,11 +59,8 @@ import java.util.stream.Collectors;
|
||||
|
||||
import static java.util.stream.Collectors.toSet;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*
|
||||
* TODO don't mix nio and io
|
||||
*/
|
||||
@@ -72,54 +68,44 @@ import static java.util.stream.Collectors.toSet;
|
||||
public final class PluginProcessor
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
private static final String INSTALLEDNAME_FORMAT = "%s.%03d";
|
||||
|
||||
/** Field description */
|
||||
private static final String DIRECTORY_CLASSES = "classes";
|
||||
|
||||
/** Field description */
|
||||
private static final String DIRECTORY_DEPENDENCIES = "lib";
|
||||
|
||||
/** Field description */
|
||||
private static final String DIRECTORY_INSTALLED = ".installed";
|
||||
|
||||
public static final String JAKARTA_COMPATIBLE = ".jakarta-compatible";
|
||||
|
||||
/** Field description */
|
||||
private static final String DIRECTORY_METAINF = "META-INF";
|
||||
|
||||
/** Field description */
|
||||
private static final String DIRECTORY_WEBAPP = "webapp";
|
||||
|
||||
/** Field description */
|
||||
private static final String EXTENSION_PLUGIN = ".smp";
|
||||
|
||||
/** Field description */
|
||||
private static final String FORMAT_DATE = "yyyy-MM-dd";
|
||||
|
||||
/** Field description */
|
||||
private static final String GLOB_JAR = "*.jar";
|
||||
|
||||
/**
|
||||
* the logger for PluginProcessor
|
||||
*/
|
||||
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(PluginProcessor.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
private final SmpDescriptorExtractor extractor = new SmpDescriptorExtractor();
|
||||
|
||||
private ClassLoaderLifeCycle classLoaderLifeCycle;
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param classLoaderLifeCycle
|
||||
* @param pluginDirectory
|
||||
*/
|
||||
private final JAXBContext context;
|
||||
|
||||
private final Path installedRootDirectory;
|
||||
|
||||
private final Path installedDirectory;
|
||||
|
||||
private final Path pluginDirectory;
|
||||
private final PluginArchiveCleaner pluginArchiveCleaner;
|
||||
|
||||
public PluginProcessor(ClassLoaderLifeCycle classLoaderLifeCycle, Path pluginDirectory){
|
||||
this(classLoaderLifeCycle, pluginDirectory, new PluginArchiveCleaner());
|
||||
}
|
||||
@@ -139,19 +125,7 @@ public final class PluginProcessor
|
||||
}
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param directory
|
||||
* @param filter
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private static DirectoryStream<Path> stream(Path directory,
|
||||
Filter<Path> filter)
|
||||
throws IOException
|
||||
@@ -159,15 +133,6 @@ public final class PluginProcessor
|
||||
return Files.newDirectoryStream(directory, filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param classLoader
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public Set<InstalledPlugin> collectPlugins(ClassLoader classLoader)
|
||||
throws IOException
|
||||
{
|
||||
@@ -268,16 +233,6 @@ public final class PluginProcessor
|
||||
return dir -> Files.exists(dir.resolve(DIRECTORY_METAINF).resolve("scm").resolve("plugin.xml"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param plugins
|
||||
* @param classLoader
|
||||
* @param node
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private void appendPluginWrapper(Set<InstalledPlugin> plugins,
|
||||
ClassLoader classLoader, PluginNode node)
|
||||
throws IOException
|
||||
@@ -321,17 +276,6 @@ public final class PluginProcessor
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param directory
|
||||
* @param filter
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private Set<Path> collect(Path directory, Filter<Path> filter)
|
||||
throws IOException
|
||||
{
|
||||
@@ -345,16 +289,7 @@ public final class PluginProcessor
|
||||
return paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param directory
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
|
||||
private List<Path> collectPluginDirectories(Path directory) throws IOException
|
||||
{
|
||||
Builder<Path> paths = ImmutableList.builder();
|
||||
@@ -372,17 +307,6 @@ public final class PluginProcessor
|
||||
return paths.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param parentClassLoader
|
||||
* @param smp
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private ClassLoader createClassLoader(ClassLoader parentClassLoader,
|
||||
ExplodedSmp smp)
|
||||
throws IOException
|
||||
@@ -436,26 +360,13 @@ public final class PluginProcessor
|
||||
return classLoader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
private String createDate()
|
||||
{
|
||||
return new SimpleDateFormat(FORMAT_DATE).format(new Date());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param root
|
||||
* @param parents
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
private ClassLoader createParentPluginClassLoader(ClassLoader root,
|
||||
List<ClassLoader> parents)
|
||||
{
|
||||
@@ -510,18 +421,6 @@ public final class PluginProcessor
|
||||
return plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
*
|
||||
* @param classLoader
|
||||
* @param nodes
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
private Set<InstalledPlugin> createPluginWrappers(ClassLoader classLoader,
|
||||
List<PluginNode> nodes)
|
||||
throws IOException
|
||||
@@ -536,14 +435,7 @@ public final class PluginProcessor
|
||||
return plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param directory
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
private WebResourceLoader createWebResourceLoader(Path directory)
|
||||
{
|
||||
WebResourceLoader resourceLoader;
|
||||
@@ -563,14 +455,7 @@ public final class PluginProcessor
|
||||
return resourceLoader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param archives
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
|
||||
private Set<ExplodedSmp> extract(Iterable<Path> archives) throws IOException
|
||||
{
|
||||
logger.debug("extract archives");
|
||||
@@ -603,12 +488,7 @@ public final class PluginProcessor
|
||||
return extracted.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
private Path findInstalledDirectory()
|
||||
{
|
||||
Path directory = null;
|
||||
@@ -635,14 +515,7 @@ public final class PluginProcessor
|
||||
return directory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param archive
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
|
||||
private void moveArchive(Path archive) throws IOException
|
||||
{
|
||||
if (!Files.exists(installedDirectory))
|
||||
@@ -670,28 +543,12 @@ public final class PluginProcessor
|
||||
Files.move(archive, installed);
|
||||
}
|
||||
|
||||
//~--- inner classes --------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Class description
|
||||
*
|
||||
*
|
||||
* @version Enter version here..., 14/06/04
|
||||
* @author Enter your name here...
|
||||
*/
|
||||
|
||||
|
||||
private static class DirectoryFilter implements DirectoryStream.Filter<Path>
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param entry
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public boolean accept(Path entry) throws IOException
|
||||
{
|
||||
@@ -701,27 +558,11 @@ public final class PluginProcessor
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Class description
|
||||
*
|
||||
*
|
||||
* @version Enter version here..., 14/06/04
|
||||
* @author Enter your name here...
|
||||
*/
|
||||
|
||||
private static class PluginArchiveFilter
|
||||
implements DirectoryStream.Filter<Path>
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param entry
|
||||
*
|
||||
* @return
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public boolean accept(Path entry) throws IOException
|
||||
{
|
||||
@@ -730,18 +571,4 @@ public final class PluginProcessor
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private final JAXBContext context;
|
||||
|
||||
private final Path installedRootDirectory;
|
||||
|
||||
/** Field description */
|
||||
private final Path installedDirectory;
|
||||
|
||||
/** Field description */
|
||||
private final Path pluginDirectory;
|
||||
private final PluginArchiveCleaner pluginArchiveCleaner;
|
||||
}
|
||||
|
||||
@@ -35,16 +35,12 @@ import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
public final class PluginTree {
|
||||
|
||||
private static final int SCM_VERSION = 3;
|
||||
|
||||
/**
|
||||
* the logger for PluginTree
|
||||
*/
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(PluginTree.class);
|
||||
|
||||
private final Stage stage;
|
||||
|
||||
@@ -38,14 +38,10 @@ import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
public final class PluginsInternal {
|
||||
|
||||
/**
|
||||
* the logger for PluginsInternal
|
||||
*/
|
||||
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(PluginsInternal.class);
|
||||
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.plugin;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
@@ -39,13 +38,10 @@ import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* {@link ClassLoader} which is able to load classes and resources from all
|
||||
* plugins.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
public final class UberClassLoader extends ClassLoader {
|
||||
|
||||
|
||||
@@ -71,7 +71,6 @@ import static sonia.scm.NotFoundException.notFound;
|
||||
/**
|
||||
* Default implementation of {@link RepositoryManager}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
@Singleton
|
||||
public class DefaultRepositoryManager extends AbstractRepositoryManager {
|
||||
|
||||
@@ -51,12 +51,14 @@ import java.util.stream.Collectors;
|
||||
@EagerSingleton
|
||||
public class DefaultRepositoryRoleManager extends AbstractRepositoryRoleManager {
|
||||
|
||||
/**
|
||||
* the logger for XmlRepositoryRoleManager
|
||||
*/
|
||||
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(DefaultRepositoryRoleManager.class);
|
||||
|
||||
private final RepositoryRoleDAO repositoryRoleDAO;
|
||||
private final ManagerDaoAdapter<RepositoryRole> managerDaoAdapter;
|
||||
private final RepositoryPermissionProvider repositoryPermissionProvider;
|
||||
|
||||
@Inject
|
||||
public DefaultRepositoryRoleManager(RepositoryRoleDAO repositoryRoleDAO,
|
||||
RepositoryPermissionProvider repositoryPermissionProvider,
|
||||
@@ -197,7 +199,4 @@ public class DefaultRepositoryRoleManager extends AbstractRepositoryRoleManager
|
||||
return repositoryRoleDAO.getLastModified();
|
||||
}
|
||||
|
||||
private final RepositoryRoleDAO repositoryRoleDAO;
|
||||
private final ManagerDaoAdapter<RepositoryRole> managerDaoAdapter;
|
||||
private final RepositoryPermissionProvider repositoryPermissionProvider;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.repository;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import jakarta.servlet.ServletContextEvent;
|
||||
@@ -34,34 +33,20 @@ import sonia.scm.plugin.Extension;
|
||||
import sonia.scm.web.security.AdministrationContext;
|
||||
import sonia.scm.web.security.PrivilegedAction;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
@Extension
|
||||
public class HealthCheckContextListener implements ServletContextListener
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param context
|
||||
*/
|
||||
private final AdministrationContext context;
|
||||
|
||||
@Inject
|
||||
public HealthCheckContextListener(AdministrationContext context)
|
||||
{
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param sce
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void contextDestroyed(ServletContextEvent sce)
|
||||
{
|
||||
@@ -69,48 +54,29 @@ public class HealthCheckContextListener implements ServletContextListener
|
||||
// do nothing
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param sce
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void contextInitialized(ServletContextEvent sce)
|
||||
{
|
||||
context.runAsAdmin(HealthCheckStartupAction.class);
|
||||
}
|
||||
|
||||
//~--- inner classes --------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Class description
|
||||
*
|
||||
*
|
||||
* @version Enter version here..., 14/01/23
|
||||
* @author Enter your name here...
|
||||
*/
|
||||
|
||||
|
||||
static class HealthCheckStartupAction implements PrivilegedAction
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param healthChecker
|
||||
*/
|
||||
private final HealthChecker healthChecker;
|
||||
|
||||
@Inject
|
||||
public HealthCheckStartupAction(HealthChecker healthChecker)
|
||||
{
|
||||
this.healthChecker = healthChecker;
|
||||
}
|
||||
|
||||
//~--- methods ------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
@@ -119,15 +85,6 @@ public class HealthCheckContextListener implements ServletContextListener
|
||||
SecurityUtils.getSubject().execute(healthChecker::lightCheckAll);
|
||||
}
|
||||
|
||||
//~--- fields -------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private final HealthChecker healthChecker;
|
||||
}
|
||||
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private final AdministrationContext context;
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ import sonia.scm.web.security.AdministrationContext;
|
||||
import sonia.scm.web.security.PrivilegedAction;
|
||||
|
||||
/**
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.37
|
||||
*/
|
||||
@Extension
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.repository;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
@@ -32,23 +31,18 @@ import com.google.inject.Provider;
|
||||
import sonia.scm.Undecorated;
|
||||
import sonia.scm.util.Decorators;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
public class RepositoryManagerProvider implements Provider<RepositoryManager>
|
||||
{
|
||||
@Inject(optional = true)
|
||||
private Set<RepositoryManagerDecoratorFactory> decoratorFactories;
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Inject
|
||||
@Undecorated
|
||||
private Provider<RepositoryManager> repositoryManagerProvider;
|
||||
|
||||
@Override
|
||||
public RepositoryManager get()
|
||||
{
|
||||
@@ -56,40 +50,19 @@ public class RepositoryManagerProvider implements Provider<RepositoryManager>
|
||||
decoratorFactories);
|
||||
}
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param decoratorFactories
|
||||
*/
|
||||
|
||||
public void setDecoratorFactories(
|
||||
Set<RepositoryManagerDecoratorFactory> decoratorFactories)
|
||||
{
|
||||
this.decoratorFactories = decoratorFactories;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param repositoryManagerProvider
|
||||
*/
|
||||
|
||||
public void setRepositoryManagerProvider(
|
||||
Provider<RepositoryManager> repositoryManagerProvider)
|
||||
{
|
||||
this.repositoryManagerProvider = repositoryManagerProvider;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
@Inject(optional = true)
|
||||
private Set<RepositoryManagerDecoratorFactory> decoratorFactories;
|
||||
|
||||
/** Field description */
|
||||
@Inject
|
||||
@Undecorated
|
||||
private Provider<RepositoryManager> repositoryManagerProvider;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ import java.util.Set;
|
||||
/**
|
||||
* RepositoryMatcher is able to check if a repository matches the requested path.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.54
|
||||
*/
|
||||
public final class RepositoryMatcher {
|
||||
|
||||
@@ -53,21 +53,15 @@ import java.util.Collection;
|
||||
* Receives all kinds of events, which affects authorization relevant data and fires an
|
||||
* {@link AuthorizationChangedEvent} if authorization data has changed.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.52
|
||||
*/
|
||||
@Singleton
|
||||
@EagerSingleton
|
||||
public class AuthorizationChangedEventProducer {
|
||||
|
||||
/**
|
||||
* the logger for AuthorizationChangedEventProducer
|
||||
*/
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AuthorizationChangedEventProducer.class);
|
||||
|
||||
/**
|
||||
* Constructs a new instance.
|
||||
*/
|
||||
public AuthorizationChangedEventProducer() {
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||
/**
|
||||
* Realm for authentication with {@link BearerToken}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Singleton
|
||||
@@ -58,12 +57,7 @@ public class BearerRealm extends AuthenticatingRealm {
|
||||
private final DAORealmHelper helper;
|
||||
private final AccessTokenResolver tokenResolver;
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
* @param helperFactory dao realm helper factory
|
||||
* @param tokenResolver resolve access token from bearer
|
||||
*/
|
||||
|
||||
@Inject
|
||||
public BearerRealm(DAORealmHelperFactory helperFactory, AccessTokenResolver tokenResolver) {
|
||||
this.helper = helperFactory.create(REALM);
|
||||
|
||||
@@ -42,25 +42,20 @@ import java.util.concurrent.TimeUnit;
|
||||
/**
|
||||
* Configurable implementation of {@link LoginAttemptHandler}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.34
|
||||
*/
|
||||
@Singleton
|
||||
public class ConfigurableLoginAttemptHandler implements LoginAttemptHandler {
|
||||
|
||||
/**
|
||||
* the logger for ConfigurableLoginAttemptHandler
|
||||
*/
|
||||
|
||||
private static final Logger LOG =
|
||||
LoggerFactory.getLogger(ConfigurableLoginAttemptHandler.class);
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
|
||||
private final ConcurrentMap<Object, LoginAttempt> attempts = new ConcurrentHashMap<>();
|
||||
|
||||
private final ScmConfiguration configuration;
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs a new instance.
|
||||
@@ -72,7 +67,6 @@ public class ConfigurableLoginAttemptHandler implements LoginAttemptHandler {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public void beforeAuthentication(AuthenticationToken token) throws AuthenticationException {
|
||||
@@ -130,7 +124,6 @@ public class ConfigurableLoginAttemptHandler implements LoginAttemptHandler {
|
||||
attempt.increase();
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
private LoginAttempt getAttempt(AuthenticationToken token){
|
||||
LoginAttempt freshAttempt = new LoginAttempt();
|
||||
@@ -151,7 +144,7 @@ public class ConfigurableLoginAttemptHandler implements LoginAttemptHandler {
|
||||
return (configuration.getLoginAttemptLimit() > 0) && (configuration.getLoginAttemptLimitTimeout() > 0l);
|
||||
}
|
||||
|
||||
//~--- inner classes --------------------------------------------------------
|
||||
|
||||
|
||||
private static class LoginAttempt {
|
||||
|
||||
|
||||
@@ -45,14 +45,11 @@ import static sonia.scm.initialization.InitializationWebTokenGenerator.INIT_TOKE
|
||||
/**
|
||||
* Generates cookies and invalidates access token cookies.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public final class DefaultAccessTokenCookieIssuer implements AccessTokenCookieIssuer, InitializationCookieIssuer {
|
||||
|
||||
/**
|
||||
* the logger for DefaultAccessTokenCookieIssuer
|
||||
*/
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(DefaultAccessTokenCookieIssuer.class);
|
||||
|
||||
private static final int DEFAULT_COOKIE_EXPIRATION_AMOUNT = 365;
|
||||
|
||||
@@ -291,7 +291,6 @@ public class DefaultAuthorizationCollector implements AuthorizationCollector {
|
||||
return UserPermissions.read(user.getName()).asShiroString();
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
private boolean isUserPermitted(User user, Set<String> groups,
|
||||
PermissionObject perm)
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.security;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@@ -33,50 +32,32 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import sonia.scm.util.Base62;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
*/
|
||||
|
||||
@Singleton
|
||||
public class DefaultKeyGenerator implements KeyGenerator
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
private static final int RANDOM_MAX = 999;
|
||||
|
||||
/** Field description */
|
||||
private static final int RANDOM_MIN = 100;
|
||||
|
||||
/**
|
||||
* the logger for DefaultKeyGenerator
|
||||
*/
|
||||
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(DefaultKeyGenerator.class);
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
private final AtomicLong sessionKey = new AtomicLong();
|
||||
|
||||
private final Random random = new Random();
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param args
|
||||
*/
|
||||
public static void main(String[] args)
|
||||
{
|
||||
System.out.println(new DefaultKeyGenerator().createKey());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public String createKey()
|
||||
{
|
||||
@@ -107,11 +88,4 @@ public class DefaultKeyGenerator implements KeyGenerator
|
||||
return random.nextInt(RANDOM_MAX - RANDOM_MIN + 1) + RANDOM_MIN;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private final AtomicLong sessionKey = new AtomicLong();
|
||||
|
||||
/** Field description */
|
||||
private final Random random = new Random();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.security;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import jakarta.inject.Inject;
|
||||
@@ -49,7 +48,6 @@ import java.util.Set;
|
||||
/**
|
||||
* Default authorizing realm.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Extension
|
||||
|
||||
@@ -67,7 +67,6 @@ import static java.util.Objects.isNull;
|
||||
|
||||
|
||||
/**
|
||||
* @author Sebastian Sdorra
|
||||
* @since 1.31
|
||||
*/
|
||||
@Singleton
|
||||
|
||||
@@ -21,10 +21,9 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
package sonia.scm.security;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import org.apache.shiro.authc.AuthenticationException;
|
||||
import org.apache.shiro.authc.AuthenticationInfo;
|
||||
@@ -39,7 +38,6 @@ import org.apache.shiro.subject.SubjectContext;
|
||||
* DisabledRememberMeManager is used to disable the cookie creation of the
|
||||
* default {@link RememberMeManager}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public class DisabledRememberMeManager implements RememberMeManager
|
||||
@@ -47,9 +45,6 @@ public class DisabledRememberMeManager implements RememberMeManager
|
||||
|
||||
/**
|
||||
* The implementation does nothing.
|
||||
*
|
||||
*
|
||||
* @param subjectContext subject context
|
||||
*/
|
||||
@Override
|
||||
public void forgetIdentity(SubjectContext subjectContext)
|
||||
@@ -60,11 +55,6 @@ public class DisabledRememberMeManager implements RememberMeManager
|
||||
|
||||
/**
|
||||
* The implementation does nothing.
|
||||
*
|
||||
*
|
||||
* @param subject subject
|
||||
* @param token authentication token
|
||||
* @param ae authentication exception
|
||||
*/
|
||||
@Override
|
||||
public void onFailedLogin(Subject subject, AuthenticationToken token,
|
||||
@@ -76,9 +66,6 @@ public class DisabledRememberMeManager implements RememberMeManager
|
||||
|
||||
/**
|
||||
* The implementation does nothing.
|
||||
*
|
||||
*
|
||||
* @param subject subject
|
||||
*/
|
||||
@Override
|
||||
public void onLogout(Subject subject)
|
||||
@@ -89,11 +76,6 @@ public class DisabledRememberMeManager implements RememberMeManager
|
||||
|
||||
/**
|
||||
* The implementation does nothing.
|
||||
*
|
||||
*
|
||||
* @param subject subject
|
||||
* @param token authentication token
|
||||
* @param info authentication info
|
||||
*/
|
||||
@Override
|
||||
public void onSuccessfulLogin(Subject subject, AuthenticationToken token,
|
||||
@@ -103,15 +85,9 @@ public class DisabledRememberMeManager implements RememberMeManager
|
||||
// do nothing
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The implementation returns always {@code null}.
|
||||
*
|
||||
*
|
||||
* @param subjectContext subject context
|
||||
*
|
||||
* @return always {@code null}
|
||||
*/
|
||||
@Override
|
||||
public PrincipalCollection getRememberedPrincipals(
|
||||
|
||||
@@ -38,7 +38,6 @@ import static java.util.Optional.ofNullable;
|
||||
/**
|
||||
* Jwt implementation of {@link AccessToken}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public final class JwtAccessToken implements AccessToken {
|
||||
|
||||
@@ -48,14 +48,11 @@ import java.util.concurrent.TimeUnit;
|
||||
/**
|
||||
* Jwt implementation of {@link AccessTokenBuilder}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public final class JwtAccessTokenBuilder implements AccessTokenBuilder {
|
||||
|
||||
/**
|
||||
* the logger for JwtAccessTokenBuilder
|
||||
*/
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(JwtAccessTokenBuilder.class);
|
||||
|
||||
@VisibleForTesting
|
||||
|
||||
@@ -33,7 +33,6 @@ import java.util.Set;
|
||||
/**
|
||||
* Jwt implementation of {@link AccessTokenBuilderFactory}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Extension
|
||||
|
||||
@@ -39,15 +39,12 @@ import java.util.Set;
|
||||
/**
|
||||
* Jwt implementation of {@link AccessTokenResolver}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Extension
|
||||
public final class JwtAccessTokenResolver implements AccessTokenResolver {
|
||||
|
||||
/**
|
||||
* the logger for JwtAccessTokenResolver
|
||||
*/
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(JwtAccessTokenResolver.class);
|
||||
|
||||
private final SecureKeyResolver keyResolver;
|
||||
|
||||
@@ -41,7 +41,6 @@ import java.util.stream.Collectors;
|
||||
/**
|
||||
* Util methods for {@link Scope}.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public final class Scopes {
|
||||
|
||||
@@ -24,51 +24,39 @@
|
||||
|
||||
package sonia.scm.security;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import jakarta.xml.bind.annotation.XmlAccessType;
|
||||
import jakarta.xml.bind.annotation.XmlAccessorType;
|
||||
import jakarta.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Secure key can be used for singing messages and tokens.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@XmlRootElement(name = "secure-key")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public final class SecureKey
|
||||
{
|
||||
/** bytes of key */
|
||||
private byte[] bytes;
|
||||
|
||||
private long creationDate;
|
||||
|
||||
/**
|
||||
* Constructs a new secure key.
|
||||
* This constructor should only be used by jaxb.
|
||||
*
|
||||
*/
|
||||
SecureKey() {}
|
||||
|
||||
/**
|
||||
* Constructs a new secure key.
|
||||
*
|
||||
*
|
||||
* @param bytes bytes of key
|
||||
* @param creationDate creation date
|
||||
*/
|
||||
public SecureKey(byte[] bytes, long creationDate)
|
||||
{
|
||||
this.bytes = bytes;
|
||||
this.creationDate = creationDate;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
@@ -88,44 +76,22 @@ public final class SecureKey
|
||||
&& Objects.equal(creationDate, other.creationDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return Objects.hashCode(bytes, creationDate);
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the bytes of the key.
|
||||
*
|
||||
*
|
||||
* @return bytes of key
|
||||
*/
|
||||
public byte[] getBytes()
|
||||
{
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the creation date of the key.
|
||||
*
|
||||
*
|
||||
* @return key creation date
|
||||
*/
|
||||
public long getCreationDate()
|
||||
{
|
||||
return creationDate;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** bytes of key */
|
||||
private byte[] bytes;
|
||||
|
||||
/** creation date */
|
||||
private long creationDate;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
package sonia.scm.security;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.Strings;
|
||||
@@ -49,34 +48,30 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
/**
|
||||
* Resolve secure keys which can be used for signing token and messages.
|
||||
*
|
||||
* @author Sebastian Sdorra
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Singleton
|
||||
public class SecureKeyResolver extends SigningKeyResolverAdapter
|
||||
{
|
||||
|
||||
/** key length */
|
||||
private static final int KEY_LENGTH = 64;
|
||||
|
||||
/** name of the configuration store */
|
||||
@VisibleForTesting
|
||||
static final String STORE_NAME = "keys";
|
||||
|
||||
/**
|
||||
* the logger for SecureKeyResolver
|
||||
*/
|
||||
|
||||
private static final Logger logger =
|
||||
LoggerFactory.getLogger(SecureKeyResolver.class);
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
/** secure randon */
|
||||
private final Random random;
|
||||
|
||||
/** configuration entry store */
|
||||
private final ConfigurationEntryStore<SecureKey> store;
|
||||
|
||||
private final JwtSettingsStore jwtSettingsStore;
|
||||
|
||||
/**
|
||||
* Constructs a new SecureKeyResolver
|
||||
*
|
||||
*
|
||||
* @param storeFactory store factory
|
||||
*/
|
||||
@Inject
|
||||
@SuppressWarnings("unchecked")
|
||||
public SecureKeyResolver(ConfigurationEntryStoreFactory storeFactory, JwtSettingsStore jwtSettingsStore) {
|
||||
@@ -93,11 +88,8 @@ public class SecureKeyResolver extends SigningKeyResolverAdapter
|
||||
this.random = random;
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public byte[] resolveSigningKeyBytes(JwsHeader header, Claims claims)
|
||||
{
|
||||
@@ -110,7 +102,6 @@ public class SecureKeyResolver extends SigningKeyResolverAdapter
|
||||
return getSecureKey(subject).getBytes();
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the secure key for the given subject, if there is no key for the
|
||||
@@ -118,7 +109,6 @@ public class SecureKeyResolver extends SigningKeyResolverAdapter
|
||||
*
|
||||
* @param subject subject
|
||||
*
|
||||
* @return secure key
|
||||
*/
|
||||
public SecureKey getSecureKey(String subject)
|
||||
{
|
||||
@@ -140,14 +130,6 @@ public class SecureKeyResolver extends SigningKeyResolverAdapter
|
||||
return key.getCreationDate() < settings.getKeysValidAfterTimestampInMs();
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Creates a new secure key.
|
||||
*
|
||||
*
|
||||
* @return new secure key
|
||||
*/
|
||||
private SecureKey createNewKey()
|
||||
{
|
||||
byte[] bytes = new byte[KEY_LENGTH];
|
||||
@@ -157,13 +139,4 @@ public class SecureKeyResolver extends SigningKeyResolverAdapter
|
||||
return new SecureKey(bytes, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** secure randon */
|
||||
private final Random random;
|
||||
|
||||
/** configuration entry store */
|
||||
private final ConfigurationEntryStore<SecureKey> store;
|
||||
|
||||
private final JwtSettingsStore jwtSettingsStore;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user