1 /*
2  * @(#) $Id: JSTKShellActions.java,v 1.2 2003/07/08 08:13:53 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 org.jstk.jstksh;
11
12import java.security.*;
13
14public class JSTKShellActions {
15    public static class ExecCommandAction implements PrivilegedExceptionAction {
16        private JSTKShell shell;
17        private String[] cmdargs;
18        public ExecCommandAction(JSTKShell shell, String[] cmdargs){
19            this.shell = shell;
20            this.cmdargs = cmdargs;
21        }
22        public Object run() throws Exception {
23            return shell.execCommand(cmdargs);
24        }
25    }
26
27    public static class CreateSessionAction implements PrivilegedExceptionAction {
28        private JSTKShell shell;
29        public CreateSessionAction(JSTKShell shell){
30            this.shell = shell;
31        }
32        public Object run() throws Exception {
33            return shell.createSession();
34        }
35    }
36
37    public static class DestroySessionAction implements PrivilegedExceptionAction {
38        private JSTKShell shell;
39        private String sessId;
40        public DestroySessionAction(JSTKShell shell, String sessId){
41            this.shell = shell;
42            this.sessId = sessId;
43        }
44        public Object run() throws Exception {
45            shell.destroySession(sessId);
46            return null;
47        }
48    }
49}
50