Accessing session/feeder values when using perUserKeyManagerFactory

I am trying to use perUserKeyManagerFactory for using multiple key stores. For this i need the system name in each request.

I have created the method createKeyManagerFactory for this. But I can’t reach the values of the session in this method. How can I access the values of the session/feeder in this method?

I am also very new to Scala.


My code looks like this :

val feeder = csv("servicesSecureTestData.csv").eager

val stringBody =

def createKeyManagerFactory(systemId: Long): KeyManagerFactory ={
 val keyStore = KeyStore.getInstance("PKCS12")

// here value session is not recognized !!! "Cannot resolve symbol session"
 val attribute: SessionAttribute = session("systemName")
 val systemName = session("systemName").as[String]
 keyStore.load(new FileInputStream("./"+ systemName+".p12"), "123456".toCharArray)
val keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm)

val httpProtocol = http // 4
 .baseUrl("https://localhost:8443") // 5
 .acceptEncodingHeader("gzip, deflate")
 .userAgentHeader("Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0").perUserKeyManagerFactory(createKeyManagerFactory)

val scn = scenario("RegisterSimulation").feed(feeder).exec(http("request_1")

setUp( // 11

It’s exactly that: you can’t use the Session when computing per user KeyManager. Find a different strategy.

Thanks for the answer. But what is the sense of giving the virtual user id to the method for perUserKeyManagerFactory? Can I use this virtual user id in my method to access these session attributes somehow?

This id is incremental, you can use it to pick the KeyManager you want, eg use a modulo to do a round-robin.

Ok I get it. It would be nice to have for the future releases, if we can access the session also in this method.