I'm having difficulty trying to implement this method. What I'm trying to do is to check if the hostname matches the request from the user (regarding SSL certificates) how sslshopper.com would display if the hostname matches or mismatches.
My connection is under Controller.java:
HttpsURLConnection connection; try { connection = (HttpsURLConnection) urlOK.openConnection(); connection.connect(); } catch (IOException ex) { throw new IOException("Failed to connect: " + ex.getMessage()); } I set up a class called getHostnameVerified and I pass these values to it from Controller.java getHostNameVerified.returnValid(this,urlOK,connection);
Here is the setter for the UI found in Controller.java:
public void getHostname(boolean hostnameValid) { if (hostnameValid) { hostName.setText("Hostname match"); } else if (!hostnameValid) { hostName.setText("Hostname mis-match"); } } Here is the class:
public abstract class getHostNameVerified implements HostnameVerifier { public static void returnValid(Controller controller, URL url, HttpsURLConnection connection) { try { HostnameVerifier hv = new HostnameVerifier() { @Override public boolean verify(String s, SSLSession sslSession) { System.out.println("DEBUG getHostNameVerified verify entered"); return true; } }; }catch (Exception ex) { System.out.print("getHostNameVerified exception: " + ex.getMessage()); } } } Nothing happens. I do not see the println statement for SSL certificates I know are true. Am I implementing something wrong? I'm completely stumped :(.
abstractclass, otherwise you won't be able to create an instance of it. Secondly,getHostNameVerified(ordoSomething) is generally the way to call methods, not classes. In the Java style guides, classes normally have names that start with a capital character (and generally not a verb), for exampleCustomHostnameVerifier): what you've done is "legal" Java, but you may find that a number of tools rely on those conventions. [...]HttpsURLConnection(or the whole class if you want it to be used by default).