-1

I have webapp and I want to give to use one person on own laptop. For that I need to deploy WAR file in tomcat on laptop from that person and I want to protect, if possible, on same way that war file . That someone doesn't take war and see all my java code.

I need to deploy war file in that person laptop and database to , but on same way to protect that not can use, see, copy or something else for that war file ?

Thanks for any help ...

zexco2
  • 149
  • 2
  • 18
  • Whats the point of preventing use of the WAR ? – Marged Jun 27 '15 at 17:48
  • Why don't you host your application and share its URL with the user? – ring bearer Jun 27 '15 at 18:08
  • That person only use webapp , and only on own laptop(it's not big app) . In that case I think is the best to deploy war in his laptop but with some way to protected war file. It doesn't cost anything to deploy on his laptop and he can use when he want, because I'm not hosted on my server or another. – zexco2 Jun 27 '15 at 18:20
  • It will helpful too http://stackoverflow.com/questions/25641771/how-to-secure-the-war-file-deployed-in-tomcat-server/37226652#37226652 – Musa May 14 '16 at 12:42

2 Answers2

2

I am just wondering why you need to ship the source code in the war? If you are worried that someone is going to decompile your code, looks at obfuscators like [ProGaurd][1] http://proguard.sourceforge.net/

YesR
  • 100
  • 1
  • 6
  • How can build war file without java classes . I go on Maven instal and building war file. In war file I have .class files but with some programs , they can see in normal java format. I looking your link ... – zexco2 Jun 27 '15 at 17:05
  • .java = source, .class=binary (which can be decompiled). You only need to put .class files into a war, not .java – Marged Jun 27 '15 at 17:09
  • I am not put java class in war , but if someone take .class file , he can see code ... – zexco2 Jun 27 '15 at 17:11
  • @Marged with Java Decompiler I can decompiled .class file – zexco2 Jun 27 '15 at 17:13
  • 1
    @zexco2 this is what I wrote, yes. But you wrote about Java classes not class files, this is what confused the rest of us. Use an obfuscator. – Marged Jun 27 '15 at 17:46
  • Thanks for the advice and program. When I said Java code, I thought it is understood that in the war file code in .class files(binary) . In any case, thank you, I will hope so, that I have some protection ... – zexco2 Jun 27 '15 at 17:59
0

WAR files don't need to contain your java code, just the compiled .class files. If you are using an IDE to create the WAR, without using a build tool, then it is possible that the .java files are included as well by default.

The IDE build options may include an option to include or exclude the java source. If not, then a WAR file is just a zip file. You can safely open this WAR file with a ZIP utility such as WinZip, delete the java source files (leave the classes folder alone, as this contains your compiled code), then save the WAR again.

Alternatively, switch to using a build tool which excludes your source files from your war.

  • Yes, I have only .class file but that files I can see in normal java code with programs , for example Java Decompiler ... – zexco2 Jun 27 '15 at 17:08
  • If you are worried about your class files being decompiled, you can use an obfuscator, as linked above. But most people don't worry about this. There is no guarranteed way to protected distributed programs from decompilation. You may want to consider using your own web server, then you can protect the code. – Chris Morgan Jun 27 '15 at 19:18