renamed project to "Remote Cache Build Server" (RBCS)
This commit is contained in:
17
rbcs-api/build.gradle
Normal file
17
rbcs-api/build.gradle
Normal file
@@ -0,0 +1,17 @@
|
||||
plugins {
|
||||
id 'java-library'
|
||||
id 'maven-publish'
|
||||
alias catalog.plugins.lombok
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api catalog.netty.buffer
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
}
|
7
rbcs-api/src/main/java/module-info.java
Normal file
7
rbcs-api/src/main/java/module-info.java
Normal file
@@ -0,0 +1,7 @@
|
||||
module net.woggioni.rbcs.api {
|
||||
requires static lombok;
|
||||
requires java.xml;
|
||||
requires io.netty.buffer;
|
||||
exports net.woggioni.rbcs.api;
|
||||
exports net.woggioni.rbcs.api.exception;
|
||||
}
|
14
rbcs-api/src/main/java/net/woggioni/rbcs/api/Cache.java
Normal file
14
rbcs-api/src/main/java/net/woggioni/rbcs/api/Cache.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package net.woggioni.rbcs.api;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.woggioni.rbcs.api.exception.ContentTooLargeException;
|
||||
|
||||
import java.nio.channels.ReadableByteChannel;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
|
||||
public interface Cache extends AutoCloseable {
|
||||
CompletableFuture<ReadableByteChannel> get(String key);
|
||||
|
||||
CompletableFuture<Void> put(String key, ByteBuf content) throws ContentTooLargeException;
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
package net.woggioni.rbcs.api;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
public interface CacheProvider<T extends Configuration.Cache> {
|
||||
|
||||
String getXmlSchemaLocation();
|
||||
|
||||
String getXmlNamespace();
|
||||
|
||||
String getXmlType();
|
||||
|
||||
T deserialize(Element parent);
|
||||
|
||||
Element serialize(Document doc, T cache);
|
||||
}
|
170
rbcs-api/src/main/java/net/woggioni/rbcs/api/Configuration.java
Normal file
170
rbcs-api/src/main/java/net/woggioni/rbcs/api/Configuration.java
Normal file
@@ -0,0 +1,170 @@
|
||||
package net.woggioni.rbcs.api;
|
||||
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
import lombok.Value;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.time.Duration;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Value
|
||||
public class Configuration {
|
||||
String host;
|
||||
int port;
|
||||
int incomingConnectionsBacklogSize;
|
||||
String serverPath;
|
||||
@NonNull
|
||||
EventExecutor eventExecutor;
|
||||
@NonNull
|
||||
Connection connection;
|
||||
Map<String, User> users;
|
||||
Map<String, Group> groups;
|
||||
Cache cache;
|
||||
Authentication authentication;
|
||||
Tls tls;
|
||||
|
||||
@Value
|
||||
public static class EventExecutor {
|
||||
boolean useVirtualThreads;
|
||||
}
|
||||
|
||||
@Value
|
||||
public static class Connection {
|
||||
Duration readTimeout;
|
||||
Duration writeTimeout;
|
||||
Duration idleTimeout;
|
||||
Duration readIdleTimeout;
|
||||
Duration writeIdleTimeout;
|
||||
int maxRequestSize;
|
||||
}
|
||||
|
||||
@Value
|
||||
public static class Quota {
|
||||
long calls;
|
||||
Duration period;
|
||||
long initialAvailableCalls;
|
||||
long maxAvailableCalls;
|
||||
}
|
||||
|
||||
@Value
|
||||
public static class Group {
|
||||
@EqualsAndHashCode.Include
|
||||
String name;
|
||||
Set<Role> roles;
|
||||
Quota groupQuota;
|
||||
Quota userQuota;
|
||||
}
|
||||
|
||||
@Value
|
||||
public static class User {
|
||||
@EqualsAndHashCode.Include
|
||||
String name;
|
||||
String password;
|
||||
Set<Group> groups;
|
||||
Quota quota;
|
||||
|
||||
public Set<Role> getRoles() {
|
||||
return groups.stream()
|
||||
.flatMap(group -> group.getRoles().stream())
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface UserExtractor {
|
||||
User extract(X509Certificate cert);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface GroupExtractor {
|
||||
Group extract(X509Certificate cert);
|
||||
}
|
||||
|
||||
@Value
|
||||
public static class Throttling {
|
||||
KeyStore keyStore;
|
||||
TrustStore trustStore;
|
||||
boolean verifyClients;
|
||||
}
|
||||
|
||||
public enum ClientCertificate {
|
||||
REQUIRED, OPTIONAL
|
||||
}
|
||||
|
||||
@Value
|
||||
public static class Tls {
|
||||
KeyStore keyStore;
|
||||
TrustStore trustStore;
|
||||
}
|
||||
|
||||
@Value
|
||||
public static class KeyStore {
|
||||
Path file;
|
||||
String password;
|
||||
String keyAlias;
|
||||
String keyPassword;
|
||||
}
|
||||
|
||||
@Value
|
||||
public static class TrustStore {
|
||||
Path file;
|
||||
String password;
|
||||
boolean checkCertificateStatus;
|
||||
boolean requireClientCertificate;
|
||||
}
|
||||
|
||||
@Value
|
||||
public static class TlsCertificateExtractor {
|
||||
String rdnType;
|
||||
String pattern;
|
||||
}
|
||||
|
||||
public interface Authentication {}
|
||||
|
||||
public static class BasicAuthentication implements Authentication {}
|
||||
|
||||
@Value
|
||||
public static class ClientCertificateAuthentication implements Authentication {
|
||||
TlsCertificateExtractor userExtractor;
|
||||
TlsCertificateExtractor groupExtractor;
|
||||
}
|
||||
|
||||
public interface Cache {
|
||||
net.woggioni.rbcs.api.Cache materialize();
|
||||
String getNamespaceURI();
|
||||
String getTypeName();
|
||||
}
|
||||
|
||||
public static Configuration of(
|
||||
String host,
|
||||
int port,
|
||||
int incomingConnectionsBacklogSize,
|
||||
String serverPath,
|
||||
EventExecutor eventExecutor,
|
||||
Connection connection,
|
||||
Map<String, User> users,
|
||||
Map<String, Group> groups,
|
||||
Cache cache,
|
||||
Authentication authentication,
|
||||
Tls tls
|
||||
) {
|
||||
return new Configuration(
|
||||
host,
|
||||
port,
|
||||
incomingConnectionsBacklogSize,
|
||||
serverPath != null && !serverPath.isEmpty() && !serverPath.equals("/") ? serverPath : null,
|
||||
eventExecutor,
|
||||
connection,
|
||||
users,
|
||||
groups,
|
||||
cache,
|
||||
authentication,
|
||||
tls
|
||||
);
|
||||
}
|
||||
}
|
5
rbcs-api/src/main/java/net/woggioni/rbcs/api/Role.java
Normal file
5
rbcs-api/src/main/java/net/woggioni/rbcs/api/Role.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package net.woggioni.rbcs.api;
|
||||
|
||||
public enum Role {
|
||||
Reader, Writer
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
package net.woggioni.rbcs.api.exception;
|
||||
|
||||
public class CacheException extends RbcsException {
|
||||
public CacheException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public CacheException(String message) {
|
||||
this(message, null);
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
package net.woggioni.rbcs.api.exception;
|
||||
|
||||
public class ConfigurationException extends RbcsException {
|
||||
public ConfigurationException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public ConfigurationException(String message) {
|
||||
this(message, null);
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
package net.woggioni.rbcs.api.exception;
|
||||
|
||||
public class ContentTooLargeException extends RbcsException {
|
||||
public ContentTooLargeException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
package net.woggioni.rbcs.api.exception;
|
||||
|
||||
public class RbcsException extends RuntimeException {
|
||||
public RbcsException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user