Skip to content

Commit

Permalink
Fixed authentication problem
Browse files Browse the repository at this point in the history
  • Loading branch information
beepbeat committed May 13, 2018
1 parent a43a4a4 commit 5b3c4c6
Show file tree
Hide file tree
Showing 10 changed files with 100 additions and 81 deletions.
14 changes: 14 additions & 0 deletions .idea/deployment.xml

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

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

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

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

4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ dependencies {
compile "commons-io:commons-io:2.5"
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.jetbrains.kotlinx:kotlinx-coroutines-core:+"
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:oauth2-essentials:0.9+"
compile "org.dmfs:http-client-types:0.15.1"
compile files("lib/JHyperlink.jar")
}
Expand Down
2 changes: 1 addition & 1 deletion src/Auth/Authenticator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Authenticator(private val twitchBaseUrl: String // Base twitch api url
) {
private val listenPort: Int = 13370 // The port to listen for the authentication callback on
val clientId: String? = secret.clientID
val redirectUri: URI? = URI.create("http://localhost:13370")
val redirectUri: URI? = URI.create("https://localhost:13370")

var accessToken: String? = null
/**
Expand Down
18 changes: 4 additions & 14 deletions src/AuthHandler.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@

import javafx.application.Application
import javafx.embed.swing.JFXPanel
import javafx.scene.layout.StackPane
import javafx.stage.Stage
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.grants.AuthorizationCodeGrant
import org.dmfs.oauth2.client.scope.BasicScope
import org.dmfs.rfc3986.encoding.Encoded
import org.dmfs.rfc3986.encoding.Precoded
import org.dmfs.rfc3986.uris.LazyUri
import org.dmfs.rfc5545.Duration
import org.swingplus.JHyperlink
Expand All @@ -29,10 +27,10 @@ class AuthHandler{
}

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 provider = BasicOAuth2AuthorizationProvider(URI.create("https://fuelrats.com/authorize"), URI.create("https://api.fuelrats.com/oauth2/token"), Duration(1,0,3600))
val credentials = BasicOAuth2ClientCredentials(secret.clientID, secret.clientSecret)
val client = BasicOAuth2Client(provider, credentials, LazyUri(Encoded("http://localhost:13370")))
val grant = AuthorizationCodeGrant(client, BasicScope("rescue.read", "rat.read"))
val client = BasicOAuth2Client(provider, credentials, LazyUri(Precoded("https://localhost:13370")))
val grant = AuthorizationCodeGrant(client, BasicScope("*"))
url = grant.authorizationUrl()!!
println(url)

Expand Down Expand Up @@ -62,17 +60,9 @@ class UrlDialog : Application() {

override fun start(stage: Stage?) {
val url = AuthHandler.url.toString()
val root = StackPane()
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
2 changes: 1 addition & 1 deletion src/Definition.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ enum class Trilean{
TRUE, FALSE, NEUTRAL;
}

fun rescueChanged(prop : Any, old : Any, new : Any) = Unit
fun rescueChanged(prop : Any, old : Any, new : Any) = updateScreen()
17 changes: 12 additions & 5 deletions src/LogHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ var LogFilefr = File(config.varMap["${entries.LogPathFr}"])
var LogFileRc = File(config.varMap["${entries.LogPathRc}"])
val listenfr = listener()
val listenrc = rclistener()
val tailerfr = Tailer.create(LogFilefr, listenfr, 20, true)
val tailerrc = Tailer.create(LogFileRc, listenrc, 20, true)
val tailerfr = Tailer.create(LogFilefr, listenfr, 2000, true)
val tailerrc = Tailer.create(LogFileRc, listenrc, 2000, true)

enum class supportedClients{hexchat, mirc, ii}

Expand Down Expand Up @@ -212,10 +212,14 @@ open class listener : TailerListenerAdapter(){
}
}

else ->{
return
}
}
updateScreen()
} else {
if (message.startsWith(config.varMap["${entries.keyword}"]!!.toUpperCase())) {
return //ignore signals for now, but keep the active Code for now
//ignore signals for now, but keep the active Code for now
//RATSIGNAL - CMDR killcrazycarl - System: COL 285 sector GM-V D2-110 (225.32 LY from Sothis) - Platform: XB - O2: OK - Language: English (en-US) (Case #1)
//RATSIGNAL - CMDR test - System: COL 285 sector GM-V D2-110 (225.32 LY from Sothis) - Platform: XB - O2: OK - Language: English (en-US) (Case #1)
//RATSIGNAL - CMDR Condor Aybarra - System: MN-t B3-6 Alrai Sector (not in EDDB) - Platform: PC - O2: OK - Language: English (en-US) - IRC Nickname: Condor_Aybarra (Case #3)
Expand All @@ -242,10 +246,13 @@ open class listener : TailerListenerAdapter(){


rescues.add(Rescue(name, System(system), lang, number, platform, cr, "-1"))
updateScreen()
}

} else {
message = message.toLowerCase()
@Suppress("NAME_SHADOWING")
val nick = nick.replaceAfter("[", "").replace("[", "")
if (message.contains("fr+")) {
getCase(message, nick).rats.filter { it.name == nick }.forEach { it.status.friended = TRUE }
}
Expand All @@ -262,11 +269,11 @@ open class listener : TailerListenerAdapter(){
getCase(message, nick).rats.filter { it.name == nick }.forEach { it.status.winged = FALSE; it.status.beacon = NEUTRAL; beep() }
}

if (message.contains("beacon+") || message.contains("bc+")) {
if (message.contains("beacon+") || message.contains("bc+") || message.contains("wb+")) {
getCase(message, nick).rats.filter { it.name == nick }.forEach { it.status.beacon = TRUE; it.status.winged = TRUE; it.status.inSys = TRUE }
}

if (message.contains("beacon-") || message.contains("bc-")) {
if (message.contains("beacon-") || message.contains("bc-") || message.contains("wb-")) {
getCase(message, nick).rats.filter { it.name == nick }.forEach { it.status.beacon = FALSE; beep() }
}

Expand Down
9 changes: 3 additions & 6 deletions src/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ fun main(args: Array<String>) {
}
}

launch{inpThr.run()}
//launch{inpThr.run()}
launch{
WebSocket.instance().init()
WebSocket.instance().request("rescues", "read")
Expand Down Expand Up @@ -127,9 +127,6 @@ fun checkTailer(task : TimerTask) {
var toPrint = ArrayList<String>()
var lastHash = -1

fun updateScreen(timerTask: TimerTask) {
updateScreen()
}
fun updateScreen() {
with(terminal!!) {
enterPrivateMode()
Expand All @@ -139,7 +136,7 @@ fun updateScreen() {
setCursorPosition(0, 0)
enableSGR(SGR.BOLD)
}
var linecount = 0
var linecount : Int
terminal?.printString("Welcome to JAFRDB", terminal!!.terminalSize.columns / 2 - 17 /* welcome string length*/, 0)
terminal?.printString("Cases: ", 2, 1)
linecount = printRescues()
Expand Down Expand Up @@ -274,7 +271,7 @@ class Rat(name : String, status : Status = Status(""), val uuid: String){
var status : Status by Delegates.observable(status, ::rescueChanged)

fun setNameCorrectly() : Rat {
name.replace(" ", "_").replaceAfter("[", "")
name = name.replace(" ", "_").substringBefore("[")
return this
}

Expand Down
Loading

0 comments on commit 5b3c4c6

Please sign in to comment.