@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 void removeAllIdentities() throws IOException { if (!isOpen()) { throw new SshException("Agent closed"); } keys.clear(); }
@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(); }
@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 protected void preClose() { signalAuthFailure(authFuture, new SshException("Session is being closed")); super.preClose(); }
@Override protected void handleDisconnect(int code, String msg, String lang, Buffer buffer) throws Exception { signalAuthFailure(authFuture, new SshException(code, msg)); super.handleDisconnect(code, msg, lang, buffer); }
protected byte[] handleUnexpectedHandlePacket(int cmd, int id, int type, int length, Buffer buffer) throws IOException { handleUnexpectedPacket(cmd, SftpConstants.SSH_FXP_HANDLE, id, type, length, buffer); throw new SshException("No handling for unexpected handle packet id=" + id + ", type=" + SftpConstants.getCommandMessageName(type) + ", length=" + length); }
@Override protected void handleDisconnect(int code, String msg, String lang, Buffer buffer) throws Exception { signalAuthFailure(authFuture, new SshException(code, msg)); super.handleDisconnect(code, msg, lang, buffer); }
@Override protected void preClose() { AuthFuture authFuture = authFutureHolder.get(); if ((authFuture != null) && (!authFuture.isDone())) { authFuture.setException(new SshException("Session is closed")); } super.preClose(); } }
@Override protected void preClose() { synchronized (buffer) { if (buffer.available() == 0) { if (pending != null) { pending.setValue(new SshException("Closed")); } } } super.preClose(); }
protected IOException handleUnexpectedPacket(int cmd, int expected, int id, int type, int length, Buffer buffer) throws IOException { throw new SshException("Unexpected SFTP packet received while awaiting " + SftpConstants.getCommandMessageName(expected) + " response to " + SftpConstants.getCommandMessageName(cmd) + ": type=" + SftpConstants.getCommandMessageName(type) + ", id=" + id + ", length=" + length); }
@Override protected void preClose() { synchronized (buffer) { if (buffer.available() == 0) { if (pending != null) { pending.setValue(new SshException("Closed")); } } } super.preClose(); }
@Override public SshAgent createClient(FactoryManager manager) throws IOException { String authSocket = manager.getString(SshAgent.SSH_AUTHSOCKET_ENV_NAME); if (GenericUtils.isEmpty(authSocket)) { throw new SshException("No " + SshAgent.SSH_AUTHSOCKET_ENV_NAME + " value"); } return new AgentClient(authSocket, newExecutor()); }
@Override public void removeIdentity(PublicKey key) throws IOException { Buffer buffer = createBuffer(SshAgentConstants.SSH2_AGENTC_REMOVE_IDENTITY); buffer.putPublicKey(key); if (log.isDebugEnabled()) { log.debug("removeIdentity({}) {}", KeyUtils.getKeyType(key), KeyUtils.getFingerPrint(key)); } buffer = request(prepare(buffer)); int available = buffer.available(); int response = (available >= 1) ? buffer.getUByte() : -1; if ((available != 1) || (response != SshAgentConstants.SSH_AGENT_SUCCESS)) { throw new SshException("Bad removeIdentity response (" + SshAgentConstants.getCommandMessageName(response) + ") - available=" + available); } }
@Override protected void preClose() { if (!authFuture.isDone()) { authFuture.setException(new SshException("Session is closed")); } super.preClose(); }
@Override protected void preClose() { if (!authFuture.isDone()) { authFuture.setException(new SshException("Session is closed")); } super.preClose(); }