1 | /******************************************************************************
|
---|
2 | *
|
---|
3 | * Copyright (c) 1998,99 by Mindbright Technology AB, Stockholm, Sweden.
|
---|
4 | * www.mindbright.se, [email protected]
|
---|
5 | *
|
---|
6 | * This program is free software; you can redistribute it and/or modify
|
---|
7 | * it under the terms of the GNU General Public License as published by
|
---|
8 | * the Free Software Foundation; either version 2 of the License, or
|
---|
9 | * (at your option) any later version.
|
---|
10 | *
|
---|
11 | * This program is distributed in the hope that it will be useful,
|
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | * GNU General Public License for more details.
|
---|
15 | *
|
---|
16 | *****************************************************************************
|
---|
17 | * $Author: mats $
|
---|
18 | * $Date: 1999/08/22 13:57:54 $
|
---|
19 | * $Name: rel1-2-1 $
|
---|
20 | *****************************************************************************/
|
---|
21 | package mindbright.ssh;
|
---|
22 |
|
---|
23 | import java.net.*;
|
---|
24 | import java.io.*;
|
---|
25 |
|
---|
26 | import mindbright.security.RSAPublicKey;
|
---|
27 |
|
---|
28 | public class SSHRSAAuthenticator implements SSHAuthenticator {
|
---|
29 | protected String fileName;
|
---|
30 | protected String username;
|
---|
31 | protected String password;
|
---|
32 | protected int cipher;
|
---|
33 |
|
---|
34 | public SSHRSAAuthenticator(String username, String password, String fileName, String cipher) {
|
---|
35 | this.username = username;
|
---|
36 | this.password = password;
|
---|
37 | this.cipher = SSH.getCipherType(cipher);
|
---|
38 | this.fileName = fileName;
|
---|
39 | }
|
---|
40 |
|
---|
41 | public SSHRSAAuthenticator(String username, String password, String fileName) {
|
---|
42 | this.username = username;
|
---|
43 | this.password = password;
|
---|
44 | this.cipher = SSH.CIPHER_DEFAULT;
|
---|
45 | this.fileName = fileName;
|
---|
46 | }
|
---|
47 |
|
---|
48 | public String getUsername(SSHClientUser origin) {
|
---|
49 | return username;
|
---|
50 | }
|
---|
51 |
|
---|
52 | public String getPassword(SSHClientUser origin) {
|
---|
53 | return "";
|
---|
54 | }
|
---|
55 |
|
---|
56 | public String getChallengeResponse(SSHClientUser origin, String challenge) {
|
---|
57 | return "";
|
---|
58 | }
|
---|
59 |
|
---|
60 | public int[] getAuthTypes(SSHClientUser origin) {
|
---|
61 | int[] types = new int[1];
|
---|
62 | types[0] = SSH.AUTH_RSA;
|
---|
63 | return types;
|
---|
64 | }
|
---|
65 |
|
---|
66 | public int getCipher(SSHClientUser origin) {
|
---|
67 | return cipher;
|
---|
68 | }
|
---|
69 |
|
---|
70 | public String getIdentityPassword(SSHClientUser origin) {
|
---|
71 | return password;
|
---|
72 | }
|
---|
73 |
|
---|
74 | public SSHRSAKeyFile getIdentityFile(SSHClientUser origin) throws IOException {
|
---|
75 | return new SSHRSAKeyFile(fileName);
|
---|
76 | }
|
---|
77 |
|
---|
78 | public boolean verifyKnownHosts(RSAPublicKey hostPub) {
|
---|
79 | return true;
|
---|
80 | }
|
---|
81 |
|
---|
82 | }
|
---|
83 |
|
---|