Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
24
Task/HTTPS-Authenticated/Scala/https-authenticated.scala
Normal file
24
Task/HTTPS-Authenticated/Scala/https-authenticated.scala
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import java.net.{Authenticator, PasswordAuthentication, URL}
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection
|
||||
|
||||
import scala.io.BufferedSource
|
||||
|
||||
|
||||
object Authenticated extends App {
|
||||
|
||||
val con: HttpsURLConnection =
|
||||
new URL("https://somehost.com").openConnection().asInstanceOf[HttpsURLConnection]
|
||||
|
||||
object PasswordAuthenticator extends Authenticator {
|
||||
override def getPasswordAuthentication =
|
||||
new PasswordAuthentication("username", "password".toCharArray)
|
||||
}
|
||||
|
||||
Authenticator.setDefault(PasswordAuthenticator)
|
||||
con.setAllowUserInteraction(true)
|
||||
con.connect()
|
||||
|
||||
new BufferedSource(con.getInputStream).getLines.foreach(println(_))
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue