本文整理汇总了Java中org.apache.commons.net.MalformedServerReplyException类的典型用法代码示例。如果您正苦于以下问题:Java MalformedServerReplyException类的具体用法?Java MalformedServerReplyException怎么用?Java MalformedServerReplyException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MalformedServerReplyException类属于org.apache.commons.net包,在下文中一共展示了MalformedServerReplyException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: _parseExtendedPassiveModeReply
import org.apache.commons.net.MalformedServerReplyException; //导入依赖的package包/类
protected void _parseExtendedPassiveModeReply(String reply) throws MalformedServerReplyException {
reply = reply.substring(reply.indexOf(40) + 1, reply.indexOf(41)).trim();
char delim1 = reply.charAt(0);
char delim2 = reply.charAt(1);
char delim3 = reply.charAt(2);
char delim4 = reply.charAt(reply.length() - 1);
if(delim1 == delim2 && delim2 == delim3 && delim3 == delim4) {
int port;
try {
port = Integer.parseInt(reply.substring(3, reply.length() - 1));
} catch (NumberFormatException var8) {
throw new MalformedServerReplyException("Could not parse extended passive host information.\nServer Reply: " + reply);
}
this.__passiveHost = this.getRemoteAddress().getHostAddress();
this.__passivePort = port;
} else {
throw new MalformedServerReplyException("Could not parse extended passive host information.\nServer Reply: " + reply);
}
}
开发者ID:Bolt-Thrower,项目名称:xdm,代码行数:21,代码来源:FTPClient.java
示例2: _parseExtendedPassiveModeReply
import org.apache.commons.net.MalformedServerReplyException; //导入依赖的package包/类
protected void _parseExtendedPassiveModeReply(String reply) throws MalformedServerReplyException {
reply = reply.substring(reply.indexOf('(') + 1, reply.indexOf(')')).trim();
char delim1, delim2, delim3, delim4;
delim1 = reply.charAt(0);
delim2 = reply.charAt(1);
delim3 = reply.charAt(2);
delim4 = reply.charAt(reply.length() - 1);
if (!(delim1 == delim2) || !(delim2 == delim3) || !(delim3 == delim4)) {
throw new MalformedServerReplyException(
"Could not parse extended passive host information.\nServer Reply: " + reply);
}
int port;
try {
port = Integer.parseInt(reply.substring(3, reply.length() - 1));
} catch (NumberFormatException e) {
throw new MalformedServerReplyException(
"Could not parse extended passive host information.\nServer Reply: " + reply);
}
// in EPSV mode, the passive host address is implicit
__passiveHost = getRemoteAddress().getHostAddress();
__passivePort = port;
}
开发者ID:AriaLyy,项目名称:Aria,代码行数:27,代码来源:FTPClient.java
示例3: mlistFile
import org.apache.commons.net.MalformedServerReplyException; //导入依赖的package包/类
/**
* Get file details using the MLST command
*
* @param pathname the file or directory to list, may be {@code null}
* @return the file details, may be {@code null}
* @throws IOException on error
* @since 3.0
*/
public FTPFile mlistFile(String pathname) throws IOException {
boolean success = FTPReply.isPositiveCompletion(sendCommand(FTPCmd.MLST, pathname));
if (success) {
String reply = getReplyStrings()[1];
/* check the response makes sense.
* Must have space before fact(s) and between fact(s) and filename
* Fact(s) can be absent, so at least 3 chars are needed.
*/
if (reply.length() < 3 || reply.charAt(0) != ' ') {
throw new MalformedServerReplyException("Invalid server reply (MLST): '" + reply + "'");
}
String entry = reply.substring(1); // skip leading space for parser
return MLSxEntryParser.parseEntry(entry);
} else {
return null;
}
}
开发者ID:AriaLyy,项目名称:Aria,代码行数:26,代码来源:FTPClient.java
示例4: _parseExtendedPassiveModeReply
import org.apache.commons.net.MalformedServerReplyException; //导入依赖的package包/类
protected void _parseExtendedPassiveModeReply(String reply)
throws MalformedServerReplyException
{
reply = reply.substring(reply.indexOf('(') + 1,
reply.indexOf(')')).trim();
char delim1, delim2, delim3, delim4;
delim1 = reply.charAt(0);
delim2 = reply.charAt(1);
delim3 = reply.charAt(2);
delim4 = reply.charAt(reply.length()-1);
if (!(delim1 == delim2) || !(delim2 == delim3)
|| !(delim3 == delim4)) {
throw new MalformedServerReplyException(
"Could not parse extended passive host information.\nServer Reply: " + reply);
}
int port;
try
{
port = Integer.parseInt(reply.substring(3, reply.length()-1));
}
catch (NumberFormatException e)
{
throw new MalformedServerReplyException(
"Could not parse extended passive host information.\nServer Reply: " + reply);
}
// in EPSV mode, the passive host address is implicit
__passiveHost = getRemoteAddress().getHostAddress();
__passivePort = port;
}
开发者ID:archos-sa,项目名称:aos-FileCoreLibrary,代码行数:35,代码来源:FTPClient.java
示例5: map
import org.apache.commons.net.MalformedServerReplyException; //导入依赖的package包/类
@Override
public BackgroundException map(final IOException e) {
final StringBuilder buffer = new StringBuilder();
this.append(buffer, e.getMessage());
if(e instanceof FTPConnectionClosedException) {
return new ConnectionRefusedException(buffer.toString(), e);
}
if(e instanceof FTPException) {
return this.handle((FTPException) e, buffer);
}
if(e instanceof MalformedServerReplyException) {
return new InteroperabilityException(buffer.toString(), e);
}
return new DefaultIOExceptionMappingService().map(e);
}
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:16,代码来源:FTPExceptionMappingService.java
示例6: _parsePassiveModeReply
import org.apache.commons.net.MalformedServerReplyException; //导入依赖的package包/类
protected void _parsePassiveModeReply(String reply) throws MalformedServerReplyException {
Matcher m = __PARMS_PAT.matcher(reply);
if(!m.find()) {
throw new MalformedServerReplyException("Could not parse passive host information.\nServer Reply: " + reply);
} else {
this.__passiveHost = m.group(1).replace(',', '.');
try {
int e = Integer.parseInt(m.group(2));
int remote = Integer.parseInt(m.group(3));
this.__passivePort = e << 8 | remote;
} catch (NumberFormatException var7) {
throw new MalformedServerReplyException("Could not parse passive port information.\nServer Reply: " + reply);
}
try {
InetAddress e1 = InetAddress.getByName(this.__passiveHost);
if(e1.isSiteLocalAddress()) {
InetAddress remote1 = this.getRemoteAddress();
if(!remote1.isSiteLocalAddress()) {
String hostAddress = remote1.getHostAddress();
this.fireReplyReceived(0, "[Replacing site local address " + this.__passiveHost + " with " + hostAddress + "]\n");
this.__passiveHost = hostAddress;
}
}
} catch (UnknownHostException var6) {
throw new MalformedServerReplyException("Could not parse passive host information.\nServer Reply: " + reply);
}
}
}
开发者ID:Bolt-Thrower,项目名称:xdm,代码行数:32,代码来源:FTPClient.java
示例7: __getReply
import org.apache.commons.net.MalformedServerReplyException; //导入依赖的package包/类
private void __getReply(boolean reportReply) throws IOException
{
int length;
_newReplyString = true;
_replyLines.clear();
String line = _controlInput_.readLine();
if (line == null) {
throw new FTPConnectionClosedException(
"Connection closed without indication.");
}
// In case we run into an anomaly we don't want fatal index exceptions
// to be thrown.
length = line.length();
if (length < REPLY_CODE_LEN) {
throw new MalformedServerReplyException(
"Truncated server reply: " + line);
}
String code = null;
try
{
code = line.substring(0, REPLY_CODE_LEN);
_replyCode = Integer.parseInt(code);
}
catch (NumberFormatException e)
{
throw new MalformedServerReplyException(
"Could not parse response code.\nServer Reply: " + line);
}
_replyLines.add(line);
// Get extra lines if message continues.
if (length > REPLY_CODE_LEN && line.charAt(REPLY_CODE_LEN) == '-')
{
do
{
line = _controlInput_.readLine();
if (line == null) {
throw new FTPConnectionClosedException(
"Connection closed without indication.");
}
_replyLines.add(line);
// The length() check handles problems that could arise from readLine()
// returning too soon after encountering a naked CR or some other
// anomaly.
}
while ( isStrictMultilineParsing() ? __strictCheck(line, code) : __lenientCheck(line));
}
fireReplyReceived(_replyCode, getReplyString());
if (_replyCode == FTPReply.SERVICE_NOT_AVAILABLE) {
throw new FTPConnectionClosedException("FTP response 421 received. Server closed connection.");
}
}
开发者ID:archos-sa,项目名称:aos-FileCoreLibrary,代码行数:64,代码来源:FTP.java
示例8: __parsePassiveModeReply
import org.apache.commons.net.MalformedServerReplyException; //导入依赖的package包/类
private void __parsePassiveModeReply(String reply)
throws MalformedServerReplyException {
int i, index, lastIndex;
String octet1, octet2;
StringBuffer host;
reply = reply.substring(reply.indexOf('(') + 1, reply.indexOf(')')).trim();
host = new StringBuffer(24);
lastIndex = 0;
index = reply.indexOf(',');
host.append(reply.substring(lastIndex, index));
for (i = 0; i < 3; i++) {
host.append('.');
lastIndex = index + 1;
index = reply.indexOf(',', lastIndex);
host.append(reply.substring(lastIndex, index));
}
lastIndex = index + 1;
index = reply.indexOf(',', lastIndex);
octet1 = reply.substring(lastIndex, index);
octet2 = reply.substring(index + 1);
// index and lastIndex now used as temporaries
try {
index = Integer.parseInt(octet1);
lastIndex = Integer.parseInt(octet2);
} catch (NumberFormatException e) {
throw new MalformedServerReplyException(
"Could not parse passive host information.\nServer Reply: " + reply);
}
index <<= 8;
index |= lastIndex;
__passiveHost = host.toString();
__passivePort = index;
}
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:42,代码来源:Client.java
示例9: __openPassiveDataConnection
import org.apache.commons.net.MalformedServerReplyException; //导入依赖的package包/类
/**
* open a passive data connection socket
*
* @param command
* @param arg
* @return
* @throws IOException
* @throws FtpExceptionCanNotHaveDataConnection
*/
protected Socket __openPassiveDataConnection(int command, String arg)
throws IOException, FtpExceptionCanNotHaveDataConnection {
Socket socket;
// // 20040317, xing, accommodate ill-behaved servers, see below
// int port_previous = __passivePort;
if (pasv() != FTPReply.ENTERING_PASSIVE_MODE)
throw new FtpExceptionCanNotHaveDataConnection("pasv() failed. "
+ getReplyString());
try {
__parsePassiveModeReply(getReplyStrings()[0]);
} catch (MalformedServerReplyException e) {
throw new FtpExceptionCanNotHaveDataConnection(e.getMessage());
}
// // 20040317, xing, accommodate ill-behaved servers, see above
// int count = 0;
// System.err.println("__passivePort "+__passivePort);
// System.err.println("port_previous "+port_previous);
// while (__passivePort == port_previous) {
// // just quit if too many tries. make it an exception here?
// if (count++ > 10)
// return null;
// // slow down further for each new try
// Thread.sleep(500*count);
// if (pasv() != FTPReply.ENTERING_PASSIVE_MODE)
// throw new FtpExceptionCanNotHaveDataConnection(
// "pasv() failed. " + getReplyString());
// //return null;
// try {
// __parsePassiveModeReply(getReplyStrings()[0]);
// } catch (MalformedServerReplyException e) {
// throw new FtpExceptionCanNotHaveDataConnection(e.getMessage());
// }
// }
socket = _socketFactory_.createSocket(__passiveHost, __passivePort);
if (!FTPReply.isPositivePreliminary(sendCommand(command, arg))) {
socket.close();
return null;
}
if (__remoteVerificationEnabled && !verifyRemote(socket)) {
InetAddress host1, host2;
host1 = socket.getInetAddress();
host2 = getRemoteAddress();
socket.close();
// our precaution
throw new FtpExceptionCanNotHaveDataConnection(
"Host attempting data connection " + host1.getHostAddress()
+ " is not same as server " + host2.getHostAddress()
+ " So we intentionally close it for security precaution.");
}
if (__dataTimeout >= 0)
socket.setSoTimeout(__dataTimeout);
return socket;
}
开发者ID:jorcox,项目名称:GeoCrawler,代码行数:75,代码来源:Client.java
示例10: __getReply
import org.apache.commons.net.MalformedServerReplyException; //导入依赖的package包/类
private void __getReply(boolean reportReply) throws IOException {
this._newReplyString = true;
this._replyLines.clear();
String line = this._controlInput_.readLine();
if(line == null) {
throw new FTPConnectionClosedException("Connection closed without indication.");
} else {
int length = line.length();
if(length < 3) {
throw new MalformedServerReplyException("Truncated server reply: " + line);
} else {
String code = null;
try {
code = line.substring(0, 3);
this._replyCode = Integer.parseInt(code);
} catch (NumberFormatException var6) {
throw new MalformedServerReplyException("Could not parse response code.\nServer Reply: " + line);
}
this._replyLines.add(line);
if(length > 3 && line.charAt(3) == 45) {
while(true) {
line = this._controlInput_.readLine();
if(line == null) {
throw new FTPConnectionClosedException("Connection closed without indication.");
}
this._replyLines.add(line);
if(this.isStrictMultilineParsing()) {
if(!this.__strictCheck(line, code)) {
break;
}
} else if(!this.__lenientCheck(line)) {
break;
}
}
}
this.fireReplyReceived(this._replyCode, this.getReplyString());
if(this._replyCode == 421) {
throw new FTPConnectionClosedException("FTP response 421 received. Server closed connection.");
}
}
}
}
开发者ID:Bolt-Thrower,项目名称:xdm,代码行数:47,代码来源:FTP.java
示例11: __getReply
import org.apache.commons.net.MalformedServerReplyException; //导入依赖的package包/类
private void __getReply(boolean reportReply) throws IOException {
int length;
_newReplyString = true;
_replyLines.clear();
String line = _controlInput_.readLine();
if (line == null) {
throw new FTPConnectionClosedException("Connection closed without indication.");
}
// In case we run into an anomaly we don't want fatal index exceptions
// to be thrown.
length = line.length();
if (length < REPLY_CODE_LEN) {
throw new MalformedServerReplyException("Truncated server reply: " + line);
}
String code = null;
try {
code = line.substring(0, REPLY_CODE_LEN);
_replyCode = Integer.parseInt(code);
} catch (NumberFormatException e) {
throw new MalformedServerReplyException(
"Could not parse response code.\nServer Reply: " + line);
}
_replyLines.add(line);
// Check the server reply type
if (length > REPLY_CODE_LEN) {
char sep = line.charAt(REPLY_CODE_LEN);
// Get extra lines if message continues.
if (sep == '-') {
do {
line = _controlInput_.readLine();
if (line == null) {
throw new FTPConnectionClosedException("Connection closed without indication.");
}
_replyLines.add(line);
// The length() check handles problems that could arise from readLine()
// returning too soon after encountering a naked CR or some other
// anomaly.
} while (isStrictMultilineParsing() ? __strictCheck(line, code) : __lenientCheck(line));
} else if (isStrictReplyParsing()) {
if (length == REPLY_CODE_LEN + 1) { // expecting some text
throw new MalformedServerReplyException("Truncated server reply: '" + line + "'");
} else if (sep != ' ') {
throw new MalformedServerReplyException("Invalid server reply: '" + line + "'");
}
}
} else if (isStrictReplyParsing()) {
throw new MalformedServerReplyException("Truncated server reply: '" + line + "'");
}
if (reportReply) {
fireReplyReceived(_replyCode, getReplyString());
}
if (_replyCode == FTPReply.SERVICE_NOT_AVAILABLE) {
throw new FTPConnectionClosedException(
"FTP response 421 received. Server closed connection.");
}
}
开发者ID:AriaLyy,项目名称:Aria,代码行数:69,代码来源:FTP.java
示例12: __parsePassiveModeReply
import org.apache.commons.net.MalformedServerReplyException; //导入依赖的package包/类
private void __parsePassiveModeReply(String reply)
throws MalformedServerReplyException
{
int i, index, lastIndex;
String octet1, octet2;
StringBuffer host;
reply = reply.substring(reply.indexOf('(') + 1,
reply.indexOf(')')).trim();
host = new StringBuffer(24);
lastIndex = 0;
index = reply.indexOf(',');
host.append(reply.substring(lastIndex, index));
for (i = 0; i < 3; i++)
{
host.append('.');
lastIndex = index + 1;
index = reply.indexOf(',', lastIndex);
host.append(reply.substring(lastIndex, index));
}
lastIndex = index + 1;
index = reply.indexOf(',', lastIndex);
octet1 = reply.substring(lastIndex, index);
octet2 = reply.substring(index + 1);
// index and lastIndex now used as temporaries
try
{
index = Integer.parseInt(octet1);
lastIndex = Integer.parseInt(octet2);
}
catch (NumberFormatException e)
{
throw new MalformedServerReplyException(
"Could not parse passive host information.\nServer Reply: " + reply);
}
index <<= 8;
index |= lastIndex;
__passiveHost = host.toString();
__passivePort = index;
}
开发者ID:yahoo,项目名称:anthelion,代码行数:48,代码来源:Client.java
示例13: __openPassiveDataConnection
import org.apache.commons.net.MalformedServerReplyException; //导入依赖的package包/类
protected Socket __openPassiveDataConnection(int command, String arg)
throws IOException, FtpExceptionCanNotHaveDataConnection {
Socket socket;
// // 20040317, xing, accommodate ill-behaved servers, see below
// int port_previous = __passivePort;
if (pasv() != FTPReply.ENTERING_PASSIVE_MODE)
throw new FtpExceptionCanNotHaveDataConnection(
"pasv() failed. " + getReplyString());
try {
__parsePassiveModeReply(getReplyStrings()[0]);
} catch (MalformedServerReplyException e) {
throw new FtpExceptionCanNotHaveDataConnection(e.getMessage());
}
// // 20040317, xing, accommodate ill-behaved servers, see above
// int count = 0;
// System.err.println("__passivePort "+__passivePort);
// System.err.println("port_previous "+port_previous);
// while (__passivePort == port_previous) {
// // just quit if too many tries. make it an exception here?
// if (count++ > 10)
// return null;
// // slow down further for each new try
// Thread.sleep(500*count);
// if (pasv() != FTPReply.ENTERING_PASSIVE_MODE)
// throw new FtpExceptionCanNotHaveDataConnection(
// "pasv() failed. " + getReplyString());
// //return null;
// try {
// __parsePassiveModeReply(getReplyStrings()[0]);
// } catch (MalformedServerReplyException e) {
// throw new FtpExceptionCanNotHaveDataConnection(e.getMessage());
// }
// }
socket = _socketFactory_.createSocket(__passiveHost, __passivePort);
if (!FTPReply.isPositivePreliminary(sendCommand(command, arg))) {
socket.close();
return null;
}
if (__remoteVerificationEnabled && !verifyRemote(socket))
{
InetAddress host1, host2;
host1 = socket.getInetAddress();
host2 = getRemoteAddress();
socket.close();
// our precaution
throw new FtpExceptionCanNotHaveDataConnection(
"Host attempting data connection " + host1.getHostAddress() +
" is not same as server " + host2.getHostAddress() +
" So we intentionally close it for security precaution."
);
}
if (__dataTimeout >= 0)
socket.setSoTimeout(__dataTimeout);
return socket;
}
开发者ID:yahoo,项目名称:anthelion,代码行数:68,代码来源:Client.java
示例14: pasv
import org.apache.commons.net.MalformedServerReplyException; //导入依赖的package包/类
public int pasv() throws IOException {
int passiveReturnCode = super.pasv();
if (passiveReturnCode == FTPReply.ENTERING_PASSIVE_MODE) {
// Parse and display reply host and port in passive mode
// It's quite ugly but there is no entry point in apache's ftp library to perform this check.
String reply = getReplyStrings()[0];
int i, index, lastIndex;
String octet1, octet2;
StringBuffer host;
reply = reply.substring(reply.indexOf('(') + 1, reply.indexOf(')')).trim();
host = new StringBuffer(24);
lastIndex = 0;
index = reply.indexOf(',');
host.append(reply.substring(lastIndex, index));
for (i = 0; i < 3; i++) {
host.append('.');
lastIndex = index + 1;
index = reply.indexOf(',', lastIndex);
host.append(reply.substring(lastIndex, index));
}
lastIndex = index + 1;
index = reply.indexOf(',', lastIndex);
octet1 = reply.substring(lastIndex, index);
octet2 = reply.substring(index + 1);
// index and lastIndex now used as temporaries
try {
index = Integer.parseInt(octet1);
lastIndex = Integer.parseInt(octet2);
} catch (NumberFormatException e) {
throw new MalformedServerReplyException("Could not parse passive host information.\nServer Reply: " + reply);
}
index <<= 8;
index |= lastIndex;
String passvHost = host.toString();
//int passvPort = index;
//Logger.defaultLogger().info("Passive host received from server : " + passvHost + ":" + passvPort);
InetAddress refAddress = InetAddress.getByName(passvHost);
if (! refAddress.equals(this._socket_.getInetAddress())) {
String msg = "Passive address (" + refAddress + ") differs from host address (" + this._socket_.getInetAddress() + "). This is probably because your server is behind a router. Please check your FTP server's configuration. (for instance, use a masquerade address)";
Logger.defaultLogger().warn(msg);
if (! ignorePasvErrors) {
throw new IOException(msg);
}
}
}
return passiveReturnCode;
}
开发者ID:chfoo,项目名称:areca-backup-release-mirror,代码行数:61,代码来源:FTPClient.java
示例15: _readReply
import org.apache.commons.net.MalformedServerReplyException; //导入依赖的package包/类
private Object _readReply(InputStream in, boolean concatenateLines) throws IOException {
// obtain the result
BufferedReader reader = new BufferedReader(new InputStreamReader(in, "ISO-8859-1"));
int replyCode = 0;
StringBuffer reply = new StringBuffer();
List replyList = new ArrayList();
String line = reader.readLine();
if (line == null)
throw new FTPConnectionClosedException("Connection closed without indication.");
reply.append(line).append("\n");
replyList.add(line);
// In case we run into an anomaly we don't want fatal index exceptions
// to be thrown.
int length = line.length();
if (length < 3)
throw new MalformedServerReplyException("Truncated server reply: " + line);
try {
String code = line.substring(0, 3);
replyCode = Integer.parseInt(code);
}
catch (NumberFormatException e) {
MalformedServerReplyException mfre = new MalformedServerReplyException("Could not parse response code.\nServer Reply [" + line+"]");
mfre.initCause(e);
throw mfre;
}
// Get extra lines if message continues.
if (length > 3 && line.charAt(3) == '-') {
do {
line = reader.readLine();
if (line == null)
throw new FTPConnectionClosedException("Connection closed without indication after having read ["+reply.toString()+"]");
reply.append(line).append("\n");
replyList.add(line);
}
while (!(line.length() >= 4 && line.charAt(3) != '-' && Character.isDigit(line.charAt(0))));
}
if (replyCode == FTPReply.SERVICE_NOT_AVAILABLE)
throw new FTPConnectionClosedException("FTP response 421 received. Server closed connection.");
if (!FTPReply.isPositiveCompletion(replyCode))
throw new IOException("Exception while sending command \n" + reply.toString());
log.debug("_readReply ["+reply.toString()+"]");
if (concatenateLines) {
return reply.toString();
}
return (String[])replyList.toArray(new String[0]);
}
开发者ID:ibissource,项目名称:iaf,代码行数:57,代码来源:FTPsClient.java
注:本文中的org.apache.commons.net.MalformedServerReplyException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论