Cleanup and clarify a bit

This commit is contained in:
nelle 2024-02-17 03:33:42 -07:00
parent acb234abe6
commit bbe93c85b3
5 changed files with 22 additions and 21 deletions

View file

@ -1,8 +1,5 @@
# OSDA
## Org Secure Data Accessor
Essentially just a wrapper for sshfs.
Built in Kotlin, and utilizes [Jexer](https://git.ouroboros.group/limepotato/jexer)
Wrapper for sshfs, built in Kotlin, and utilizes [Jexer](https://git.ouroboros.group/limepotato/jexer)
## Installation Instructions:

View file

@ -1,5 +1,4 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import groovy.xml.dom.DOMCategory.attributes
plugins {
kotlin("jvm") version "1.9.22"

View file

@ -5,6 +5,7 @@ import jexer.demos.DemoApplication
import org.bm00.DataAccessor.windows.WelcomeWindow
import java.util.*
//// OS CHECKER ////
enum class OS {
WINDOWS, LINUX, MAC
}
@ -34,6 +35,7 @@ val osName =
OS.LINUX -> "LINUX"
else -> throw Exception("Operating System could not be detected!")
}
//// OS CHECKER ////
// Set Jexer backend type
// Possible answers: SWING, XTERM, ECMA48

View file

@ -7,7 +7,7 @@ import jexer.layout.StretchLayoutManager
import org.bm00.DataAccessor.osName
import java.util.*
//// OS CHECKER ////
enum class OS {
WINDOWS, LINUX, MAC
}
@ -37,7 +37,7 @@ val osName =
OS.LINUX -> "LINUX"
else -> throw Exception("Operating System could not be detected!")
}
//// OS CHECKER ////
class LoginWindow private constructor(parent: TApplication, flags: Int) :
TWindow(parent, "Login", 0, 0, 36, 19, flags) {
@ -54,7 +54,7 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) :
loginActivityWindows()
}
else {
TODO()
throw Exception ("The Operating-System you are on is not recognized, and thus this program cannot be run!")
}
}
},
@ -77,7 +77,7 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) :
loginActivityWindows()
}
else {
TODO()
throw Exception ("The Operating-System you are on is not recognized, and thus this program cannot be run!")
}
}
},
@ -89,15 +89,18 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) :
}
);
//Called if on Linux and the login has been initiated
fun loginActivityLinux() {
var usernameDetail = loginField.text
var serverDetail = serverField.text
//openssh-askpass as well
// Create directory using bash
ProcessBuilder("mkdir", "/tmp/osda_mount")
.redirectOutput(ProcessBuilder.Redirect.INHERIT)
.redirectError(ProcessBuilder.Redirect.INHERIT)
.start()
.waitFor()
// mount remote directory via sshfs
ProcessBuilder(
"sshfs",
"$usernameDetail@$serverDetail:/home/$usernameDetail",
@ -109,25 +112,20 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) :
.waitFor()
}
//Called if on Windows and the login has been initiated
fun loginActivityWindows() {
var usernameDetail = loginField.text
var serverDetail = serverField.text
// Due to the way sshfs-win works, we will additionally ask the user for a password
var passwordBox = inputBox("Password", "Please enter your remote password")
var passwordDetail = passwordBox.text
//TODO: https://github.com/winfsp/sshfs-win for sshfs?
// and https://github.com/git-ecosystem/git-credential-manager/ for askpass????
// `net use X: \\sshfs\username@servername`
// use the windows network mount command to mount via sshfs-win
ProcessBuilder(
"net",
"use",
"O:",
"\\\\sshfs\\$usernameDetail@$serverDetail",
"\\\\sshfs\\$usernameDetail@$serverDetail:/home/$usernameDetail",
"$passwordDetail"
/*
"net",
"use",
"X:",
"\\\\sshfs\\$usernameDetail@$serverDetail:/home/$usernameDetail"*/
)
.redirectOutput(ProcessBuilder.Redirect.INHERIT)
.redirectError(ProcessBuilder.Redirect.INHERIT)
@ -143,8 +141,10 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) :
)
)
addCheckBox( CENTERED + 4, CENTERED + 5, "Shared Folder?",false)
var sharedCheck = addCheckBox( CENTERED + 4, CENTERED + 5, "Shared Folder?",false)
//TODO: Login to shared folder?... hmmm
// Initiates login process after determining OS
addButton("Login", CENTERED + 9, CENTERED + 8,
object : TAction() {
override fun DO() {
@ -155,12 +155,14 @@ class LoginWindow private constructor(parent: TApplication, flags: Int) :
loginActivityWindows()
}
else {
TODO()
//TODO: Research Mac Support, will be difficult without a Mac for testing...
throw Exception ("The Operating-System you are on is not recognized, and thus this program cannot be run!")
}
}
}
)
// Closes login window
addButton("Back...", CENTERED + 8, CENTERED + 10,
object : TAction() {
override fun DO() {

View file

@ -26,6 +26,7 @@ class WelcomeWindow private constructor(parent: TApplication, flags: Int) :
}
)
// Close program, after detecting OS and unmounting the filesystem if necessary.
addButton("Exit...", CENTERED + 28, CENTERED,
object : TAction() {
override fun DO() {