Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is really the age old "How do I protect my Java application from X?".</p> <p>The fact is you can't. Anyone with enough time and work will be able to take apart your Java app and sew it back together. You of course can work with some great obfusacaters that make it impractical for any who wants to do it fast.</p> <p>Past that point you have asked a somewhat of a trivial question. Which is "How do I hide 'new URL'". I've made the assumption that you will end up relying on the urlconnection class to actually work with the url. This could deal with a great bit of optimization and you could add more layers such as storing the class name and url as a byte array and many other things. It also could do with some caching of the constructor and class. <strong>I really recommend you not use this!</strong></p> <pre><code>public static URLConnection getConnection() { try { Class&lt;?&gt; cla = Class.forName("java.net.URL"); return (URLConnection) cla.getMethod("openConnection", new Class[0]).invoke(cla.getConstructor(String.class).newInstance("http://somtopsecereturl.tld"), new Object[0]); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } return null; } </code></pre> <p>You of course could keep going down the stack and do the actually reading through reflection calls so you never reference the real object types making it very hard to find.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload