1 /*
2 * SSHTools - Java SSH2 API
3 *
4 * Copyright (C) 2002-2003 Lee David Painter and Contributors.
5 *
6 * Contributions made by:
7 *
8 * Brett Smith
9 * Richard Pernavas
10 * Erwin Bolwidt
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 */
26 package com.sshtools.j2ssh.authentication;
27
28 import java.io.IOException;
29
30 import java.util.Properties;
31
32
33 /**
34 *
35 *
36 * @author $author$
37 * @version $Revision: 1.15 $
38 */
39 public abstract class SshAuthenticationClient {
40 private String username;
41 private SshAuthenticationPrompt prompt;
42
43 /**
44 *
45 *
46 * @return
47 */
48 public abstract String getMethodName();
49
50 /**
51 *
52 *
53 * @param authentication
54 * @param serviceToStart
55 *
56 * @throws IOException
57 * @throws TerminatedStateException
58 */
59 public abstract void authenticate(
60 AuthenticationProtocolClient authentication, String serviceToStart)
61 throws IOException, TerminatedStateException;
62
63 /**
64 *
65 *
66 * @param prompt
67 *
68 * @throws AuthenticationProtocolException
69 */
70 public void setAuthenticationPrompt(SshAuthenticationPrompt prompt)
71 throws AuthenticationProtocolException {
72 //prompt.setInstance(this);
73 this.prompt = prompt;
74 }
75
76 /**
77 *
78 *
79 * @return
80 */
81 public SshAuthenticationPrompt getAuthenticationPrompt() {
82 return prompt;
83 }
84
85 /**
86 *
87 *
88 * @param username
89 */
90 public void setUsername(String username) {
91 this.username = username;
92 }
93
94 /**
95 *
96 *
97 * @return
98 */
99 public String getUsername() {
100 return username;
101 }
102
103 /**
104 *
105 *
106 * @return
107 */
108 public abstract Properties getPersistableProperties();
109
110 /**
111 *
112 */
113 public abstract void reset();
114
115 /**
116 *
117 *
118 * @param properties
119 */
120 public abstract void setPersistableProperties(Properties properties);
121
122 /**
123 *
124 *
125 * @return
126 */
127 public abstract boolean canAuthenticate();
128
129 /**
130 *
131 *
132 * @return
133 */
134 public boolean canPrompt() {
135 return prompt != null;
136 }
137 }