Package org.opennms.protocols.sftp
Class SftpUrlConnection
- java.lang.Object
-
- java.net.URLConnection
-
- org.opennms.protocols.sftp.SftpUrlConnection
-
- Direct Known Subclasses:
Sftp3gppUrlConnection
public class SftpUrlConnection extends URLConnection
The class for managing SFTP URL Connection.The default connection timeout is 30 seconds.
- Author:
- Alejandro Galue
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_TIMEOUTThe Constant default timeout in milliseconds.-
Fields inherited from class java.net.URLConnection
allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedSftpUrlConnection(URL url)Instantiates a new SFTP URL connection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconnect()voiddisconnect()Disconnect.com.jcraft.jsch.ChannelSftpgetChannel()Gets the channel.InputStreamgetInputStream()protected StringgetPath()Gets the path.-
Methods inherited from class java.net.URLConnection
addRequestProperty, getAllowUserInteraction, getConnectTimeout, getContent, getContent, getContentEncoding, getContentLength, getContentLengthLong, getContentType, getDate, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getDefaultUseCaches, getDoInput, getDoOutput, getExpiration, getFileNameMap, getHeaderField, getHeaderField, getHeaderFieldDate, getHeaderFieldInt, getHeaderFieldKey, getHeaderFieldLong, getHeaderFields, getIfModifiedSince, getLastModified, getOutputStream, getPermission, getReadTimeout, getRequestProperties, getRequestProperty, getURL, getUseCaches, guessContentTypeFromName, guessContentTypeFromStream, setAllowUserInteraction, setConnectTimeout, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setDefaultUseCaches, setDefaultUseCaches, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setReadTimeout, setRequestProperty, setUseCaches, toString
-
-
-
-
Field Detail
-
DEFAULT_TIMEOUT
public static final int DEFAULT_TIMEOUT
The Constant default timeout in milliseconds.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SftpUrlConnection
protected SftpUrlConnection(URL url)
Instantiates a new SFTP URL connection.- Parameters:
url- the URL
-
-
Method Detail
-
connect
public void connect() throws IOException- Specified by:
connectin classURLConnection- Throws:
IOException
-
disconnect
public void disconnect() throws IOExceptionDisconnect.- Throws:
IOException- Signals that an I/O exception has occurred.
-
getChannel
public com.jcraft.jsch.ChannelSftp getChannel() throws IOExceptionGets the channel.- Returns:
- the channel
- Throws:
IOException
-
getInputStream
public InputStream getInputStream() throws IOException
- Overrides:
getInputStreamin classURLConnection- Throws:
IOException
-
getPath
protected String getPath() throws SftpUrlException
Gets the path.- Returns:
- the path
- Throws:
SftpUrlException- the SFTP URL exception
-
-