/
AbstractSSHKeyWizardPageModel.java
63 lines (52 loc) · 1.85 KB
/
AbstractSSHKeyWizardPageModel.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*******************************************************************************
* Copyright (c) 2012 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
******************************************************************************/
package org.jboss.tools.openshift.express.internal.ui.wizard.ssh;
import org.jboss.tools.common.ui.databinding.ObservableUIPojo;
import org.jboss.tools.openshift.express.internal.core.connection.Connection;
import org.jboss.tools.openshift.express.internal.ui.utils.SSHUtils;
import com.openshift.client.OpenShiftException;
/**
* @author Andre Dietisheim
*/
public abstract class AbstractSSHKeyWizardPageModel extends ObservableUIPojo implements ISSHKeyWizardPageModel {
private String name;
private Connection connection;
public AbstractSSHKeyWizardPageModel(Connection user) {
this.connection = user;
}
@Override
public String getName() {
return name;
}
@Override
public void setName(String name) {
firePropertyChange(PROPERTY_NAME, this.name, this.name = name);
}
@Override
public boolean hasKeyName(String name) {
return connection.hasSSHKeyName(name);
}
@Override
public boolean hasPublicKey(String publicKeyContent) {
return connection.hasSSHPublicKey(publicKeyContent);
}
protected Connection getConnection() {
return connection;
}
protected String checkedGetSSH2Home() throws OpenShiftException {
String ssh2Home = SSHUtils.getSSH2Home();
if (ssh2Home == null
|| ssh2Home.trim().length() == 0) {
throw new OpenShiftException("Could not determine your ssh2 home directory");
}
return ssh2Home;
}
}