public NVPair getUsernamePassword(AuthorizationInfo challenge, boolean forProxy) { if (forProxy && pa_name != null) { if (been_here) { System.out.println(); System.out.println("Proxy authorization failed"); return null; } been_here = true; return new NVPair(pa_name, pa_pass); } if (been_here) { System.out.println(); System.out.println("Proxy authorization succeeded"); } // print out all challenge info System.out.println(); if (forProxy) System.out.println("The proxy requires authorization"); else System.out.println("The server requires authorization for this resource"); System.out.println(); System.out.println("Scheme: " + challenge.getScheme()); System.out.println("Realm: " + challenge.getRealm()); System.out.println(); System.out.println("Add the following line near the beginning of your application:"); System.out.println(); if (challenge.getScheme().equalsIgnoreCase("Basic")) System.out.println( " AuthorizationInfo.addBasicAuthorization(\"" + challenge.getHost() + "\", " + challenge.getPort() + ", \"" + challenge.getRealm() + "\", " + "<username>, <password>);"); else if (challenge.getScheme().equalsIgnoreCase("Digest")) System.out.println( " AuthorizationInfo.addDigestAuthorization(\"" + challenge.getHost() + "\", " + challenge.getPort() + ", \"" + challenge.getRealm() + "\", " + "<username>, <password>);"); else System.out.println( " AuthorizationInfo.addAuthorization(\"" + challenge.getHost() + "\", " + challenge.getPort() + ", \"" + challenge.getScheme() + "\", \"" + challenge.getRealm() + "\", " + "...);"); System.out.println(); return null; }