@Override public void removeIdentity(PublicKey key) throws IOException { if (!isOpen()) { throw new SshException("Agent closed"); } Map.Entry<KeyPair, String> kp = getKeyPair(keys, key); if (kp == null) { throw new SshException("Key not found"); } keys.remove(kp); }
int code = ((SshException) t).getDisconnectCode(); if (code > 0) { try {
public SshException(int disconnectCode, String message, Throwable cause) { super(GenericUtils.isEmpty(message) ? SshConstants.getDisconnectReasonName(disconnectCode) : message); this.disconnectCode = disconnectCode; if (cause != null) { initCause(cause); } }
break; } catch (SshException e) { // expected outputDebugMessage("%s on retry #%d: %s", e.getClass().getSimpleName(), index, e.getMessage()); Throwable t = e.getCause(); assertObjectInstanceOf("Unexpected failure cause at retry #" + index, InvalidKeySpecException.class, t);
break; } catch (SshException e) { // expected outputDebugMessage("%s on retry #%d: %s", e.getClass().getSimpleName(), index, e.getMessage()); Throwable t = e.getCause(); assertObjectInstanceOf("Unexpected failure cause at retry #" + index, InvalidKeySpecException.class, t);
@Override public void removeAllIdentities() throws IOException { if (!isOpen()) { throw new SshException("Agent closed"); } keys.clear(); }
break; } catch (SshException e) { // expected outputDebugMessage("%s on retry #%d: %s", e.getClass().getSimpleName(), index, e.getMessage()); Throwable t = e.getCause(); assertObjectInstanceOf("Unexpected failure cause at retry #" + index, InvalidKeySpecException.class, t);
public SshException(int disconnectCode, String message, Throwable cause) { super(GenericUtils.isEmpty(message) ? SshConstants.getDisconnectReasonName(disconnectCode) : message); this.disconnectCode = disconnectCode; if (cause != null) { initCause(cause); } }
int code = ((SshException) t).getDisconnectCode(); if (code > 0) { try {
@Override public void addIdentity(KeyPair key, String comment) throws IOException { if (!isOpen()) { throw new SshException("Agent closed"); } keys.add(new SimpleImmutableEntry<>(Objects.requireNonNull(key, "No key"), comment)); }
@Override public void sessionCreated(IoSession session) throws Exception { if (isClosing()) { throw new SshException("SocksProxy is closing or closed"); } }
protected ServerConnectionService(AbstractServerSession s) throws SshException { super(s); if (!s.isAuthenticated()) { throw new SshException("Session is not authenticated"); } }
@Override public void addIdentity(KeyPair key, String comment) throws IOException { if (!isOpen()) { throw new SshException("Agent closed"); } keys.add(new SimpleImmutableEntry<>(Objects.requireNonNull(key, "No key"), comment)); }
@Override public void removeAllIdentities() throws IOException { if (!isOpen()) { throw new SshException("Agent closed"); } keys.clear(); }
protected ServerConnectionService(AbstractServerSession s) throws SshException { super(s); if (!s.isAuthenticated()) { throw new SshException("Session is not authenticated"); } }
@Override public void sessionCreated(IoSession session) throws Exception { if (isClosing()) { throw new SshException("SocksProxy is closing or closed"); } }
@Override public void removeIdentity(PublicKey key) throws IOException { if (!isOpen()) { throw new SshException("Agent closed"); } Map.Entry<KeyPair, String> kp = getKeyPair(keys, key); if (kp == null) { throw new SshException("Key not found"); } keys.remove(kp); }
@Override public List<? extends Map.Entry<PublicKey, String>> getIdentities() throws IOException { if (!isOpen()) { throw new SshException("Agent closed"); } return GenericUtils.map(keys, kp -> new SimpleImmutableEntry<>(kp.getKey().getPublic(), kp.getValue())); }
@Override public Iterable<? extends Map.Entry<PublicKey, String>> getIdentities() throws IOException { if (!isOpen()) { throw new SshException("Agent closed"); } return GenericUtils.map(keys, kp -> new SimpleImmutableEntry<>(kp.getKey().getPublic(), kp.getValue())); }
/** * Invoked when a request to receive something is processed * * @param path The local target {@link Path} of the request * @param recursive Whether the request is recursive * @param shouldBeDir Whether target path is expected to be a directory * @param preserve Whether target path is expected to preserve attributes (permissions, times) * @return The effective target path - default=same as input * @throws IOException If failed to resolve target location */ default Path resolveIncomingReceiveLocation( Path path, boolean recursive, boolean shouldBeDir, boolean preserve) throws IOException { if (!shouldBeDir) { return path; } LinkOption[] options = IoUtils.getLinkOptions(true); Boolean status = IoUtils.checkFileExists(path, options); if (status == null) { throw new SshException("Target directory " + path + " is most like inaccessible"); } if (!status) { throw new SshException("Target directory " + path + " does not exist"); } if (!Files.isDirectory(path, options)) { throw new SshException("Target directory " + path + " is not a directory"); } return path; }