1 /*
2 * @(#)Login.java
3 *
4 * Copyright 2001-2002 Sun Microsystems, Inc. All Rights Reserved.
5 *
6 * Redistribution and use in source and binary forms, with or
7 * without modification, are permitted provided that the following
8 * conditions are met:
9 *
10 * -Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * -Redistribution in binary form must reproduct the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 *
18 * Neither the name of Sun Microsystems, Inc. or the names of
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific prior written permission.
21 *
22 * This software is provided "AS IS," without a warranty of any
23 * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
24 * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
25 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
26 * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY
27 * DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT OF OR
28 * RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THE SOFTWARE OR
29 * ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE
30 * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
31 * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
32 * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF
33 * THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN
34 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
35 *
36 * You acknowledge that Software is not designed, licensed or
37 * intended for use in the design, construction, operation or
38 * maintenance of any nuclear facility.
39 */
40
41 package no.feide.mellon.jaas.loginutility;
42
43 /***
44 * @author Rikke Amilde Løvlid
45 *
46 * The original class file has not been modified.
47 * The original name is MyAction.java.
48 */
49
50 class MoriaAction implements java.security.PrivilegedExceptionAction {
51
52 String[] origArgs;
53
54 public MoriaAction(String[] origArgs) {
55 this.origArgs = (String[])origArgs.clone();
56 }
57
58 public Object run() throws Exception {
59
60 // get the ContextClassLoader
61 ClassLoader cl = Thread.currentThread().getContextClassLoader();
62
63 try {
64 // get the application class's main method
65 Class c = Class.forName(origArgs[0], true, cl);
66 Class[] PARAMS = { origArgs.getClass() };
67 java.lang.reflect.Method mainMethod = c.getMethod("main", PARAMS);
68
69 // invoke the main method with the remaining args
70 String[] appArgs = new String[origArgs.length - 1];
71 System.arraycopy(origArgs, 1, appArgs, 0, origArgs.length - 1);
72 Object[] args = { appArgs };
73 mainMethod.invoke(null /*ignored*/, args);
74 }
75 catch (Exception e) {
76 throw new java.security.PrivilegedActionException(e);
77 }
78
79 // successful completion
80 return null;
81 }
82 }