DigestAuthenticator authenticator = new DigestAuthenticator(); authenticator.setNonceValidity(10 * 1000L); // Shorten from 5 minutes to 10 seconds authenticator.setNonceCacheSize(20000); // Increase from 1000 to 20000
final String userName = "user"; final String password = "password"; // Instantiate the cache Cache cache = new DiskBasedCache(getCacheDir(), 1024 * 1024); // 1MB cap DigestAuthenticator auth = new DigestAuthenticator() { @Override protected PasswordAuthentication requestPasswordAuthentication(String rHost, InetAddress rAddr, int rPort, String rProtocol, String realm, String scheme, URL rURL, Authenticator.RequestorType reqType) { return new PasswordAuthentication(userName, password.toCharArray()); } }; HurlStack.UrlRewriter urlRewriter = new HurlStack.UrlRewriter() { String rewriteUrl(String url) { return url; } }; HttpDigestStack digestStack = new HttpDigestStack(auth, urlRewriter); // Set up the network to use HttpURLConnection as the HTTP client. Network network = new BasicNetwork(digestStack); // Instantiate the RequestQueue with the cache and network. RequestQueue mRequestQueue = new RequestQueue(cache, network);
DigestAuthenticator authenticator = new DigestAuthenticator(); authenticator.setNonceValidity(10 * 1000L); // Shorten from 5 minutes to 10 seconds authenticator.setNonceCacheSize(20000); // Increase from 1000 to 20000
context.addValve(new BasicAuthenticator()); } else if ("DIGEST".equals(authMethod)) { context.addValve(new DigestAuthenticator()); } else if ("CLIENT-CERT".equals(authMethod)) { context.addValve(new SSLAuthenticator());
this.addValve(new BasicAuthenticator()); } else if ("DIGEST".equals(authMethod) ){ this.addValve(new DigestAuthenticator()); } else if ("CLIENT-CERT".equals(authMethod) ){ this.addValve(new SSLAuthenticator());
context.addValve(new BasicAuthenticator()); } else if ("DIGEST".equals(authMethod)) { context.addValve(new DigestAuthenticator()); } else if ("CLIENT-CERT".equals(authMethod)) { context.addValve(new SSLAuthenticator());