0

I want to create a dynamic class or method. The server sends the complete class as the response. I want to use the response to create a dynamic class.

Nandha Kumar
  • 131
  • 3
  • 13
  • Possible duplicate of [Create new class from a Variable in Java](https://stackoverflow.com/questions/1268817/create-new-class-from-a-variable-in-java) – Northern Poet Nov 16 '17 at 07:42
  • No. I'm sending class in response. So I just want to load those into the class loader and use it (like generic class loader). – Nandha Kumar Nov 16 '17 at 07:48
  • You want to create classes from raw string source? It's possible. But **highly not recommended**. Google for `cglib` or `javassist`. But I cant imagine the real business case that require compiling classes dynamically. – Northern Poet Nov 16 '17 at 07:54
  • We want to send class that contains API keys, encryption key generation methods for the security. – Nandha Kumar Nov 16 '17 at 07:56
  • Yes, we want to create the class from the raw string. – Nandha Kumar Nov 16 '17 at 08:00
  • Just imagine: you send a complete guide of how to generate keys from server to the application. Anyone can grab it, it's absolutely not secure. I recommend you to take a look at asymmetrical cryptography. – Northern Poet Nov 16 '17 at 08:07
  • I'm doing this to avoid code extraction during APK decompilation. – Nandha Kumar Nov 16 '17 at 08:08
  • APK decompilation will give attacker everything required to request your method from server and use for generate new keys. Doing this is not secure. – Northern Poet Nov 16 '17 at 08:13
  • Yeah, you're right. But Is there any way to do so? I'm just asking to learn. – Nandha Kumar Nov 16 '17 at 08:22
  • Answer depends of what you're trying to protect. May be apk resources, network requests, server content. A lot of varieties. – Northern Poet Nov 16 '17 at 08:28

0 Answers0