Is it possible to set the user name and password on an HTAccess certificate directly from my code rather than have the user do it from the HTAccess prompt?
Created May 7, 2012
Bogdan Sheptunov Yes. This is the code for BASIC http authorization:
// use this to encode the username/password private String encodeAuthorization String username, String password) { String authorization = username + ":" + password; sun.misc.BASE64Encoder enCoder = new sun.misc.BASE64Encoder(); return "Basic " + enCoder.encode(authorization.getBytes()); } // insert this piece into setting the connection properties, where encodedAuthorization is a result of the function given above: connection.setRequestProperty("Authorization", encodedAuthorization);