1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.common.util.secure;
17
18
19
20
21 @Deprecated
22 public class ChannelUtils {
23
24 public static String getLocation(String username, String hostname, RemoteFile file) {
25 return getLocation(username, hostname) + ":" + file.getAbsolutePath();
26 }
27
28 public static String getLocation(String username, String hostname) {
29 return (username == null) ? hostname : username + "@" + hostname;
30 }
31
32 public static Result getExecutionResult(int exitValue, long start, String command, String stdin, String stdout, String stderr, String encoding) {
33 long stop = System.currentTimeMillis();
34 long elapsed = stop - start;
35 Result result = new Result();
36 result.setEncoding(encoding);
37 result.setCommand(command);
38 result.setElapsed(elapsed);
39 result.setStart(start);
40 result.setStop(stop);
41 result.setExitValue(exitValue);
42 result.setStdin(stdin);
43 result.setStdout(stdout);
44 result.setStderr(stderr);
45 return result;
46 }
47
48 public static void closeQuietly(SecureChannel channel) {
49 if (channel != null) {
50 channel.close();
51 }
52 }
53
54 }