Question

I am writing an Assertion Generator Plugin in Java to fetch a user details from Session Store and modify the values in Assertion(SAML 2.0) accordingly.

I am able to identify the method(Link) using which I can pull the user values from Session Store (agentAPIObject.getSessionVariables()) based on SessionID, but, I am having trouble writing a code to fetch specific parameters from the session store. (speficially around setting values for Attribute method and making it as an array)

Can someone post a sample code if you have ever seen/written around it, so that I can fetch user attributes from Session Store.

I am having trouble understanding Java docs around it.

Thanks in advance,

Was it helpful?

Solution

The API mentions this:

responseAttributeList - On successful return from this method (YES is returned), this output parameter contains the retrieved variable names and their values. If the method returns UNRESOLVED, this parameter includes variables that could not be retrieved.

You'll need to create two AttributeList Objects. If the response of getSessionVariables(...) is YES, then the variable responseAttributeList will contain the session variables. Since Java uses references, that same variable responseAttributeList will be updated. You can then use getAttributeAt(...) to access the Attribute Objects.

String sessionID = "sampleID";
ResourceContextDef rcd = //whatever it needs to be equal to
AttributeList requestAttributeList = new AttributeList();
AttributeList responseAttributeList = new AttributeList();

if(getSessionVariables(sessionId, rcd, requestAttributeList, responseAttributeList) == YES){
    Attribute att = responseAttributeList.getAttributeAt(0);//or whatever index. 
}

Remember to carefully read the API.

NOTE: This is just pseudo code. I have not tested this. However, this should be plenty enough to get you going where you need to.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top