/** * Test that the given url is "compatible" with the * session specified dataset. Wrapper around * HTTPAuthUtil.httphostCompatible(). * * @param other to test for compatibility against this method's * @return true if compatible, false otherwise. */ protected boolean sessionCompatible(AuthScope other) { return HTTPAuthUtil.authscopeCompatible(session.getAuthScope(), other); }
/** * Given a session url AuthScope and a Method url AuthScope, * return a new AuthScope that is the upgrade/merge of the other two. * Here, upgrade changes the scheme (only) to move http -> https. * Assumes authscopeCompatible() is true. * * @param ss Session authScope * @param ms Method authScope * @return upgraded AuthScope. */ static AuthScope authscopeUpgrade(AuthScope ss, AuthScope ms) { assert (HTTPAuthUtil.authscopeCompatible(ss, ms)); String sss = ss.getScheme().toLowerCase(); String mss = ms.getScheme().toLowerCase(); String upgrade = sss; if(sss.startsWith("http") && mss.startsWith("http")) { if(sss.equals("https") || mss.equals("https")) upgrade = "https"; } AuthScope host = new AuthScope(ss.getHost(), ss.getPort(), AuthScope.ANY_REALM, upgrade); return host; }