-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* generic RESTful 'Clipboard' * added dependencies on micrometer.io and OkHttp * added generic Data[Container] and MIME-type definition classes N.B. an experimental concept to be expanded (not tackled: HTML and CSS PMD issues)
- Loading branch information
1 parent
08727d5
commit cf5b1ab
Showing
51 changed files
with
4,272 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# demo password file -- please change for production since these 'password's are not safe!! | ||
admin:$2a$10$h.dl5J86rGH7I8bD9bZeZe:$2a$10$h.dl5J86rGH7I8bD9bZeZeci0pDt0.VwFTGujlnEaZXPf/q7vM5wO:ADMIN: | ||
anonymous:$2a$10$e0MYzXyjpJS7Pd0RVvHwHe:$2a$10$e0MYzXyjpJS7Pd0RVvHwHe1HlCS4bZJ18JuywdEMLT83E1KDmUhCy:READ_WRITE: | ||
alex:$2a$10$rQu1pxN6wCsS.bf6zYObX.:$2a$10$rQu1pxN6wCsS.bf6zYObX.QdkJN85dFpkcrzy1xwWK57ToqpKEVBy:READ_WRITE: | ||
bernd:$2a$10$j2l8uniY45FyKvZLy3ZvaO:$2a$10$j2l8uniY45FyKvZLy3ZvaORFZjPHuGr69Rb/rRCs0W2aPdIfH99pi:READ_ONLY: | ||
zoro:$2a$10$vLiwSkM2/krIqO1eDhGgcu:$2a$10$vLiwSkM2/krIqO1eDhGgcuRv/vJxE8Sh4xePZkBKKZeswP2pTzlAi:ANYONE: |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
nopassword |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
java -server -XX:G1HeapRegionSize=32M -Dglass.platform=Monocle -Dmonocle.platform=Headless -Dprism.order=j2d,sw -Dprism.verbose=true -DrestKeyStore=keystore.jks -DrestKeyStorePassword=keystore.pwd -DrestUserPasswordStore=DefaultRestUserPasswords.pwd -jar Clipboard.jar |
39 changes: 39 additions & 0 deletions
39
chartfx-acc/src/main/java/de/gsi/acc/remote/BasicRestRoles.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package de.gsi.acc.remote; | ||
|
||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.Locale; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import io.javalin.core.security.Role; | ||
|
||
public enum BasicRestRoles implements Role { | ||
NULL, | ||
ANYONE, | ||
ADMIN, | ||
READ_ONLY, | ||
READ_WRITE; | ||
|
||
public static String getRoles(final Set<Role> roleSet) { | ||
return roleSet.stream().map(Role::toString).collect(Collectors.joining(", ")); | ||
} | ||
|
||
public static Set<Role> getRoles(@NotNull final String roleString) { | ||
if (roleString.contains(":")) { | ||
throw new IllegalArgumentException("roleString must not contain [:]"); | ||
} | ||
|
||
final HashSet<Role> roles = new HashSet<>(); | ||
for (final String role : roleString.replaceAll("\\s", "").split(",")) { | ||
if (role == null || role.isEmpty() || "*".equals(role)) { // NOPMD | ||
continue; | ||
} | ||
roles.add(valueOf(role.toUpperCase(Locale.UK))); | ||
} | ||
|
||
return Collections.unmodifiableSet(roles); | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
chartfx-acc/src/main/java/de/gsi/acc/remote/RestCommonThreadPool.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package de.gsi.acc.remote; | ||
|
||
import java.util.concurrent.ExecutorService; | ||
import java.util.concurrent.Executors; | ||
import java.util.concurrent.ScheduledExecutorService; | ||
import java.util.concurrent.ThreadFactory; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
@SuppressWarnings("PMD.DoNotUseThreads") // purpose of this class | ||
public final class RestCommonThreadPool implements ThreadFactory { | ||
private static final int MAX_THREADS = getDefaultThreadCount(); | ||
private static final int MAX_SCHEDULED_THREADS = getDefaultScheduledThreadCount(); | ||
private static final ThreadFactory DEFAULT_FACTORY = Executors.defaultThreadFactory(); | ||
private static final RestCommonThreadPool SELF = new RestCommonThreadPool(); | ||
private static final ExecutorService COMMON_POOL = Executors.newFixedThreadPool(MAX_THREADS, SELF); | ||
private static final ScheduledExecutorService SCHEDULED_POOL = Executors.newScheduledThreadPool(MAX_SCHEDULED_THREADS, SELF); | ||
private static final AtomicInteger THREAD_COUNTER = new AtomicInteger(); | ||
|
||
private RestCommonThreadPool() { | ||
// helper class | ||
} | ||
|
||
@Override | ||
public Thread newThread(final Runnable r) { | ||
final Thread thread = DEFAULT_FACTORY.newThread(r); | ||
THREAD_COUNTER.incrementAndGet(); | ||
thread.setName("RestCommonThreadPool#" + THREAD_COUNTER.intValue()); | ||
thread.setDaemon(true); | ||
return thread; | ||
} | ||
|
||
public static ExecutorService getCommonPool() { | ||
return COMMON_POOL; | ||
} | ||
|
||
public static ScheduledExecutorService getCommonScheduledPool() { | ||
return SCHEDULED_POOL; | ||
} | ||
|
||
public static RestCommonThreadPool getInstance() { | ||
return SELF; | ||
} | ||
|
||
public static int getNumbersOfThreads() { | ||
return MAX_THREADS; | ||
} | ||
|
||
private static int getDefaultScheduledThreadCount() { | ||
int nthreads = 32; | ||
try { | ||
nthreads = Integer.parseInt(System.getProperty("restScheduledThreadCount", "32")); | ||
} catch (final NumberFormatException e) { | ||
// malformed number | ||
} | ||
|
||
return Math.max(32, nthreads); | ||
} | ||
|
||
private static int getDefaultThreadCount() { | ||
int nthreads = 32; | ||
try { | ||
nthreads = Integer.parseInt(System.getProperty("restThreadCount", "64")); | ||
} catch (final NumberFormatException e) { | ||
// malformed number | ||
} | ||
|
||
return Math.max(32, nthreads); | ||
} | ||
} |
Oops, something went wrong.