Calling a Metro based Security Token Service from an Axis2 STS Client

324 Views Asked by At

I want to call a Security Token Service which was created and deployed using Metro 2.2 framework from an Axis 2 STS Client. I'm trying to do the same but getting issues like the one below: -

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

I went deep into the source code and saw that in SecureConversationTokenBuilder class code is wriiten something like this:-

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

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

then I went into the SP11Constants.getInclusionFromAttributeValue(inclusionValue) and saw the following piece of code:-

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" which is not equal to what is defined by metro in policy.xml like

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

Therefore the above code always return -1 and in turn throws a runtime exception as below:-

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

Just wanted to know whether it is possible to get token from Security Token Service (STS) created in Metro Framework invoked from an Axis2 based STS Client.Please advise as I'm stuck in between.

Thanks in advance.

0

There are 0 best solutions below