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