class AuthzHelper {

    public static String retrieveResourceDomain(String resource, String op, String trustDomain) {

        // special handling for ASSUME_ROLE assertions. Since any assertion with
        // that action refers to a resource in another domain, there is no point
        // to retrieve the domain name from the resource. In these cases the caller
        // must specify the trust domain attribute so we'll use that instead and
        // if one is not specified then we'll fall back to using the domain name
        // from the resource

        String domainName;
        if (ASSUME_ROLE.equalsIgnoreCase(op) && trustDomain != null) {
            domainName = trustDomain;
        } else {
            domainName = extractResourceDomainName(resource);
        }
        return domainName;
    }

}