1

我想从 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;
    }   
}

作为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);
    }
}

只是想知道是否可以从 Metro 框架中创建的安全令牌服务 (STS) 获取令牌,该服务是从基于 Axis2 的 STS 客户端调用的。请告知,因为我正处于两者之间。

提前致谢。

4

0 回答 0