从Axis2 STS客户端调用基于Metro的安全令牌服务

时间:2012-05-26 07:38:04

标签: axis2 java-metro-framework sts-securitytokenservice rampart

我想调用一个安全令牌服务,该服务是使用来自Axis 2 STS客户端的Metro 2.2框架创建和部署的。我正在尝试做同样的事情,但遇到如下问题: -

java.lang.RuntimeException:Incorrect inclusion value: -1

我深入研究了源代码,发现 SecureConversationTokenBuilder 类代码中的代码是这样的: -

String inclusionValue = attribute.getAttributeValue().trim();

conversationToken.setInclusion(SP11Constants.getInclusionFromAttributeValue(inclusionValue));

然后我进入SP11Constants.getInclusionFromAttributeValue(inclusionValue)并看到以下代码: -

public static int getInclusionFromAttributeValue(String value ) {

    if (INCLUDE_ALWAYS.equals(value)) {
        return SPConstants.INCLUDE_TOEKN_ALWAYS;
    } else if (INCLUDE_ALWAYS_TO_RECIPIENT.equals(value)) {
        return SPConstants.INCLUDE_TOEKN_ALWAYS_TO_RECIPIENT;
    } else if (INCLUDE_NEVER.equals(value)) {
        return SPConstants.INCLUDE_TOKEN_NEVER;
    } else if (INCLUDE_ONCE.equals(value)) {
        return SPConstants.INCLUDE_TOKEN_ONCE;
    } else {
        return -1;
    }   
}

as INCLUDE_ALWAYS =“http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Always”,它不等于policy.xml中的metro定义的内容像

http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/Always

因此,上面的代码总是返回-1,然后抛出一个运行时异常,如下所示: -

public void setInclusion(int inclusion)  {
    if(SPConstants.INCLUDE_TOEKN_ALWAYS == inclusion || 
       SPConstants.INCLUDE_TOEKN_ALWAYS_TO_RECIPIENT == inclusion ||
       SPConstants.INCLUDE_TOEKN_ALWAYS_TO_INITIATOR == inclusion ||
       SPConstants.INCLUDE_TOKEN_NEVER == inclusion ||
       SPConstants.INCLUDE_TOKEN_ONCE == inclusion ) {
        this.inclusion = inclusion;
    } else {
        //TODO replace this with a proper (WSSPolicyException) exception
        throw new RuntimeException("Incorrect inclusion value: " + inclusion);
    }
}

只是想知道是否有可能从基于Axis2的STS Client调用的Metro Framework中创建的安全令牌服务(STS)中获取令牌。请告知我,因为我陷入其间。

提前致谢。

0 个答案:

没有答案