View Javadoc
1   /*
2    * Copyright (C) 2007-2012 Argeo GmbH
3    *
4    * Licensed under the Apache 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.apache.org/licenses/LICENSE-2.0
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.argeo.slc.jsch;
17  
18  import java.io.File;
19  
20  import com.jcraft.jsch.Session;
21  import com.jcraft.jsch.UserInfo;
22  
23  public class SshTarget {
24  	private String host;
25  	private Integer port = 22;
26  	private String user;
27  	private UserInfo userInfo = new SimpleUserInfo();
28  
29  	private Boolean usePrivateKey = true;
30  	private File localPrivateKey = new File(System.getProperty("user.home")
31  			+ File.separator + ".ssh" + File.separator + "id_rsa");
32  
33  	/** cached session */
34  	private transient Session session;
35  
36  	public String getHost() {
37  		return host;
38  	}
39  
40  	public void setHost(String host) {
41  		this.host = host;
42  	}
43  
44  	public Integer getPort() {
45  		return port;
46  	}
47  
48  	public void setPort(Integer port) {
49  		this.port = port;
50  	}
51  
52  	public String getUser() {
53  		return user;
54  	}
55  
56  	public void setUser(String user) {
57  		this.user = user;
58  	}
59  
60  	public UserInfo getUserInfo() {
61  		return userInfo;
62  	}
63  
64  	public void setUserInfo(UserInfo userInfo) {
65  		this.userInfo = userInfo;
66  	}
67  
68  	public void setLocalPrivateKey(File localPrivateKey) {
69  		this.localPrivateKey = localPrivateKey;
70  	}
71  
72  	public File getLocalPrivateKey() {
73  		return localPrivateKey;
74  	}
75  
76  	public Boolean getUsePrivateKey() {
77  		return usePrivateKey;
78  	}
79  
80  	public void setUsePrivateKey(Boolean usePrivateKey) {
81  		this.usePrivateKey = usePrivateKey;
82  	}
83  
84  	public String toString() {
85  		return getUser() + "@" + getHost() + ":" + getPort();
86  	}
87  
88  	public synchronized Session getSession() {
89  		return session;
90  	}
91  
92  	public synchronized void setSession(Session session) {
93  		this.session = session;
94  	}
95  }