1 /*
2  * @(#) $Id: DisplayFileLauncher.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  */
10import javax.security.auth.Subject;
11import javax.security.auth.login.LoginContext;
12import java.security.PrivilegedExceptionAction;
13
14public class DisplayFileLauncher {
15    public static void main(String[] args) throws Exception {
16        if (args.length < 1){
17            System.out.println("Usage:: java DisplayFile <filename>");
18            return;
19        }
20        final String fileName = args[0];
21        LoginContext lc = new LoginContext("DF", new DFCallbackHandler());
22        lc.login();
23        PrivilegedExceptionAction action = new PrivilegedExceptionAction() {
24            public Object run() throws Exception{
25                DisplayFile df = new DisplayFile();
26                df.disp(fileName);
27                return null;
28            }
29        };
30        Subject.doAs(lc.getSubject(), action);
31    }
32}
33