-
Notifications
You must be signed in to change notification settings - Fork 0
/
kotlin_template.kts
54 lines (43 loc) · 1.7 KB
/
kotlin_template.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import org.apache.commons.httpclient.URI
import org.parosproxy.paros.network.HttpHeader
import org.parosproxy.paros.network.HttpMessage
import org.parosproxy.paros.network.HttpRequestHeader
import org.zaproxy.zap.authentication.AuthenticationHelper
import org.zaproxy.zap.authentication.GenericAuthenticationCredentials
import org.apache.log4j.LogManager
val PARAM_TARGET_URL = "https://pp-services.signin.education.gov.uk/"
val logger = LogManager.getLogger("external-script")
logger.debug("Kotlin auth template 1")
fun authenticate(
helper: AuthenticationHelper,
paramsValues: Map<String, String>,
credentials: GenericAuthenticationCredentials): HttpMessage {
println("Kotlin auth template 2")
println("TARGET_URL: ${paramsValues[PARAM_TARGET_URL]}")
logger.debug("Kotlin auth template")
logger.debug("TARGET_URL: ${paramsValues[PARAM_TARGET_URL]}")
val msg = helper.prepareMessage()
msg.requestHeader = HttpRequestHeader(HttpRequestHeader.GET, URI(paramsValues[PARAM_TARGET_URL], true),
HttpHeader.HTTP11)
println("msg: $msg ${msg.requestHeader.headers.size}")
logger.debug("msg: $msg ${msg.requestHeader.headers.size}")
msg.requestHeader.headers.forEach { println(it) }
msg.requestHeader.headers.forEach { logger.debug(it) }
helper.sendAndReceive(msg)
return msg
}
fun getRequiredParamsNames(): Array<String> {
return arrayOf(PARAM_TARGET_URL)
}
fun getOptionalParamsNames(): Array<String> {
return arrayOf("cookie_file")
}
fun getCredentialsParamsNames(): Array<String> {
return arrayOf()
}
fun getLoggedInIndicator(): String {
return "Access DfE services"
}
fun getLoggedOutIndicator(): String {
return "DfE Sign-in"
}