class DataStore implements DataCacheProvider, RolesProvider {

    void processTrustedDomain(DataCache trustData, String identity, String rolePrefix,
            String[] requestedRoleList, Set<String> trustedResources, Set<String> accessibleRoles,
            boolean keepFullName) {

        /* verify that our data cache and list of trusted resources are valid */
        
        if (trustData == null || trustedResources == null) {
            return;
        }
        
        /* first we need to process our regular roles that include
         * our identity */

        Set<MemberRole> memberRoles = trustData.getMemberRoleSet(identity);
        if (memberRoles != null) {
        
            for (String resource : trustedResources) {
                
                /* in this case our resource is the role name */
                    
                processSingleTrustedDomainRole(resource, rolePrefix, requestedRoleList,
                        memberRoles, accessibleRoles, keepFullName);
            }
        }
        
        /* next we should process all the * wildcard roles */
        
        memberRoles = trustData.getAllMemberRoleSet();
        if (memberRoles != null && !memberRoles.isEmpty()) {
        
            for (String resource : trustedResources) {
                
                /* in this case our resource is the role name */
                    
                processSingleTrustedDomainRole(resource, rolePrefix, requestedRoleList,
                        memberRoles, accessibleRoles, keepFullName);
            }
        }
        
        /* finally we're going to process the wildcard roles
         * but we need to first confirm that our identity
         * matches to member before processing it */
        
        Map<String, Set<MemberRole>> roleSetMap = trustData.getPrefixMemberRoleSetMap();
        for (String identityPrefix : roleSetMap.keySet()) {
            if (identity.startsWith(identityPrefix)) {
                
                memberRoles = roleSetMap.get(identityPrefix);
                for (String resource : trustedResources) {
                    
                    /* in this case our resource is the role name */
                        
                    processSingleTrustedDomainRole(resource, rolePrefix, requestedRoleList,
                            memberRoles, accessibleRoles, keepFullName);
                }
            }
        }
    }

    public  DataStore(ChangeLogStore clogStore, CloudStore cloudStore);

}