Skip to content

Commit

Permalink
rewrote rendering code
Browse files Browse the repository at this point in the history
changed stuff around
still no secretFile in here
theunk0wn asked for this
SSL problems in binaries, runs fine when launched from IDE
  • Loading branch information
Holladiewal committed Nov 16, 2017
1 parent 5acd75b commit 09dfc82
Show file tree
Hide file tree
Showing 11 changed files with 215 additions and 142 deletions.
11 changes: 11 additions & 0 deletions .idea/libraries/JHyperlink.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 0 additions & 15 deletions .idea/libraries/com_baulsupp_kolja_jcurses_0_9_5_3.xml

This file was deleted.

14 changes: 14 additions & 0 deletions .idea/libraries/com_googlecode_lanterna_lanterna_3_0_0.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .idea/modules/untitled1.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib"
compile "org.jetbrains.kotlin:kotlin-reflect"
compile "commons-io:commons-io:2.5"
compile "com.baulsupp.kolja:jcurses:0.9.5.3"
compile "com.googlecode.lanterna:lanterna:3.0.0"
compile "com.google.code.gson:gson:2.8.2"
compile "org.jetbrains.kotlinx:kotlinx-coroutines-core:0.19"
compile "org.java-websocket:Java-WebSocket:1.3.5"
compile "org.dmfs:httpurlconnection-executor:0.15.1"
compile "org.dmfs:oauth2-essentials:0.8.1"
compile "org.dmfs:http-client-types:0.15.1"
compile files("lib/JHyperlink.jar")
}

sourceSets{
Expand Down
Binary file added lib/JHyperlink.jar
Binary file not shown.
40 changes: 24 additions & 16 deletions src/AuthHandler.kt
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@

import javafx.application.Application
import javafx.scene.Scene
import javafx.embed.swing.JFXPanel
import javafx.scene.layout.StackPane
import javafx.scene.text.Text
import javafx.stage.Stage
import org.dmfs.httpessentials.client.HttpRequestExecutor
import org.dmfs.httpessentials.httpurlconnection.HttpUrlConnectionExecutor
import kotlinx.coroutines.experimental.launch
import org.dmfs.oauth2.client.BasicOAuth2AuthorizationProvider
import org.dmfs.oauth2.client.BasicOAuth2Client
import org.dmfs.oauth2.client.BasicOAuth2ClientCredentials
import org.dmfs.oauth2.client.OAuth2AccessToken
import org.dmfs.oauth2.client.grants.AuthorizationCodeGrant
import org.dmfs.oauth2.client.scope.BasicScope
import org.dmfs.rfc3986.encoding.Encoded
import org.dmfs.rfc3986.uris.LazyUri
import org.dmfs.rfc5545.Duration
import org.swingplus.JHyperlink
import java.awt.Rectangle
import java.net.URI
import javax.swing.JFrame


/**
Expand All @@ -28,43 +28,51 @@ class AuthHandler{
var redirectUrl : String = ""
}

var executor: HttpRequestExecutor = HttpUrlConnectionExecutor()
lateinit var token : OAuth2AccessToken


fun authorize(){
val provider = BasicOAuth2AuthorizationProvider(URI.create("https://beta.fuelrats.com/authorize"), URI.create("https://dev.api.fuelrats.com/oauth2/token"), Duration(1,0,3600))
val credentials = BasicOAuth2ClientCredentials(secret.clientID, secret.clientSecret)
val client = BasicOAuth2Client(provider, credentials, LazyUri(Encoded("https://localhost:13370")))
val client = BasicOAuth2Client(provider, credentials, LazyUri(Encoded("http://localhost:13370")))
val grant = AuthorizationCodeGrant(client, BasicScope("rescue.read", "rat.read"))
url = grant.authorizationUrl()!!
println(url)

val auth = Auth.Authenticator("")
Application.launch(UrlDialog().javaClass)
launch{Application.launch(UrlDialog().javaClass)}
val result = auth.awaitAccessToken()
UrlDialog.frame.isVisible = false
println("$result")
if (!result){
throw IllegalStateException("couldnt start Server " + auth.authenticationError?.name + "," + auth.authenticationError?.description)
}
while (!auth.hasAccessToken()){
;
}
//token = grant.withRedirect(client.redirectUri()).accessToken(executor)
}



}

class UrlDialog : Application() {
companion object {
val frame = JFrame()
}



override fun start(stage: Stage?) {
val url = AuthHandler.url.toString()
val root = StackPane()
root.children.add(Text(200.0, 32.0, url))
val scene = Scene(root, 800.0, 64.0)
stage!!.scene = scene
stage.show()
val pane = JFXPanel()
//pane.add(JHyperlink("Click here!", url))
//root.children.add(pane.)
frame.bounds = Rectangle(800, 600)
frame.add(JHyperlink("Click here!", url))
frame.isVisible = true
//val scene = Scene(root, 800.0, 64.0)

//stage!!.scene = scene
//stage.show()
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/LogHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ open class listener : TailerListenerAdapter(){
if (message.split(" ", limit = 3).size < 3) return
val rt = message.split(" ", limit = 3)[2]
var rats = ArrayList<Rat>()
rt.split(" ").mapTo(rats) { Rat("", Status("")).setNameCorrectly(it) }
rt.split(" ").mapTo(rats) { Rat(it, Status("")).setNameCorrectly() }
if (number.contains("#").and(containsNumber(number)) || number.toIntOrNull() != null) {
number = getNumber(number)
rescues.filter { it.number == number.toInt() }.forEach { val tmp = it.rats; it.rats.addAll(rats.filter { !tmp.contains(it) && it.name.isNotBlank() }) }
Expand All @@ -124,7 +124,7 @@ open class listener : TailerListenerAdapter(){
var number = message.split(" ")[1]
val rt = message.split(" ", limit = 3)[2]
var rats = ArrayList<Rat>()
rt.split(" ").mapTo(rats) { Rat("", Status("")).setNameCorrectly(it) }
rt.split(" ").mapTo(rats) { Rat(it, Status("")).setNameCorrectly() }
if (number.contains("#").and(containsNumber(number)) || number.toIntOrNull() != null) {
number = getNumber(number)

Expand Down
Loading

0 comments on commit 09dfc82

Please sign in to comment.