Slick Forums

Discuss the Slick 2D Library
It is currently Mon May 20, 2013 6:07 am

All times are UTC




Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Thu Oct 07, 2010 8:28 am 
Offline
Regular

Joined: Sun Oct 11, 2009 8:53 pm
Posts: 219
i got few questions about stuff that i saw in epic game called "Fantasy Tales Online" (http://slick.javaunlimited.net/viewtopi ... 5929#15929)

this are my questions:
1. i saw the game code used SHA1-Digest, BENOITGI.SF
what are this stuff? they are somthings that help to protect the code?
i got a online game 2, and i want to add more protections for my game to help protecting the code.

2. is the jnlp files helps to protect the game? i mean, does it auto update if there is a change in the code?
how does it "knows" when the code change?

tnx


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 07, 2010 11:04 am 
Offline
Game Developer
User avatar

Joined: Wed Feb 17, 2010 12:24 am
Posts: 594
1: I don't know what they use, if any. That might be their signing key.
If you want to protect your byte code you could use something like ProGuard:
http://proguard.sourceforge.net/

2: jnlp is for Java WebStart: https://secure.wikimedia.org/wikipedia/ ... _Web_Start It comes standard with java, it doesn't protect the code. Just a way to deliver application though the internet.


Top
 Profile  
 
PostPosted: Thu Oct 07, 2010 11:42 am 
Offline
Game Developer
User avatar

Joined: Sun Nov 12, 2006 8:40 pm
Posts: 574
waltobc6 wrote:
2. is the jnlp files helps to protect the game? i mean, does it auto update if there is a change in the code?
how does it "knows" when the code change?


Yes Java Web Start is one of the deployment technologies that comes with all Oracle Java runtimes (among others like Java Applets). It associates itself with .JNLP files (basically XML files) and uses those to know which files and jars to use in your java application.

It does auto update your java application, it basically detects if the jar files of your java application have changed since the last time it ran it, if so it downloads them again.


Top
 Profile  
 
PostPosted: Thu Oct 07, 2010 11:53 am 
Offline
Regular

Joined: Sun Oct 11, 2009 8:53 pm
Posts: 219
kappa wrote:
waltobc6 wrote:
2. is the jnlp files helps to protect the game? i mean, does it auto update if there is a change in the code?
how does it "knows" when the code change?


Yes Java Web Start is one of the deployment technologies that comes with all Oracle Java runtimes (among others like Java Applets). It associates itself with .JNLP files (basically XML files) and uses those to know which files and jars to use in your java application.

It does auto update your java application, it basically detects if the jar files of your java application have changed since the last time it ran it, if so it downloads them again.


ty very much i got more questions:

about the SHA1-Digest, BENOITGI.SF ,
there are only for puting ur signicher on the code?
or does they do more like protecting the code from copys, i mean like
taking the soruce change it abit and start playing with the copy one you mad.

also, i tryed to do JNLP file to run my game, but for some reason
i get this error:
Code:
com.sun.deploy.net.JARSigningException: Found unsigned entry in resource: **mysite**/game.jar
    at com.sun.javaws.security.SigningInfo.getCommonCodeSignersForJar(Unknown Source)
    at com.sun.javaws.security.SigningInfo.check(Unknown Source)
    at com.sun.javaws.LaunchDownload.checkSignedResourcesHelper(Unknown Source)
    at com.sun.javaws.LaunchDownload.checkSignedResources(Unknown Source)
    at com.sun.javaws.Launcher.prepareResources(Unknown Source)
    at com.sun.javaws.Launcher.prepareAllResources(Unknown Source)
    at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
    at com.sun.javaws.Launcher.prepareToLaunch(Unknown Source)
    at com.sun.javaws.Launcher.launch(Unknown Source)
    at com.sun.javaws.Main.launchApp(Unknown Source)
    at com.sun.javaws.Main.continueInSecureThread(Unknown Source)
    at com.sun.javaws.Main$1.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)


when i run the JNLP, why is that?
how i can fix it?

and also, how it deceted if there is a change in the jar( i am asking just because its intersting).


Top
 Profile  
 
PostPosted: Thu Oct 07, 2010 12:15 pm 
Offline
Game Developer
User avatar

Joined: Sun Nov 12, 2006 8:40 pm
Posts: 574
You should have a read of the webstart tutorial, it should help with understanding how java webstart works and how to sign jars.

waltobc6 wrote:
and also, how it deceted if there is a change in the jar( i am asking just because its intersting).

Well I can't tell you the exact inner workings of JWS but I did attempt something similar with the LWJGL AppletLoader, which is probably very similar to how its done in JWS.

Basically everytime a file is put on a web server it gets a time stamp 'last-modified', when JWS downloads the file, it saves this value somewhere, so next time it needs to download the file it checks the time stamp and if its the same, then its assumed the file has not changed either and it is not redownloaded. Otherwise it just redownloads the file.


Top
 Profile  
 
PostPosted: Thu Oct 07, 2010 12:20 pm 
Offline
Regular

Joined: Sun Oct 11, 2009 8:53 pm
Posts: 219
kappa wrote:
You should have a read of the webstart tutorial, it should help with understanding how java webstart works and how to sign jars.

waltobc6 wrote:
and also, how it deceted if there is a change in the jar( i am asking just because its intersting).

Well I can't tell you the exact inner workings of JWS but I did attempt something similar with the LWJGL AppletLoader, which is probably very similar to how its done in JWS.

Basically everytime a file is put on a web server it gets a time stamp 'last-modified', when JWS downloads the file, it saves this value somewhere, so next time it needs to download the file it checks the time stamp and if its the same, then its assumed the file has not changed either and it is not redownloaded. Otherwise it just redownloads the file.


i read the tut, but i dont know where i need to write this code:
keytool -genkey -keystore myKeyStore -alias myName

in cmd? in what?

also, how i choose my "myKeyStore" or think about it?
also, in the part of "myName" to just but my name or what?


Top
 Profile  
 
PostPosted: Thu Oct 07, 2010 12:57 pm 
Offline
Game Developer
User avatar

Joined: Sun Nov 12, 2006 8:40 pm
Posts: 574
waltobc6 wrote:

in cmd? in what?

also, how i choose my "myKeyStore" or think about it?
also, in the part of "myName" to just but my name or what?


yes in the cmd, if for whatever reason keytool is not found you might have to go to the jdk bin directory (in cmd) that contains keytool.exe.

yes the my* names can just be replaced with whatever you want.


Top
 Profile  
 
PostPosted: Thu Oct 07, 2010 2:05 pm 
Offline
Regular

Joined: Sun Oct 11, 2009 8:53 pm
Posts: 219
kappa wrote:
waltobc6 wrote:

in cmd? in what?

also, how i choose my "myKeyStore" or think about it?
also, in the part of "myName" to just but my name or what?


yes in the cmd, if for whatever reason keytool is not found you might have to go to the jdk bin directory (in cmd) that contains keytool.exe.

yes the my* names can just be replaced with whatever you want.


i got another problem

i got a config.txt that is saved when a player save the options,
i mean, you can choose ur name, ur avatar in my game and every thing is saved on a config.txt, and when the game is load it read the config.txt and set the name and the img to what you saved in the config.txt last time.

how do i make throw JNLP that it will downlad the config.txt at the first time and then read only the config.txt from ur own computer and now re-download the config.txt every time i open the game.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 07, 2010 2:19 pm 
Offline
Game Developer
User avatar

Joined: Sun Nov 12, 2006 8:40 pm
Posts: 574
all resource files (images, sounds, data like txt files) should go inside jar files, then you must read the file from the jar.

So what you need to do is check if it txt file exists on the user computer, if so then load it, otherwise load it from the jar and save it on the computer.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 07, 2010 2:35 pm 
Offline
Regular

Joined: Sun Oct 11, 2009 8:53 pm
Posts: 219
pump


Last edited by waltobc6 on Fri Oct 08, 2010 7:35 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 08, 2010 7:35 am 
Offline
Regular

Joined: Sun Oct 11, 2009 8:53 pm
Posts: 219
kappa wrote:
all resource files (images, sounds, data like txt files) should go inside jar files, then you must read the file from the jar.

So what you need to do is check if it txt file exists on the user computer, if so then load it, otherwise load it from the jar and save it on the computer.


i dont know why

but for some reason when i launch the game its launching it and then nothing happen, the window wont open, no error nothing...
i want to make my program launch throw JNLP,
the problem is that when i launch the program throw JNLP it doesn't open the window and my program.

my program need 2 files, 1 is resources.jar that hold all the imgs and the sounds of the program
and the secound file is the config.properties that hold all the saves the used did in the options.

i got 2 problems with the JNLP,
1. the JNLP load but doesn't open my program (mean there is a problem)
2. how i do that the JNLP doesn't re-download every time the config.properties, after i save and change it?

for the first problem:
the code that run and use the resources.jar is this:
Code:
public void init(String jarLocation) throws IOException, SlickException {
      list = LoadingList.get();
                java.util.zip.ZipFile zipFile = new java.util.zip.ZipFile(jarLocation);
                zipFile.entries();
      JarFile jarFile = new JarFile(jarLocation);
      Enumeration<JarEntry> e = jarFile.entries();
      while (e.hasMoreElements()) {
         JarEntry je = e.nextElement();
         String path = je.getName();
         if (path.startsWith("resources") && path.length() > 10) {
            String dataInfo = path.split("/")[1];
            if (!path.endsWith("/")) {
               String name = path.split("/")[2].split("[.]")[0];
               if (dataInfo.equals("images")) {
                  list.add(new DeferredImage(name, path));
               } else {
                                            if (dataInfo.equals("cards")) {
                  list.add(new DeferredCards(name, path));
                  }
                                        }
            }
         }
      }
   }

and the jarLocation is "libs/resources.jar"

and the code that get and use the config is this:
Code:
public static void init(String fileLocation) throws IOException {
      Configuration.fileLocation = fileLocation;
                InputStreamReader is = new InputStreamReader(new FileInputStream(fileLocation));
      configurationFile = new Properties();
      configurationFile.load(is);
      is.close();
   }

the fileLocation is "config/config.properties"

my JNLP code looks like this:
(the game.jar is the program that use resources.jar and the config)
Code:
  <resources>
    <j2se href="http://java.sun.com/products/autodl/j2se" version="1.4+" max-heap-size="128m"/>
    <jar href="*site*/game.jar" main="true" />
    <jar href="*site*/libs/resources.jar"/>
    <jar href="*site*/libs/slick.jar" main="false"/>
    <jar href="*site*/libs/lwjgl.jar" main="false"/>
    <jar href="*site*/libs/twl.jar" main="false"/>
    <jar href="*site*/libs/kryo-1.01.jar" main="false"/>
    <jar href="*site*/libs/kryonet-1.01.jar" main="false"/>
    <jar href="*site*/libs/xpp3-1.1.4c.jar" main="false"/>
    <jar href="*site*/libs/minlog-1.2.jar" main="false"/>
    <jar href="*site*/libs/jogg-0.0.7.jar" main="false"/>
    <jar href="*site*/libs/jorbis-0.0.15.jar" main="false"/>
  </resources>

and the manifest.mf of the game.jar is this:
Code:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.1
Class-Path: libs/lwjgl.jar libs/slick.jar libs/resources.jar libs/ibxm
.jar libs/jogg-0.0.7.jar libs/jorbis-0.0.15.jar libs/xpp3-1.1.4c.jar
libs/asm-3.2.jar libs/kryo-1.01.jar libs/kryonet-1.01.jar libs/minlog
-1.2.jar libs/twl.jar libs/reflectasm-0.8.jar
Created-By: 1.6.0_21-b07 (Sun Microsystems Inc.)
Main-Class: azora.Launch

what is wrong and how i can fix both of this problems?


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 08, 2010 12:35 pm 
Offline
Game Developer

Joined: Sun Nov 12, 2006 11:18 pm
Posts: 890
Location: Germany
For the config problems you might want to take a look at Slick's Muffin class.
http://slick.cokeandcode.com/javadoc/org/newdawn/slick/muffin/Muffin.html or the more useful wrapping class SavedState:
http://slick.cokeandcode.com/javadoc/org/newdawn/slick/SavedState.html
It's basically a way to store properties (or configurations) on the client machine without interfering with other webstart mechanisms.
The SavedState class also nicely separates between webstart applications and local applications in your file system so that you don't need to modify your source code.

It works fine with my game SpiderTrap.
Feel free to follow the links in my signature and download the source code.
The interesting classes are net.haaks.spidertrap.SavedGameData.java and net.haaks.spidertrap.GameOptions.java.

I don't have the time ATM to look at your first JNLP problem.

Hope that helps a bit,
Tommy

_________________
Right Angle Games | Marte Engine
Back to the past | Star Cleaner | SpiderTrap


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 09, 2010 9:23 am 
Offline
Regular

Joined: Sun Oct 11, 2009 8:53 pm
Posts: 219
Tommy wrote:
For the config problems you might want to take a look at Slick's Muffin class.
http://slick.cokeandcode.com/javadoc/org/newdawn/slick/muffin/Muffin.html or the more useful wrapping class SavedState:
http://slick.cokeandcode.com/javadoc/org/newdawn/slick/SavedState.html
It's basically a way to store properties (or configurations) on the client machine without interfering with other webstart mechanisms.
The SavedState class also nicely separates between webstart applications and local applications in your file system so that you don't need to modify your source code.

It works fine with my game SpiderTrap.
Feel free to follow the links in my signature and download the source code.
The interesting classes are net.haaks.spidertrap.SavedGameData.java and net.haaks.spidertrap.GameOptions.java.

I don't have the time ATM to look at your first JNLP problem.

Hope that helps a bit,
Tommy


for the second problem you talk about:
i almost fix the problem i just got one last thing:
i manage to load the config or the player from inside the JAR by this code:
Code:
InputStreamReader is = new InputStreamReader(Thread.currentThread().getContextClassLoader().getResource(fileLocation).openStream());


but i can't mannage saving the file inside the jar, i tryed this:
Code:
OutputStream os = new FileOutputStream(fileLocation);
but its save the config outsaide, next to the jar and not inside the jar
and i also tryed this code:
Code:
OutputStream os = new FileOutputStream(Thread.currentThread().getContextClassLoader().getResource(fileLocation).toString());

but i got long error ....

if you can tell me how to fix the code of the save so its will save inside the jar?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 09, 2010 10:04 am 
Offline
User avatar

Joined: Tue Dec 25, 2007 7:23 pm
Posts: 45
Location: Iowa, US
For loading resources (images, sounds, etc) look at the class:
ResourceLoader

For saving user preferences and game state I would suggest you look at what Tommy sent to you about the "Muffin" and "SaveState". It was designed to let you do what you want.


Last edited by b2s on Sat Oct 09, 2010 10:13 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sat Oct 09, 2010 10:05 am 
Offline
Regular

Joined: Sun Oct 11, 2009 8:53 pm
Posts: 219
b2s wrote:
Why do you want to save the game state in the JAR?

I assume it is because you want to know where the user's data is at all times. So when they play the game again you know where the data is to load. Manipulating your JAR at runtime just does not sound like a good idea.

I would suggest you look at what Tommy sent to you about the "Muffin" and "SaveState". It was designed to let you do what you want.


ya
i understood that and i make my save like Tommy said,
throw SaveState
its working great i must say
althow i have no idea where its save the data
(do you know?)

now i am down to one problem:
http://slick.javaunlimited.net/viewtopic.php?t=2732


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group