Search in sources :

Example 1 with SOAP12Version

use of org.apache.axiom.soap.SOAP12Version in project webservices-axiom by apache.

the class RolePlayerChecker method matches.

@Override
public boolean matches(AxiomElement header, String unused1, String unused2) {
    // If we're filtering on namespace, check that first since the compare is simpler.
    if (namespace != null) {
        OMNamespace headerNamespace = header.getNamespace();
        if (headerNamespace == null || !namespace.equals(headerNamespace.getNamespaceURI())) {
            return false;
        }
    }
    String role = SOAPHeaderBlockHelper.getRole(header, soapHelper);
    SOAPVersion version = soapHelper.getVersion();
    // 1. If role is ultimatedest, go by what the rolePlayer says
    if (role == null || role.equals("") || (version instanceof SOAP12Version && role.equals(SOAP12Constants.SOAP_ROLE_ULTIMATE_RECEIVER))) {
        return (rolePlayer == null || rolePlayer.isUltimateDestination());
    }
    // 2. If role is next, always return true
    if (role.equals(version.getNextRoleURI()))
        return true;
    // 3. If role is none, always return false
    if (version instanceof SOAP12Version && role.equals(SOAP12Constants.SOAP_ROLE_NONE)) {
        return false;
    }
    // 4. Return t/f depending on match
    List<String> roles = (rolePlayer == null) ? null : rolePlayer.getRoles();
    if (roles != null) {
        for (String thisRole : roles) {
            if (thisRole.equals(role))
                return true;
        }
    }
    return false;
}
Also used : OMNamespace(org.apache.axiom.om.OMNamespace) SOAPVersion(org.apache.axiom.soap.SOAPVersion) SOAP12Version(org.apache.axiom.soap.SOAP12Version)

Aggregations

OMNamespace (org.apache.axiom.om.OMNamespace)1 SOAP12Version (org.apache.axiom.soap.SOAP12Version)1 SOAPVersion (org.apache.axiom.soap.SOAPVersion)1