1 /*
2  * @(#) $Id: Client2.java,v 1.2 2003/07/08 08:13:52 pankaj Exp $
3  *
4  * Copyright (c) 2002-03 by Pankaj Kumar (http://www.pankaj-k.net). 
5  * All rights reserved.
6  *
7  * The license governing the use of this file can be found in the 
8  * root directory of the containing software.
9  */
10package client;
11
12import javax.security.auth.Subject;
13import javax.security.auth.login.LoginContext;
14
15public class Client2 {
16    public static void main(String[] args) throws Exception {
17        String url = null;
18        String uname = null;
19        String passwd = null;
20        if (args.length > 2){
21            url = args[0];
22            uname = args[1];
23            passwd = args[2];
24        } else {
25            System.out.println("Usage:: java client.Client <url> <uname> <passwd>");
26            System.exit(0);
27        }
28
29        LoginContext loginContext = new LoginContext("Sample",
30            new SampleCallbackHandler(uname, passwd, url));
31        loginContext.login();
32        Subject subject = loginContext.getSubject();
33        SampleAction sampleAction = new SampleAction(url);
34        Subject.doAs(subject, sampleAction);
35    }
36}
37