Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Contributor
akhalsa
Posts: 4
Registered: ‎07-15-2010
My Device: Not Specified
Accepted Solution

restrict OTA downloads

Hi guys

I made a blackberry application that I want to sell through my LAMP based website to complement the app store sales. I am a bit unclear on how to place my JAD file on my server so that I can allow people who have paid to download it without just making it publicly available. Does anyone have any advice on how to go about restricting access like this? 

Thanks in advance!

Please use plain text.
Developer
lcamobile
Posts: 76
Registered: ‎03-15-2010
My Device: 9800, 9630
My Carrier: Rogers

Re: restrict OTA downloads

Hi,

 

We have used a PHP script which reads an encrypted copy of the JAD from the server, decrypts it, and sends it down to the destination. If you send the content type header as "Content-Type: text/vnd.sun.j2me.app-descriptor", and the content length properly, and send down the JAD contents, it is properly executed on the BB side.

 

The script itself validates a transaction ID assigned during the purchase process and tracks its own flag to restrict the number of downloads from a single transaction.

 

Hope this gives you some ideas,

Jason

www.lcamobile.com

Please use plain text.
New Contributor
akhalsa
Posts: 4
Registered: ‎07-15-2010
My Device: Not Specified

Re: restrict OTA downloads

Thanks a lot Jason! I think I almost have it working, but I'm getting the following error:

 

java.io.IOException: Resource could not be found http://www.mysite.com/Test/appcod1.cod: 411 - Length Required

 

I tried setting the Content-Length tag on the php page as the size of the .jad file, but it seems to be having issues with the size of the component .cod files. Any thoughts?

 

Thanks again!

Please use plain text.
New Contributor
akhalsa
Posts: 4
Registered: ‎07-15-2010
My Device: Not Specified

Re: restrict OTA downloads

Oh, I should add, if I direct my blackberry to the .jad file directly, it works just fine, so I think the problem is in the php header.

Please use plain text.
New Contributor
akhalsa
Posts: 4
Registered: ‎07-15-2010
My Device: Not Specified

Re: restrict OTA downloads

Figured that part out, I think I just had the .jad file size wrong.

 

Please use plain text.
New Contributor
briandb10
Posts: 2
Registered: ‎11-17-2010
My Device: Not Specified

Re: restrict OTA downloads

Hi, I am having the same issue. I'm not sure what I'm doing wrong. When I attempt to provide the file using readfile via php it fails saying "Resource could not be found <http address>: 411 - Length Required. My php code is:

 

header( 'Content-Description: File Transfer' );
header( 'Content-Type: text/vnd.sun.j2me.app-descriptor' );
header( 'Content-Disposition: attachment; filename=' . basename( $jad_file ) );
header( 'Content-Transfer-Encoding: binary' );
header( 'Expires: 0' );
header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' );
header( 'Pragma: public' );
header( 'Content-Length:' . filesize( $jad_file ) );

readfile( $jad_file );

 

I've confirmed that the filesize returned is the file size of the JAD file on the disk. It works on the simulator but fails on the actual phone (this is also weird).

 

Any ideas would be greatly appreciated.

 

Thank you,

Brian

Please use plain text.
Developer
lcamobile
Posts: 76
Registered: ‎03-15-2010
My Device: 9800, 9630
My Carrier: Rogers

Re: restrict OTA downloads

 

    $retVal = $db->checkTxnID($txnid);
        
        if ($retVal == 1)         {
            $fName = 'MyApp.jad';

            $jadContents = "";
            try {
                $file = fopen($fName, 'r');
                $jadContents = fread($file, filesize($fName));
                fclose($file);
            }
            catch (Exception $e) {
                $jadContents = "";
            }

            if ($jadContents != "") {
                header("HTTP/1.1 200 OK", true);
                header("Content-Type: text/vnd.sun.j2me.app-descriptor", true);
                header("Content-Length: " . strlen($jadContents), true);
                echo($jadContents);
            }
            else {
                echo("Sorry, there appears to be a problem accessing your download.<br/><br/>");
                
            }

 

This is what works for me, hope it helps you.

 

Jason

 

 

Please use plain text.
New Contributor
briandb10
Posts: 2
Registered: ‎11-17-2010
My Device: Not Specified

Re: restrict OTA downloads

Thanks, Jason. I appreciate the help. I used your code as an example and was able to get it to work. One interesting thing is that it works for me when my webpage uses GET method, but not when it uses POST. I wasn't able to figure out why it as the only change in the PHP script is to use $_GET instead of $_POST. But whatever the reason, it is working with GET and I'll just go with that.

 

Thanks again,

Brian

Please use plain text.