Configuration

class Configuration

CallId feature's configuration

Constructors

Link copied to clipboard
fun Configuration()

Functions

Link copied to clipboard
fun generate(block: CallIdProvider)

block function will be applied when there is no call id retrieved. It should generate a string to be used as call id or null if it is impossible to generate call id for some reason. Note that it should conform to call id verification otherwise it may be discarded or may lead to complete call rejection

Link copied to clipboard
fun header(headerName: String)

Setup retrieve/reply cycle via HTTP request and response headers headerName. Identical to retrieveFromHeader and replyToHeader invocations with the same headerName

Link copied to clipboard
fun reply(block: (call: ApplicationCall, callId: String) -> Unit)

Replies with retrieved or generated callId. Usually replyToHeader could be used instead.

Link copied to clipboard
fun replyToHeader(headerName: String)

Replies retrieved or generated callId using HTTP response header headerName

Link copied to clipboard
fun retrieve(block: CallIdProvider)

block will be used to retrieve call id from a call. It should return null if no call id found in request

Link copied to clipboard
fun retrieveFromHeader(headerName: String)

Fetch call id from a request header named headerName that is treated as optional

Link copied to clipboard
fun verify(predicate: CallIdVerifier)

Verify retrieved or generated call ids using the specified predicate. Should return true for valid call ids, false to ignore an illegal retrieved or generated call id or throw an RejectedCallIdException to reject an ApplicationCall. Only one verify condition could be specified. It is not recommended to disable verification (allow all call id values) as it could be abused so that it may become a security risk. By default there is always the default verifier against CALL_ID_DEFAULT_DICTIONARY so all illegal call ids will be discarded.

fun verify(dictionary: String, reject: Boolean = false)

Verify retrieved or generated call ids against the specified dictionary. Rejects an ApplicationCall if reject is true otherwise an illegal call id will be simply ignored. Only one verify condition or dictionary could be specified

Extensions

Link copied to clipboard
fun CallId.Configuration.generate(length: Int = 64, dictionary: String = CALL_ID_DEFAULT_DICTIONARY)

Generates fixed length call ids using the specified dictionary. Please note that this function generates pseudo-random identifiers via regular java.util.Random and should not be considered as cryptographically secure. Also note that you should use the same dictionary for CallIdVerifier otherwise a generated call id could be discarded or may lead to complete call rejection.