diff --git a/src/main/java/com/jcraft/jsch/AgentIdentityRepository.java b/src/main/java/com/jcraft/jsch/AgentIdentityRepository.java index c4e25168..51c3d7b2 100644 --- a/src/main/java/com/jcraft/jsch/AgentIdentityRepository.java +++ b/src/main/java/com/jcraft/jsch/AgentIdentityRepository.java @@ -37,7 +37,7 @@ public AgentIdentityRepository(AgentConnector connector) { } @Override - public Vector getIdentities() { + public Vector getIdentities() { return agent.getIdentities(); } diff --git a/src/main/java/com/jcraft/jsch/ChannelAgentForwarding.java b/src/main/java/com/jcraft/jsch/ChannelAgentForwarding.java index 34e2004a..05ccf617 100644 --- a/src/main/java/com/jcraft/jsch/ChannelAgentForwarding.java +++ b/src/main/java/com/jcraft/jsch/ChannelAgentForwarding.java @@ -127,6 +127,7 @@ void write(byte[] foo, int s, int l) throws IOException { if (typ == SSH2_AGENTC_REQUEST_IDENTITIES) { mbuf.putByte(SSH2_AGENT_IDENTITIES_ANSWER); + @SuppressWarnings("unchecked") Vector identities = irepo.getIdentities(); synchronized (identities) { int count = 0; @@ -157,6 +158,7 @@ void write(byte[] foo, int s, int l) throws IOException { // datafellows = SSH_BUG_SIGBLOB; // } + @SuppressWarnings("unchecked") Vector identities = irepo.getIdentities(); Identity identity = null; synchronized (identities) { diff --git a/src/main/java/com/jcraft/jsch/IdentityRepository.java b/src/main/java/com/jcraft/jsch/IdentityRepository.java index cc0a91ce..58addd27 100644 --- a/src/main/java/com/jcraft/jsch/IdentityRepository.java +++ b/src/main/java/com/jcraft/jsch/IdentityRepository.java @@ -37,7 +37,8 @@ public interface IdentityRepository { public int getStatus(); - public Vector getIdentities(); + @SuppressWarnings("rawtypes") + public Vector getIdentities(); public boolean add(byte[] identity); diff --git a/src/main/java/com/jcraft/jsch/IdentityRepositoryWrapper.java b/src/main/java/com/jcraft/jsch/IdentityRepositoryWrapper.java index 73b7e711..795c01b2 100644 --- a/src/main/java/com/jcraft/jsch/IdentityRepositoryWrapper.java +++ b/src/main/java/com/jcraft/jsch/IdentityRepositoryWrapper.java @@ -74,13 +74,13 @@ public void removeAll() { } @Override - public Vector getIdentities() { - Vector result = new Vector<>(); + public Vector getIdentities() { + Vector result = new Vector<>(); for (int i = 0; i < cache.size(); i++) { Identity identity = cache.elementAt(i); result.add(identity); } - Vector tmp = ir.getIdentities(); + Vector tmp = ir.getIdentities(); for (int i = 0; i < tmp.size(); i++) { result.add(tmp.elementAt(i)); } diff --git a/src/main/java/com/jcraft/jsch/JSch.java b/src/main/java/com/jcraft/jsch/JSch.java index b5d642d3..f942eaff 100644 --- a/src/main/java/com/jcraft/jsch/JSch.java +++ b/src/main/java/com/jcraft/jsch/JSch.java @@ -41,7 +41,7 @@ public class JSch { config.put("kex", Util.getSystemProperty("jsch.kex", "curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256")); config.put("server_host_key", Util.getSystemProperty("jsch.server_host_key", - "ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256")); + "ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256,ssh-rsa")); config.put("prefer_known_host_key_types", Util.getSystemProperty("jsch.prefer_known_host_key_types", "yes")); config.put("enable_strict_kex", Util.getSystemProperty("jsch.enable_strict_kex", "yes")); @@ -230,7 +230,7 @@ public class JSch { config.put("PreferredAuthentications", Util.getSystemProperty("jsch.preferred_authentications", "gssapi-with-mic,publickey,keyboard-interactive,password")); config.put("PubkeyAcceptedAlgorithms", Util.getSystemProperty("jsch.client_pubkey", - "ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256")); + "ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256,ssh-rsa")); config.put("enable_pubkey_auth_query", Util.getSystemProperty("jsch.enable_pubkey_auth_query", "yes")); config.put("try_additional_pubkey_algorithms", @@ -541,6 +541,7 @@ public void addIdentity(Identity identity, byte[] passphrase) throws JSchExcepti */ @Deprecated public void removeIdentity(String name) throws JSchException { + @SuppressWarnings("unchecked") Vector identities = identityRepository.getIdentities(); for (int i = 0; i < identities.size(); i++) { Identity identity = identities.elementAt(i); @@ -571,6 +572,7 @@ public void removeIdentity(Identity identity) throws JSchException { */ public Vector getIdentityNames() throws JSchException { Vector foo = new Vector<>(); + @SuppressWarnings("unchecked") Vector identities = identityRepository.getIdentities(); for (int i = 0; i < identities.size(); i++) { Identity identity = identities.elementAt(i); diff --git a/src/main/java/com/jcraft/jsch/LocalIdentityRepository.java b/src/main/java/com/jcraft/jsch/LocalIdentityRepository.java index c2a6328a..5b692d07 100644 --- a/src/main/java/com/jcraft/jsch/LocalIdentityRepository.java +++ b/src/main/java/com/jcraft/jsch/LocalIdentityRepository.java @@ -49,7 +49,7 @@ public int getStatus() { } @Override - public synchronized Vector getIdentities() { + public synchronized Vector getIdentities() { removeDupulicates(); Vector v = new Vector<>(); for (int i = 0; i < identities.size(); i++) { diff --git a/src/main/java/com/jcraft/jsch/UserAuthPublicKey.java b/src/main/java/com/jcraft/jsch/UserAuthPublicKey.java index 0b5f01b3..5efa84e4 100644 --- a/src/main/java/com/jcraft/jsch/UserAuthPublicKey.java +++ b/src/main/java/com/jcraft/jsch/UserAuthPublicKey.java @@ -39,6 +39,7 @@ class UserAuthPublicKey extends UserAuth { public boolean start(Session session) throws Exception { super.start(session); + @SuppressWarnings("unchecked") Vector identities = session.getIdentityRepository().getIdentities(); synchronized (identities) { diff --git a/src/test/java/com/jcraft/jsch/KeyPair2Test.java b/src/test/java/com/jcraft/jsch/KeyPair2Test.java index 22fad28f..bbfa5189 100644 --- a/src/test/java/com/jcraft/jsch/KeyPair2Test.java +++ b/src/test/java/com/jcraft/jsch/KeyPair2Test.java @@ -51,6 +51,6 @@ void loadKey(String path, String password, String keyType) jSch.addIdentity(prvkey); } }); - assertEquals(keyType, jSch.getIdentityRepository().getIdentities().get(0).getAlgName()); + assertEquals(keyType, ((Identity) jSch.getIdentityRepository().getIdentities().get(0)).getAlgName()); } } diff --git a/src/test/java/com/jcraft/jsch/KeyPairTest.java b/src/test/java/com/jcraft/jsch/KeyPairTest.java index 46823322..faada575 100644 --- a/src/test/java/com/jcraft/jsch/KeyPairTest.java +++ b/src/test/java/com/jcraft/jsch/KeyPairTest.java @@ -135,7 +135,7 @@ void loadKey(String path, String password, String keyType) jSch.addIdentity(prvkey); } }); - assertEquals(keyType, jSch.getIdentityRepository().getIdentities().get(0).getAlgName()); + assertEquals(keyType, ((Identity) jSch.getIdentityRepository().getIdentities().get(0)).getAlgName()); } @Test