@Override public void closed() { if (!_closeReceived) { throw new TransportException("connection aborted"); } }
public TransportException(String format, Object ... args) { this(format(format, args)); }
@Override public ByteBuffer tail() { if (_tail_closed) { if (_parsingError != null) { throw new TransportException(_parsingError.getMessage()); } else { throw new TransportException("tail closed"); } } return _inputBuffer; }
try { ssh.connect(envConf.getIp(), port); } catch (TransportException e) { if (e.getDisconnectReason() == DisconnectReason.HOST_KEY_NOT_VERIFIABLE) { String msg = e.getMessage(); String[] split = msg.split("`"); String vc = split[3]; ssh = new SSHClient(); ssh.addHostKeyVerifier(vc); ssh.connect(envConf.getIp(), port); } else { throw e; } } ssh.authPassword(envConf.getName(), envConf.getPw()); ssh.newSCPFileTransfer().download(envConf.getHomePath() + FilePath, toPath);
@Override public void closed(TransportException error) { if (!_closeReceived || error != null) { // Set an error condition, but only if one was not already set if(!_conditionSet) { String description = error == null ? "connection aborted" : error.toString(); setCondition(new ErrorCondition(ConnectionError.FRAMING_ERROR, description)); } _head_closed = true; } if (_conditionSet && !postedTransportError) { put(Event.Type.TRANSPORT_ERROR, this); postedTransportError = true; } if (!postedTailClosed) { put(Event.Type.TRANSPORT_TAIL_CLOSED, this); postedTailClosed = true; maybePostClosed(); } }
@Override public void closed(TransportException error) { if (!_closeReceived || error != null) { if (error == null) { _condition = new ErrorCondition(ConnectionError.FRAMING_ERROR, "connection aborted"); } else { _condition = new ErrorCondition(ConnectionError.FRAMING_ERROR, error.toString()); } _head_closed = true; } if (_condition != null && !postedTransportError) { put(Event.Type.TRANSPORT_ERROR, this); postedTransportError = true; } if (!postedTailClosed) { put(Event.Type.TRANSPORT_TAIL_CLOSED, this); postedTailClosed = true; maybePostClosed(); } }
@Override public ByteBuffer tail() { if (_tail_closed) throw new TransportException("tail closed"); return _inputBuffer; }
public TransportException(String format, Object ... args) { this(format(format, args)); }
@Override public ByteBuffer tail() { if (_tail_closed) throw new TransportException("tail closed"); return _inputBuffer; }
public TransportException(String format, Object ... args) { this(format(format, args)); }
@Override public ByteBuffer tail() { if (_tail_closed) throw new TransportException("tail closed"); return _inputBuffer; }
private static Method getMethod(Class klass, String name, Class<?> ... params) { if (klass == null) { return null; } try { return klass.getMethod(name, params); } catch (NoSuchMethodException e) { throw new TransportException(e); } }
private static Constructor getConstructor(Class klass, Class<?> ... params) { if (klass == null) { return null; } try { return klass.getConstructor(params); } catch (NoSuchMethodException e) { throw new TransportException(e); } }
private Object getPasswordFinderFor(final String keyPassword) { if (passwordProxy == null) { throw new ProtonUnsupportedOperationException(); } try { Constructor con = passwordProxy.getConstructor(new Class[] {InvocationHandler.class}); Object finder = con.newInstance(new InvocationHandler() { public Object invoke(Object obj, Method meth, Object[] args) { return keyPassword.toCharArray(); } }); return finder; } catch (NoSuchMethodException e) { throw new TransportException(e); } catch (InstantiationException e) { throw new TransportException(e); } catch (IllegalAccessException e) { throw new TransportException(e); } catch (InvocationTargetException e) { throw new TransportException(e); } }
@Override public ByteBuffer tail() { if (_tail_closed) { throw new TransportException("tail closed"); } if (_inputBuffer == null) { _inputBuffer = newWriteableBuffer(_inputBufferSize); } return _inputBuffer; }
@Override public ByteBuffer tail() { if (_tail_closed) { throw new TransportException("tail closed"); } if (_inputBuffer == null) { _inputBuffer = newWriteableBuffer(_inputBufferSize); } return _inputBuffer; }
@Override public void process() throws TransportException { if (_tail_closed) throw new TransportException("tail closed"); _inputBuffer.flip(); try { unwrapInput(); } catch (TransportException e) { _inputBuffer.position(_inputBuffer.limit()); _tail_closed = true; throw e; } finally { _inputBuffer.compact(); } }
Certificate readCertificate(String pemFile) { InputStream is = null; try { CertificateFactory cFactory = CertificateFactory.getInstance("X.509"); is = new FileInputStream(pemFile); return cFactory.generateCertificate(is); } catch (CertificateException ce) { String msg = "Failed to load certificate [" + pemFile + "]"; _logger.log(Level.SEVERE, msg, ce); throw new TransportException(msg, ce); } catch (FileNotFoundException e) { String msg = "Certificate file not found [" + pemFile + "]"; _logger.log(Level.SEVERE, msg); throw new TransportException(msg, e); } finally { closeSafely(is); } }
@Override public void process() throws TransportException { if (_tail_closed) throw new TransportException("tail closed"); _inputBuffer.flip(); try { unwrapInput(); } catch (SSLException e) { _logger.log(Level.WARNING, e.getMessage()); _inputBuffer.position(_inputBuffer.limit()); _tail_closed = true; } finally { _inputBuffer.compact(); } }
private Object readPemObject(String pemFile) { Reader reader = null; Object pemParser = null; Object pemObject = null; try { reader = new FileReader(pemFile); pemParser = pemParserCons.newInstance(reader); // = new PEMParser(reader); pemObject = pemReadMethod.invoke(pemParser); // = pemParser.readObject(); } catch (IOException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | InstantiationException e) { _logger.log(Level.SEVERE, "Unable to read PEM object. Perhaps you need the unlimited strength libraries in <java-home>/jre/lib/security/ ?", e); throw new TransportException("Unable to read PEM object from file " + pemFile, e); } finally { closeSafely(reader); } return pemObject; }