• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
keywi

Java Game Launcher/Downloader - User Authentication

6 posts in this topic

Hi there,

I'm trying to make a game launcher in Java that will request a username and password, post the data to a website, let the website check its database for a match and then let the user receive/update the game depending on whether it is a success or not.

I've been looking deeper into PHP, MySQL, TLS/SSL and Apache, but I am still not sure how to set this up correctly. I'd like good security as well which makes it a tad more difficult.

I have been searching like crazy but I still have some unanswered questions:

1. How can I establish a secure connection from a client-side Java program to a server-side PHP/MySQL structure? Any libraries/packages?

2. How is the data sent from the client interpreted server-side? Is it by extending an URL with the data like "https://127.0.0.1/login.php?data=stuff&method=login"?

Any tips or hints on what I should look at would be greatly appreciated!

Thanks for reading my wall of text!
0

Share this post


Link to post
Share on other sites

Simply use a SSL (or HTTPS) library on the Java side. Configure Apache (or Nginx, or whatever your PHP host is) to run HTTPS with a certificate. If you use self-signed certificates, install the public certificate on the client machine and load that for the SSL library.
 
Then formulate a HTTPS POST with the data in whatever format you want -- JSON, XML or x-www-form-urlencoded are common formats. Send it to the server. Wait for the reply.
 
On the server, in PHP, you read the input like so:
 

$contents = file_get_contents("php:" . "//input"); // split the string because gamedev.net

"php input" is a string that I for some reason can't post as-is into the forum software (!)

 

The input comes from the POST or PUT request to the URL from the request body.

 

And parse it (if it's JSON) like so:

$variables = json_decode($contents)

Typically, you store the user name, and the bcrypt() of the password salted with the username, in a database table. You can then check for proper login by simply doing a select where username=(thename) and bcrypt_password=bcrypt(thepassword + thename). This avoids storing the password in an easily recoverable format in the database, so if the database somehow leaks to the greater internet, the plaintext passwords are not revealed.
 
Also, do not put user arguments into strings for database queries; use a database API that allows you to use symbolic query parameters so there is no risk of SQL injection.

Edited by hplus0603
1

Share this post


Link to post
Share on other sites

It looks like I'll be using Apache and I'll look into finding a good Java library for SSL. After reading up a bit on certificates I guess it makes sense for me to use a self-signed certificate for now as it's not a website that will be displayed.

 

I'm familiar with JSON so that shouldn't be a problem.

 

Thanks for the security tips. I figured I'd have to encrypt the data, and shield the database from SQL injections, but now I know what API to look for.

 

How would I read the input in PHP? I think you missed filling in the field by accident.

 

EDIT: My guess would be something like 

$contents = $_GET["data"];
Edited by keywi
0

Share this post


Link to post
Share on other sites

No, the input is the post / put request body, and is parsed from php input (the URL which I cannot post straight in this forum !)

 

A HTTP request has a URL, which may have a query string, some headers, and a body.

 

PHP will attempt to decode the query string, and provide the values of that query string in $_GET.

PHP will also attempt to decode the request body if it is in the format x-www-form-urlencoded (which looks like a query string) and provide the values of that decode in $_POST. However, it will not decode JSON or XML formatted request bodies, so you have to do that yourself.

1

Share this post


Link to post
Share on other sites
OK, everything you say makes sense. I was stuck in the mindset that input had to be processed as part of a query string.

Would you recommend any particular software to run a locally hosted version on a Windows machine? I'm currently using xampp (it's working fine so far) and I tried using a Ubuntu virtual machine on Amazon EC2, but it feels very impractical in these early stages. I definitely think EC2 is the way to go though when it's ready for launch.

The reason I'm asking is that it would be practical for me to use a local setup that is almost identical to an EC2 setup. The easier it is for me to upload my files and get it running the better. I guess my real question is if there's anything I should look out for? Like versions of PHP or anything else that could differ between a live and local version.
0

Share this post


Link to post
Share on other sites

Would you recommend any particular software to run a locally hosted version on a Windows machine?


At work, we use VMWare Workstation, running one (or a few) Ubuntu images that look a lot like our production hardware. This is great, and lets developers use Macs, Windowses, or raw Ubuntu for development. Workstation costs money, though. There are alternative VM hosts that are free if this is an issue for you.

Another option is to use a server technology that has both Windows and Linux support. Apache/PHP on Windows is troublesome, but can be made to work. node.js works on both Windows and Linux. Python works on both Windows and Linux, and you can use the "simple" self-hosted version for development, and use a WSGI server in production.
1

Share this post


Link to post
Share on other sites
I think I'm starting to get a hang of it. Managed to make a request with a username and password in the HTTP request body, receive the data in PHP, look for a match in the database and send back a simple header response. I need to do some research on setting up SSL. I'm not entirely sure what software to use to make self-signed private and public keys. I used the keytool in the jre7/bin folder to make one, but I don't know how to make a private one for the server. I'm pretty sure I need to specify its settings in the server.xml file, but its just the creation and storage of keys that's got me a bit stumped.

Thanks for all the help you've given me thus far!
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0