mirror of
https://github.com/SimplexDevelopment/FreedomNetworkSuite.git
synced 2025-07-18 13:24:04 +00:00
Added Obsidian Module
Obsidian HTTPD module replacement
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package me.totalfreedom.obsidian.core;
|
||||
|
||||
public interface Disposable
|
||||
{
|
||||
void dispose();
|
||||
|
||||
boolean isDisposed();
|
||||
}
|
||||
|
@@ -0,0 +1,5 @@
|
||||
package me.totalfreedom.obsidian.core;
|
||||
|
||||
public interface Observable<T> {
|
||||
void subscribe(Observer<T> observer);
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
package me.totalfreedom.obsidian.core;
|
||||
|
||||
public interface Observer<T>
|
||||
{
|
||||
void onNext(T item);
|
||||
|
||||
void onError(Throwable throwable);
|
||||
|
||||
void onComplete();
|
||||
}
|
||||
|
@@ -0,0 +1,15 @@
|
||||
package me.totalfreedom.obsidian.core;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public interface Scheduler
|
||||
{
|
||||
Disposable schedule(Runnable task);
|
||||
|
||||
Disposable schedule(Runnable task, long delay, TimeUnit unit);
|
||||
|
||||
Disposable schedulePeriodically(Runnable task, long initialDelay, long period, TimeUnit unit);
|
||||
|
||||
void dispose();
|
||||
}
|
||||
|
@@ -0,0 +1,8 @@
|
||||
package me.totalfreedom.obsidian.http;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
public interface WebClient {
|
||||
Mono<WebResponse> sendRequest(WebRequest request);
|
||||
}
|
||||
|
@@ -0,0 +1,8 @@
|
||||
package me.totalfreedom.obsidian.http;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
public interface WebHandler {
|
||||
Mono<WebResponse> handleRequest(WebRequest request);
|
||||
}
|
||||
|
@@ -0,0 +1,20 @@
|
||||
package me.totalfreedom.obsidian.http;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface WebHeaders
|
||||
{
|
||||
List<String> getHeader(String name);
|
||||
|
||||
void addHeader(String name, String value);
|
||||
|
||||
void setHeader(String name, String value);
|
||||
|
||||
void removeHeader(String name);
|
||||
|
||||
boolean containsHeader(String name);
|
||||
|
||||
Set<String> getHeaderNames();
|
||||
}
|
||||
|
@@ -0,0 +1,12 @@
|
||||
package me.totalfreedom.obsidian.http;
|
||||
|
||||
public enum WebMethod {
|
||||
GET,
|
||||
POST,
|
||||
PUT,
|
||||
DELETE,
|
||||
PATCH,
|
||||
HEAD,
|
||||
OPTIONS
|
||||
}
|
||||
|
@@ -0,0 +1,15 @@
|
||||
package me.totalfreedom.obsidian.http;
|
||||
|
||||
import java.awt.image.DataBuffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
public interface WebRequest {
|
||||
WebMethod getMethod();
|
||||
String getUri();
|
||||
WebHeaders getHeaders();
|
||||
Mono<ByteBuffer> getBody();
|
||||
Flux<DataBuffer> getBodyFlux();
|
||||
}
|
||||
|
@@ -0,0 +1,17 @@
|
||||
package me.totalfreedom.obsidian.http;
|
||||
|
||||
import java.awt.image.DataBuffer;
|
||||
import java.nio.ByteBuffer;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
public interface WebResponse {
|
||||
WebStatus getStatus();
|
||||
WebHeaders getHeaders();
|
||||
void setStatus(WebStatus status);
|
||||
void setHeader(String name, String value);
|
||||
Mono<Void> write(ByteBuffer data);
|
||||
Mono<Void> write(DataBuffer dataBuffer);
|
||||
Mono<Void> write(Flux<DataBuffer> dataFlux);
|
||||
}
|
||||
|
@@ -0,0 +1,9 @@
|
||||
package me.totalfreedom.obsidian.http;
|
||||
|
||||
public interface WebServer {
|
||||
void start();
|
||||
void stop();
|
||||
void registerHandler(String uri, WebHandler handler);
|
||||
void unregisterHandler(String uri);
|
||||
}
|
||||
|
@@ -0,0 +1,26 @@
|
||||
package me.totalfreedom.obsidian.http;
|
||||
|
||||
public enum WebStatus
|
||||
{
|
||||
OK(200),
|
||||
CREATED(201),
|
||||
NO_CONTENT(204),
|
||||
BAD_REQUEST(400),
|
||||
UNAUTHORIZED(401),
|
||||
FORBIDDEN(403),
|
||||
NOT_FOUND(404),
|
||||
INTERNAL_SERVER_ERROR(500);
|
||||
|
||||
private final int code;
|
||||
|
||||
WebStatus(final int code)
|
||||
{
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public int getCode()
|
||||
{
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,15 @@
|
||||
package me.totalfreedom.obsidian.security;
|
||||
|
||||
public interface OAuth2Credentials
|
||||
{
|
||||
String getClientId();
|
||||
|
||||
String getClientSecret();
|
||||
|
||||
String getUsername();
|
||||
|
||||
String getPassword();
|
||||
|
||||
String getScope();
|
||||
}
|
||||
|
@@ -0,0 +1,12 @@
|
||||
package me.totalfreedom.obsidian.security;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
public interface OAuth2Service
|
||||
{
|
||||
Mono<OAuth2Token> authenticate(OAuth2Credentials credentials);
|
||||
|
||||
Mono<Boolean> validateToken(OAuth2Token token);
|
||||
|
||||
Mono<OAuth2Token> refreshAccessToken(OAuth2Token token);
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
package me.totalfreedom.obsidian.security;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
public interface OAuth2Token
|
||||
{
|
||||
String getAccessToken();
|
||||
|
||||
void setAccessToken(String accessToken);
|
||||
|
||||
String getRefreshToken();
|
||||
|
||||
void setRefreshToken(String refreshToken);
|
||||
|
||||
String getTokenType();
|
||||
|
||||
void setTokenType(String tokenType);
|
||||
|
||||
Instant getExpiresAt();
|
||||
|
||||
void setExpiresAt(Instant expiresAt);
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
package me.totalfreedom.obsidian.sql;
|
||||
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
public interface SQLConnection
|
||||
{
|
||||
Mono<SQLResult> executeQuery(SQLQuery query);
|
||||
|
||||
Mono<Integer> executeUpdate(SQLQuery query);
|
||||
|
||||
void close();
|
||||
}
|
||||
|
@@ -0,0 +1,10 @@
|
||||
package me.totalfreedom.obsidian.sql;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SQLQuery {
|
||||
String getQuery();
|
||||
List<Object> getParameters();
|
||||
void setParameter(int index, Object value);
|
||||
}
|
||||
|
@@ -0,0 +1,8 @@
|
||||
package me.totalfreedom.obsidian.sql;
|
||||
|
||||
public interface SQLResult
|
||||
{
|
||||
boolean next();
|
||||
|
||||
<T> T getColumn(int index, Class<T> type);
|
||||
}
|
7
Obsidian/src/main/resources/plugin.yml
Normal file
7
Obsidian/src/main/resources/plugin.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
name: Obsidian
|
||||
version: '${version}'
|
||||
main: me.totalfreedom.obsidian.Obsidian
|
||||
api-version: '1.20'
|
||||
load: STARTUP
|
||||
libraries:
|
||||
- io.projectreactor:reactor-core:3.5.4
|
Reference in New Issue
Block a user