MarkM_63051
Mar 12, 2012Nimbostratus
Password Encoding
Hello,
I am writing to ask what the appropriate way is to encode a password when locating stubs. The following code snippet was pulled out of an F5 sample file:
m_endpoint = "https://" + args[2] + ":" + args[3] + "@" + args[0] + ":" + args[1] + "/iControl/iControlPortal.cgi";
m_pool = (iControl.LocalLBPoolBindingStub) new iControl.LocalLBPoolLocator().getLocalLBPoolPort(new java.net.URL(m_endpoint));
This will work fine as long as the password does not contain special characters such as the ":" character. Will the following code work or is there a better way?
String endpoint = "https://" + URLEncoder.encode(username, "UTF-8") + ":" + URLEncoder.encode(password, "UTF-8") + "@" + URLEncoder.encode(hostname, "UTF-8") + ":" + port + "/iControl/iControlPortal.cgi";
Regards,
Mark