用于获取会话存储属性值的Java代码

时间:2014-04-21 15:02:33

标签: java siteminder

我正在用Java编写一个Assertion Generator插件,用于从Session Store获取用户详细信息,并相应地修改Assertion(SAML 2.0)中的值。

我能够识别方法(Link),我可以根据SessionID从Session Store(agentAPIObject.getSessionVariables())中提取用户值,但是,我在编写代码时遇到问题会话存储中的特定参数。 (特别是围绕设置Attribute方法的值并将其作为数组)

如果您曾经看过/写过示例代码,有人可以发布示例代码,以便我可以从Session Store获取用户属性。

我无法理解围绕它的Java文档。

提前致谢,

1 个答案:

答案 0 :(得分:1)

API提到了这个:

  

responseAttributeList - 从此方法成功返回时(是   返回),此输出参数包含检索到的变量名称   和他们的价值观。如果该方法返回UNRESOLVED,则此参数   包括无法检索的变量。

您需要创建两个AttributeList对象。如果getSessionVariables(...)的响应为YES,则变量responseAttributeList将包含会话变量。由于Java使用引用,因此将更新相同的变量responseAttributeList。然后,您可以使用getAttributeAt(...)访问Attribute对象。

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. 
}

请务必仔细阅读API。

注意:这只是伪代码。我没有测试过这个。但是,这应该足以让你到达你需要的地方。