View Javadoc
1   /**
2    * Copyright 2010-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.common.util.secure;
17  
18  /**
19   * @deprecated
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  }