Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Enhort
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Michael Menzel
Enhort
Commits
82054bb9
Commit
82054bb9
authored
Aug 07, 2019
by
Michael Menzel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
secret key as start param
parent
f60749a6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
13 deletions
+17
-13
backend/src/main/java/de/thm/run/BackendServer.java
backend/src/main/java/de/thm/run/BackendServer.java
+12
-2
backend/src/main/java/de/thm/run/ClientController.java
backend/src/main/java/de/thm/run/ClientController.java
+5
-11
No files found.
backend/src/main/java/de/thm/run/BackendServer.java
View file @
82054bb9
...
...
@@ -28,6 +28,8 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
java.io.File
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Path
;
import
static
net
.
sourceforge
.
argparse4j
.
impl
.
Arguments
.
store
;
...
...
@@ -41,13 +43,13 @@ import static net.sourceforge.argparse4j.impl.Arguments.store;
*/
public
final
class
BackendServer
{
public
static
String
secretKey
=
"abcddferti5iwiei"
;
private
static
int
port
;
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
BackendServer
.
class
);
public
static
Path
basePath
;
public
static
String
dbfilepath
;
public
static
String
customtrackpath
;
public
static
void
main
(
String
[]
args
)
{
logger
.
info
(
"Starting Enhort backend server"
);
...
...
@@ -62,6 +64,7 @@ public final class BackendServer {
parser
.
addArgument
(
"--db"
).
help
(
"Path to sqlite metadata database"
).
action
(
store
());
parser
.
addArgument
(
"--custom"
).
help
(
"Path to custom files"
).
action
(
store
());
parser
.
addArgument
(
"-p"
,
"--port"
).
help
(
"Port to listen on"
).
setDefault
(
42412
).
action
(
store
());
parser
.
addArgument
(
"-s"
,
"--secret"
).
help
(
"Keyfile for encrpytion."
).
setDefault
(
"/home/mmnz21/enhort/key.dat"
).
action
(
store
());
try
{
input
=
parser
.
parseArgs
(
args
);
...
...
@@ -79,7 +82,7 @@ public final class BackendServer {
System
.
exit
(
1
);
}
port
=
input
.
getInt
(
"port"
);
port
=
Integer
.
parseInt
(
input
.
getString
(
"port"
)
);
if
(
input
.
getString
(
"data_path"
)
!=
null
&&
input
.
getString
(
"db"
)
!=
null
)
{
basePath
=
new
File
(
input
.
getString
(
"data_path"
)).
toPath
();
...
...
@@ -102,6 +105,13 @@ public final class BackendServer {
}).
run
();
try
{
secretKey
=
Files
.
readAllLines
(
new
File
(
input
.
getString
(
"secret"
)).
toPath
()).
get
(
0
);
}
catch
(
IOException
e
)
{
logger
.
warn
(
"No secret key. Using unsafe hard-coded key for encryption."
);
}
//run an inital client controller, which will listen to clients
ClientController
server
=
new
ClientController
(
port
);
...
...
backend/src/main/java/de/thm/run/ClientController.java
View file @
82054bb9
...
...
@@ -28,11 +28,13 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
javax.crypto.SealedObject
;
import
java.io.*
;
import
java.io.EOFException
;
import
java.io.IOException
;
import
java.io.ObjectInputStream
;
import
java.io.ObjectOutputStream
;
import
java.net.BindException
;
import
java.net.ServerSocket
;
import
java.net.Socket
;
import
java.nio.file.Files
;
import
java.util.concurrent.Executors
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.atomic.AtomicInteger
;
...
...
@@ -125,15 +127,7 @@ class ClientController implements Runnable{
logger
.
error
(
"["
+
clientID
+
"]: "
+
"Exception {}"
,
e
.
getMessage
(),
e
);
}
try
{
secret
=
Files
.
readAllLines
(
new
File
(
"/home/mmnz21/enhort/key.dat"
).
toPath
()).
get
(
0
);
}
catch
(
IOException
e
)
{
//e.printStackTrace();
logger
.
info
(
"using local key"
);
secret
=
"abcddferti5iwiei"
;
}
secret
=
BackendServer
.
secretKey
;
}
@Override
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment