Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

Commit

Permalink
0.2-alpha03
Browse files Browse the repository at this point in the history
  • Loading branch information
lesclaz committed Jun 21, 2023
1 parent 3611c8f commit da44d75
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import cu.suitetecsa.sdk.nauta.framework.model.ResultType
import org.jsoup.Jsoup
import org.jsoup.nodes.Element

internal class JsoupConnectPortalScraper : ConnectPortalScraper {
class JsoupConnectPortalScraper : ConnectPortalScraper {
private fun getInputs(formSoup: Element): Map<String, String> {
val inputs = mutableMapOf<String, String>()
for (input in formSoup.select("input[name]")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import cu.suitetecsa.sdk.nauta.framework.model.ResultType
import cu.suitetecsa.sdk.nauta.domain.model.*
import org.jsoup.Jsoup

internal class JsoupUserPortalScrapper : UserPortalScraper {
class JsoupUserPortalScrapper : UserPortalScraper {
override fun parseErrors(html: String): ResultType<String> {
val htmlParsed = Jsoup.parse(html)
return try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class NautaApi(
is ResultType.Error -> throw loginResult.throwable
is ResultType.Success -> {
val (loginAction, loginData) = connectPortalScraper.parseActionForm(loginResult.result ?: "")
wlanUserIp = loginData["wlanuserip"] ?: ""
wlanUserIp = data["wlanuserip"] ?: ""
csrfHw = loginData["CSRFHW"] ?: ""
actionLogin = loginAction
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import cu.suitetecsa.sdk.nauta.framework.model.HttpResponse
import cu.suitetecsa.sdk.nauta.framework.model.ResultType
import org.jsoup.Connection

internal class DefaultNautaSession : NautaSession {
class DefaultNautaSession : NautaSession {
override val cookies = mutableMapOf<String, String>()
private var portalManager: Portal = Portal.CONNECT

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ class JsoupConnectPortalCommunicator(private val nautaSession: NautaSession) : C
override fun getLoginPage(url: String, data: Map<String, String>): ResultType<String?> {
return when (val response = nautaSession.post(url, data)) {
is ResultType.Error -> ResultType.Error(response.throwable)
is ResultType.Success -> ResultType.Success(response.result.text)
is ResultType.Success -> {
response.result.cookies?.forEach { (key, value) ->
nautaSession.cookies[key] = value
}
ResultType.Success(response.result.text)
}
}
}

Expand Down

0 comments on commit da44d75

Please sign in to comment.