aspose file tools*
The moose likes Java in General and the fly likes basic authentication Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "basic authentication" Watch "basic authentication" New topic
Author

basic authentication

JigaR Parekh
Ranch Hand

Joined: May 23, 2005
Posts: 112
Hi,

I have created web application which has all servlet secured and i am using basic http authentication.
so when ever i execute any servlet first it will ask me user name and password and then it will allow me execute that servlet.
now one of the jsp page is loading applet in same context and this applet is calling servlet. This call again ask for that password though i have sucessfully login.
So i think when call that servlet using urlconnection i have to provide some username and password

how can i achive that ??

any help and sugestion will be appriciated.

Jigar
Chetan Parekh
Ranch Hand

Joined: Sep 16, 2004
Posts: 3636
Put username and password in session as soon as user login into the application.Pass username and password from session to applet using applet parameter. Applet internally passes username and password to Servlet while calling it.


My blood is tested +ve for Java.
JigaR Parekh
Ranch Hand

Joined: May 23, 2005
Posts: 112
thx chetan for reply,

I am not using programatic security,
I am using container managed security for authentication.

Jigar
[ October 20, 2005: Message edited by: JigaR Parekh ]
Chetan Parekh
Ranch Hand

Joined: Sep 16, 2004
Posts: 3636
Jigar!

I don�t have any ideas about container-managed security.

Which is your app server?
[ October 20, 2005: Message edited by: Chetan Parekh ]
JigaR Parekh
Ranch Hand

Joined: May 23, 2005
Posts: 112
i am using jboss and DatabaseServerLoginModule as authenticator
Chetan Parekh
Ranch Hand

Joined: Sep 16, 2004
Posts: 3636
Hey Jigar,

I feel that you should put your problem in JBoss Forum1 or JBoss Forum2, as it is more related to it.
[ October 20, 2005: Message edited by: Chetan Parekh ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41905
    
  63
There's nothing JBoss-specific about this. It's just that the browser and the JVM use different network code, so both need to send the username/password independently of each other. You can use Chetans suggestion of encoding the username and password as applet parameters in the web page (although that's a security risk).

If you're using a [Http]URLConnection in the applet, the following code adds the authentication header to the connection:

String authorization = Base64Coder.encode(username + ":" + password);
connection.setRequestProperty("Authorization", "Basic " + authorization).

The Base64Coder class can be found here, or you can use any other Base64 encoding classes, e.g. Jakarta Commons Codec.
[ October 20, 2005: Message edited by: Ulf Dittmer ]

Ping & DNS - my free Android networking tools app
JigaR Parekh
Ranch Hand

Joined: May 23, 2005
Posts: 112
Thx Dittmer,

Your solution works fine.

Thx
Jigar
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: basic authentication