BlackBerry Forums Support Community

BlackBerry Forums Support Community (http://www.blackberryforums.com/index.php)
-   Developer Forum (http://www.blackberryforums.com/forumdisplay.php?f=15)
-   -   HTTP Authentication on Rogers WAP Gateway (http://www.blackberryforums.com/showthread.php?t=1058)

dinouye 10-06-2004 05:59 PM

HTTP Authentication on Rogers WAP Gateway
 
Was curious has anyone else out there had any problems using HTTP Authentication and a WAP gateway?

I am able to use both the WAP gateway and the Sim MDS to access a site without any problems. However as soon as I turn on HTTP Authentication the WAP Gateway version throws a net.rim.device.cldc.io.waphttp.WAPIOException. The SIM/MDS version works fine with HTTP Authentication. The offending code seems to be where I am setting the authentication header:

httpConnection.setRequestProperty("Authorization", password);

perhaps I need another header? I'm sifting through the documentation but haven't come across anything.

Any help/advice/pointers are greatly appreciated!

Thanks

Darren



On a separate note is there any way to get at the message in WAPIOException when you are building a midlet blackberry app? my app can't seem to utilize the RIM libraries when it is being built as a midlet, I've tried to include the libraries but the compiler won't allow me.

Mark Rejhon 10-12-2004 07:20 PM

Try this....

Quote:

You can add the header with "WWW-Authenticate" and then base64 the username/password. Of course that is in the clear. There are more complex challenge-response authentication mechanisms than "Basic" such as NTLM, but you will have to write the code to prepare the response from the challenge.

http://www.w3.org/Protocols/HTTP/1.0/spec.html#BasicAA
You might have already done this... but just making sure you did!

Mark Rejhon 10-12-2004 07:22 PM

Edit: I found you've already done this -- in this post

Try the Search Results "HTTP Authentication" and see if any of this is relevant...

Please reply here to let all of us know how you solved your problem, if you do!

dinouye 10-13-2004 04:46 PM

Thanks
 
Thanks Mark,

I'll go over my headers again and see if I'm missing anything and report finding back here.

cheers,

Darren

jbartel 10-15-2004 08:48 AM

I assume you are trying to do Basic Authentication (not NTLM/Digest). If so, I found 3 things:

1. With a WAP gateway, it only works if you leave the username/password as plaintext (base64 encoding does not work).
2. With IDEN (6510/7510) or MDS you need to base64 encode the username/password string
3. On the 3.6 OS when using WAP, some http headers get dropped on a http POST if the post data is over a certain size (I think the size is ~38 bytes if I remember correctly).

Here is the code I am using for basic authentication which works:
Code:

private static String AUTHORIZATION          = "Authorization";
private static String BASIC                  = "Basic";


private void addAuthorizationSettingsxxx40;String username, String password, HttpConnection connectionxxx41;
xxx123;
        ifxxx40; username.lengthxxx40;xxx41; > 0 && password.lengthxxx40;xxx41; > 0 xxx41;
        xxx123;
                //Base64 encode only for IDEN, use plaintext with WAP       
                ifxxx40; RadioInfo.getNetworkTypexxx40;xxx41; == RadioInfo.NETWORK_IDEN xxx41;
                xxx123;
                        encoded = encodeUsernamePasswordxxx40;username, passwordxxx41;;
                xxx125; else
                xxx123;
                        encoded = username + "xxx58;" + password;
                xxx125;
                ifxxx40; encoded.lengthxxx40;xxx41; > 0 xxx41;
                xxx123;
                        connection.setRequestPropertyxxx40;AUTHORIZATION, BASIC + " " + encodedxxx41;;
                xxx125;
        xxx125;
xxx125;

The encodeUsernamePassword function just creates a new String with the username and password separated by a ":" (i.e. username:password), and base64 encodes that string.


All times are GMT -5. The time now is 01:16 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.