diff --git a/src/main/kotlin/cu/suitetecsa/sdk/nauta/framework/JsoupConnectPortalScraper.kt b/src/main/kotlin/cu/suitetecsa/sdk/nauta/framework/JsoupConnectPortalScraper.kt index 415a354..1e761f7 100755 --- a/src/main/kotlin/cu/suitetecsa/sdk/nauta/framework/JsoupConnectPortalScraper.kt +++ b/src/main/kotlin/cu/suitetecsa/sdk/nauta/framework/JsoupConnectPortalScraper.kt @@ -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 { val inputs = mutableMapOf() for (input in formSoup.select("input[name]")) { diff --git a/src/main/kotlin/cu/suitetecsa/sdk/nauta/framework/JsoupUserPortalScrapper.kt b/src/main/kotlin/cu/suitetecsa/sdk/nauta/framework/JsoupUserPortalScrapper.kt index 2ba75c7..41b39a4 100644 --- a/src/main/kotlin/cu/suitetecsa/sdk/nauta/framework/JsoupUserPortalScrapper.kt +++ b/src/main/kotlin/cu/suitetecsa/sdk/nauta/framework/JsoupUserPortalScrapper.kt @@ -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 { val htmlParsed = Jsoup.parse(html) return try { diff --git a/src/main/kotlin/cu/suitetecsa/sdk/nauta/framework/NautaApi.kt b/src/main/kotlin/cu/suitetecsa/sdk/nauta/framework/NautaApi.kt index 8f1be44..133d9ab 100755 --- a/src/main/kotlin/cu/suitetecsa/sdk/nauta/framework/NautaApi.kt +++ b/src/main/kotlin/cu/suitetecsa/sdk/nauta/framework/NautaApi.kt @@ -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 } diff --git a/src/main/kotlin/cu/suitetecsa/sdk/nauta/framework/network/DefaultNautaSession.kt b/src/main/kotlin/cu/suitetecsa/sdk/nauta/framework/network/DefaultNautaSession.kt index ca8a894..be3d42c 100755 --- a/src/main/kotlin/cu/suitetecsa/sdk/nauta/framework/network/DefaultNautaSession.kt +++ b/src/main/kotlin/cu/suitetecsa/sdk/nauta/framework/network/DefaultNautaSession.kt @@ -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() private var portalManager: Portal = Portal.CONNECT diff --git a/src/main/kotlin/cu/suitetecsa/sdk/nauta/framework/network/JsoupConnectPortalCommunicator.kt b/src/main/kotlin/cu/suitetecsa/sdk/nauta/framework/network/JsoupConnectPortalCommunicator.kt index ed3bae6..2a52446 100755 --- a/src/main/kotlin/cu/suitetecsa/sdk/nauta/framework/network/JsoupConnectPortalCommunicator.kt +++ b/src/main/kotlin/cu/suitetecsa/sdk/nauta/framework/network/JsoupConnectPortalCommunicator.kt @@ -45,7 +45,12 @@ class JsoupConnectPortalCommunicator(private val nautaSession: NautaSession) : C override fun getLoginPage(url: String, data: Map): ResultType { 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) + } } }