[wagon2] 02/18: New upstream version 2.12
Tony Mancill
tmancill at moszumanska.debian.org
Sun May 7 17:47:31 UTC 2017
This is an automated email from the git hooks/post-receive script.
tmancill pushed a commit to branch experimental
in repository wagon2.
commit d793482dc90ffaafc8081fd8b10fcca1baeaf349
Author: tony mancill <tmancill at debian.org>
Date: Sat May 6 10:18:11 2017 -0700
New upstream version 2.12
---
NOTICE | 2 +-
deploySite.sh | 46 +-
pom.xml | 1148 +++--
src/main/assembly/source-release.xml | 92 +-
src/site/apt/privacy-policy.apt | 108 +-
src/site/resources/download.cgi | 42 +-
src/site/site.xml | 158 +-
src/site/xdoc/download.xml.vm | 252 +-
src/site/xdoc/index.xml | 158 +-
wagon-provider-api/pom.xml | 95 +-
.../java/org/apache/maven/wagon/AbstractWagon.java | 1874 +++++----
.../maven/wagon/CommandExecutionException.java | 96 +-
.../org/apache/maven/wagon/CommandExecutor.java | 72 +-
.../apache/maven/wagon/ConnectionException.java | 100 +-
.../java/org/apache/maven/wagon/InputData.java | 112 +-
.../apache/maven/wagon/LazyFileOutputStream.java | 312 +-
.../java/org/apache/maven/wagon/OutputData.java | 110 +-
.../java/org/apache/maven/wagon/PathUtils.java | 994 ++---
.../apache/maven/wagon/PermissionModeUtils.java | 148 +-
.../maven/wagon/ResourceDoesNotExistException.java | 94 +-
.../java/org/apache/maven/wagon/StreamWagon.java | 584 +--
.../org/apache/maven/wagon/StreamingWagon.java | 178 +-
.../main/java/org/apache/maven/wagon/Streams.java | 100 +-
.../maven/wagon/TransferFailedException.java | 98 +-
.../maven/wagon/UnsupportedProtocolException.java | 100 +-
.../main/java/org/apache/maven/wagon/Wagon.java | 600 +--
.../org/apache/maven/wagon/WagonConstants.java | 78 +-
.../org/apache/maven/wagon/WagonException.java | 232 +-
.../java/org/apache/maven/wagon/WagonUtils.java | 244 +-
.../authentication/AuthenticationException.java | 106 +-
.../wagon/authentication/AuthenticationInfo.java | 272 +-
.../authorization/AuthorizationException.java | 106 +-
.../apache/maven/wagon/events/SessionEvent.java | 452 +-
.../maven/wagon/events/SessionEventSupport.java | 448 +-
.../apache/maven/wagon/events/SessionListener.java | 234 +-
.../apache/maven/wagon/events/TransferEvent.java | 636 +--
.../maven/wagon/events/TransferEventSupport.java | 378 +-
.../maven/wagon/events/TransferListener.java | 116 +-
.../org/apache/maven/wagon/events/WagonEvent.java | 156 +-
.../wagon/observers/AbstractTransferListener.java | 126 +-
.../maven/wagon/observers/ChecksumObserver.java | 284 +-
.../org/apache/maven/wagon/observers/Debug.java | 412 +-
.../org/apache/maven/wagon/proxy/ProxyInfo.java | 436 +-
.../maven/wagon/proxy/ProxyInfoProvider.java | 66 +-
.../org/apache/maven/wagon/proxy/ProxyUtils.java | 138 +-
.../apache/maven/wagon/repository/Repository.java | 660 +--
.../wagon/repository/RepositoryPermissions.java | 222 +-
.../org/apache/maven/wagon/resource/Resource.java | 292 +-
wagon-provider-api/src/site/apt/index.apt | 78 +-
wagon-provider-api/src/site/site.xml | 74 +-
.../org/apache/maven/wagon/AbstractWagonTest.java | 1154 +++---
.../maven/wagon/CannotConnectExceptionTest.java | 86 +-
.../org/apache/maven/wagon/InputStreamMock.java | 160 +-
.../maven/wagon/LazyFileOutputStreamTest.java | 124 +-
.../maven/wagon/NotAuthorizedExceptionTest.java | 88 +-
.../org/apache/maven/wagon/OutputStreamMock.java | 160 +-
.../java/org/apache/maven/wagon/PathUtilsTest.java | 672 +--
.../maven/wagon/PermissionModeUtilsTest.java | 140 +-
.../wagon/ResourceDoesNotExistExceptionTest.java | 86 +-
.../org/apache/maven/wagon/StreamWagonTest.java | 1086 ++---
.../maven/wagon/TransferFailedExceptionTest.java | 86 +-
.../java/org/apache/maven/wagon/WagonMock.java | 260 +-
.../AuthenticationExceptionTest.java | 86 +-
.../authentication/AuthenticationInfoTest.java | 138 +-
.../wagon/events/SessionEventSupportTest.java | 514 +--
.../maven/wagon/events/SessionEventTest.java | 264 +-
.../wagon/events/TransferEventSupportTest.java | 380 +-
.../maven/wagon/events/TransferEventTest.java | 332 +-
.../wagon/observers/ChecksumObserverTest.java | 246 +-
.../apache/maven/wagon/proxy/ProxyInfoTest.java | 146 +-
.../maven/wagon/proxy/ProxyInfoUtilsTest.java | 184 +-
.../repository/RepositoryPermissionsTest.java | 132 +-
.../maven/wagon/repository/RepositoryTest.java | 328 +-
.../wagon/manager/DefaultWagonManagerTest.xml | 84 +-
wagon-provider-test/pom.xml | 130 +-
.../maven/wagon/CommandExecutorTestCase.java | 218 +-
.../java/org/apache/maven/wagon/FileTestUtils.java | 242 +-
.../apache/maven/wagon/StreamingWagonTestCase.java | 624 +--
.../java/org/apache/maven/wagon/WagonTestCase.java | 2178 +++++-----
.../apache/maven/wagon/http/HttpWagonTestCase.java | 4375 ++++++++++----------
wagon-provider-test/src/site/apt/index.apt | 62 +-
wagon-provider-test/src/site/site.xml | 64 +-
wagon-providers/pom.xml | 162 +-
wagon-providers/src/site/site.xml | 66 +-
wagon-providers/wagon-file/pom.xml | 87 +-
.../maven/wagon/providers/file/FileWagon.java | 547 ++-
wagon-providers/wagon-file/src/site/apt/index.apt | 80 +-
wagon-providers/wagon-file/src/site/site.xml | 64 +-
.../maven/wagon/providers/file/FileWagonTest.java | 195 +-
wagon-providers/wagon-ftp/pom.xml | 126 +-
.../apache/maven/wagon/providers/ftp/FtpWagon.java | 1618 ++++----
.../maven/wagon/providers/ftp/FtpsWagon.java | 64 +
wagon-providers/wagon-ftp/src/site/apt/index.apt | 143 +-
wagon-providers/wagon-ftp/src/site/site.xml | 64 +-
.../maven/wagon/providers/ftp/FtpWagonTest.java | 474 +--
.../maven/wagon/providers/ftp/FtpWagonTest.xml | 42 +-
wagon-providers/wagon-http-lightweight/pom.xml | 124 +-
.../wagon/providers/http/LightweightHttpWagon.java | 935 ++---
.../http/LightweightHttpWagonAuthenticator.java | 122 +-
.../providers/http/LightweightHttpsWagon.java | 164 +-
.../wagon-http-lightweight/src/site/apt/index.apt | 90 +-
.../wagon-http-lightweight/src/site/site.xml | 64 +-
.../providers/http/LightweightHttpWagonTest.java | 132 +-
...tHttpWagonWithPreemptiveAuthenticationTest.java | 102 +-
.../providers/http/LightweightHttpsWagonTest.java | 108 +-
.../apache/maven/wagon/providers/http/TckTest.java | 70 +-
.../test/resources/META-INF/plexus/components.xml | 76 +-
wagon-providers/wagon-http-shared/pom.xml | 111 +-
.../maven/wagon/shared/http/EncodingUtil.java | 212 +-
.../wagon/shared/http/HtmlFileListParser.java | 327 +-
.../wagon-http-shared/src/site/site.xml | 64 +-
.../maven/wagon/shared/http/EncodingUtilTest.java | 106 +-
.../wagon/shared/http/HtmlFileListParserTest.java | 1454 +++----
.../test/resources/filelistings/commons-lang.html | 62 +-
.../test/resources/filelistings/ibiblio-wagon.html | 198 +-
.../test/resources/filelistings/jetty-wagon.html | 180 +-
.../src/test/resources/filelistings/mevenide.html | 84 +-
.../test/resources/filelistings/mirror-wagon.html | 224 +-
.../src/test/resources/filelistings/nekohtml.html | 46 +-
.../src/test/resources/filelistings/net_sf.html | 142 +-
.../resources/filelistings/org.apache.maven.html | 84 +-
.../test/resources/filelistings/org.codehaus.html | 164 +-
wagon-providers/wagon-http/pom.xml | 317 +-
.../providers/http/AbstractHttpClientWagon.java | 2294 +++++-----
.../maven/wagon/providers/http/BasicAuthScope.java | 336 +-
.../wagon/providers/http/ConfigurationUtils.java | 460 +-
.../wagon/providers/http/HttpConfiguration.java | 213 +-
.../providers/http/HttpMethodConfiguration.java | 348 +-
.../maven/wagon/providers/http/HttpWagon.java | 250 +-
.../wagon/providers/http/RelaxedTrustStrategy.java | 152 +-
.../main/resources/META-INF/plexus/components.xml | 70 +-
wagon-providers/wagon-http/src/site/apt/index.apt | 118 +-
wagon-providers/wagon-http/src/site/site.xml | 64 +-
.../http/AbstractHttpClientWagonTest.java | 104 +-
.../wagon/providers/http/BasicAuthScopeTest.java | 200 +-
.../http/ErrorWithReasonPhaseServlet.java | 127 +-
.../wagon/providers/http/HttpClientWagonTest.java | 272 +-
.../http/HttpWagonHttpServerTestCase.java | 142 +-
.../providers/http/HttpWagonPreemptiveTest.java | 116 +-
.../providers/http/HttpWagonReasonPhraseTest.java | 372 +-
.../maven/wagon/providers/http/HttpWagonTest.java | 140 +-
.../wagon/providers/http/HttpWagonTimeoutTest.java | 438 +-
.../providers/http/HttpsWagonPreemptiveTest.java | 166 +-
.../maven/wagon/providers/http/HttpsWagonTest.java | 106 +-
.../wagon/providers/http/HugeFileDownloadTest.java | 368 +-
.../apache/maven/wagon/providers/http/TckTest.java | 70 +-
.../wagon/providers/http/WaitForeverServlet.java | 109 +-
.../test/resources/META-INF/plexus/components.xml | 76 +-
.../wagon-http/src/test/resources/log4j.xml | 94 +-
wagon-providers/wagon-scm/pom.xml | 172 +-
.../apache/maven/wagon/providers/scm/ScmWagon.java | 1556 +++----
wagon-providers/wagon-scm/src/site/apt/index.apt | 108 +-
.../wagon-scm/src/site/apt/usage.apt.vm | 376 +-
wagon-providers/wagon-scm/src/site/site.xml | 74 +-
.../providers/scm/AbstractScmCvsWagonTest.java | 92 +-
.../providers/scm/AbstractScmSvnWagonTest.java | 158 +-
.../wagon/providers/scm/AbstractScmWagonTest.java | 290 +-
.../wagon/providers/scm/ScmCvsExeWagonTest.java | 128 +-
.../wagon/providers/scm/ScmSvnExeWagonTest.java | 80 +-
wagon-providers/wagon-ssh-common-test/pom.xml | 134 +-
.../ssh/AbstractEmbeddedScpWagonTest.java | 202 +-
.../ssh/AbstractEmbeddedScpWagonWithKeyTest.java | 336 +-
.../maven/wagon/providers/ssh/ScpCommand.java | 1176 +++---
.../wagon/providers/ssh/ScpCommandFactory.java | 224 +-
.../maven/wagon/providers/ssh/ShellCommand.java | 342 +-
.../wagon/providers/ssh/SshServerEmbedded.java | 416 +-
.../apache/maven/wagon/providers/ssh/TestData.java | 162 +-
.../providers/ssh/TestPasswordAuthenticator.java | 162 +-
.../providers/ssh/TestPublickeyAuthenticator.java | 375 +-
.../ssh/knownhost/KnownHostsProviderTestCase.java | 252 +-
.../wagon-ssh-common-test/src/site/site.xml | 64 +-
wagon-providers/wagon-ssh-common/pom.xml | 103 +-
.../ssh/CommandExecutorStreamProcessor.java | 178 +-
.../apache/maven/wagon/providers/ssh/LSParser.java | 192 +-
.../maven/wagon/providers/ssh/ScpHelper.java | 726 ++--
.../apache/maven/wagon/providers/ssh/SshWagon.java | 74 +-
.../interactive/ConsoleInteractiveUserInfo.java | 204 +-
.../ssh/interactive/InteractiveUserInfo.java | 80 +-
.../ssh/interactive/NullInteractiveUserInfo.java | 158 +-
.../ssh/knownhost/AbstractKnownHostsProvider.java | 145 +-
.../ssh/knownhost/FileKnownHostsProvider.java | 187 +-
.../ssh/knownhost/KnownHostChangedException.java | 68 +-
.../providers/ssh/knownhost/KnownHostEntry.java | 282 +-
.../ssh/knownhost/KnownHostsProvider.java | 87 +-
.../ssh/knownhost/NullKnownHostProvider.java | 70 +-
.../ssh/knownhost/SingleKnownHostProvider.java | 92 +-
.../ssh/knownhost/StreamKnownHostsProvider.java | 176 +-
.../ssh/knownhost/UnknownHostException.java | 68 +-
wagon-providers/wagon-ssh-common/src/site/site.xml | 64 +-
.../maven/wagon/providers/ssh/LSParserTest.java | 260 +-
.../ssh/knownhost/FileKnownHostsProviderTest.java | 150 +-
.../src/test/resources/known_hosts | 4 +-
.../src/test/resources/known_hosts_same | 4 +-
wagon-providers/wagon-ssh-external/pom.xml | 254 +-
.../ssh/external/ScpExternalCommandExecutor.java | 86 +-
.../providers/ssh/external/ScpExternalWagon.java | 1040 ++---
.../wagon-ssh-external/src/site/apt/index.apt | 82 +-
.../wagon-ssh-external/src/site/site.xml | 64 +-
.../EmbeddedScpExternalWagonWithKeyTest.java | 226 +-
.../ssh/external/ScpExternalWagonTest.java | 234 +-
.../ScpWagonWithSshPrivateKeySearchTest.java | 162 +-
.../ssh/external/SshCommandExecutorTest.java | 78 +-
.../src/test/resources/log4j.xml | 82 +-
wagon-providers/wagon-ssh/pom.xml | 362 +-
.../providers/ssh/jsch/AbstractJschWagon.java | 908 ++--
.../providers/ssh/jsch/ScpCommandExecutor.java | 82 +-
.../maven/wagon/providers/ssh/jsch/ScpWagon.java | 904 ++--
.../maven/wagon/providers/ssh/jsch/SftpWagon.java | 1138 ++---
.../wagon/providers/ssh/jsch/WagonUserInfo.java | 178 +-
.../interactive/PrompterUIKeyboardInteractive.java | 188 +-
.../UserInfoUIKeyboardInteractiveProxy.java | 212 +-
wagon-providers/wagon-ssh/src/site/apt/index.apt | 82 +-
wagon-providers/wagon-ssh/src/site/site.xml | 64 +-
.../wagon-ssh/src/site/xdoc/configuration.xml | 448 +-
.../providers/ssh/jsch/EmbeddedScpWagonTest.java | 170 +-
.../ssh/jsch/EmbeddedScpWagonWithKeyTest.java | 184 +-
.../providers/ssh/jsch/KnownHostsProviderTest.java | 70 +-
.../wagon/providers/ssh/jsch/ScpWagonTest.java | 152 +-
.../providers/ssh/jsch/ScpWagonWithProxyTest.java | 407 +-
.../jsch/ScpWagonWithSshPrivateKeySearchTest.java | 228 +-
.../wagon/providers/ssh/jsch/SftpWagonTest.java | 130 +-
.../providers/ssh/jsch/SshCommandExecutorTest.java | 78 +-
.../wagon-ssh/src/test/resources/log4j.xml | 82 +-
.../maven/wagon/providers/ssh/ScpWagonTest.xml | 72 +-
.../ssh/ScpWagonWithSshPrivateKeySearchTest.xml | 72 +-
.../maven/wagon/providers/ssh/SftpWagonTest.xml | 72 +-
.../wagon/providers/ssh/SshCommandExecutorTest.xml | 72 +-
wagon-providers/wagon-webdav-jackrabbit/pom.xml | 334 +-
.../org/apache/jackrabbit/webdav/MultiStatus.java | 420 +-
.../webdav/client/methods/XmlRequestEntity.java | 188 +-
.../providers/webdav/AbstractHttpClientWagon.java | 1652 ++++----
.../wagon/providers/webdav/HttpConfiguration.java | 214 +-
.../providers/webdav/HttpMethodConfiguration.java | 638 +--
.../wagon/providers/webdav/PathNavigator.java | 146 +-
.../maven/wagon/providers/webdav/WebDavWagon.java | 686 +--
.../resources/META-INF/plexus/default-bindings.xml | 126 +-
.../wagon-webdav-jackrabbit/src/site/apt/index.apt | 86 +-
.../wagon-webdav-jackrabbit/src/site/site.xml | 64 +-
.../providers/webdav/HttpClientWagonTest.java | 484 +--
.../wagon/providers/webdav/PathNavigatorTest.java | 126 +-
.../wagon/providers/webdav/WebDavWagonTest.java | 1013 ++---
.../wagon/providers/webdav/WebDavsWagonTest.java | 112 +-
.../src/test/resources/log4j.xml | 72 +-
wagon-tcks/pom.xml | 88 +-
wagon-tcks/src/site/site.xml | 66 +-
wagon-tcks/wagon-tck-http/pom.xml | 138 +-
.../wagon-tck-http/sample-tck-consumer/pom.xml | 132 +-
.../maven/wagon/tck/http/consumer/TestSuite.java | 62 +-
.../test/resources/META-INF/plexus/components.xml | 76 +-
.../apache/maven/wagon/tck/http/Assertions.java | 138 +-
.../apache/maven/wagon/tck/http/GetWagonTests.java | 1122 ++---
.../maven/wagon/tck/http/HttpWagonTests.java | 670 +--
.../maven/wagon/tck/http/HttpsGetWagonTests.java | 68 +-
.../wagon/tck/http/WagonTestCaseConfigurator.java | 276 +-
.../wagon/tck/http/fixture/AuthSnoopFilter.java | 142 +-
.../wagon/tck/http/fixture/ErrorCodeServlet.java | 110 +-
.../wagon/tck/http/fixture/LatencyServlet.java | 251 +-
.../http/fixture/ProxyAuthenticationFilter.java | 178 +-
.../fixture/ProxyConnectionVerifierFilter.java | 163 +-
.../wagon/tck/http/fixture/RedirectionServlet.java | 192 +-
.../wagon/tck/http/fixture/ServerFixture.java | 426 +-
.../tck/http/fixture/ServletExceptionServlet.java | 104 +-
.../apache/maven/wagon/tck/http/util/TestUtil.java | 290 +-
.../maven/wagon/tck/http/util/ValueHolder.java | 96 +-
.../main/resources/default-server-root/large.txt | 4 +-
wagon-tcks/wagon-tck-http/src/site/site.xml | 64 +-
266 files changed, 38048 insertions(+), 37530 deletions(-)
diff --git a/NOTICE b/NOTICE
index e1baae0..238ef73 100644
--- a/NOTICE
+++ b/NOTICE
@@ -1,6 +1,6 @@
Apache Maven Wagon
-Copyright 2003-2015 The Apache Software Foundation
+Copyright 2003-2017 The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
diff --git a/deploySite.sh b/deploySite.sh
old mode 100755
new mode 100644
index f6c265d..46157a3
--- a/deploySite.sh
+++ b/deploySite.sh
@@ -1,23 +1,23 @@
-#!/bin/sh
-
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-mvn -Preporting site site:stage $@
-mvn scm-publish:publish-scm $@
+#!/bin/sh
+
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+mvn -Preporting site site:stage $@
+mvn scm-publish:publish-scm $@
diff --git a/pom.xml b/pom.xml
index f2fae1f..087388b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,580 +1,568 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <artifactId>maven-parent</artifactId>
- <groupId>org.apache.maven</groupId>
- <version>26</version>
- <relativePath>../pom/maven/pom.xml</relativePath>
- </parent>
-
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon</artifactId>
- <version>2.10</version>
- <packaging>pom</packaging>
-
- <name>Apache Maven Wagon</name>
- <description>Tools to manage artifacts and deployment</description>
- <url>http://maven.apache.org/wagon</url>
- <inceptionYear>2003</inceptionYear>
-
- <properties>
- <maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile>
- <slf4jVersion>1.7.7</slf4jVersion>
- <maven.site.path>wagon-archives/wagon-LATEST</maven.site.path>
- </properties>
-
- <contributors>
- <contributor>
- <name>James William Dumay</name>
- </contributor>
- <contributor>
- <name>Nathan Beyer</name>
- </contributor>
- <contributor>
- <name>Gregory Block</name>
- </contributor>
- <contributor>
- <name>Thomas Recloux</name>
- </contributor>
- <contributor>
- <name>Trustin Lee</name>
- </contributor>
- <contributor>
- <name>John Wells</name>
- </contributor>
- <contributor>
- <name>Marcel Schutte</name>
- </contributor>
- <contributor>
- <name>David Hawkins</name>
- </contributor>
- <contributor>
- <name>Juan F. Codagnone</name>
- </contributor>
- <contributor>
- <name>ysoonleo</name>
- </contributor>
- <contributor>
- <name>Thomas Champagne</name>
- </contributor>
- <contributor>
- <name>M. van der Plas</name>
- </contributor>
- <contributor>
- <name>Jason Dillon</name>
- </contributor>
- <contributor>
- <name>Jochen Wiedmann</name>
- </contributor>
- <contributor>
- <name>Gilles Scokart</name>
- </contributor>
- <contributor>
- <name>Wolfgang Glas</name>
- </contributor>
- <contributor>
- <name>Kohsuke Kawaguchi</name>
- </contributor>
- <contributor>
- <name>Antti Virtanen</name>
- </contributor>
- <contributor>
- <name>Thorsten Heit</name>
- </contributor>
- <contributor>
- <name>Michal Maczka</name>
- <email>michal at codehaus.org</email>
- <organization>Codehaus</organization>
- <roles>
- <role>Developer</role>
- </roles>
- </contributor>
- <contributor>
- <name>Adrián Boimvaser</name>
- <organization>Application Security, Inc.</organization>
- <roles>
- <role>Developer</role>
- </roles>
- </contributor>
- <contributor>
- <name>Oleg Kalnichevski</name>
- </contributor>
- <contributor>
- <name>William Bernardet</name>
- </contributor>
- <contributor>
- <name>Michael Neale</name>
- </contributor>
- <contributor>
- <name>Grzegorz Grzybek</name>
- </contributor>
- </contributors>
-
- <mailingLists>
- <mailingList>
- <name>Maven Developer List</name>
- <subscribe>dev-subscribe at maven.apache.org</subscribe>
- <unsubscribe>dev-unsubscribe at maven.apache.org</unsubscribe>
- <post>dev at maven.apache.org</post>
- <archive>http://mail-archives.apache.org/mod_mbox/maven-dev</archive>
- <otherArchives>
- <otherArchive>http://www.mail-archive.com/dev@maven.apache.org/</otherArchive>
- <otherArchive>http://maven.40175.n5.nabble.com/Maven-Developers-f142166.html</otherArchive>
- <otherArchive>http://maven-dev.markmail.org/</otherArchive>
- </otherArchives>
- </mailingList>
- <mailingList>
- <name>Maven User List</name>
- <subscribe>users-subscribe at maven.apache.org</subscribe>
- <unsubscribe>users-unsubscribe at maven.apache.org</unsubscribe>
- <post>users at maven.apache.org</post>
- <archive>http://mail-archives.apache.org/mod_mbox/maven-users</archive>
- <otherArchives>
- <otherArchive>http://www.mail-archive.com/users@maven.apache.org/</otherArchive>
- <otherArchive>http://maven.40175.n5.nabble.com/Maven-Users-f40176.html</otherArchive>
- <otherArchive>http://maven-users.markmail.org/</otherArchive>
- </otherArchives>
- </mailingList>
-
- <mailingList>
- <name>LEGACY Wagon User List (deprecated)</name>
- <post>wagon-users at maven.apache.org</post>
- <subscribe>wagon-users-subscribe at maven.apache.org</subscribe>
- <unsubscribe>wagon-users-unsubscribe at maven.apache.org</unsubscribe>
- <archive>http://mail-archives.apache.org/mod_mbox/maven-wagon-users/</archive>
- <otherArchives>
- <otherArchive>http://www.mail-archive.com/wagon-users@maven.apache.org</otherArchive>
- <otherArchive>http://maven.40175.n5.nabble.com/Wagon-Users-f326332.html</otherArchive>
- <otherArchive>http://maven-wagon-users.markmail.org/</otherArchive>
- </otherArchives>
- </mailingList>
- <mailingList>
- <name>LEGACY Wagon Developer List (deprecated)</name>
- <post>wagon-dev at maven.apache.org</post>
- <subscribe>wagon-dev-subscribe at maven.apache.org</subscribe>
- <unsubscribe>wagon-dev-unsubscribe at maven.apache.org</unsubscribe>
- <archive>http://mail-archives.apache.org/mod_mbox/maven-wagon-dev/</archive>
- <otherArchives>
- <otherArchive>http://www.mail-archive.com/wagon-dev@maven.apache.org</otherArchive>
- <otherArchive>http://maven.40175.n5.nabble.com/Wagon-Dev-f326406.html</otherArchive>
- <otherArchive>http://maven-wagon-dev.markmail.org/</otherArchive>
- </otherArchives>
- </mailingList>
- <mailingList>
- <name>Wagon Commits List</name>
- <subscribe>wagon-commits-subscribe at maven.apache.org</subscribe>
- <unsubscribe>wagon-commits-unsubscribe at maven.apache.org</unsubscribe>
- <archive>http://mail-archives.apache.org/mod_mbox/maven-wagon-commits/</archive>
- <otherArchives>
- <otherArchive>http://maven-wagon-commits.markmail.org/</otherArchive>
- </otherArchives>
- </mailingList>
- </mailingLists>
-
- <scm>
- <connection>scm:git:https://git-wip-us.apache.org/repos/asf/maven-wagon.git</connection>
- <developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/maven-wagon.git</developerConnection>
- <url>https://github.com/apache/maven-wagon/tree/${project.scm.tag}</url>
- <tag>wagon-2.10</tag>
- </scm>
-
- <issueManagement>
- <system>jira</system>
- <url>https://issues.apache.org/jira/browse/WAGON</url>
- </issueManagement>
- <ciManagement>
- <system>Jenkins</system>
- <url>https://builds.apache.org/job/maven-wagon/</url>
- </ciManagement>
-
- <distributionManagement>
- <site>
- <id>apache.website</id>
- <url>scm:svn:https://svn.apache.org/repos/infra/websites/production/maven/components/${maven.site.path}</url>
- </site>
- </distributionManagement>
-
- <modules>
- <module>wagon-provider-api</module>
- <module>wagon-providers</module>
- <module>wagon-provider-test</module>
- <module>wagon-tcks</module>
- </modules>
-
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-provider-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-provider-test</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-ssh-common-test</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-ssh-common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.11</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-interactivity-api</artifactId>
- <version>1.0-alpha-6</version>
- <exclusions>
- <exclusion>
- <groupId>plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-container-default</artifactId>
- </exclusion>
- <exclusion>
- <groupId>classworlds</groupId>
- <artifactId>classworlds</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-container-default</artifactId>
- <version>1.5.5</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>3.0.15</version>
- </dependency>
-
- <!-- for slf4j -->
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- <version>${slf4jVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- <version>${slf4jVersion}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <version>${slf4jVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- <version>${slf4jVersion}</version>
- </dependency>
-
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- <version>2.6</version>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>2.2</version>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <version>3.2</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty</artifactId>
- <version>6.1.26</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <forkedProcessTimeoutInSeconds>400</forkedProcessTimeoutInSeconds>
- <systemPropertyVariables>
- <java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
- </systemPropertyVariables>
- </configuration>
- </plugin>
- <plugin><!-- TODO remove when upgrading maven-parent to 25 -->
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-site-plugin</artifactId>
- <configuration>
- <topSiteURL>scm:svn:https://svn.apache.org/repos/infra/websites/production/maven/components/${maven.site.path}</topSiteURL>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-plugin</artifactId>
- <configuration>
- <excludes combine.children="append">
- <exclude>**/*.odg</exclude>
- <exclude>src/test/resources/**</exclude>
- <exclude>src/main/resources/default-server-root/**</exclude>
- <exclude>src/main/resources/ssh-keys/**</exclude>
- <exclude>src/test/ssh-keys/**</exclude>
- <exclude>.repository/**</exclude><!-- for CI -->
- </excludes>
- </configuration>
- </plugin>
- <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
- <plugin>
- <groupId>org.eclipse.m2e</groupId>
- <artifactId>lifecycle-mapping</artifactId>
- <version>1.0.0</version>
- <configuration>
- <lifecycleMappingMetadata>
- <pluginExecutions>
- <pluginExecution>
- <pluginExecutionFilter>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-plugin</artifactId>
- <versionRange>[0.11,)</versionRange>
- <goals>
- <goal>check</goal>
- </goals>
- </pluginExecutionFilter>
- <action>
- <ignore />
- </action>
- </pluginExecution>
- </pluginExecutions>
- </lifecycleMappingMetadata>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-metadata</artifactId>
- <executions>
- <execution>
- <id>generate</id>
- <goals>
- <goal>generate-metadata</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>animal-sniffer-maven-plugin</artifactId>
- <version>1.9</version>
- <configuration>
- <signature>
- <groupId>org.codehaus.mojo.signature</groupId>
- <artifactId>java15</artifactId>
- <version>1.0</version>
- </signature>
- </configuration>
- <executions>
- <execution>
- <id>check-java-1.5-compat</id>
- <phase>process-classes</phase>
- <goals>
- <goal>check</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-enforcer-plugin</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>enforce</goal>
- </goals>
- <configuration>
- <rules>
- <requireJavaVersion>
- <version>1.6.0</version>
- </requireJavaVersion>
- </rules>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <profiles>
-
- <profile>
- <id>reporting</id>
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-javadoc-plugin</artifactId>
- <configuration>
- <linksource>true</linksource>
- <links>
- <link>http://java.sun.com/j2ee/1.4/docs/api</link>
- <link>http://commons.apache.org/collections/apidocs-COLLECTIONS_3_0/</link>
- <link>http://commons.apache.org/logging/apidocs/</link>
- <link>http://commons.apache.org/pool/apidocs/</link>
- <link>http://junit.sourceforge.net/javadoc/</link>
- <link>http://logging.apache.org/log4j/1.2/apidocs/</link>
- <link>http://jakarta.apache.org/regexp/apidocs/</link>
- <link>http://velocity.apache.org/engine/releases/velocity-1.5/apidocs/</link>
- <link>http://maven.apache.org/ref/current/maven-artifact/apidocs/</link>
- <link>http://maven.apache.org/ref/current/maven-artifact-manager/apidocs/</link>
- <link>http://maven.apache.org/ref/current/maven-model/apidocs/</link>
- <link>http://maven.apache.org/ref/current/maven-plugin-api/apidocs/</link>
- <link>http://maven.apache.org/ref/current/maven-project/apidocs/</link>
- <link>http://maven.apache.org/ref/current/maven-reporting/maven-reporting-api/apidocs/</link>
- <link>http://maven.apache.org/ref/current/maven-settings/apidocs/</link>
- </links>
- <groups>
- <group>
- <title>API + Test</title>
- <packages>org.apache.maven.wagon*</packages>
- </group>
- <group>
- <title>File Provider</title>
- <packages>org.apache.maven.wagon.providers.file*</packages>
- </group>
- <group>
- <title>FTP Provider</title>
- <packages>org.apache.maven.wagon.providers.ftp*</packages>
- </group>
- <group>
- <title>HTTP Providers</title>
- <packages>org.apache.maven.wagon.providers.http*:org.apache.maven.wagon.shared.http*</packages>
- </group>
- <group>
- <title>SCM Provider</title>
- <packages>org.apache.maven.wagon.providers.scm*</packages>
- </group>
- <group>
- <title>SSH Providers</title>
- <packages>org.apache.maven.wagon.providers.ssh*</packages>
- </group>
- <group>
- <title>Webdav Provider</title>
- <packages>org.apache.maven.wagon.providers.webdav*:org.apache.jackrabbit.webdav*</packages>
- </group>
- <group>
- <title>HTTP TCK</title>
- <packages>org.apache.maven.wagon.tck.http*</packages>
- </group>
- </groups>
- </configuration>
- <reportSets>
- <reportSet>
- <id>non-aggregate</id>
- <reports>
- <report>javadoc</report>
- <report>test-javadoc</report>
- </reports>
- </reportSet>
- <reportSet>
- <id>aggregate</id>
- <inherited>false</inherited>
- <reports>
- <report>aggregate</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jxr-plugin</artifactId>
- <reportSets>
- <reportSet>
- <id>non-aggregate</id>
- <reports>
- <report>jxr</report>
- <report>test-jxr</report>
- </reports>
- </reportSet>
- <reportSet>
- <id>aggregate</id>
- <inherited>false</inherited>
- <reports>
- <report>aggregate</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <reportSets>
- <reportSet>
- <id>non-aggregate</id>
- <reports>
- <report>checkstyle</report>
- </reports>
- </reportSet>
- <reportSet>
- <id>aggregate</id>
- <inherited>false</inherited>
- <reports>
- <report>checkstyle-aggregate</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- </plugins>
- </reporting>
- </profile>
- </profiles>
-
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>maven-parent</artifactId>
+ <groupId>org.apache.maven</groupId>
+ <version>27</version>
+ <relativePath>../pom/maven/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon</artifactId>
+ <version>2.12</version>
+ <packaging>pom</packaging>
+
+ <name>Apache Maven Wagon</name>
+ <description>Tools to manage artifacts and deployment</description>
+ <url>http://maven.apache.org/wagon</url>
+ <inceptionYear>2003</inceptionYear>
+
+ <properties>
+ <maven.test.redirectTestOutputToFile>true</maven.test.redirectTestOutputToFile>
+ <slf4jVersion>1.7.22</slf4jVersion>
+ <maven.site.path>wagon-archives/wagon-LATEST</maven.site.path>
+ </properties>
+
+ <contributors>
+ <contributor>
+ <name>James William Dumay</name>
+ </contributor>
+ <contributor>
+ <name>Nathan Beyer</name>
+ </contributor>
+ <contributor>
+ <name>Gregory Block</name>
+ </contributor>
+ <contributor>
+ <name>Thomas Recloux</name>
+ </contributor>
+ <contributor>
+ <name>Trustin Lee</name>
+ </contributor>
+ <contributor>
+ <name>John Wells</name>
+ </contributor>
+ <contributor>
+ <name>Marcel Schutte</name>
+ </contributor>
+ <contributor>
+ <name>David Hawkins</name>
+ </contributor>
+ <contributor>
+ <name>Juan F. Codagnone</name>
+ </contributor>
+ <contributor>
+ <name>ysoonleo</name>
+ </contributor>
+ <contributor>
+ <name>Thomas Champagne</name>
+ </contributor>
+ <contributor>
+ <name>M. van der Plas</name>
+ </contributor>
+ <contributor>
+ <name>Jason Dillon</name>
+ </contributor>
+ <contributor>
+ <name>Jochen Wiedmann</name>
+ </contributor>
+ <contributor>
+ <name>Gilles Scokart</name>
+ </contributor>
+ <contributor>
+ <name>Wolfgang Glas</name>
+ </contributor>
+ <contributor>
+ <name>Kohsuke Kawaguchi</name>
+ </contributor>
+ <contributor>
+ <name>Antti Virtanen</name>
+ </contributor>
+ <contributor>
+ <name>Thorsten Heit</name>
+ </contributor>
+ <contributor>
+ <name>Michal Maczka</name>
+ <email>michal at codehaus.org</email>
+ <organization>Codehaus</organization>
+ <roles>
+ <role>Developer</role>
+ </roles>
+ </contributor>
+ <contributor>
+ <name>Adrián Boimvaser</name>
+ <organization>Application Security, Inc.</organization>
+ <roles>
+ <role>Developer</role>
+ </roles>
+ </contributor>
+ <contributor>
+ <name>Oleg Kalnichevski</name>
+ </contributor>
+ <contributor>
+ <name>William Bernardet</name>
+ </contributor>
+ <contributor>
+ <name>Michael Neale</name>
+ </contributor>
+ <contributor>
+ <name>Grzegorz Grzybek</name>
+ </contributor>
+ <contributor>
+ <name>Jean Niklas L'orange</name>
+ </contributor>
+ </contributors>
+
+ <mailingLists>
+ <mailingList>
+ <name>Maven Developer List</name>
+ <subscribe>dev-subscribe at maven.apache.org</subscribe>
+ <unsubscribe>dev-unsubscribe at maven.apache.org</unsubscribe>
+ <post>dev at maven.apache.org</post>
+ <archive>http://mail-archives.apache.org/mod_mbox/maven-dev</archive>
+ <otherArchives>
+ <otherArchive>http://www.mail-archive.com/dev@maven.apache.org/</otherArchive>
+ <otherArchive>http://maven.40175.n5.nabble.com/Maven-Developers-f142166.html</otherArchive>
+ <otherArchive>http://maven-dev.markmail.org/</otherArchive>
+ </otherArchives>
+ </mailingList>
+ <mailingList>
+ <name>Maven User List</name>
+ <subscribe>users-subscribe at maven.apache.org</subscribe>
+ <unsubscribe>users-unsubscribe at maven.apache.org</unsubscribe>
+ <post>users at maven.apache.org</post>
+ <archive>http://mail-archives.apache.org/mod_mbox/maven-users</archive>
+ <otherArchives>
+ <otherArchive>http://www.mail-archive.com/users@maven.apache.org/</otherArchive>
+ <otherArchive>http://maven.40175.n5.nabble.com/Maven-Users-f40176.html</otherArchive>
+ <otherArchive>http://maven-users.markmail.org/</otherArchive>
+ </otherArchives>
+ </mailingList>
+
+ <mailingList>
+ <name>LEGACY Wagon User List (deprecated)</name>
+ <post>wagon-users at maven.apache.org</post>
+ <subscribe>wagon-users-subscribe at maven.apache.org</subscribe>
+ <unsubscribe>wagon-users-unsubscribe at maven.apache.org</unsubscribe>
+ <archive>http://mail-archives.apache.org/mod_mbox/maven-wagon-users/</archive>
+ <otherArchives>
+ <otherArchive>http://www.mail-archive.com/wagon-users@maven.apache.org</otherArchive>
+ <otherArchive>http://maven.40175.n5.nabble.com/Wagon-Users-f326332.html</otherArchive>
+ <otherArchive>http://maven-wagon-users.markmail.org/</otherArchive>
+ </otherArchives>
+ </mailingList>
+ <mailingList>
+ <name>LEGACY Wagon Developer List (deprecated)</name>
+ <post>wagon-dev at maven.apache.org</post>
+ <subscribe>wagon-dev-subscribe at maven.apache.org</subscribe>
+ <unsubscribe>wagon-dev-unsubscribe at maven.apache.org</unsubscribe>
+ <archive>http://mail-archives.apache.org/mod_mbox/maven-wagon-dev/</archive>
+ <otherArchives>
+ <otherArchive>http://www.mail-archive.com/wagon-dev@maven.apache.org</otherArchive>
+ <otherArchive>http://maven.40175.n5.nabble.com/Wagon-Dev-f326406.html</otherArchive>
+ <otherArchive>http://maven-wagon-dev.markmail.org/</otherArchive>
+ </otherArchives>
+ </mailingList>
+ <mailingList>
+ <name>Wagon Commits List</name>
+ <subscribe>wagon-commits-subscribe at maven.apache.org</subscribe>
+ <unsubscribe>wagon-commits-unsubscribe at maven.apache.org</unsubscribe>
+ <archive>http://mail-archives.apache.org/mod_mbox/maven-wagon-commits/</archive>
+ <otherArchives>
+ <otherArchive>http://maven-wagon-commits.markmail.org/</otherArchive>
+ </otherArchives>
+ </mailingList>
+ </mailingLists>
+
+ <scm>
+ <connection>scm:git:https://git-wip-us.apache.org/repos/asf/maven-wagon.git</connection>
+ <developerConnection>scm:git:https://git-wip-us.apache.org/repos/asf/maven-wagon.git</developerConnection>
+ <url>https://github.com/apache/maven-wagon/tree/${project.scm.tag}</url>
+ <tag>wagon-2.12</tag>
+ </scm>
+
+ <issueManagement>
+ <system>jira</system>
+ <url>https://issues.apache.org/jira/browse/WAGON</url>
+ </issueManagement>
+ <ciManagement>
+ <system>Jenkins</system>
+ <url>https://builds.apache.org/job/maven-wagon/</url>
+ </ciManagement>
+
+ <distributionManagement>
+ <site>
+ <id>apache.website</id>
+ <url>scm:svn:https://svn.apache.org/repos/infra/websites/production/maven/components/${maven.site.path}</url>
+ </site>
+ </distributionManagement>
+
+ <modules>
+ <module>wagon-provider-api</module>
+ <module>wagon-providers</module>
+ <module>wagon-provider-test</module>
+ <module>wagon-tcks</module>
+ </modules>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-provider-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-provider-test</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-ssh-common-test</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-ssh-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-interactivity-api</artifactId>
+ <version>1.0-alpha-6</version>
+ <exclusions>
+ <exclusion>
+ <groupId>plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>classworlds</groupId>
+ <artifactId>classworlds</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ <version>1.5.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>3.0.24</version>
+ </dependency>
+
+ <!-- for slf4j -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>${slf4jVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>${slf4jVersion}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <version>${slf4jVersion}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <version>2.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <version>3.2</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.jetty.aggregate</groupId>
+ <artifactId>jetty-all</artifactId>
+ <version>8.1.22.v20160922</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <version>3.0.1</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <forkedProcessTimeoutInSeconds>800</forkedProcessTimeoutInSeconds>
+ <systemPropertyVariables>
+ <java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ <plugin><!-- TODO remove when upgrading maven-parent to 25 -->
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-site-plugin</artifactId>
+ <configuration>
+ <topSiteURL>scm:svn:https://svn.apache.org/repos/infra/websites/production/maven/components/${maven.site.path}</topSiteURL>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <configuration>
+ <excludes combine.children="append">
+ <exclude>**/*.odg</exclude>
+ <exclude>src/test/resources/**</exclude>
+ <exclude>src/main/resources/default-server-root/**</exclude>
+ <exclude>src/main/resources/ssh-keys/**</exclude>
+ <exclude>src/test/ssh-keys/**</exclude>
+ <exclude>.repository/**</exclude><!-- for CI -->
+ </excludes>
+ </configuration>
+ </plugin>
+ <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
+ <plugin>
+ <groupId>org.eclipse.m2e</groupId>
+ <artifactId>lifecycle-mapping</artifactId>
+ <version>1.0.0</version>
+ <configuration>
+ <lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <versionRange>[0.11,)</versionRange>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <ignore />
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+ </lifecycleMappingMetadata>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-metadata</artifactId>
+ <executions>
+ <execution>
+ <id>generate</id>
+ <goals>
+ <goal>generate-metadata</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>animal-sniffer-maven-plugin</artifactId>
+ <version>1.15</version>
+ <configuration>
+ <signature>
+ <groupId>org.codehaus.mojo.signature</groupId>
+ <artifactId>java15</artifactId>
+ <version>1.0</version>
+ </signature>
+ </configuration>
+ <executions>
+ <execution>
+ <id>check-java-1.5-compat</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <requireJavaVersion>
+ <version>1.6.0</version>
+ </requireJavaVersion>
+ </rules>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+
+ <profile>
+ <id>reporting</id>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <configuration>
+ <linksource>true</linksource>
+ <links>
+ <link>http://java.sun.com/j2ee/1.4/docs/api</link>
+ <link>http://commons.apache.org/collections/apidocs-COLLECTIONS_3_0/</link>
+ <link>http://commons.apache.org/logging/apidocs/</link>
+ <link>http://commons.apache.org/pool/apidocs/</link>
+ <link>http://junit.sourceforge.net/javadoc/</link>
+ <link>http://logging.apache.org/log4j/1.2/apidocs/</link>
+ <link>http://jakarta.apache.org/regexp/apidocs/</link>
+ <link>http://velocity.apache.org/engine/releases/velocity-1.5/apidocs/</link>
+ <link>http://maven.apache.org/ref/current/maven-artifact/apidocs/</link>
+ <link>http://maven.apache.org/ref/current/maven-artifact-manager/apidocs/</link>
+ <link>http://maven.apache.org/ref/current/maven-model/apidocs/</link>
+ <link>http://maven.apache.org/ref/current/maven-plugin-api/apidocs/</link>
+ <link>http://maven.apache.org/ref/current/maven-project/apidocs/</link>
+ <link>http://maven.apache.org/ref/current/maven-reporting/maven-reporting-api/apidocs/</link>
+ <link>http://maven.apache.org/ref/current/maven-settings/apidocs/</link>
+ </links>
+ <groups>
+ <group>
+ <title>API + Test</title>
+ <packages>org.apache.maven.wagon*</packages>
+ </group>
+ <group>
+ <title>File Provider</title>
+ <packages>org.apache.maven.wagon.providers.file*</packages>
+ </group>
+ <group>
+ <title>FTP Provider</title>
+ <packages>org.apache.maven.wagon.providers.ftp*</packages>
+ </group>
+ <group>
+ <title>HTTP Providers</title>
+ <packages>org.apache.maven.wagon.providers.http*:org.apache.maven.wagon.shared.http*</packages>
+ </group>
+ <group>
+ <title>SCM Provider</title>
+ <packages>org.apache.maven.wagon.providers.scm*</packages>
+ </group>
+ <group>
+ <title>SSH Providers</title>
+ <packages>org.apache.maven.wagon.providers.ssh*</packages>
+ </group>
+ <group>
+ <title>WebDAV Provider</title>
+ <packages>org.apache.maven.wagon.providers.webdav*:org.apache.jackrabbit.webdav*</packages>
+ </group>
+ <group>
+ <title>HTTP TCK</title>
+ <packages>org.apache.maven.wagon.tck.http*</packages>
+ </group>
+ </groups>
+ </configuration>
+ <reportSets>
+ <reportSet>
+ <id>non-aggregate</id>
+ <reports>
+ <report>javadoc</report>
+ <report>test-javadoc</report>
+ </reports>
+ </reportSet>
+ <reportSet>
+ <id>aggregate</id>
+ <inherited>false</inherited>
+ <reports>
+ <report>aggregate</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jxr-plugin</artifactId>
+ <reportSets>
+ <reportSet>
+ <id>non-aggregate</id>
+ <reports>
+ <report>jxr</report>
+ <report>test-jxr</report>
+ </reports>
+ </reportSet>
+ <reportSet>
+ <id>aggregate</id>
+ <inherited>false</inherited>
+ <reports>
+ <report>aggregate</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <reportSets>
+ <reportSet>
+ <id>non-aggregate</id>
+ <reports>
+ <report>checkstyle</report>
+ </reports>
+ </reportSet>
+ <reportSet>
+ <id>aggregate</id>
+ <inherited>false</inherited>
+ <reports>
+ <report>checkstyle-aggregate</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ </plugins>
+ </reporting>
+ </profile>
+ </profiles>
+
+</project>
diff --git a/src/main/assembly/source-release.xml b/src/main/assembly/source-release.xml
index a78f489..ae4a9af 100644
--- a/src/main/assembly/source-release.xml
+++ b/src/main/assembly/source-release.xml
@@ -1,46 +1,46 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-
-<assembly>
- <id>source-release</id>
- <formats>
- <format>tar.gz</format>
- <format>tar.bz2</format>
- <format>zip</format>
- </formats>
- <fileSets>
- <fileSet>
- <directory>${project.basedir}</directory>
- <outputDirectory>/</outputDirectory>
- <useDefaultExcludes>true</useDefaultExcludes>
- <excludes>
- <exclude>*.log</exclude>
- <exclude>%regex[(?!.*src/).*${project.build.directory}.*]</exclude>
- </excludes>
- </fileSet>
- <fileSet>
- <directory>${project.build.directory}/maven-shared-archive-resources/META-INF</directory>
- <outputDirectory>/</outputDirectory>
- <excludes>
- <exclude>DEPENDENCIES</exclude>
- </excludes>
- </fileSet>
- </fileSets>
-</assembly>
+<?xml version='1.0' encoding='UTF-8'?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+
+<assembly>
+ <id>source-release</id>
+ <formats>
+ <format>tar.gz</format>
+ <format>tar.bz2</format>
+ <format>zip</format>
+ </formats>
+ <fileSets>
+ <fileSet>
+ <directory>${project.basedir}</directory>
+ <outputDirectory>/</outputDirectory>
+ <useDefaultExcludes>true</useDefaultExcludes>
+ <excludes>
+ <exclude>*.log</exclude>
+ <exclude>%regex[(?!.*src/).*${project.build.directory}.*]</exclude>
+ </excludes>
+ </fileSet>
+ <fileSet>
+ <directory>${project.build.directory}/maven-shared-archive-resources/META-INF</directory>
+ <outputDirectory>/</outputDirectory>
+ <excludes>
+ <exclude>DEPENDENCIES</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+</assembly>
diff --git a/src/site/apt/privacy-policy.apt b/src/site/apt/privacy-policy.apt
index a683d54..818a0f4 100644
--- a/src/site/apt/privacy-policy.apt
+++ b/src/site/apt/privacy-policy.apt
@@ -1,55 +1,55 @@
- ----
- Privacy Policy
- -----
- Olivier Lamy
- -----
- 2012-06-18
- -----
-
-~~ Licensed to the Apache Software Foundation (ASF) under one
-~~ or more contributor license agreements. See the NOTICE file
-~~ distributed with this work for additional information
-~~ regarding copyright ownership. The ASF licenses this file
-~~ to you under the Apache License, Version 2.0 (the
-~~ "License"); you may not use this file except in compliance
-~~ with the License. You may obtain a copy of the License at
-~~
-~~ http://www.apache.org/licenses/LICENSE-2.0
-~~
-~~ Unless required by applicable law or agreed to in writing,
-~~ software distributed under the License is distributed on an
-~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-~~ KIND, either express or implied. See the License for the
-~~ specific language governing permissions and limitations
-~~ under the License.
-
-~~ NOTE: For help with the syntax of this file, see:
-~~ http://maven.apache.org/doxia/references/apt-format.html
-
-Privacy Policy
-
- Information about your use of this website is collected using server access logs and a tracking cookie. The
- collected information consists of the following:
-
- [[1]] The IP address from which you access the website;
-
- [[2]] The type of browser and operating system you use to access our site;
-
- [[3]] The date and time you access our site;
-
- [[4]] The pages you visit; and
-
- [[5]] The addresses of pages from where you followed a link to our site.
-
- []
-
- Part of this information is gathered using a tracking cookie set by the
- {{{http://www.google.com/analytics/}Google Analytics}} service and handled by Google as described in their
- {{{http://www.google.com/privacy.html}privacy policy}}. See your browser documentation for instructions on how to
- disable the cookie if you prefer not to share this data with Google.
-
- We use the gathered information to help us make our site more useful to visitors and to better understand how and
- when our site is used. We do not track or collect personally identifiable information or associate gathered data
- with any personally identifying information from other sources.
-
+ ----
+ Privacy Policy
+ -----
+ Olivier Lamy
+ -----
+ 2012-06-18
+ -----
+
+~~ Licensed to the Apache Software Foundation (ASF) under one
+~~ or more contributor license agreements. See the NOTICE file
+~~ distributed with this work for additional information
+~~ regarding copyright ownership. The ASF licenses this file
+~~ to you under the Apache License, Version 2.0 (the
+~~ "License"); you may not use this file except in compliance
+~~ with the License. You may obtain a copy of the License at
+~~
+~~ http://www.apache.org/licenses/LICENSE-2.0
+~~
+~~ Unless required by applicable law or agreed to in writing,
+~~ software distributed under the License is distributed on an
+~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+~~ KIND, either express or implied. See the License for the
+~~ specific language governing permissions and limitations
+~~ under the License.
+
+~~ NOTE: For help with the syntax of this file, see:
+~~ http://maven.apache.org/doxia/references/apt-format.html
+
+Privacy Policy
+
+ Information about your use of this website is collected using server access logs and a tracking cookie. The
+ collected information consists of the following:
+
+ [[1]] The IP address from which you access the website;
+
+ [[2]] The type of browser and operating system you use to access our site;
+
+ [[3]] The date and time you access our site;
+
+ [[4]] The pages you visit; and
+
+ [[5]] The addresses of pages from where you followed a link to our site.
+
+ []
+
+ Part of this information is gathered using a tracking cookie set by the
+ {{{http://www.google.com/analytics/}Google Analytics}} service and handled by Google as described in their
+ {{{http://www.google.com/privacy.html}privacy policy}}. See your browser documentation for instructions on how to
+ disable the cookie if you prefer not to share this data with Google.
+
+ We use the gathered information to help us make our site more useful to visitors and to better understand how and
+ when our site is used. We do not track or collect personally identifiable information or associate gathered data
+ with any personally identifying information from other sources.
+
By using this website, you consent to the collection of this data in the manner and for the purpose described above.
\ No newline at end of file
diff --git a/src/site/resources/download.cgi b/src/site/resources/download.cgi
index 1b178d2..015d8ae 100644
--- a/src/site/resources/download.cgi
+++ b/src/site/resources/download.cgi
@@ -1,22 +1,22 @@
-#!/bin/sh
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-# Just call the standard mirrors.cgi script. It will use download.html
-# as the input template.
+#!/bin/sh
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# Just call the standard mirrors.cgi script. It will use download.html
+# as the input template.
exec /www/www.apache.org/dyn/mirrors/mirrors.cgi $*
\ No newline at end of file
diff --git a/src/site/site.xml b/src/site/site.xml
index 766f399..1a26fb0 100644
--- a/src/site/site.xml
+++ b/src/site/site.xml
@@ -1,79 +1,79 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
- <version position="right" />
-
- <bannerLeft>
- <name>${project.name}</name>
- <src>http://maven.apache.org/images/apache-maven-project.png</src>
- <href>http://maven.apache.org/</href>
- </bannerLeft>
- <bannerRight>
- <src>http://maven.apache.org/images/maventxt_logo_200.gif</src>
- </bannerRight>
-
- <skin>
- <groupId>org.apache.maven.skins</groupId>
- <artifactId>maven-fluido-skin</artifactId>
- <version>1.3.0</version>
- </skin>
-
- <custom>
- <fluidoSkin>
- <topBarEnabled>true</topBarEnabled>
- <sideBarEnabled>false</sideBarEnabled>
- <leftColumnClass>span2</leftColumnClass>
- <bodyColumnClass>span10</bodyColumnClass>
- <googleSearch>
- <sitesearch>${project.url}</sitesearch>
- </googleSearch>
- </fluidoSkin>
-
- </custom>
-
- <body>
- <breadcrumbs>
- <item name="Wagon" href="http://maven.apache.org/wagon/index.html" />
- </breadcrumbs>
- <menu name="Overview">
- <item name="Introduction" href="index.html"/>
- <item name="JavaDocs" href="apidocs/index.html"/>
- <!-- According to http://jira.codehaus.org/browse/MNGSITE-152 -->
- <item name="License" href="http://www.apache.org/licenses/"/>
- <item name="Download" href="download.html"/>
- </menu>
- <menu ref="modules" />
- <menu ref="reports" />
-
-
- <footer>
- <div class="row span16"><div>Apache Maven, Apache, the Apache feather logo, and the Apache Maven project logos are trademarks of The Apache Software Foundation.
- All other marks mentioned may be trademarks or registered trademarks of their respective owners.</div>
- <a href="${project.url}/privacy-policy.html">Privacy Policy</a>
- </div>
- </footer>
-
- </body>
-
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
+ <version position="right" />
+
+ <bannerLeft>
+ <name>${project.name}</name>
+ <src>http://maven.apache.org/images/apache-maven-project.png</src>
+ <href>http://maven.apache.org/</href>
+ </bannerLeft>
+ <bannerRight>
+ <src>http://maven.apache.org/images/maventxt_logo_200.gif</src>
+ </bannerRight>
+
+ <skin>
+ <groupId>org.apache.maven.skins</groupId>
+ <artifactId>maven-fluido-skin</artifactId>
+ <version>1.3.0</version>
+ </skin>
+
+ <custom>
+ <fluidoSkin>
+ <topBarEnabled>true</topBarEnabled>
+ <sideBarEnabled>false</sideBarEnabled>
+ <leftColumnClass>span2</leftColumnClass>
+ <bodyColumnClass>span10</bodyColumnClass>
+ <googleSearch>
+ <sitesearch>${project.url}</sitesearch>
+ </googleSearch>
+ </fluidoSkin>
+
+ </custom>
+
+ <body>
+ <breadcrumbs>
+ <item name="Wagon" href="http://maven.apache.org/wagon/index.html" />
+ </breadcrumbs>
+ <menu name="Overview">
+ <item name="Introduction" href="index.html"/>
+ <item name="JavaDocs" href="apidocs/index.html"/>
+ <!-- According to http://jira.codehaus.org/browse/MNGSITE-152 -->
+ <item name="License" href="http://www.apache.org/licenses/"/>
+ <item name="Download" href="download.html"/>
+ </menu>
+ <menu ref="modules" />
+ <menu ref="reports" />
+
+
+ <footer>
+ <div class="row span16"><div>Apache Maven, Apache, the Apache feather logo, and the Apache Maven project logos are trademarks of The Apache Software Foundation.
+ All other marks mentioned may be trademarks or registered trademarks of their respective owners.</div>
+ <a href="${project.url}/privacy-policy.html">Privacy Policy</a>
+ </div>
+ </footer>
+
+ </body>
+
+</project>
diff --git a/src/site/xdoc/download.xml.vm b/src/site/xdoc/download.xml.vm
index 8817f80..3085c58 100644
--- a/src/site/xdoc/download.xml.vm
+++ b/src/site/xdoc/download.xml.vm
@@ -1,126 +1,126 @@
-<?xml version="1.0"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<document>
- <properties>
- <title>Download ${project.name} Source</title>
- </properties>
- <body>
- <section name="Download ${project.name} ${project.version} Source">
-
- <p>${project.name} ${project.version} is distributed in source format. Use a source archive if you intend to build
- ${project.name} yourself. Otherwise, simply use the ready-made binary artifacts from central repository.</p>
-
- <p>You will be prompted for a mirror - if the file is not found on yours, please be patient, as it may take 24
- hours to reach all mirrors.<p/>
-
- <p>In order to guard against corrupted downloads/installations, it is highly recommended to
- <a href="http://www.apache.org/dev/release-signing#verifying-signature">verify the signature</a>
- of the release bundles against the public <a href="http://www.apache.org/dist/maven/KEYS">KEYS</a> used by the Apache Maven
- developers.</p>
-
- <p>${project.name} is distributed under the <a href="http://www.apache.org/licenses/">Apache License, version 2.0</a>.</p>
-
- <p></p>We <b>strongly</b> encourage our users to configure a Maven repository mirror closer to their location, please read <a href="./guides/mini/guide-mirror-settings.html">How to Use Mirrors for Repositories</a>.</p>
-
- <a name="mirror"/>
- <subsection name="Mirror">
-
- <p>
- [if-any logo]
- <a href="[link]">
- <img align="right" src="[logo]" border="0"
- alt="logo"/>
- </a>
- [end]
- The currently selected mirror is
- <b>[preferred]</b>.
- If you encounter a problem with this mirror,
- please select another mirror.
- If all mirrors are failing, there are
- <i>backup</i>
- mirrors
- (at the end of the mirrors list) that should be available.
- </p>
-
- <form action="[location]" method="get" id="SelectMirror">
- Other mirrors:
- <select name="Preferred">
- [if-any http]
- [for http]
- <option value="[http]">[http]</option>
- [end]
- [end]
- [if-any ftp]
- [for ftp]
- <option value="[ftp]">[ftp]</option>
- [end]
- [end]
- [if-any backup]
- [for backup]
- <option value="[backup]">[backup] (backup)</option>
- [end]
- [end]
- </select>
- <input type="submit" value="Change"/>
- </form>
-
- <p>
- You may also consult the
- <a href="http://www.apache.org/mirrors/">complete list of
- mirrors.</a>
- </p>
-
- </subsection>
-
- <subsection name="${project.name} ${project.version}">
-
- <p>This is the current stable version of ${project.name}.</p>
-
- <table>
- <thead>
- <tr>
- <th></th>
- <th>Link</th>
- <th>Checksum</th>
- <th>Signature</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>${project.name} ${project.version} (Source zip)</td>
- <td><a href="[preferred]maven/wagon/${project.artifactId}-${project.version}-source-release.zip">maven/wagon/${project.artifactId}-${project.version}-source-release.zip</a></td>
- <td><a href="http://www.apache.org/dist/maven/wagon/${project.artifactId}-${project.version}-source-release.zip.md5">maven/wagon/${project.artifactId}-${project.version}-source-release.zip.md5</a></td>
- <td><a href="http://www.apache.org/dist/maven/wagon/${project.artifactId}-${project.version}-source-release.zip.asc">maven/wagon/${project.artifactId}-${project.version}-source-release.zip.asc</a></td>
- </tr>
- </tbody>
- </table>
- </subsection>
-
- <subsection name="Previous Versions">
-
- <p>Older non-recommended releases can be found on our <a href="http://archive.apache.org/dist/maven/wagon/">archive site</a>.</p>
-
- </subsection>
- </section>
- </body>
-</document>
-
+<?xml version="1.0"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<document>
+ <properties>
+ <title>Download ${project.name} Source</title>
+ </properties>
+ <body>
+ <section name="Download ${project.name} ${project.version} Source">
+
+ <p>${project.name} ${project.version} is distributed in source format. Use a source archive if you intend to build
+ ${project.name} yourself. Otherwise, simply use the ready-made binary artifacts from central repository.</p>
+
+ <p>You will be prompted for a mirror - if the file is not found on yours, please be patient, as it may take 24
+ hours to reach all mirrors.<p/>
+
+ <p>In order to guard against corrupted downloads/installations, it is highly recommended to
+ <a href="http://www.apache.org/dev/release-signing#verifying-signature">verify the signature</a>
+ of the release bundles against the public <a href="http://www.apache.org/dist/maven/KEYS">KEYS</a> used by the Apache Maven
+ developers.</p>
+
+ <p>${project.name} is distributed under the <a href="http://www.apache.org/licenses/">Apache License, version 2.0</a>.</p>
+
+ <p></p>We <b>strongly</b> encourage our users to configure a Maven repository mirror closer to their location, please read <a href="./guides/mini/guide-mirror-settings.html">How to Use Mirrors for Repositories</a>.</p>
+
+ <a name="mirror"/>
+ <subsection name="Mirror">
+
+ <p>
+ [if-any logo]
+ <a href="[link]">
+ <img align="right" src="[logo]" border="0"
+ alt="logo"/>
+ </a>
+ [end]
+ The currently selected mirror is
+ <b>[preferred]</b>.
+ If you encounter a problem with this mirror,
+ please select another mirror.
+ If all mirrors are failing, there are
+ <i>backup</i>
+ mirrors
+ (at the end of the mirrors list) that should be available.
+ </p>
+
+ <form action="[location]" method="get" id="SelectMirror">
+ Other mirrors:
+ <select name="Preferred">
+ [if-any http]
+ [for http]
+ <option value="[http]">[http]</option>
+ [end]
+ [end]
+ [if-any ftp]
+ [for ftp]
+ <option value="[ftp]">[ftp]</option>
+ [end]
+ [end]
+ [if-any backup]
+ [for backup]
+ <option value="[backup]">[backup] (backup)</option>
+ [end]
+ [end]
+ </select>
+ <input type="submit" value="Change"/>
+ </form>
+
+ <p>
+ You may also consult the
+ <a href="http://www.apache.org/mirrors/">complete list of
+ mirrors.</a>
+ </p>
+
+ </subsection>
+
+ <subsection name="${project.name} ${project.version}">
+
+ <p>This is the current stable version of ${project.name}.</p>
+
+ <table>
+ <thead>
+ <tr>
+ <th></th>
+ <th>Link</th>
+ <th>Checksum</th>
+ <th>Signature</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>${project.name} ${project.version} (Source zip)</td>
+ <td><a href="[preferred]maven/wagon/${project.artifactId}-${project.version}-source-release.zip">maven/wagon/${project.artifactId}-${project.version}-source-release.zip</a></td>
+ <td><a href="http://www.apache.org/dist/maven/wagon/${project.artifactId}-${project.version}-source-release.zip.md5">maven/wagon/${project.artifactId}-${project.version}-source-release.zip.md5</a></td>
+ <td><a href="http://www.apache.org/dist/maven/wagon/${project.artifactId}-${project.version}-source-release.zip.asc">maven/wagon/${project.artifactId}-${project.version}-source-release.zip.asc</a></td>
+ </tr>
+ </tbody>
+ </table>
+ </subsection>
+
+ <subsection name="Previous Versions">
+
+ <p>Older non-recommended releases can be found on our <a href="http://archive.apache.org/dist/maven/wagon/">archive site</a>.</p>
+
+ </subsection>
+ </section>
+ </body>
+</document>
+
diff --git a/src/site/xdoc/index.xml b/src/site/xdoc/index.xml
index 88c3c6b..29be5df 100644
--- a/src/site/xdoc/index.xml
+++ b/src/site/xdoc/index.xml
@@ -1,79 +1,79 @@
-<?xml version="1.0"?>
-
-<!--
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
--->
-
-<document xmlns="http://maven.apache.org/XDOC/2.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
-
- <properties>
- <title>Introduction</title>
- <author>Jason van Zyl</author>
- <author email="hboutemy_AT_apache_DOT_org">Hervé Boutemy</author>
- </properties>
-
- <body>
-
- <section name="Maven Wagon">
-
- <p>Maven Wagon is a transport abstraction that is used in Maven's artifact and
- repository handling code.</p>
-
- <p>Wagon defines a <a href="./wagon-provider-api/">unified API</a>, and it currently has the following providers:</p>
- <ul>
- <li><a href="./wagon-providers/wagon-file/">File</a></li>
- <li><a href="./wagon-providers/wagon-http/">HTTP</a></li>
- <li><a href="./wagon-providers/wagon-http-lightweight/">HTTP lightweight</a></li>
- <li><a href="./wagon-providers/wagon-ftp/">FTP</a></li>
- <li><a href="./wagon-providers/wagon-ssh/">SSH/SCP</a></li>
- <li><a href="./wagon-providers/wagon-webdav-jackrabbit/">WebDAV</a></li>
- <li><a href="./wagon-providers/wagon-scm/">SCM</a> (in progress)</li>
- </ul>
-
- <p>
- <img src="images/wagon-deps.png" width="529" height="398" border="0" usemap="#Wagon_dependencies" alt="Wagon Dependencies"/>
- <map name="Wagon_dependencies" id="Wagon_dependencies">
- <area shape="rect" coords="94,0,221,32" alt="wagon-provider-api" href="./wagon-provider-api/" />
- <area shape="rect" coords="330,0,459,32" alt="wagon-provider-test" href="./wagon-provider-test/" />
- <area shape="rect" coords="329,37,425,70" alt="wagon-tck-http" href="./wagon-tcks/wagon-tck-http/" />
- <area shape="rect" coords="159,68,226,100" alt="wagon-file" href="./wagon-providers/wagon-file/" />
- <area shape="rect" coords="13,133,138,164" alt="wagon-http-shared" href="./wagon-providers/wagon-http-shared/" />
- <area shape="rect" coords="159,110,304,141" alt="wagon-http-lightweight" href="./wagon-providers/wagon-http-lightweight/" />
- <area shape="rect" coords="159,151,226,183" alt="wagon-http" href="./wagon-providers/wagon-http/" />
- <area shape="rect" coords="159,193,257,225" alt="wagon-webdav-jackrabbit" href="./wagon-providers/wagon-webdav-jackrabbit/" />
- <area shape="rect" coords="159,234,226,266" alt="wagon-ftp" href="./wagon-providers/wagon-ftp/" />
- <area shape="rect" coords="12,298,134,330" alt="wagon-ssh-common" href="./wagon-providers/wagon-ssh-common/" />
- <area shape="rect" coords="159,276,282,308" alt="wagon-ssh-external" href="./wagon-providers/wagon-ssh-external/" />
- <area shape="rect" coords="159,317,226,349" alt="wagon-ssh" href="./wagon-providers/wagon-ssh/" />
- <area shape="rect" coords="159,359,226,391" alt="wagon-scm" href="./wagon-providers/wagon-scm/" />
- <area shape="rect" coords="0,61,315,397" alt="wagon-providers" href="./wagon-providers/" />
- <area shape="rect" coords="339,150,528,183" alt="HttpComponents" href="http://hc.apache.org/" />
- <area shape="rect" coords="340,193,455,225" alt="Jackrabbit" href="http://jackrabbit.apache.org/" />
- <area shape="rect" coords="340,234,480,266" alt="Commons Net" href="http://commons.apache.org/net/" />
- <area shape="rect" coords="340,318,405,350" alt="jsch" href="http://www.jcraft.com/jsch/" />
- <area shape="rect" coords="340,358,493,391" alt="maven-scm-api" href="/scm/maven-scm-api/" />
- </map>
- </p>
-
- </section>
-
- </body>
-
-</document>
+<?xml version="1.0"?>
+
+<!--
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+-->
+
+<document xmlns="http://maven.apache.org/XDOC/2.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd">
+
+ <properties>
+ <title>Introduction</title>
+ <author>Jason van Zyl</author>
+ <author email="hboutemy_AT_apache_DOT_org">Hervé Boutemy</author>
+ </properties>
+
+ <body>
+
+ <section name="Maven Wagon">
+
+ <p>Maven Wagon is a transport abstraction that is used in Maven's artifact and
+ repository handling code.</p>
+
+ <p>Wagon defines a <a href="./wagon-provider-api/">unified API</a>, and it currently has the following providers:</p>
+ <ul>
+ <li><a href="./wagon-providers/wagon-file/">File</a></li>
+ <li><a href="./wagon-providers/wagon-http/">HTTP</a></li>
+ <li><a href="./wagon-providers/wagon-http-lightweight/">HTTP lightweight</a></li>
+ <li><a href="./wagon-providers/wagon-ftp/">FTP</a></li>
+ <li><a href="./wagon-providers/wagon-ssh/">SSH/SCP</a></li>
+ <li><a href="./wagon-providers/wagon-webdav-jackrabbit/">WebDAV</a></li>
+ <li><a href="./wagon-providers/wagon-scm/">SCM</a> (in progress)</li>
+ </ul>
+
+ <p>
+ <img src="images/wagon-deps.png" width="529" height="398" border="0" usemap="#Wagon_dependencies" alt="Wagon Dependencies"/>
+ <map name="Wagon_dependencies" id="Wagon_dependencies">
+ <area shape="rect" coords="94,0,221,32" alt="wagon-provider-api" href="./wagon-provider-api/" />
+ <area shape="rect" coords="330,0,459,32" alt="wagon-provider-test" href="./wagon-provider-test/" />
+ <area shape="rect" coords="329,37,425,70" alt="wagon-tck-http" href="./wagon-tcks/wagon-tck-http/" />
+ <area shape="rect" coords="159,68,226,100" alt="wagon-file" href="./wagon-providers/wagon-file/" />
+ <area shape="rect" coords="13,133,138,164" alt="wagon-http-shared" href="./wagon-providers/wagon-http-shared/" />
+ <area shape="rect" coords="159,110,304,141" alt="wagon-http-lightweight" href="./wagon-providers/wagon-http-lightweight/" />
+ <area shape="rect" coords="159,151,226,183" alt="wagon-http" href="./wagon-providers/wagon-http/" />
+ <area shape="rect" coords="159,193,257,225" alt="wagon-webdav-jackrabbit" href="./wagon-providers/wagon-webdav-jackrabbit/" />
+ <area shape="rect" coords="159,234,226,266" alt="wagon-ftp" href="./wagon-providers/wagon-ftp/" />
+ <area shape="rect" coords="12,298,134,330" alt="wagon-ssh-common" href="./wagon-providers/wagon-ssh-common/" />
+ <area shape="rect" coords="159,276,282,308" alt="wagon-ssh-external" href="./wagon-providers/wagon-ssh-external/" />
+ <area shape="rect" coords="159,317,226,349" alt="wagon-ssh" href="./wagon-providers/wagon-ssh/" />
+ <area shape="rect" coords="159,359,226,391" alt="wagon-scm" href="./wagon-providers/wagon-scm/" />
+ <area shape="rect" coords="0,61,315,397" alt="wagon-providers" href="./wagon-providers/" />
+ <area shape="rect" coords="339,150,528,183" alt="HttpComponents" href="http://hc.apache.org/" />
+ <area shape="rect" coords="340,193,455,225" alt="Jackrabbit" href="http://jackrabbit.apache.org/" />
+ <area shape="rect" coords="340,234,480,266" alt="Commons Net" href="http://commons.apache.org/net/" />
+ <area shape="rect" coords="340,318,405,350" alt="jsch" href="http://www.jcraft.com/jsch/" />
+ <area shape="rect" coords="340,358,493,391" alt="maven-scm-api" href="/scm/maven-scm-api/" />
+ </map>
+ </p>
+
+ </section>
+
+ </body>
+
+</document>
diff --git a/wagon-provider-api/pom.xml b/wagon-provider-api/pom.xml
index b3f06ee..12f8add 100644
--- a/wagon-provider-api/pom.xml
+++ b/wagon-provider-api/pom.xml
@@ -1,45 +1,50 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon</artifactId>
- <version>2.10</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>wagon-provider-api</artifactId>
- <name>Apache Maven Wagon :: API</name>
- <description>Maven Wagon API that defines the contract between different Wagon implementations</description>
-
- <dependencies>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon</artifactId>
+ <version>2.12</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>wagon-provider-api</artifactId>
+ <name>Apache Maven Wagon :: API</name>
+ <description>Maven Wagon API that defines the contract between different Wagon implementations</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java
index e808dc3..9b83309 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java
@@ -1,915 +1,959 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
-import org.apache.maven.wagon.authorization.AuthorizationException;
-import org.apache.maven.wagon.events.SessionEvent;
-import org.apache.maven.wagon.events.SessionEventSupport;
-import org.apache.maven.wagon.events.SessionListener;
-import org.apache.maven.wagon.events.TransferEvent;
-import org.apache.maven.wagon.events.TransferEventSupport;
-import org.apache.maven.wagon.events.TransferListener;
-import org.apache.maven.wagon.proxy.ProxyInfo;
-import org.apache.maven.wagon.proxy.ProxyInfoProvider;
-import org.apache.maven.wagon.proxy.ProxyUtils;
-import org.apache.maven.wagon.repository.Repository;
-import org.apache.maven.wagon.repository.RepositoryPermissions;
-import org.apache.maven.wagon.resource.Resource;
-import org.codehaus.plexus.util.IOUtil;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.List;
-
-/**
- * Implementation of common facilities for Wagon providers.
- *
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- */
-public abstract class AbstractWagon
- implements Wagon
-{
- protected static final int DEFAULT_BUFFER_SIZE = 1024 * 4;
-
- protected Repository repository;
-
- protected SessionEventSupport sessionEventSupport = new SessionEventSupport();
-
- protected TransferEventSupport transferEventSupport = new TransferEventSupport();
-
- protected AuthenticationInfo authenticationInfo;
-
- protected boolean interactive = true;
-
-
- private int connectionTimeout = DEFAULT_CONNECTION_TIMEOUT;
-
- /**
- * read timeout value
- *
- * @since 2.2
- */
- private int readTimeout =
- Integer.parseInt( System.getProperty( "maven.wagon.rto", Integer.toString( Wagon.DEFAULT_READ_TIMEOUT ) ) );
-
- private ProxyInfoProvider proxyInfoProvider;
-
- /**
- * @deprecated
- */
- protected ProxyInfo proxyInfo;
-
- private RepositoryPermissions permissionsOverride;
-
- // ----------------------------------------------------------------------
- // Accessors
- // ----------------------------------------------------------------------
-
- public Repository getRepository()
- {
- return repository;
- }
-
- public ProxyInfo getProxyInfo()
- {
- return proxyInfoProvider != null ? proxyInfoProvider.getProxyInfo( null ) : null;
- }
-
- public AuthenticationInfo getAuthenticationInfo()
- {
- return authenticationInfo;
- }
-
- // ----------------------------------------------------------------------
- // Connection
- // ----------------------------------------------------------------------
-
- public void openConnection()
- throws ConnectionException, AuthenticationException
- {
- try
- {
- openConnectionInternal();
- }
- catch ( ConnectionException e )
- {
- fireSessionConnectionRefused();
-
- throw e;
- }
- catch ( AuthenticationException e )
- {
- fireSessionConnectionRefused();
-
- throw e;
- }
- }
-
- public void connect( Repository repository )
- throws ConnectionException, AuthenticationException
- {
- connect( repository, null, (ProxyInfoProvider) null );
- }
-
- public void connect( Repository repository, ProxyInfo proxyInfo )
- throws ConnectionException, AuthenticationException
- {
- connect( repository, null, proxyInfo );
- }
-
- public void connect( Repository repository, ProxyInfoProvider proxyInfoProvider )
- throws ConnectionException, AuthenticationException
- {
- connect( repository, null, proxyInfoProvider );
- }
-
- public void connect( Repository repository, AuthenticationInfo authenticationInfo )
- throws ConnectionException, AuthenticationException
- {
- connect( repository, authenticationInfo, (ProxyInfoProvider) null );
- }
-
- public void connect( Repository repository, AuthenticationInfo authenticationInfo, ProxyInfo proxyInfo )
- throws ConnectionException, AuthenticationException
- {
- final ProxyInfo proxy = proxyInfo;
- connect( repository, authenticationInfo, new ProxyInfoProvider()
- {
- public ProxyInfo getProxyInfo( String protocol )
- {
- if ( protocol == null || proxy == null || protocol.equalsIgnoreCase( proxy.getType() ) )
- {
- return proxy;
- }
- else
- {
- return null;
- }
- }
- } );
- }
-
- public void connect( Repository repository, AuthenticationInfo authenticationInfo,
- ProxyInfoProvider proxyInfoProvider )
- throws ConnectionException, AuthenticationException
- {
- if ( repository == null )
- {
- throw new IllegalStateException( "The repository specified cannot be null." );
- }
-
- if ( permissionsOverride != null )
- {
- repository.setPermissions( permissionsOverride );
- }
-
- this.repository = repository;
-
- if ( authenticationInfo == null )
- {
- authenticationInfo = new AuthenticationInfo();
- }
-
- if ( authenticationInfo.getUserName() == null )
- {
- // Get user/pass that were encoded in the URL.
- if ( repository.getUsername() != null )
- {
- authenticationInfo.setUserName( repository.getUsername() );
- if ( repository.getPassword() != null && authenticationInfo.getPassword() == null )
- {
- authenticationInfo.setPassword( repository.getPassword() );
- }
- }
- }
-
- // TODO: Do these needs to be fields, or are they only used in openConnection()?
- this.authenticationInfo = authenticationInfo;
-
- this.proxyInfoProvider = proxyInfoProvider;
-
- fireSessionOpening();
-
- openConnection();
-
- fireSessionOpened();
- }
-
- protected abstract void openConnectionInternal()
- throws ConnectionException, AuthenticationException;
-
- public void disconnect()
- throws ConnectionException
- {
- fireSessionDisconnecting();
-
- try
- {
- closeConnection();
- }
- catch ( ConnectionException e )
- {
- fireSessionError( e );
- throw e;
- }
-
- fireSessionDisconnected();
- }
-
- protected abstract void closeConnection()
- throws ConnectionException;
-
- protected void createParentDirectories( File destination )
- throws TransferFailedException
- {
- File destinationDirectory = destination.getParentFile();
- try
- {
- destinationDirectory = destinationDirectory.getCanonicalFile();
- }
- catch ( IOException e )
- {
- // not essential to have a canonical file
- }
- if ( destinationDirectory != null && !destinationDirectory.exists() )
- {
- destinationDirectory.mkdirs();
- if ( !destinationDirectory.exists() )
- {
- throw new TransferFailedException(
- "Specified destination directory cannot be created: " + destinationDirectory );
- }
- }
- }
-
- public void setTimeout( int timeoutValue )
- {
- connectionTimeout = timeoutValue;
- }
-
- public int getTimeout()
- {
- return connectionTimeout;
- }
-
- // ----------------------------------------------------------------------
- // Stream i/o
- // ----------------------------------------------------------------------
-
- protected void getTransfer( Resource resource, File destination, InputStream input )
- throws TransferFailedException
- {
- getTransfer( resource, destination, input, true, Long.MAX_VALUE );
- }
-
- protected void getTransfer( Resource resource, OutputStream output, InputStream input )
- throws TransferFailedException
- {
- getTransfer( resource, output, input, true, Long.MAX_VALUE );
- }
-
- @Deprecated
- protected void getTransfer( Resource resource, File destination, InputStream input, boolean closeInput,
- int maxSize )
- throws TransferFailedException
- {
- getTransfer( resource, destination, input, closeInput, (long) maxSize );
- }
-
- protected void getTransfer( Resource resource, File destination, InputStream input, boolean closeInput,
- long maxSize )
- throws TransferFailedException
- {
- // ensure that the destination is created only when we are ready to transfer
- fireTransferDebug( "attempting to create parent directories for destination: " + destination.getName() );
- createParentDirectories( destination );
-
- OutputStream output = new LazyFileOutputStream( destination );
-
- fireGetStarted( resource, destination );
-
- try
- {
- getTransfer( resource, output, input, closeInput, maxSize );
- }
- catch ( TransferFailedException e )
- {
- if ( destination.exists() )
- {
- boolean deleted = destination.delete();
-
- if ( !deleted )
- {
- destination.deleteOnExit();
- }
- }
- throw e;
- }
- finally
- {
- IOUtil.close( output );
- }
-
- fireGetCompleted( resource, destination );
- }
-
- @Deprecated
- protected void getTransfer( Resource resource, OutputStream output, InputStream input, boolean closeInput,
- int maxSize )
- throws TransferFailedException
- {
- getTransfer( resource, output, input, closeInput, (long) maxSize );
- }
-
- protected void getTransfer( Resource resource, OutputStream output, InputStream input, boolean closeInput,
- long maxSize )
- throws TransferFailedException
- {
- try
- {
- transfer( resource, input, output, TransferEvent.REQUEST_GET, maxSize );
-
- finishGetTransfer( resource, input, output );
- }
- catch ( IOException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_GET );
-
- String msg = "GET request of: " + resource.getName() + " from " + repository.getName() + " failed";
-
- throw new TransferFailedException( msg, e );
- }
- finally
- {
- if ( closeInput )
- {
- IOUtil.close( input );
- }
-
- cleanupGetTransfer( resource );
- }
- }
-
- protected void finishGetTransfer( Resource resource, InputStream input, OutputStream output )
- throws TransferFailedException
- {
- }
-
- protected void cleanupGetTransfer( Resource resource )
- {
- }
-
- protected void putTransfer( Resource resource, File source, OutputStream output, boolean closeOutput )
- throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
- {
- firePutStarted( resource, source );
-
- transfer( resource, source, output, closeOutput );
-
- firePutCompleted( resource, source );
- }
-
- /**
- * Write from {@link File} to {@link OutputStream}
- *
- * @param resource resource to transfer
- * @param source file to read from
- * @param output output stream
- * @param closeOutput whether the output stream should be closed or not
- * @throws TransferFailedException
- * @throws ResourceDoesNotExistException
- * @throws AuthorizationException
- * @since 1.0-beta-1
- */
- protected void transfer( Resource resource, File source, OutputStream output, boolean closeOutput )
- throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
- {
- InputStream input = null;
-
- try
- {
- input = new FileInputStream( source );
-
- putTransfer( resource, input, output, closeOutput );
- }
- catch ( FileNotFoundException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
-
- throw new TransferFailedException( "Specified source file does not exist: " + source, e );
- }
- finally
- {
- IOUtil.close( input );
- }
- }
-
- protected void putTransfer( Resource resource, InputStream input, OutputStream output, boolean closeOutput )
- throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
- {
- try
- {
- transfer( resource, input, output, TransferEvent.REQUEST_PUT,
- resource.getContentLength() == WagonConstants.UNKNOWN_LENGTH
- ? Long.MAX_VALUE
- : resource.getContentLength() );
-
- finishPutTransfer( resource, input, output );
- }
- catch ( IOException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
-
- String msg = "PUT request to: " + resource.getName() + " in " + repository.getName() + " failed";
-
- throw new TransferFailedException( msg, e );
- }
- finally
- {
- if ( closeOutput )
- {
- IOUtil.close( output );
- }
-
- cleanupPutTransfer( resource );
- }
- }
-
- protected void cleanupPutTransfer( Resource resource )
- {
- }
-
- protected void finishPutTransfer( Resource resource, InputStream input, OutputStream output )
- throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
- {
- }
-
- /**
- * Write from {@link InputStream} to {@link OutputStream}.
- * Equivalent to {@link #transfer(Resource, InputStream, OutputStream, int, int)} with a maxSize equals to
- * {@link Integer#MAX_VALUE}
- *
- * @param resource resource to transfer
- * @param input input stream
- * @param output output stream
- * @param requestType one of {@link TransferEvent#REQUEST_GET} or {@link TransferEvent#REQUEST_PUT}
- * @throws IOException
- */
- protected void transfer( Resource resource, InputStream input, OutputStream output, int requestType )
- throws IOException
- {
- transfer( resource, input, output, requestType, Long.MAX_VALUE );
- }
-
- /**
- * Write from {@link InputStream} to {@link OutputStream}.
- * Equivalent to {@link #transfer(Resource, InputStream, OutputStream, int, int)} with a maxSize equals to
- * {@link Integer#MAX_VALUE}
- *
- * @param resource resource to transfer
- * @param input input stream
- * @param output output stream
- * @param requestType one of {@link TransferEvent#REQUEST_GET} or {@link TransferEvent#REQUEST_PUT}
- * @param maxSize size of the buffer
- * @throws IOException
- * @deprecated Please use the transfer using long as type of maxSize
- */
- @Deprecated
- protected void transfer( Resource resource, InputStream input, OutputStream output, int requestType, int maxSize )
- throws IOException
- {
- transfer( resource, input, output, requestType, (long) maxSize );
- }
-
- /**
- * Write from {@link InputStream} to {@link OutputStream}.
- * Equivalent to {@link #transfer(Resource, InputStream, OutputStream, int, long)} with a maxSize equals to
- * {@link Integer#MAX_VALUE}
- *
- * @param resource resource to transfer
- * @param input input stream
- * @param output output stream
- * @param requestType one of {@link TransferEvent#REQUEST_GET} or {@link TransferEvent#REQUEST_PUT}
- * @param maxSize size of the buffer
- * @throws IOException
- */
- protected void transfer( Resource resource, InputStream input, OutputStream output, int requestType, long maxSize )
- throws IOException
- {
- byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
-
- TransferEvent transferEvent = new TransferEvent( this, resource, TransferEvent.TRANSFER_PROGRESS, requestType );
- transferEvent.setTimestamp( System.currentTimeMillis() );
-
- long remaining = maxSize;
- while ( remaining > 0 )
- {
- // let's safely cast to int because the min value will be lower than the buffer size.
- int n = input.read( buffer, 0, (int) Math.min( buffer.length, remaining ) );
-
- if ( n == -1 )
- {
- break;
- }
-
- fireTransferProgress( transferEvent, buffer, n );
-
- output.write( buffer, 0, n );
-
- remaining -= n;
- }
- output.flush();
- }
-
- // ----------------------------------------------------------------------
- //
- // ----------------------------------------------------------------------
-
- protected void fireTransferProgress( TransferEvent transferEvent, byte[] buffer, int n )
- {
- transferEventSupport.fireTransferProgress( transferEvent, buffer, n );
- }
-
- protected void fireGetCompleted( Resource resource, File localFile )
- {
- long timestamp = System.currentTimeMillis();
-
- TransferEvent transferEvent =
- new TransferEvent( this, resource, TransferEvent.TRANSFER_COMPLETED, TransferEvent.REQUEST_GET );
-
- transferEvent.setTimestamp( timestamp );
-
- transferEvent.setLocalFile( localFile );
-
- transferEventSupport.fireTransferCompleted( transferEvent );
- }
-
- protected void fireGetStarted( Resource resource, File localFile )
- {
- long timestamp = System.currentTimeMillis();
-
- TransferEvent transferEvent =
- new TransferEvent( this, resource, TransferEvent.TRANSFER_STARTED, TransferEvent.REQUEST_GET );
-
- transferEvent.setTimestamp( timestamp );
-
- transferEvent.setLocalFile( localFile );
-
- transferEventSupport.fireTransferStarted( transferEvent );
- }
-
- protected void fireGetInitiated( Resource resource, File localFile )
- {
- long timestamp = System.currentTimeMillis();
-
- TransferEvent transferEvent =
- new TransferEvent( this, resource, TransferEvent.TRANSFER_INITIATED, TransferEvent.REQUEST_GET );
-
- transferEvent.setTimestamp( timestamp );
-
- transferEvent.setLocalFile( localFile );
-
- transferEventSupport.fireTransferInitiated( transferEvent );
- }
-
- protected void firePutInitiated( Resource resource, File localFile )
- {
- long timestamp = System.currentTimeMillis();
-
- TransferEvent transferEvent =
- new TransferEvent( this, resource, TransferEvent.TRANSFER_INITIATED, TransferEvent.REQUEST_PUT );
-
- transferEvent.setTimestamp( timestamp );
-
- transferEvent.setLocalFile( localFile );
-
- transferEventSupport.fireTransferInitiated( transferEvent );
- }
-
- protected void firePutCompleted( Resource resource, File localFile )
- {
- long timestamp = System.currentTimeMillis();
-
- TransferEvent transferEvent =
- new TransferEvent( this, resource, TransferEvent.TRANSFER_COMPLETED, TransferEvent.REQUEST_PUT );
-
- transferEvent.setTimestamp( timestamp );
-
- transferEvent.setLocalFile( localFile );
-
- transferEventSupport.fireTransferCompleted( transferEvent );
- }
-
- protected void firePutStarted( Resource resource, File localFile )
- {
- long timestamp = System.currentTimeMillis();
-
- TransferEvent transferEvent =
- new TransferEvent( this, resource, TransferEvent.TRANSFER_STARTED, TransferEvent.REQUEST_PUT );
-
- transferEvent.setTimestamp( timestamp );
-
- transferEvent.setLocalFile( localFile );
-
- transferEventSupport.fireTransferStarted( transferEvent );
- }
-
- protected void fireSessionDisconnected()
- {
- long timestamp = System.currentTimeMillis();
-
- SessionEvent sessionEvent = new SessionEvent( this, SessionEvent.SESSION_DISCONNECTED );
-
- sessionEvent.setTimestamp( timestamp );
-
- sessionEventSupport.fireSessionDisconnected( sessionEvent );
- }
-
- protected void fireSessionDisconnecting()
- {
- long timestamp = System.currentTimeMillis();
-
- SessionEvent sessionEvent = new SessionEvent( this, SessionEvent.SESSION_DISCONNECTING );
-
- sessionEvent.setTimestamp( timestamp );
-
- sessionEventSupport.fireSessionDisconnecting( sessionEvent );
- }
-
- protected void fireSessionLoggedIn()
- {
- long timestamp = System.currentTimeMillis();
-
- SessionEvent sessionEvent = new SessionEvent( this, SessionEvent.SESSION_LOGGED_IN );
-
- sessionEvent.setTimestamp( timestamp );
-
- sessionEventSupport.fireSessionLoggedIn( sessionEvent );
- }
-
- protected void fireSessionLoggedOff()
- {
- long timestamp = System.currentTimeMillis();
-
- SessionEvent sessionEvent = new SessionEvent( this, SessionEvent.SESSION_LOGGED_OFF );
-
- sessionEvent.setTimestamp( timestamp );
-
- sessionEventSupport.fireSessionLoggedOff( sessionEvent );
- }
-
- protected void fireSessionOpened()
- {
- long timestamp = System.currentTimeMillis();
-
- SessionEvent sessionEvent = new SessionEvent( this, SessionEvent.SESSION_OPENED );
-
- sessionEvent.setTimestamp( timestamp );
-
- sessionEventSupport.fireSessionOpened( sessionEvent );
- }
-
- protected void fireSessionOpening()
- {
- long timestamp = System.currentTimeMillis();
-
- SessionEvent sessionEvent = new SessionEvent( this, SessionEvent.SESSION_OPENING );
-
- sessionEvent.setTimestamp( timestamp );
-
- sessionEventSupport.fireSessionOpening( sessionEvent );
- }
-
- protected void fireSessionConnectionRefused()
- {
- long timestamp = System.currentTimeMillis();
-
- SessionEvent sessionEvent = new SessionEvent( this, SessionEvent.SESSION_CONNECTION_REFUSED );
-
- sessionEvent.setTimestamp( timestamp );
-
- sessionEventSupport.fireSessionConnectionRefused( sessionEvent );
- }
-
- protected void fireSessionError( Exception exception )
- {
- long timestamp = System.currentTimeMillis();
-
- SessionEvent sessionEvent = new SessionEvent( this, exception );
-
- sessionEvent.setTimestamp( timestamp );
-
- sessionEventSupport.fireSessionError( sessionEvent );
-
- }
-
- protected void fireTransferDebug( String message )
- {
- transferEventSupport.fireDebug( message );
- }
-
- protected void fireSessionDebug( String message )
- {
- sessionEventSupport.fireDebug( message );
- }
-
- public boolean hasTransferListener( TransferListener listener )
- {
- return transferEventSupport.hasTransferListener( listener );
- }
-
- public void addTransferListener( TransferListener listener )
- {
- transferEventSupport.addTransferListener( listener );
- }
-
- public void removeTransferListener( TransferListener listener )
- {
- transferEventSupport.removeTransferListener( listener );
- }
-
- public void addSessionListener( SessionListener listener )
- {
- sessionEventSupport.addSessionListener( listener );
- }
-
- public boolean hasSessionListener( SessionListener listener )
- {
- return sessionEventSupport.hasSessionListener( listener );
- }
-
- public void removeSessionListener( SessionListener listener )
- {
- sessionEventSupport.removeSessionListener( listener );
- }
-
- protected void fireTransferError( Resource resource, Exception e, int requestType )
- {
- TransferEvent transferEvent = new TransferEvent( this, resource, e, requestType );
- transferEventSupport.fireTransferError( transferEvent );
- }
-
-
- public SessionEventSupport getSessionEventSupport()
- {
- return sessionEventSupport;
- }
-
- public void setSessionEventSupport( SessionEventSupport sessionEventSupport )
- {
- this.sessionEventSupport = sessionEventSupport;
- }
-
- public TransferEventSupport getTransferEventSupport()
- {
- return transferEventSupport;
- }
-
- public void setTransferEventSupport( TransferEventSupport transferEventSupport )
- {
- this.transferEventSupport = transferEventSupport;
- }
-
- /**
- * This method is used if you are not streaming the transfer, to make sure any listeners dependent on state
- * (eg checksum observers) succeed.
- */
- protected void postProcessListeners( Resource resource, File source, int requestType )
- throws TransferFailedException
- {
- byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
-
- TransferEvent transferEvent = new TransferEvent( this, resource, TransferEvent.TRANSFER_PROGRESS, requestType );
- transferEvent.setTimestamp( System.currentTimeMillis() );
- transferEvent.setLocalFile( source );
-
- InputStream input = null;
- try
- {
- input = new FileInputStream( source );
-
- while ( true )
- {
- int n = input.read( buffer );
-
- if ( n == -1 )
- {
- break;
- }
-
- fireTransferProgress( transferEvent, buffer, n );
- }
- }
- catch ( IOException e )
- {
- fireTransferError( resource, e, requestType );
-
- throw new TransferFailedException( "Failed to post-process the source file", e );
- }
- finally
- {
- IOUtil.close( input );
- }
- }
-
- public void putDirectory( File sourceDirectory, String destinationDirectory )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- throw new UnsupportedOperationException( "The wagon you are using has not implemented putDirectory()" );
- }
-
- public boolean supportsDirectoryCopy()
- {
- return false;
- }
-
- protected static String getPath( String basedir, String dir )
- {
- String path;
- path = basedir;
- if ( !basedir.endsWith( "/" ) && !dir.startsWith( "/" ) )
- {
- path += "/";
- }
- path += dir;
- return path;
- }
-
- public boolean isInteractive()
- {
- return interactive;
- }
-
- public void setInteractive( boolean interactive )
- {
- this.interactive = interactive;
- }
-
- public List<String> getFileList( String destinationDirectory )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- throw new UnsupportedOperationException( "The wagon you are using has not implemented getFileList()" );
- }
-
- public boolean resourceExists( String resourceName )
- throws TransferFailedException, AuthorizationException
- {
- throw new UnsupportedOperationException( "The wagon you are using has not implemented resourceExists()" );
- }
-
- protected ProxyInfo getProxyInfo( String protocol, String host )
- {
- if ( proxyInfoProvider != null )
- {
- ProxyInfo proxyInfo = proxyInfoProvider.getProxyInfo( protocol );
- if ( !ProxyUtils.validateNonProxyHosts( proxyInfo, host ) )
- {
- return proxyInfo;
- }
- }
- return null;
- }
-
- public RepositoryPermissions getPermissionsOverride()
- {
- return permissionsOverride;
- }
-
- public void setPermissionsOverride( RepositoryPermissions permissionsOverride )
- {
- this.permissionsOverride = permissionsOverride;
- }
-
- public void setReadTimeout( int readTimeout )
- {
- this.readTimeout = readTimeout;
- }
-
- public int getReadTimeout()
- {
- return this.readTimeout;
- }
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.events.SessionEvent;
+import org.apache.maven.wagon.events.SessionEventSupport;
+import org.apache.maven.wagon.events.SessionListener;
+import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.events.TransferEventSupport;
+import org.apache.maven.wagon.events.TransferListener;
+import org.apache.maven.wagon.proxy.ProxyInfo;
+import org.apache.maven.wagon.proxy.ProxyInfoProvider;
+import org.apache.maven.wagon.proxy.ProxyUtils;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.repository.RepositoryPermissions;
+import org.apache.maven.wagon.resource.Resource;
+import org.codehaus.plexus.util.IOUtil;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.List;
+
+/**
+ * Implementation of common facilities for Wagon providers.
+ *
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ */
+public abstract class AbstractWagon
+ implements Wagon
+{
+ protected static final int DEFAULT_BUFFER_SIZE = 1024 * 4;
+
+ protected Repository repository;
+
+ protected SessionEventSupport sessionEventSupport = new SessionEventSupport();
+
+ protected TransferEventSupport transferEventSupport = new TransferEventSupport();
+
+ protected AuthenticationInfo authenticationInfo;
+
+ protected boolean interactive = true;
+
+
+ private int connectionTimeout = DEFAULT_CONNECTION_TIMEOUT;
+
+ /**
+ * read timeout value
+ *
+ * @since 2.2
+ */
+ private int readTimeout =
+ Integer.parseInt( System.getProperty( "maven.wagon.rto", Integer.toString( Wagon.DEFAULT_READ_TIMEOUT ) ) );
+
+ private ProxyInfoProvider proxyInfoProvider;
+
+ /**
+ * @deprecated
+ */
+ protected ProxyInfo proxyInfo;
+
+ private RepositoryPermissions permissionsOverride;
+
+ // ----------------------------------------------------------------------
+ // Accessors
+ // ----------------------------------------------------------------------
+
+ public Repository getRepository()
+ {
+ return repository;
+ }
+
+ public ProxyInfo getProxyInfo()
+ {
+ return proxyInfoProvider != null ? proxyInfoProvider.getProxyInfo( null ) : null;
+ }
+
+ public AuthenticationInfo getAuthenticationInfo()
+ {
+ return authenticationInfo;
+ }
+
+ // ----------------------------------------------------------------------
+ // Connection
+ // ----------------------------------------------------------------------
+
+ public void openConnection()
+ throws ConnectionException, AuthenticationException
+ {
+ try
+ {
+ openConnectionInternal();
+ }
+ catch ( ConnectionException e )
+ {
+ fireSessionConnectionRefused();
+
+ throw e;
+ }
+ catch ( AuthenticationException e )
+ {
+ fireSessionConnectionRefused();
+
+ throw e;
+ }
+ }
+
+ public void connect( Repository repository )
+ throws ConnectionException, AuthenticationException
+ {
+ connect( repository, null, (ProxyInfoProvider) null );
+ }
+
+ public void connect( Repository repository, ProxyInfo proxyInfo )
+ throws ConnectionException, AuthenticationException
+ {
+ connect( repository, null, proxyInfo );
+ }
+
+ public void connect( Repository repository, ProxyInfoProvider proxyInfoProvider )
+ throws ConnectionException, AuthenticationException
+ {
+ connect( repository, null, proxyInfoProvider );
+ }
+
+ public void connect( Repository repository, AuthenticationInfo authenticationInfo )
+ throws ConnectionException, AuthenticationException
+ {
+ connect( repository, authenticationInfo, (ProxyInfoProvider) null );
+ }
+
+ public void connect( Repository repository, AuthenticationInfo authenticationInfo, ProxyInfo proxyInfo )
+ throws ConnectionException, AuthenticationException
+ {
+ final ProxyInfo proxy = proxyInfo;
+ connect( repository, authenticationInfo, new ProxyInfoProvider()
+ {
+ public ProxyInfo getProxyInfo( String protocol )
+ {
+ if ( protocol == null || proxy == null || protocol.equalsIgnoreCase( proxy.getType() ) )
+ {
+ return proxy;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ } );
+ }
+
+ public void connect( Repository repository, AuthenticationInfo authenticationInfo,
+ ProxyInfoProvider proxyInfoProvider )
+ throws ConnectionException, AuthenticationException
+ {
+ if ( repository == null )
+ {
+ throw new NullPointerException( "repository cannot be null" );
+ }
+
+ if ( permissionsOverride != null )
+ {
+ repository.setPermissions( permissionsOverride );
+ }
+
+ this.repository = repository;
+
+ if ( authenticationInfo == null )
+ {
+ authenticationInfo = new AuthenticationInfo();
+ }
+
+ if ( authenticationInfo.getUserName() == null )
+ {
+ // Get user/pass that were encoded in the URL.
+ if ( repository.getUsername() != null )
+ {
+ authenticationInfo.setUserName( repository.getUsername() );
+ if ( repository.getPassword() != null && authenticationInfo.getPassword() == null )
+ {
+ authenticationInfo.setPassword( repository.getPassword() );
+ }
+ }
+ }
+
+ this.authenticationInfo = authenticationInfo;
+
+ this.proxyInfoProvider = proxyInfoProvider;
+
+ fireSessionOpening();
+
+ openConnection();
+
+ fireSessionOpened();
+ }
+
+ protected abstract void openConnectionInternal()
+ throws ConnectionException, AuthenticationException;
+
+ public void disconnect()
+ throws ConnectionException
+ {
+ fireSessionDisconnecting();
+
+ try
+ {
+ closeConnection();
+ }
+ catch ( ConnectionException e )
+ {
+ fireSessionError( e );
+ throw e;
+ }
+
+ fireSessionDisconnected();
+ }
+
+ protected abstract void closeConnection()
+ throws ConnectionException;
+
+ protected void createParentDirectories( File destination )
+ throws TransferFailedException
+ {
+ File destinationDirectory = destination.getParentFile();
+ try
+ {
+ destinationDirectory = destinationDirectory.getCanonicalFile();
+ }
+ catch ( IOException e )
+ {
+ // not essential to have a canonical file
+ }
+ if ( destinationDirectory != null && !destinationDirectory.exists() )
+ {
+ destinationDirectory.mkdirs();
+ if ( !destinationDirectory.exists() )
+ {
+ throw new TransferFailedException(
+ "Specified destination directory cannot be created: " + destinationDirectory );
+ }
+ }
+ }
+
+ public void setTimeout( int timeoutValue )
+ {
+ connectionTimeout = timeoutValue;
+ }
+
+ public int getTimeout()
+ {
+ return connectionTimeout;
+ }
+
+ // ----------------------------------------------------------------------
+ // Stream i/o
+ // ----------------------------------------------------------------------
+
+ protected void getTransfer( Resource resource, File destination, InputStream input )
+ throws TransferFailedException
+ {
+ getTransfer( resource, destination, input, true, Long.MAX_VALUE );
+ }
+
+ protected void getTransfer( Resource resource, OutputStream output, InputStream input )
+ throws TransferFailedException
+ {
+ getTransfer( resource, output, input, true, Long.MAX_VALUE );
+ }
+
+ @Deprecated
+ protected void getTransfer( Resource resource, File destination, InputStream input, boolean closeInput,
+ int maxSize )
+ throws TransferFailedException
+ {
+ getTransfer( resource, destination, input, closeInput, (long) maxSize );
+ }
+
+ protected void getTransfer( Resource resource, File destination, InputStream input, boolean closeInput,
+ long maxSize )
+ throws TransferFailedException
+ {
+ // ensure that the destination is created only when we are ready to transfer
+ fireTransferDebug( "attempting to create parent directories for destination: " + destination.getName() );
+ createParentDirectories( destination );
+
+ fireGetStarted( resource, destination );
+
+ OutputStream output = null;
+ try
+ {
+ output = new LazyFileOutputStream( destination );
+ getTransfer( resource, output, input, closeInput, maxSize );
+ output.close();
+ output = null;
+ }
+ catch ( final IOException e )
+ {
+ if ( destination.exists() )
+ {
+ boolean deleted = destination.delete();
+
+ if ( !deleted )
+ {
+ destination.deleteOnExit();
+ }
+ }
+
+ fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+
+ String msg = "GET request of: " + resource.getName() + " from " + repository.getName() + " failed";
+
+ throw new TransferFailedException( msg, e );
+ }
+ catch ( TransferFailedException e )
+ {
+ if ( destination.exists() )
+ {
+ boolean deleted = destination.delete();
+
+ if ( !deleted )
+ {
+ destination.deleteOnExit();
+ }
+ }
+ throw e;
+ }
+ finally
+ {
+ IOUtil.close( output );
+ }
+
+ fireGetCompleted( resource, destination );
+ }
+
+ @Deprecated
+ protected void getTransfer( Resource resource, OutputStream output, InputStream input, boolean closeInput,
+ int maxSize )
+ throws TransferFailedException
+ {
+ getTransfer( resource, output, input, closeInput, (long) maxSize );
+ }
+
+ protected void getTransfer( Resource resource, OutputStream output, InputStream input, boolean closeInput,
+ long maxSize )
+ throws TransferFailedException
+ {
+ try
+ {
+ transfer( resource, input, output, TransferEvent.REQUEST_GET, maxSize );
+
+ finishGetTransfer( resource, input, output );
+
+ if ( closeInput )
+ {
+ input.close();
+ input = null;
+ }
+
+ }
+ catch ( IOException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+
+ String msg = "GET request of: " + resource.getName() + " from " + repository.getName() + " failed";
+
+ throw new TransferFailedException( msg, e );
+ }
+ finally
+ {
+ if ( closeInput )
+ {
+ IOUtil.close( input );
+ }
+
+ cleanupGetTransfer( resource );
+ }
+ }
+
+ protected void finishGetTransfer( Resource resource, InputStream input, OutputStream output )
+ throws TransferFailedException
+ {
+ }
+
+ protected void cleanupGetTransfer( Resource resource )
+ {
+ }
+
+ protected void putTransfer( Resource resource, File source, OutputStream output, boolean closeOutput )
+ throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
+ {
+ firePutStarted( resource, source );
+
+ transfer( resource, source, output, closeOutput );
+
+ firePutCompleted( resource, source );
+ }
+
+ /**
+ * Write from {@link File} to {@link OutputStream}
+ *
+ * @param resource resource to transfer
+ * @param source file to read from
+ * @param output output stream
+ * @param closeOutput whether the output stream should be closed or not
+ * @throws TransferFailedException
+ * @throws ResourceDoesNotExistException
+ * @throws AuthorizationException
+ * @since 1.0-beta-1
+ */
+ protected void transfer( Resource resource, File source, OutputStream output, boolean closeOutput )
+ throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
+ {
+ InputStream input = null;
+
+ try
+ {
+ input = new FileInputStream( source );
+
+ putTransfer( resource, input, output, closeOutput );
+
+ input.close();
+ input = null;
+ }
+ catch ( FileNotFoundException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
+ throw new TransferFailedException( "Specified source file does not exist: " + source, e );
+ }
+ catch ( final IOException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
+ throw new TransferFailedException( "Failure transferring " + source, e );
+ }
+ finally
+ {
+ IOUtil.close( input );
+ }
+ }
+
+ protected void putTransfer( Resource resource, InputStream input, OutputStream output, boolean closeOutput )
+ throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
+ {
+ try
+ {
+ transfer( resource, input, output, TransferEvent.REQUEST_PUT,
+ resource.getContentLength() == WagonConstants.UNKNOWN_LENGTH
+ ? Long.MAX_VALUE
+ : resource.getContentLength() );
+
+ finishPutTransfer( resource, input, output );
+
+ if ( closeOutput )
+ {
+ output.close();
+ output = null;
+ }
+ }
+ catch ( IOException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
+ String msg = "PUT request to: " + resource.getName() + " in " + repository.getName() + " failed";
+
+ throw new TransferFailedException( msg, e );
+ }
+ finally
+ {
+ if ( closeOutput )
+ {
+ IOUtil.close( output );
+ }
+
+ cleanupPutTransfer( resource );
+ }
+ }
+
+ protected void cleanupPutTransfer( Resource resource )
+ {
+ }
+
+ protected void finishPutTransfer( Resource resource, InputStream input, OutputStream output )
+ throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
+ {
+ }
+
+ /**
+ * Write from {@link InputStream} to {@link OutputStream}.
+ * Equivalent to {@link #transfer(Resource, InputStream, OutputStream, int, int)} with a maxSize equals to
+ * {@link Integer#MAX_VALUE}
+ *
+ * @param resource resource to transfer
+ * @param input input stream
+ * @param output output stream
+ * @param requestType one of {@link TransferEvent#REQUEST_GET} or {@link TransferEvent#REQUEST_PUT}
+ * @throws IOException
+ */
+ protected void transfer( Resource resource, InputStream input, OutputStream output, int requestType )
+ throws IOException
+ {
+ transfer( resource, input, output, requestType, Long.MAX_VALUE );
+ }
+
+ /**
+ * Write from {@link InputStream} to {@link OutputStream}.
+ * Equivalent to {@link #transfer(Resource, InputStream, OutputStream, int, int)} with a maxSize equals to
+ * {@link Integer#MAX_VALUE}
+ *
+ * @param resource resource to transfer
+ * @param input input stream
+ * @param output output stream
+ * @param requestType one of {@link TransferEvent#REQUEST_GET} or {@link TransferEvent#REQUEST_PUT}
+ * @param maxSize size of the buffer
+ * @throws IOException
+ * @deprecated Please use the transfer using long as type of maxSize
+ */
+ @Deprecated
+ protected void transfer( Resource resource, InputStream input, OutputStream output, int requestType, int maxSize )
+ throws IOException
+ {
+ transfer( resource, input, output, requestType, (long) maxSize );
+ }
+
+ /**
+ * Write from {@link InputStream} to {@link OutputStream}.
+ * Equivalent to {@link #transfer(Resource, InputStream, OutputStream, int, long)} with a maxSize equals to
+ * {@link Integer#MAX_VALUE}
+ *
+ * @param resource resource to transfer
+ * @param input input stream
+ * @param output output stream
+ * @param requestType one of {@link TransferEvent#REQUEST_GET} or {@link TransferEvent#REQUEST_PUT}
+ * @param maxSize size of the buffer
+ * @throws IOException
+ */
+ protected void transfer( Resource resource, InputStream input, OutputStream output, int requestType, long maxSize )
+ throws IOException
+ {
+ byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
+
+ TransferEvent transferEvent = new TransferEvent( this, resource, TransferEvent.TRANSFER_PROGRESS, requestType );
+ transferEvent.setTimestamp( System.currentTimeMillis() );
+
+ long remaining = maxSize;
+ while ( remaining > 0 )
+ {
+ // let's safely cast to int because the min value will be lower than the buffer size.
+ int n = input.read( buffer, 0, (int) Math.min( buffer.length, remaining ) );
+
+ if ( n == -1 )
+ {
+ break;
+ }
+
+ fireTransferProgress( transferEvent, buffer, n );
+
+ output.write( buffer, 0, n );
+
+ remaining -= n;
+ }
+ output.flush();
+ }
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ protected void fireTransferProgress( TransferEvent transferEvent, byte[] buffer, int n )
+ {
+ transferEventSupport.fireTransferProgress( transferEvent, buffer, n );
+ }
+
+ protected void fireGetCompleted( Resource resource, File localFile )
+ {
+ long timestamp = System.currentTimeMillis();
+
+ TransferEvent transferEvent =
+ new TransferEvent( this, resource, TransferEvent.TRANSFER_COMPLETED, TransferEvent.REQUEST_GET );
+
+ transferEvent.setTimestamp( timestamp );
+
+ transferEvent.setLocalFile( localFile );
+
+ transferEventSupport.fireTransferCompleted( transferEvent );
+ }
+
+ protected void fireGetStarted( Resource resource, File localFile )
+ {
+ long timestamp = System.currentTimeMillis();
+
+ TransferEvent transferEvent =
+ new TransferEvent( this, resource, TransferEvent.TRANSFER_STARTED, TransferEvent.REQUEST_GET );
+
+ transferEvent.setTimestamp( timestamp );
+
+ transferEvent.setLocalFile( localFile );
+
+ transferEventSupport.fireTransferStarted( transferEvent );
+ }
+
+ protected void fireGetInitiated( Resource resource, File localFile )
+ {
+ long timestamp = System.currentTimeMillis();
+
+ TransferEvent transferEvent =
+ new TransferEvent( this, resource, TransferEvent.TRANSFER_INITIATED, TransferEvent.REQUEST_GET );
+
+ transferEvent.setTimestamp( timestamp );
+
+ transferEvent.setLocalFile( localFile );
+
+ transferEventSupport.fireTransferInitiated( transferEvent );
+ }
+
+ protected void firePutInitiated( Resource resource, File localFile )
+ {
+ long timestamp = System.currentTimeMillis();
+
+ TransferEvent transferEvent =
+ new TransferEvent( this, resource, TransferEvent.TRANSFER_INITIATED, TransferEvent.REQUEST_PUT );
+
+ transferEvent.setTimestamp( timestamp );
+
+ transferEvent.setLocalFile( localFile );
+
+ transferEventSupport.fireTransferInitiated( transferEvent );
+ }
+
+ protected void firePutCompleted( Resource resource, File localFile )
+ {
+ long timestamp = System.currentTimeMillis();
+
+ TransferEvent transferEvent =
+ new TransferEvent( this, resource, TransferEvent.TRANSFER_COMPLETED, TransferEvent.REQUEST_PUT );
+
+ transferEvent.setTimestamp( timestamp );
+
+ transferEvent.setLocalFile( localFile );
+
+ transferEventSupport.fireTransferCompleted( transferEvent );
+ }
+
+ protected void firePutStarted( Resource resource, File localFile )
+ {
+ long timestamp = System.currentTimeMillis();
+
+ TransferEvent transferEvent =
+ new TransferEvent( this, resource, TransferEvent.TRANSFER_STARTED, TransferEvent.REQUEST_PUT );
+
+ transferEvent.setTimestamp( timestamp );
+
+ transferEvent.setLocalFile( localFile );
+
+ transferEventSupport.fireTransferStarted( transferEvent );
+ }
+
+ protected void fireSessionDisconnected()
+ {
+ long timestamp = System.currentTimeMillis();
+
+ SessionEvent sessionEvent = new SessionEvent( this, SessionEvent.SESSION_DISCONNECTED );
+
+ sessionEvent.setTimestamp( timestamp );
+
+ sessionEventSupport.fireSessionDisconnected( sessionEvent );
+ }
+
+ protected void fireSessionDisconnecting()
+ {
+ long timestamp = System.currentTimeMillis();
+
+ SessionEvent sessionEvent = new SessionEvent( this, SessionEvent.SESSION_DISCONNECTING );
+
+ sessionEvent.setTimestamp( timestamp );
+
+ sessionEventSupport.fireSessionDisconnecting( sessionEvent );
+ }
+
+ protected void fireSessionLoggedIn()
+ {
+ long timestamp = System.currentTimeMillis();
+
+ SessionEvent sessionEvent = new SessionEvent( this, SessionEvent.SESSION_LOGGED_IN );
+
+ sessionEvent.setTimestamp( timestamp );
+
+ sessionEventSupport.fireSessionLoggedIn( sessionEvent );
+ }
+
+ protected void fireSessionLoggedOff()
+ {
+ long timestamp = System.currentTimeMillis();
+
+ SessionEvent sessionEvent = new SessionEvent( this, SessionEvent.SESSION_LOGGED_OFF );
+
+ sessionEvent.setTimestamp( timestamp );
+
+ sessionEventSupport.fireSessionLoggedOff( sessionEvent );
+ }
+
+ protected void fireSessionOpened()
+ {
+ long timestamp = System.currentTimeMillis();
+
+ SessionEvent sessionEvent = new SessionEvent( this, SessionEvent.SESSION_OPENED );
+
+ sessionEvent.setTimestamp( timestamp );
+
+ sessionEventSupport.fireSessionOpened( sessionEvent );
+ }
+
+ protected void fireSessionOpening()
+ {
+ long timestamp = System.currentTimeMillis();
+
+ SessionEvent sessionEvent = new SessionEvent( this, SessionEvent.SESSION_OPENING );
+
+ sessionEvent.setTimestamp( timestamp );
+
+ sessionEventSupport.fireSessionOpening( sessionEvent );
+ }
+
+ protected void fireSessionConnectionRefused()
+ {
+ long timestamp = System.currentTimeMillis();
+
+ SessionEvent sessionEvent = new SessionEvent( this, SessionEvent.SESSION_CONNECTION_REFUSED );
+
+ sessionEvent.setTimestamp( timestamp );
+
+ sessionEventSupport.fireSessionConnectionRefused( sessionEvent );
+ }
+
+ protected void fireSessionError( Exception exception )
+ {
+ long timestamp = System.currentTimeMillis();
+
+ SessionEvent sessionEvent = new SessionEvent( this, exception );
+
+ sessionEvent.setTimestamp( timestamp );
+
+ sessionEventSupport.fireSessionError( sessionEvent );
+
+ }
+
+ protected void fireTransferDebug( String message )
+ {
+ transferEventSupport.fireDebug( message );
+ }
+
+ protected void fireSessionDebug( String message )
+ {
+ sessionEventSupport.fireDebug( message );
+ }
+
+ public boolean hasTransferListener( TransferListener listener )
+ {
+ return transferEventSupport.hasTransferListener( listener );
+ }
+
+ public void addTransferListener( TransferListener listener )
+ {
+ transferEventSupport.addTransferListener( listener );
+ }
+
+ public void removeTransferListener( TransferListener listener )
+ {
+ transferEventSupport.removeTransferListener( listener );
+ }
+
+ public void addSessionListener( SessionListener listener )
+ {
+ sessionEventSupport.addSessionListener( listener );
+ }
+
+ public boolean hasSessionListener( SessionListener listener )
+ {
+ return sessionEventSupport.hasSessionListener( listener );
+ }
+
+ public void removeSessionListener( SessionListener listener )
+ {
+ sessionEventSupport.removeSessionListener( listener );
+ }
+
+ protected void fireTransferError( Resource resource, Exception e, int requestType )
+ {
+ TransferEvent transferEvent = new TransferEvent( this, resource, e, requestType );
+ transferEventSupport.fireTransferError( transferEvent );
+ }
+
+
+ public SessionEventSupport getSessionEventSupport()
+ {
+ return sessionEventSupport;
+ }
+
+ public void setSessionEventSupport( SessionEventSupport sessionEventSupport )
+ {
+ this.sessionEventSupport = sessionEventSupport;
+ }
+
+ public TransferEventSupport getTransferEventSupport()
+ {
+ return transferEventSupport;
+ }
+
+ public void setTransferEventSupport( TransferEventSupport transferEventSupport )
+ {
+ this.transferEventSupport = transferEventSupport;
+ }
+
+ /**
+ * This method is used if you are not streaming the transfer, to make sure any listeners dependent on state
+ * (eg checksum observers) succeed.
+ */
+ protected void postProcessListeners( Resource resource, File source, int requestType )
+ throws TransferFailedException
+ {
+ byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
+
+ TransferEvent transferEvent = new TransferEvent( this, resource, TransferEvent.TRANSFER_PROGRESS, requestType );
+ transferEvent.setTimestamp( System.currentTimeMillis() );
+ transferEvent.setLocalFile( source );
+
+ InputStream input = null;
+ try
+ {
+ input = new FileInputStream( source );
+
+ while ( true )
+ {
+ int n = input.read( buffer );
+
+ if ( n == -1 )
+ {
+ break;
+ }
+
+ fireTransferProgress( transferEvent, buffer, n );
+ }
+
+ input.close();
+ input = null;
+ }
+ catch ( IOException e )
+ {
+ fireTransferError( resource, e, requestType );
+
+ throw new TransferFailedException( "Failed to post-process the source file", e );
+ }
+ finally
+ {
+ IOUtil.close( input );
+ }
+ }
+
+ public void putDirectory( File sourceDirectory, String destinationDirectory )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ throw new UnsupportedOperationException( "The wagon you are using has not implemented putDirectory()" );
+ }
+
+ public boolean supportsDirectoryCopy()
+ {
+ return false;
+ }
+
+ protected static String getPath( String basedir, String dir )
+ {
+ String path;
+ path = basedir;
+ if ( !basedir.endsWith( "/" ) && !dir.startsWith( "/" ) )
+ {
+ path += "/";
+ }
+ path += dir;
+ return path;
+ }
+
+ public boolean isInteractive()
+ {
+ return interactive;
+ }
+
+ public void setInteractive( boolean interactive )
+ {
+ this.interactive = interactive;
+ }
+
+ public List<String> getFileList( String destinationDirectory )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ throw new UnsupportedOperationException( "The wagon you are using has not implemented getFileList()" );
+ }
+
+ public boolean resourceExists( String resourceName )
+ throws TransferFailedException, AuthorizationException
+ {
+ throw new UnsupportedOperationException( "The wagon you are using has not implemented resourceExists()" );
+ }
+
+ protected ProxyInfo getProxyInfo( String protocol, String host )
+ {
+ if ( proxyInfoProvider != null )
+ {
+ ProxyInfo proxyInfo = proxyInfoProvider.getProxyInfo( protocol );
+ if ( !ProxyUtils.validateNonProxyHosts( proxyInfo, host ) )
+ {
+ return proxyInfo;
+ }
+ }
+ return null;
+ }
+
+ public RepositoryPermissions getPermissionsOverride()
+ {
+ return permissionsOverride;
+ }
+
+ public void setPermissionsOverride( RepositoryPermissions permissionsOverride )
+ {
+ this.permissionsOverride = permissionsOverride;
+ }
+
+ public void setReadTimeout( int readTimeout )
+ {
+ this.readTimeout = readTimeout;
+ }
+
+ public int getReadTimeout()
+ {
+ return this.readTimeout;
+ }
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/CommandExecutionException.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/CommandExecutionException.java
index 5568e1d..7382254 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/CommandExecutionException.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/CommandExecutionException.java
@@ -1,48 +1,48 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Exception which should be thrown when a command fails to execute on the repository.
- *
- * @author <a href="brett at apache.org">Brett Porter</a>
- *
- */
-public class CommandExecutionException
- extends WagonException
-{
-
- /**
- * @see org.apache.maven.wagon.WagonException
- */
- public CommandExecutionException( String message )
- {
- super( message );
- }
-
- /**
- * @see org.apache.maven.wagon.WagonException
- */
- public CommandExecutionException( String message, Throwable cause )
- {
- super( message, cause );
- }
-
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Exception which should be thrown when a command fails to execute on the repository.
+ *
+ * @author <a href="brett at apache.org">Brett Porter</a>
+ *
+ */
+public class CommandExecutionException
+ extends WagonException
+{
+
+ /**
+ * @see org.apache.maven.wagon.WagonException
+ */
+ public CommandExecutionException( String message )
+ {
+ super( message );
+ }
+
+ /**
+ * @see org.apache.maven.wagon.WagonException
+ */
+ public CommandExecutionException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/CommandExecutor.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/CommandExecutor.java
index 5476c8f..c21548f 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/CommandExecutor.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/CommandExecutor.java
@@ -1,36 +1,36 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * @author <a href="mailto:brett at apache.org">Brett Porter</a>
- *
- */
-public interface CommandExecutor
- extends Wagon
-{
- String ROLE = CommandExecutor.class.getName();
-
- void executeCommand( String command )
- throws CommandExecutionException;
-
- Streams executeCommand( String command, boolean ignoreFailures )
- throws CommandExecutionException;
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author <a href="mailto:brett at apache.org">Brett Porter</a>
+ *
+ */
+public interface CommandExecutor
+ extends Wagon
+{
+ String ROLE = CommandExecutor.class.getName();
+
+ void executeCommand( String command )
+ throws CommandExecutionException;
+
+ Streams executeCommand( String command, boolean ignoreFailures )
+ throws CommandExecutionException;
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/ConnectionException.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/ConnectionException.java
index ad4a64e..6f44228 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/ConnectionException.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/ConnectionException.java
@@ -1,50 +1,50 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * The exception is thrown when a connection
- * to repository cannot be established or open connection cannot be closed.
- *
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class ConnectionException
- extends WagonException
-{
-
-
- /**
- * @see org.apache.maven.wagon.WagonException
- */
- public ConnectionException( final String message )
- {
- super( message );
- }
-
- /**
- * @see org.apache.maven.wagon.WagonException
- */
- public ConnectionException( final String message, final Throwable cause )
- {
- super( message, cause );
- }
-
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * The exception is thrown when a connection
+ * to repository cannot be established or open connection cannot be closed.
+ *
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class ConnectionException
+ extends WagonException
+{
+
+
+ /**
+ * @see org.apache.maven.wagon.WagonException
+ */
+ public ConnectionException( final String message )
+ {
+ super( message );
+ }
+
+ /**
+ * @see org.apache.maven.wagon.WagonException
+ */
+ public ConnectionException( final String message, final Throwable cause )
+ {
+ super( message, cause );
+ }
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/InputData.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/InputData.java
index c9b4b6b..e7c1bf6 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/InputData.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/InputData.java
@@ -1,56 +1,56 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.resource.Resource;
-
-import java.io.InputStream;
-
-/**
- * @author <a href="mailto:michal at codehaus.org">Michal Maczka</a>
- *
- */
-public class InputData
-{
- private InputStream inputStream;
-
- private Resource resource;
-
- public InputStream getInputStream()
- {
- return inputStream;
- }
-
- public void setInputStream( InputStream inputStream )
- {
- this.inputStream = inputStream;
- }
-
- public Resource getResource()
- {
- return resource;
- }
-
- public void setResource( Resource resource )
- {
- this.resource = resource;
- }
-
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.resource.Resource;
+
+import java.io.InputStream;
+
+/**
+ * @author <a href="mailto:michal at codehaus.org">Michal Maczka</a>
+ *
+ */
+public class InputData
+{
+ private InputStream inputStream;
+
+ private Resource resource;
+
+ public InputStream getInputStream()
+ {
+ return inputStream;
+ }
+
+ public void setInputStream( InputStream inputStream )
+ {
+ this.inputStream = inputStream;
+ }
+
+ public Resource getResource()
+ {
+ return resource;
+ }
+
+ public void setResource( Resource resource )
+ {
+ this.resource = resource;
+ }
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/LazyFileOutputStream.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/LazyFileOutputStream.java
index bb37340..e96f7c9 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/LazyFileOutputStream.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/LazyFileOutputStream.java
@@ -1,156 +1,156 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.io.FileDescriptor;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.channels.FileChannel;
-
-
-/**
- * Variant of FileOutputStream which creates the file only when first portion
- * of data is written.
- *
- * @author <a href="mailto:mmaczka at interia.pl">Michal Maczka</a>
- *
- */
-public class LazyFileOutputStream
- extends OutputStream
-{
-
- private File file;
-
- private FileOutputStream delegee;
-
-
- public LazyFileOutputStream( String filename )
- {
- this.file = new File( filename );
- }
-
- public LazyFileOutputStream( File file )
- {
- this.file = file;
- }
-
-
- public void close()
- throws IOException
- {
- if ( delegee != null )
- {
- delegee.close();
- }
- }
-
-
- public boolean equals( Object obj )
- {
- return delegee.equals( obj );
- }
-
-
- public void flush()
- throws IOException
- {
- if ( delegee != null )
- {
- delegee.flush();
- }
- }
-
-
- public FileChannel getChannel()
- {
- return delegee.getChannel();
- }
-
-
- public FileDescriptor getFD()
- throws IOException
- {
- return delegee.getFD();
- }
-
- public int hashCode()
- {
- return delegee.hashCode();
- }
-
-
- public String toString()
- {
- return delegee.toString();
- }
-
- public void write( byte[] b )
- throws IOException
- {
- if ( delegee == null )
- {
- initialize();
- }
-
- delegee.write( b );
- }
-
- /**
- * @see java.io.OutputStream#write(byte[], int, int)
- */
- public void write( byte[] b, int off, int len )
- throws IOException
- {
- if ( delegee == null )
- {
- initialize();
- }
-
- delegee.write( b, off, len );
- }
-
- /**
- * @param b
- * @throws java.io.IOException
- */
- public void write( int b )
- throws IOException
- {
- if ( delegee == null )
- {
- initialize();
- }
-
- delegee.write( b );
- }
-
-
- /**
- *
- */
- private void initialize()
- throws FileNotFoundException
- {
- delegee = new FileOutputStream( file );
- }
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.FileDescriptor;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.nio.channels.FileChannel;
+
+
+/**
+ * Variant of FileOutputStream which creates the file only when first portion
+ * of data is written.
+ *
+ * @author <a href="mailto:mmaczka at interia.pl">Michal Maczka</a>
+ *
+ */
+public class LazyFileOutputStream
+ extends OutputStream
+{
+
+ private File file;
+
+ private FileOutputStream delegee;
+
+
+ public LazyFileOutputStream( String filename )
+ {
+ this.file = new File( filename );
+ }
+
+ public LazyFileOutputStream( File file )
+ {
+ this.file = file;
+ }
+
+
+ public void close()
+ throws IOException
+ {
+ if ( delegee != null )
+ {
+ delegee.close();
+ }
+ }
+
+
+ public boolean equals( Object obj )
+ {
+ return delegee.equals( obj );
+ }
+
+
+ public void flush()
+ throws IOException
+ {
+ if ( delegee != null )
+ {
+ delegee.flush();
+ }
+ }
+
+
+ public FileChannel getChannel()
+ {
+ return delegee.getChannel();
+ }
+
+
+ public FileDescriptor getFD()
+ throws IOException
+ {
+ return delegee.getFD();
+ }
+
+ public int hashCode()
+ {
+ return delegee.hashCode();
+ }
+
+
+ public String toString()
+ {
+ return delegee.toString();
+ }
+
+ public void write( byte[] b )
+ throws IOException
+ {
+ if ( delegee == null )
+ {
+ initialize();
+ }
+
+ delegee.write( b );
+ }
+
+ /**
+ * @see java.io.OutputStream#write(byte[], int, int)
+ */
+ public void write( byte[] b, int off, int len )
+ throws IOException
+ {
+ if ( delegee == null )
+ {
+ initialize();
+ }
+
+ delegee.write( b, off, len );
+ }
+
+ /**
+ * @param b
+ * @throws java.io.IOException
+ */
+ public void write( int b )
+ throws IOException
+ {
+ if ( delegee == null )
+ {
+ initialize();
+ }
+
+ delegee.write( b );
+ }
+
+
+ /**
+ *
+ */
+ private void initialize()
+ throws FileNotFoundException
+ {
+ delegee = new FileOutputStream( file );
+ }
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/OutputData.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/OutputData.java
index 792f785..72d55c6 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/OutputData.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/OutputData.java
@@ -1,55 +1,55 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.resource.Resource;
-
-import java.io.OutputStream;
-
-/**
- * @author <a href="mailto:michal at codehaus.org">Michal Maczka</a>
- *
- */
-public class OutputData
-{
- private OutputStream outputStream;
-
- private Resource resource;
-
- public OutputStream getOutputStream()
- {
- return outputStream;
- }
-
- public void setOutputStream( OutputStream outputStream )
- {
- this.outputStream = outputStream;
- }
-
- public Resource getResource()
- {
- return resource;
- }
-
- public void setResource( Resource resource )
- {
- this.resource = resource;
- }
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.resource.Resource;
+
+import java.io.OutputStream;
+
+/**
+ * @author <a href="mailto:michal at codehaus.org">Michal Maczka</a>
+ *
+ */
+public class OutputData
+{
+ private OutputStream outputStream;
+
+ private Resource resource;
+
+ public OutputStream getOutputStream()
+ {
+ return outputStream;
+ }
+
+ public void setOutputStream( OutputStream outputStream )
+ {
+ this.outputStream = outputStream;
+ }
+
+ public Resource getResource()
+ {
+ return resource;
+ }
+
+ public void setResource( Resource resource )
+ {
+ this.resource = resource;
+ }
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/PathUtils.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/PathUtils.java
index 4641473..139e917 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/PathUtils.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/PathUtils.java
@@ -1,497 +1,497 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.util.StringTokenizer;
-
-/**
- * Various path (URL) manipulation routines
- *
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public final class PathUtils
-{
- private PathUtils()
- {
- }
-
- /**
- * Returns the directory path portion of a file specification string.
- * Matches the equally named unix command.
- *
- * @return The directory portion excluding the ending file separator.
- */
- public static String dirname( final String path )
- {
- final int i = path.lastIndexOf( "/" );
-
- return ( ( i >= 0 ) ? path.substring( 0, i ) : "" );
- }
-
- /**
- * Returns the filename portion of a file specification string.
- *
- * @return The filename string with extension.
- */
- public static String filename( final String path )
- {
- final int i = path.lastIndexOf( "/" );
- return ( ( i >= 0 ) ? path.substring( i + 1 ) : path );
- }
-
- public static String[] dirnames( final String path )
- {
- final String dirname = PathUtils.dirname( path );
- return split( dirname, "/", -1 );
-
- }
-
- private static String[] split( final String str, final String separator, final int max )
- {
- final StringTokenizer tok;
-
- if ( separator == null )
- {
- // Null separator means we're using StringTokenizer's default
- // delimiter, which comprises all whitespace characters.
- tok = new StringTokenizer( str );
- }
- else
- {
- tok = new StringTokenizer( str, separator );
- }
-
- int listSize = tok.countTokens();
-
- if ( max > 0 && listSize > max )
- {
- listSize = max;
- }
-
- final String[] list = new String[listSize];
-
- int i = 0;
-
- int lastTokenBegin;
- int lastTokenEnd = 0;
-
- while ( tok.hasMoreTokens() )
- {
- if ( max > 0 && i == listSize - 1 )
- {
- // In the situation where we hit the max yet have
- // tokens left over in our input, the last list
- // element gets all remaining text.
- final String endToken = tok.nextToken();
-
- lastTokenBegin = str.indexOf( endToken, lastTokenEnd );
-
- list[i] = str.substring( lastTokenBegin );
-
- break;
-
- }
- else
- {
- list[i] = tok.nextToken();
-
- lastTokenBegin = str.indexOf( list[i], lastTokenEnd );
-
- lastTokenEnd = lastTokenBegin + list[i].length();
- }
-
- i++;
- }
- return list;
- }
-
- /**
- * Return the host name (Removes protocol and path from the URL) E.g: for input
- * <code>http://www.codehause.org</code> this method will return <code>www.apache.org</code>
- *
- * @param url the url
- * @return the host name
- */
- public static String host( final String url )
- {
- if ( url == null || url.length() == 0 )
- {
- return "localhost";
- }
- String authorization = authorization( url );
- int index = authorization.indexOf( '@' );
- String host = ( index >= 0 ) ? authorization.substring( index + 1 ) : authorization;
- // In case we have IPv6 in the host portion of url
- // we have to remove brackets '[' and ']'
- return ( ( host.charAt( 0 ) == '[' ) && ( host.charAt( host.length() - 1 ) == ']' ) )
- ? host.substring( 1, host.length() - 1 )
- : host;
- }
-
- /**
- * This was changed from private to package local so that it can be unit tested.
- */
- static String authorization( final String url )
- {
- if ( url == null )
- {
- return "localhost";
- }
-
- final String protocol = PathUtils.protocol( url );
-
- if ( protocol == null || protocol.equalsIgnoreCase( "file" ) )
- {
- return "localhost";
- }
-
- String host = url;
- if ( protocol.equalsIgnoreCase( "scm" ) )
- {
- // skip over type
- host = host.substring( host.indexOf( ":", 4 ) + 1 ).trim();
- }
-
- // skip over protocol
- host = host.substring( host.indexOf( ":" ) + 1 ).trim();
- if ( host.startsWith( "//" ) )
- {
- host = host.substring( 2 );
- }
-
- int pos = host.indexOf( "/" );
-
- if ( pos > 0 )
- {
- host = host.substring( 0, pos );
- }
-
- pos = host.indexOf( '@' );
-
- pos = ( pos > 0 ) ? endOfHostPosition( host, pos ) : endOfHostPosition( host, 0 );
-
- if ( pos > 0 )
- {
- host = host.substring( 0, pos );
- }
- return host;
- }
-
- private static int endOfHostPosition( String host, int pos )
- {
- // if this is IPv6 then it will be in IPv6 Literal Addresses in URL's format
- // see: http://www.ietf.org/rfc/rfc2732.txt
- int endOfIPv6Pos = host.indexOf( ']', pos );
- return ( endOfIPv6Pos > 0 ) ? endOfIPv6Pos + 1 : host.indexOf( ":", pos );
- }
-
- /**
- * /**
- * Return the protocol name.
- * <br/>
- * E.g: for input
- * <code>http://www.codehause.org</code> this method will return <code>http</code>
- *
- * @param url the url
- * @return the host name
- */
- public static String protocol( final String url )
- {
- final int pos = url.indexOf( ":" );
-
- if ( pos == -1 )
- {
- return "";
- }
- return url.substring( 0, pos ).trim();
- }
-
- /**
- * @param url
- * @return the port or {@link WagonConstants#UNKNOWN_PORT} if not existent
- */
- public static int port( String url )
- {
-
- final String protocol = PathUtils.protocol( url );
-
- if ( protocol == null || protocol.equalsIgnoreCase( "file" ) )
- {
- return WagonConstants.UNKNOWN_PORT;
- }
-
- final String authorization = PathUtils.authorization( url );
-
- if ( authorization == null )
- {
- return WagonConstants.UNKNOWN_PORT;
- }
-
- if ( protocol.equalsIgnoreCase( "scm" ) )
- {
- // skip over type
- url = url.substring( url.indexOf( ":", 4 ) + 1 ).trim();
- }
-
- if ( url.regionMatches( true, 0, "file:", 0, 5 ) || url.regionMatches( true, 0, "local:", 0, 6 ) )
- {
- return WagonConstants.UNKNOWN_PORT;
- }
-
- // skip over protocol
- url = url.substring( url.indexOf( ":" ) + 1 ).trim();
- if ( url.startsWith( "//" ) )
- {
- url = url.substring( 2 );
- }
-
- int start = authorization.length();
-
- if ( url.length() > start && url.charAt( start ) == ':' )
- {
- int end = url.indexOf( '/', start );
-
- if ( end == start + 1 )
- {
- // it is :/
- return WagonConstants.UNKNOWN_PORT;
- }
-
- if ( end == -1 )
- {
- end = url.length();
- }
-
- return Integer.parseInt( url.substring( start + 1, end ) );
- }
- else
- {
- return WagonConstants.UNKNOWN_PORT;
- }
-
- }
-
- /**
- * Derive the path portion of the given URL.
- *
- * @param url the repository URL
- * @return the basedir of the repository
- * @todo need to URL decode for spaces?
- */
- public static String basedir( String url )
- {
- String protocol = PathUtils.protocol( url );
-
- String retValue = null;
-
- if ( protocol.equalsIgnoreCase( "scm" ) )
- {
- // skip over SCM bits
- if ( url.regionMatches( true, 0, "scm:svn:", 0, 8 ) )
- {
- url = url.substring( url.indexOf( ":", 4 ) + 1 );
- protocol = PathUtils.protocol( url );
- }
- }
-
- if ( protocol.equalsIgnoreCase( "file" ) )
- {
- retValue = url.substring( protocol.length() + 1 );
- retValue = decode( retValue );
- // special case: if omitted // on protocol, keep path as is
- if ( retValue.startsWith( "//" ) )
- {
- retValue = retValue.substring( 2 );
-
- if ( retValue.length() >= 2 && ( retValue.charAt( 1 ) == '|' || retValue.charAt( 1 ) == ':' ) )
- {
- // special case: if there is a windows drive letter, then keep the original return value
- retValue = retValue.charAt( 0 ) + ":" + retValue.substring( 2 );
- }
- else
- {
- // Now we expect the host
- int index = retValue.indexOf( "/" );
- if ( index >= 0 )
- {
- retValue = retValue.substring( index + 1 );
- }
-
- // special case: if there is a windows drive letter, then keep the original return value
- if ( retValue.length() >= 2 && ( retValue.charAt( 1 ) == '|' || retValue.charAt( 1 ) == ':' ) )
- {
- retValue = retValue.charAt( 0 ) + ":" + retValue.substring( 2 );
- }
- else if ( index >= 0 )
- {
- // leading / was previously stripped
- retValue = "/" + retValue;
- }
- }
- }
-
- // special case: if there is a windows drive letter using |, switch to :
- if ( retValue.length() >= 2 && retValue.charAt( 1 ) == '|' )
- {
- retValue = retValue.charAt( 0 ) + ":" + retValue.substring( 2 );
- }
- }
- else
- {
- final String authorization = PathUtils.authorization( url );
-
- final int port = PathUtils.port( url );
-
- int pos = 0;
-
- if ( protocol.equalsIgnoreCase( "scm" ) )
- {
- pos = url.indexOf( ":", 4 ) + 1;
- pos = url.indexOf( ":", pos ) + 1;
- }
- else
- {
- int index = url.indexOf( "://" );
- if ( index != -1 )
- {
- pos = index + 3;
- }
- }
-
- pos += authorization.length();
-
- if ( port != WagonConstants.UNKNOWN_PORT )
- {
- pos = pos + Integer.toString( port ).length() + 1;
- }
-
- if ( url.length() > pos )
- {
- retValue = url.substring( pos );
- if ( retValue.startsWith( ":" ) )
- {
- // this is for :/ after the host
- retValue = retValue.substring( 1 );
- }
-
- // one module may be allowed in the path in CVS
- retValue = retValue.replace( ':', '/' );
- }
- }
-
- if ( retValue == null )
- {
- retValue = "/";
- }
- return retValue.trim();
- }
-
- /**
- * Decodes the specified (portion of a) URL. <strong>Note:</strong> This decoder assumes that ISO-8859-1 is used to
- * convert URL-encoded octets to characters.
- *
- * @param url The URL to decode, may be <code>null</code>.
- * @return The decoded URL or <code>null</code> if the input was <code>null</code>.
- */
- private static String decode( String url )
- {
- String decoded = url;
- if ( url != null )
- {
- int pos = -1;
- while ( ( pos = decoded.indexOf( '%', pos + 1 ) ) >= 0 )
- {
- if ( pos + 2 < decoded.length() )
- {
- String hexStr = decoded.substring( pos + 1, pos + 3 );
- char ch = (char) Integer.parseInt( hexStr, 16 );
- decoded = decoded.substring( 0, pos ) + ch + decoded.substring( pos + 3 );
- }
- }
- }
- return decoded;
- }
-
- public static String user( String url )
- {
- String host = authorization( url );
- int index = host.indexOf( '@' );
- if ( index > 0 )
- {
- String userInfo = host.substring( 0, index );
- index = userInfo.indexOf( ':' );
- if ( index > 0 )
- {
- return userInfo.substring( 0, index );
- }
- else if ( index < 0 )
- {
- return userInfo;
- }
- }
- return null;
- }
-
- public static String password( String url )
- {
- String host = authorization( url );
- int index = host.indexOf( '@' );
- if ( index > 0 )
- {
- String userInfo = host.substring( 0, index );
- index = userInfo.indexOf( ':' );
- if ( index >= 0 )
- {
- return userInfo.substring( index + 1 );
- }
- }
- return null;
- }
-
- // TODO: move to plexus-utils or use something appropriate from there
- public static String toRelative( File basedir, String absolutePath )
- {
- String relative;
-
- absolutePath = absolutePath.replace( '\\', '/' );
- String basedirPath = basedir.getAbsolutePath().replace( '\\', '/' );
-
- if ( absolutePath.startsWith( basedirPath ) )
- {
- relative = absolutePath.substring( basedirPath.length() );
- if ( relative.startsWith( "/" ) )
- {
- relative = relative.substring( 1 );
- }
- if ( relative.length() <= 0 )
- {
- relative = ".";
- }
- }
- else
- {
- relative = absolutePath;
- }
-
- return relative;
- }
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.StringTokenizer;
+
+/**
+ * Various path (URL) manipulation routines
+ *
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public final class PathUtils
+{
+ private PathUtils()
+ {
+ }
+
+ /**
+ * Returns the directory path portion of a file specification string.
+ * Matches the equally named unix command.
+ *
+ * @return The directory portion excluding the ending file separator.
+ */
+ public static String dirname( final String path )
+ {
+ final int i = path.lastIndexOf( "/" );
+
+ return ( ( i >= 0 ) ? path.substring( 0, i ) : "" );
+ }
+
+ /**
+ * Returns the filename portion of a file specification string.
+ *
+ * @return The filename string with extension.
+ */
+ public static String filename( final String path )
+ {
+ final int i = path.lastIndexOf( "/" );
+ return ( ( i >= 0 ) ? path.substring( i + 1 ) : path );
+ }
+
+ public static String[] dirnames( final String path )
+ {
+ final String dirname = PathUtils.dirname( path );
+ return split( dirname, "/", -1 );
+
+ }
+
+ private static String[] split( final String str, final String separator, final int max )
+ {
+ final StringTokenizer tok;
+
+ if ( separator == null )
+ {
+ // Null separator means we're using StringTokenizer's default
+ // delimiter, which comprises all whitespace characters.
+ tok = new StringTokenizer( str );
+ }
+ else
+ {
+ tok = new StringTokenizer( str, separator );
+ }
+
+ int listSize = tok.countTokens();
+
+ if ( max > 0 && listSize > max )
+ {
+ listSize = max;
+ }
+
+ final String[] list = new String[listSize];
+
+ int i = 0;
+
+ int lastTokenBegin;
+ int lastTokenEnd = 0;
+
+ while ( tok.hasMoreTokens() )
+ {
+ if ( max > 0 && i == listSize - 1 )
+ {
+ // In the situation where we hit the max yet have
+ // tokens left over in our input, the last list
+ // element gets all remaining text.
+ final String endToken = tok.nextToken();
+
+ lastTokenBegin = str.indexOf( endToken, lastTokenEnd );
+
+ list[i] = str.substring( lastTokenBegin );
+
+ break;
+
+ }
+ else
+ {
+ list[i] = tok.nextToken();
+
+ lastTokenBegin = str.indexOf( list[i], lastTokenEnd );
+
+ lastTokenEnd = lastTokenBegin + list[i].length();
+ }
+
+ i++;
+ }
+ return list;
+ }
+
+ /**
+ * Return the host name (Removes protocol and path from the URL) E.g: for input
+ * <code>http://www.codehause.org</code> this method will return <code>www.apache.org</code>
+ *
+ * @param url the url
+ * @return the host name
+ */
+ public static String host( final String url )
+ {
+ if ( url == null || url.length() == 0 )
+ {
+ return "localhost";
+ }
+ String authorization = authorization( url );
+ int index = authorization.indexOf( '@' );
+ String host = ( index >= 0 ) ? authorization.substring( index + 1 ) : authorization;
+ // In case we have IPv6 in the host portion of url
+ // we have to remove brackets '[' and ']'
+ return ( ( host.charAt( 0 ) == '[' ) && ( host.charAt( host.length() - 1 ) == ']' ) )
+ ? host.substring( 1, host.length() - 1 )
+ : host;
+ }
+
+ /**
+ * This was changed from private to package local so that it can be unit tested.
+ */
+ static String authorization( final String url )
+ {
+ if ( url == null )
+ {
+ return "localhost";
+ }
+
+ final String protocol = PathUtils.protocol( url );
+
+ if ( protocol == null || protocol.equalsIgnoreCase( "file" ) )
+ {
+ return "localhost";
+ }
+
+ String host = url;
+ if ( protocol.equalsIgnoreCase( "scm" ) )
+ {
+ // skip over type
+ host = host.substring( host.indexOf( ":", 4 ) + 1 ).trim();
+ }
+
+ // skip over protocol
+ host = host.substring( host.indexOf( ":" ) + 1 ).trim();
+ if ( host.startsWith( "//" ) )
+ {
+ host = host.substring( 2 );
+ }
+
+ int pos = host.indexOf( "/" );
+
+ if ( pos > 0 )
+ {
+ host = host.substring( 0, pos );
+ }
+
+ pos = host.indexOf( '@' );
+
+ pos = ( pos > 0 ) ? endOfHostPosition( host, pos ) : endOfHostPosition( host, 0 );
+
+ if ( pos > 0 )
+ {
+ host = host.substring( 0, pos );
+ }
+ return host;
+ }
+
+ private static int endOfHostPosition( String host, int pos )
+ {
+ // if this is IPv6 then it will be in IPv6 Literal Addresses in URL's format
+ // see: http://www.ietf.org/rfc/rfc2732.txt
+ int endOfIPv6Pos = host.indexOf( ']', pos );
+ return ( endOfIPv6Pos > 0 ) ? endOfIPv6Pos + 1 : host.indexOf( ":", pos );
+ }
+
+ /**
+ * /**
+ * Return the protocol name.
+ * <br/>
+ * E.g: for input
+ * <code>http://www.codehause.org</code> this method will return <code>http</code>
+ *
+ * @param url the url
+ * @return the host name
+ */
+ public static String protocol( final String url )
+ {
+ final int pos = url.indexOf( ":" );
+
+ if ( pos == -1 )
+ {
+ return "";
+ }
+ return url.substring( 0, pos ).trim();
+ }
+
+ /**
+ * @param url
+ * @return the port or {@link WagonConstants#UNKNOWN_PORT} if not existent
+ */
+ public static int port( String url )
+ {
+
+ final String protocol = PathUtils.protocol( url );
+
+ if ( protocol == null || protocol.equalsIgnoreCase( "file" ) )
+ {
+ return WagonConstants.UNKNOWN_PORT;
+ }
+
+ final String authorization = PathUtils.authorization( url );
+
+ if ( authorization == null )
+ {
+ return WagonConstants.UNKNOWN_PORT;
+ }
+
+ if ( protocol.equalsIgnoreCase( "scm" ) )
+ {
+ // skip over type
+ url = url.substring( url.indexOf( ":", 4 ) + 1 ).trim();
+ }
+
+ if ( url.regionMatches( true, 0, "file:", 0, 5 ) || url.regionMatches( true, 0, "local:", 0, 6 ) )
+ {
+ return WagonConstants.UNKNOWN_PORT;
+ }
+
+ // skip over protocol
+ url = url.substring( url.indexOf( ":" ) + 1 ).trim();
+ if ( url.startsWith( "//" ) )
+ {
+ url = url.substring( 2 );
+ }
+
+ int start = authorization.length();
+
+ if ( url.length() > start && url.charAt( start ) == ':' )
+ {
+ int end = url.indexOf( '/', start );
+
+ if ( end == start + 1 )
+ {
+ // it is :/
+ return WagonConstants.UNKNOWN_PORT;
+ }
+
+ if ( end == -1 )
+ {
+ end = url.length();
+ }
+
+ return Integer.parseInt( url.substring( start + 1, end ) );
+ }
+ else
+ {
+ return WagonConstants.UNKNOWN_PORT;
+ }
+
+ }
+
+ /**
+ * Derive the path portion of the given URL.
+ *
+ * @param url the repository URL
+ * @return the basedir of the repository
+ * @todo need to URL decode for spaces?
+ */
+ public static String basedir( String url )
+ {
+ String protocol = PathUtils.protocol( url );
+
+ String retValue = null;
+
+ if ( protocol.equalsIgnoreCase( "scm" ) )
+ {
+ // skip over SCM bits
+ if ( url.regionMatches( true, 0, "scm:svn:", 0, 8 ) )
+ {
+ url = url.substring( url.indexOf( ":", 4 ) + 1 );
+ protocol = PathUtils.protocol( url );
+ }
+ }
+
+ if ( protocol.equalsIgnoreCase( "file" ) )
+ {
+ retValue = url.substring( protocol.length() + 1 );
+ retValue = decode( retValue );
+ // special case: if omitted // on protocol, keep path as is
+ if ( retValue.startsWith( "//" ) )
+ {
+ retValue = retValue.substring( 2 );
+
+ if ( retValue.length() >= 2 && ( retValue.charAt( 1 ) == '|' || retValue.charAt( 1 ) == ':' ) )
+ {
+ // special case: if there is a windows drive letter, then keep the original return value
+ retValue = retValue.charAt( 0 ) + ":" + retValue.substring( 2 );
+ }
+ else
+ {
+ // Now we expect the host
+ int index = retValue.indexOf( "/" );
+ if ( index >= 0 )
+ {
+ retValue = retValue.substring( index + 1 );
+ }
+
+ // special case: if there is a windows drive letter, then keep the original return value
+ if ( retValue.length() >= 2 && ( retValue.charAt( 1 ) == '|' || retValue.charAt( 1 ) == ':' ) )
+ {
+ retValue = retValue.charAt( 0 ) + ":" + retValue.substring( 2 );
+ }
+ else if ( index >= 0 )
+ {
+ // leading / was previously stripped
+ retValue = "/" + retValue;
+ }
+ }
+ }
+
+ // special case: if there is a windows drive letter using |, switch to :
+ if ( retValue.length() >= 2 && retValue.charAt( 1 ) == '|' )
+ {
+ retValue = retValue.charAt( 0 ) + ":" + retValue.substring( 2 );
+ }
+ }
+ else
+ {
+ final String authorization = PathUtils.authorization( url );
+
+ final int port = PathUtils.port( url );
+
+ int pos = 0;
+
+ if ( protocol.equalsIgnoreCase( "scm" ) )
+ {
+ pos = url.indexOf( ":", 4 ) + 1;
+ pos = url.indexOf( ":", pos ) + 1;
+ }
+ else
+ {
+ int index = url.indexOf( "://" );
+ if ( index != -1 )
+ {
+ pos = index + 3;
+ }
+ }
+
+ pos += authorization.length();
+
+ if ( port != WagonConstants.UNKNOWN_PORT )
+ {
+ pos = pos + Integer.toString( port ).length() + 1;
+ }
+
+ if ( url.length() > pos )
+ {
+ retValue = url.substring( pos );
+ if ( retValue.startsWith( ":" ) )
+ {
+ // this is for :/ after the host
+ retValue = retValue.substring( 1 );
+ }
+
+ // one module may be allowed in the path in CVS
+ retValue = retValue.replace( ':', '/' );
+ }
+ }
+
+ if ( retValue == null )
+ {
+ retValue = "/";
+ }
+ return retValue.trim();
+ }
+
+ /**
+ * Decodes the specified (portion of a) URL. <strong>Note:</strong> This decoder assumes that ISO-8859-1 is used to
+ * convert URL-encoded octets to characters.
+ *
+ * @param url The URL to decode, may be <code>null</code>.
+ * @return The decoded URL or <code>null</code> if the input was <code>null</code>.
+ */
+ private static String decode( String url )
+ {
+ String decoded = url;
+ if ( url != null )
+ {
+ int pos = -1;
+ while ( ( pos = decoded.indexOf( '%', pos + 1 ) ) >= 0 )
+ {
+ if ( pos + 2 < decoded.length() )
+ {
+ String hexStr = decoded.substring( pos + 1, pos + 3 );
+ char ch = (char) Integer.parseInt( hexStr, 16 );
+ decoded = decoded.substring( 0, pos ) + ch + decoded.substring( pos + 3 );
+ }
+ }
+ }
+ return decoded;
+ }
+
+ public static String user( String url )
+ {
+ String host = authorization( url );
+ int index = host.indexOf( '@' );
+ if ( index > 0 )
+ {
+ String userInfo = host.substring( 0, index );
+ index = userInfo.indexOf( ':' );
+ if ( index > 0 )
+ {
+ return userInfo.substring( 0, index );
+ }
+ else if ( index < 0 )
+ {
+ return userInfo;
+ }
+ }
+ return null;
+ }
+
+ public static String password( String url )
+ {
+ String host = authorization( url );
+ int index = host.indexOf( '@' );
+ if ( index > 0 )
+ {
+ String userInfo = host.substring( 0, index );
+ index = userInfo.indexOf( ':' );
+ if ( index >= 0 )
+ {
+ return userInfo.substring( index + 1 );
+ }
+ }
+ return null;
+ }
+
+ // TODO: move to plexus-utils or use something appropriate from there
+ public static String toRelative( File basedir, String absolutePath )
+ {
+ String relative;
+
+ absolutePath = absolutePath.replace( '\\', '/' );
+ String basedirPath = basedir.getAbsolutePath().replace( '\\', '/' );
+
+ if ( absolutePath.startsWith( basedirPath ) )
+ {
+ relative = absolutePath.substring( basedirPath.length() );
+ if ( relative.startsWith( "/" ) )
+ {
+ relative = relative.substring( 1 );
+ }
+ if ( relative.length() <= 0 )
+ {
+ relative = ".";
+ }
+ }
+ else
+ {
+ relative = absolutePath;
+ }
+
+ return relative;
+ }
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/PermissionModeUtils.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/PermissionModeUtils.java
index bc4c86c..b1fa16f 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/PermissionModeUtils.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/PermissionModeUtils.java
@@ -1,74 +1,74 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Utility class for common operations for file/directory permissions.
- *
- * @author <a href="mailto:juam at users.sourceforge.net">Juan F. Codagnone</a>
- * @see PermissionModeUtils
- * @since Sep 3, 2005
- */
-public final class PermissionModeUtils
-{
- private PermissionModeUtils()
- {
- }
-
- /**
- * See the System Interfaces volume of IEEE Std 1003.1-2001, umask(1)
- *
- * @param modeStr permission mode (numeric or symbolic)
- * @return the mode that can be used with umask to accomplish modeStr.
- */
- public static String getUserMaskFor( String modeStr )
- {
- String ret = null;
-
- try
- {
- int mode = Integer.valueOf( modeStr, 8 ).intValue();
-
- mode = mode % 8 + ( ( mode / 8 ) % 8 ) * 8 + ( ( mode / 64 ) % 8 ) * 64;
-
- // CHECKSTYLE_OFF: MagicNumber
- ret = Integer.toOctalString( 0777 - mode );
- // CHECKSTYLE_ON: MagicNumber
- }
- catch ( final NumberFormatException e )
- {
- try
- {
- Integer.parseInt( modeStr );
- }
- catch ( final NumberFormatException e1 )
- {
- ret = modeStr;
- }
- }
-
- if ( ret == null )
- {
- throw new IllegalArgumentException( "The mode is a number but is not octal" );
- }
-
- return ret;
- }
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Utility class for common operations for file/directory permissions.
+ *
+ * @author <a href="mailto:juam at users.sourceforge.net">Juan F. Codagnone</a>
+ * @see PermissionModeUtils
+ * @since Sep 3, 2005
+ */
+public final class PermissionModeUtils
+{
+ private PermissionModeUtils()
+ {
+ }
+
+ /**
+ * See the System Interfaces volume of IEEE Std 1003.1-2001, umask(1)
+ *
+ * @param modeStr permission mode (numeric or symbolic)
+ * @return the mode that can be used with umask to accomplish modeStr.
+ */
+ public static String getUserMaskFor( String modeStr )
+ {
+ String ret = null;
+
+ try
+ {
+ int mode = Integer.valueOf( modeStr, 8 ).intValue();
+
+ mode = mode % 8 + ( ( mode / 8 ) % 8 ) * 8 + ( ( mode / 64 ) % 8 ) * 64;
+
+ // CHECKSTYLE_OFF: MagicNumber
+ ret = Integer.toOctalString( 0777 - mode );
+ // CHECKSTYLE_ON: MagicNumber
+ }
+ catch ( final NumberFormatException e )
+ {
+ try
+ {
+ Integer.parseInt( modeStr );
+ }
+ catch ( final NumberFormatException e1 )
+ {
+ ret = modeStr;
+ }
+ }
+
+ if ( ret == null )
+ {
+ throw new IllegalArgumentException( "The mode is a number but is not octal" );
+ }
+
+ return ret;
+ }
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/ResourceDoesNotExistException.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/ResourceDoesNotExistException.java
index 8e8919b..5ada967 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/ResourceDoesNotExistException.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/ResourceDoesNotExistException.java
@@ -1,47 +1,47 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class ResourceDoesNotExistException
- extends WagonException
-{
-
- /**
- * @param message
- */
- public ResourceDoesNotExistException( final String message )
- {
- super( message );
- }
-
- /**
- * @param message
- * @param cause
- */
- public ResourceDoesNotExistException( final String message, final Throwable cause )
- {
- super( message, cause );
- }
-
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class ResourceDoesNotExistException
+ extends WagonException
+{
+
+ /**
+ * @param message
+ */
+ public ResourceDoesNotExistException( final String message )
+ {
+ super( message );
+ }
+
+ /**
+ * @param message
+ * @param cause
+ */
+ public ResourceDoesNotExistException( final String message, final Throwable cause )
+ {
+ super( message, cause );
+ }
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamWagon.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamWagon.java
index 3990139..beb2607 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamWagon.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamWagon.java
@@ -1,282 +1,302 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.apache.maven.wagon.authorization.AuthorizationException;
-import org.apache.maven.wagon.events.TransferEvent;
-import org.apache.maven.wagon.resource.Resource;
-import org.codehaus.plexus.util.IOUtil;
-
-/**
- * Base class for wagon which provide stream based API.
- *
- * @author <a href="mailto:michal at codehaus.org">Michal Maczka</a>
- *
- */
-public abstract class StreamWagon
- extends AbstractWagon
- implements StreamingWagon
-{
- // ----------------------------------------------------------------------
- //
- // ----------------------------------------------------------------------
-
- public abstract void fillInputData( InputData inputData )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;
-
- public abstract void fillOutputData( OutputData outputData )
- throws TransferFailedException;
-
- public abstract void closeConnection()
- throws ConnectionException;
-
- // ----------------------------------------------------------------------
- //
- // ----------------------------------------------------------------------
-
- public void get( String resourceName, File destination )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- getIfNewer( resourceName, destination, 0 );
- }
-
- protected void checkInputStream( InputStream is, Resource resource )
- throws TransferFailedException
- {
- if ( is == null )
- {
- TransferFailedException e =
- new TransferFailedException( getRepository().getUrl()
- + " - Could not open input stream for resource: '" + resource + "'" );
- fireTransferError( resource, e, TransferEvent.REQUEST_GET );
- throw e;
- }
- }
-
- public boolean getIfNewer( String resourceName, File destination, long timestamp )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- boolean retValue = false;
-
- Resource resource = new Resource( resourceName );
-
- fireGetInitiated( resource, destination );
-
- resource.setLastModified( timestamp );
-
- InputStream is = getInputStream( resource );
-
- // always get if timestamp is 0 (ie, target doesn't exist), otherwise only if older than the remote file
- if ( timestamp == 0 || timestamp < resource.getLastModified() )
- {
- retValue = true;
-
- checkInputStream( is, resource );
-
- getTransfer( resource, destination, is );
- }
- else
- {
- IOUtil.close( is );
- }
-
- return retValue;
- }
-
- protected InputStream getInputStream( Resource resource )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- InputData inputData = new InputData();
-
- inputData.setResource( resource );
-
- try
- {
- fillInputData( inputData );
- }
- catch ( TransferFailedException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_GET );
- cleanupGetTransfer( resource );
- throw e;
- }
- catch ( ResourceDoesNotExistException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_GET );
- cleanupGetTransfer( resource );
- throw e;
- }
- catch ( AuthorizationException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_GET );
- cleanupGetTransfer( resource );
- throw e;
- }
- finally
- {
- if ( inputData.getInputStream() == null )
- {
- cleanupGetTransfer( resource );
- }
- }
-
- return inputData.getInputStream();
- }
-
- // source doesn't exist exception
- public void put( File source, String resourceName )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- Resource resource = new Resource( resourceName );
-
- firePutInitiated( resource, source );
-
- resource.setContentLength( source.length() );
-
- resource.setLastModified( source.lastModified() );
-
- OutputStream os = getOutputStream( resource );
-
- checkOutputStream( resource, os );
-
- putTransfer( resource, source, os, true );
- }
-
- protected void checkOutputStream( Resource resource, OutputStream os )
- throws TransferFailedException
- {
- if ( os == null )
- {
- TransferFailedException e =
- new TransferFailedException( getRepository().getUrl()
- + " - Could not open output stream for resource: '" + resource + "'" );
- fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
- throw e;
- }
- }
-
- protected OutputStream getOutputStream( Resource resource )
- throws TransferFailedException
- {
- OutputData outputData = new OutputData();
-
- outputData.setResource( resource );
-
- try
- {
- fillOutputData( outputData );
- }
- catch ( TransferFailedException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
-
- throw e;
- }
- finally
- {
- if ( outputData.getOutputStream() == null )
- {
- cleanupPutTransfer( resource );
- }
- }
-
- return outputData.getOutputStream();
- }
-
- public boolean getIfNewerToStream( String resourceName, OutputStream stream, long timestamp )
- throws ResourceDoesNotExistException, TransferFailedException, AuthorizationException
- {
- boolean retValue = false;
-
- Resource resource = new Resource( resourceName );
-
- fireGetInitiated( resource, null );
-
- InputStream is = getInputStream( resource );
-
- // always get if timestamp is 0 (ie, target doesn't exist), otherwise only if older than the remote file
- if ( timestamp == 0 || timestamp < resource.getLastModified() )
- {
- retValue = true;
-
- checkInputStream( is, resource );
-
- fireGetStarted( resource, null );
-
- getTransfer( resource, stream, is, true, Integer.MAX_VALUE );
-
- fireGetCompleted( resource, null );
- }
- else
- {
- IOUtil.close( is );
- }
-
- return retValue;
- }
-
- public void getToStream( String resourceName, OutputStream stream )
- throws ResourceDoesNotExistException, TransferFailedException, AuthorizationException
- {
- getIfNewerToStream( resourceName, stream, 0 );
- }
-
- public void putFromStream( InputStream stream, String destination )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- Resource resource = new Resource( destination );
-
- firePutInitiated( resource, null );
-
- putFromStream( stream, resource );
- }
-
- public void putFromStream( InputStream stream, String destination, long contentLength, long lastModified )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- Resource resource = new Resource( destination );
-
- firePutInitiated( resource, null );
-
- resource.setContentLength( contentLength );
-
- resource.setLastModified( lastModified );
-
- putFromStream( stream, resource );
- }
-
- protected void putFromStream( InputStream stream, Resource resource )
- throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
- {
- OutputStream os = getOutputStream( resource );
-
- checkOutputStream( resource, os );
-
- firePutStarted( resource, null );
-
- putTransfer( resource, stream, os, true );
-
- firePutCompleted( resource, null );
- }
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.resource.Resource;
+
+/**
+ * Base class for wagon which provide stream based API.
+ *
+ * @author <a href="mailto:michal at codehaus.org">Michal Maczka</a>
+ *
+ */
+public abstract class StreamWagon
+ extends AbstractWagon
+ implements StreamingWagon
+{
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ public abstract void fillInputData( InputData inputData )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;
+
+ public abstract void fillOutputData( OutputData outputData )
+ throws TransferFailedException;
+
+ public abstract void closeConnection()
+ throws ConnectionException;
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ public void get( String resourceName, File destination )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ getIfNewer( resourceName, destination, 0 );
+ }
+
+ protected void checkInputStream( InputStream is, Resource resource )
+ throws TransferFailedException
+ {
+ if ( is == null )
+ {
+ TransferFailedException e =
+ new TransferFailedException( getRepository().getUrl()
+ + " - Could not open input stream for resource: '" + resource + "'" );
+ fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+ throw e;
+ }
+ }
+
+ public boolean getIfNewer( String resourceName, File destination, long timestamp )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ boolean retValue = false;
+
+ Resource resource = new Resource( resourceName );
+
+ fireGetInitiated( resource, destination );
+
+ resource.setLastModified( timestamp );
+
+ InputStream is = getInputStream( resource );
+
+ // always get if timestamp is 0 (ie, target doesn't exist), otherwise only if older than the remote file
+ if ( timestamp == 0 || timestamp < resource.getLastModified() )
+ {
+ retValue = true;
+
+ checkInputStream( is, resource );
+
+ getTransfer( resource, destination, is );
+ }
+ else
+ {
+ try
+ {
+ if ( is != null )
+ {
+ is.close();
+ }
+ }
+ catch ( final IOException e )
+ {
+ throw new TransferFailedException( "Failure transferring " + resourceName, e );
+ }
+ }
+
+ return retValue;
+ }
+
+ protected InputStream getInputStream( Resource resource )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ InputData inputData = new InputData();
+
+ inputData.setResource( resource );
+
+ try
+ {
+ fillInputData( inputData );
+ }
+ catch ( TransferFailedException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+ cleanupGetTransfer( resource );
+ throw e;
+ }
+ catch ( ResourceDoesNotExistException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+ cleanupGetTransfer( resource );
+ throw e;
+ }
+ catch ( AuthorizationException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+ cleanupGetTransfer( resource );
+ throw e;
+ }
+ finally
+ {
+ if ( inputData.getInputStream() == null )
+ {
+ cleanupGetTransfer( resource );
+ }
+ }
+
+ return inputData.getInputStream();
+ }
+
+ // source doesn't exist exception
+ public void put( File source, String resourceName )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ Resource resource = new Resource( resourceName );
+
+ firePutInitiated( resource, source );
+
+ resource.setContentLength( source.length() );
+
+ resource.setLastModified( source.lastModified() );
+
+ OutputStream os = getOutputStream( resource );
+
+ checkOutputStream( resource, os );
+
+ putTransfer( resource, source, os, true );
+ }
+
+ protected void checkOutputStream( Resource resource, OutputStream os )
+ throws TransferFailedException
+ {
+ if ( os == null )
+ {
+ TransferFailedException e =
+ new TransferFailedException( getRepository().getUrl()
+ + " - Could not open output stream for resource: '" + resource + "'" );
+ fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+ throw e;
+ }
+ }
+
+ protected OutputStream getOutputStream( Resource resource )
+ throws TransferFailedException
+ {
+ OutputData outputData = new OutputData();
+
+ outputData.setResource( resource );
+
+ try
+ {
+ fillOutputData( outputData );
+ }
+ catch ( TransferFailedException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
+ throw e;
+ }
+ finally
+ {
+ if ( outputData.getOutputStream() == null )
+ {
+ cleanupPutTransfer( resource );
+ }
+ }
+
+ return outputData.getOutputStream();
+ }
+
+ public boolean getIfNewerToStream( String resourceName, OutputStream stream, long timestamp )
+ throws ResourceDoesNotExistException, TransferFailedException, AuthorizationException
+ {
+ boolean retValue = false;
+
+ Resource resource = new Resource( resourceName );
+
+ fireGetInitiated( resource, null );
+
+ InputStream is = getInputStream( resource );
+
+ // always get if timestamp is 0 (ie, target doesn't exist), otherwise only if older than the remote file
+ if ( timestamp == 0 || timestamp < resource.getLastModified() )
+ {
+ retValue = true;
+
+ checkInputStream( is, resource );
+
+ fireGetStarted( resource, null );
+
+ getTransfer( resource, stream, is, true, Integer.MAX_VALUE );
+
+ fireGetCompleted( resource, null );
+ }
+ else
+ {
+ try
+ {
+ if ( is != null )
+ {
+ is.close();
+ }
+ }
+ catch ( final IOException e )
+ {
+ throw new TransferFailedException( "Failure transferring " + resourceName, e );
+ }
+ }
+
+ return retValue;
+ }
+
+ public void getToStream( String resourceName, OutputStream stream )
+ throws ResourceDoesNotExistException, TransferFailedException, AuthorizationException
+ {
+ getIfNewerToStream( resourceName, stream, 0 );
+ }
+
+ public void putFromStream( InputStream stream, String destination )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ Resource resource = new Resource( destination );
+
+ firePutInitiated( resource, null );
+
+ putFromStream( stream, resource );
+ }
+
+ public void putFromStream( InputStream stream, String destination, long contentLength, long lastModified )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ Resource resource = new Resource( destination );
+
+ firePutInitiated( resource, null );
+
+ resource.setContentLength( contentLength );
+
+ resource.setLastModified( lastModified );
+
+ putFromStream( stream, resource );
+ }
+
+ protected void putFromStream( InputStream stream, Resource resource )
+ throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
+ {
+ OutputStream os = getOutputStream( resource );
+
+ checkOutputStream( resource, os );
+
+ firePutStarted( resource, null );
+
+ putTransfer( resource, stream, os, true );
+
+ firePutCompleted( resource, null );
+ }
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamingWagon.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamingWagon.java
index a6208f2..087c35d 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamingWagon.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamingWagon.java
@@ -1,89 +1,89 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.apache.maven.wagon.authorization.AuthorizationException;
-
-/**
- *
- */
-public interface StreamingWagon
- extends Wagon
-{
- /**
- * Downloads specified resource from the repository to given output stream.
- *
- * @param resourceName
- * @param stream
- * @throws TransferFailedException
- * @throws ResourceDoesNotExistException
- * @throws AuthorizationException
- * @throws AuthorizationException
- */
- void getToStream( String resourceName, OutputStream stream )
- throws ResourceDoesNotExistException, TransferFailedException, AuthorizationException;
-
- /**
- * Downloads specified resource from the repository if it was modified since specified date. The date is measured in
- * milliseconds, between the current time and midnight, January 1, 1970 UTC and aligned to GMT timezone.
- *
- * @param resourceName
- * @param stream
- * @param timestamp
- * @return <code>true</code> if newer resource has been downloaded, <code>false</code> if resource in the
- * repository is older or has the same age.
- * @throws TransferFailedException
- * @throws ResourceDoesNotExistException
- * @throws AuthorizationException
- * @throws AuthorizationException
- */
- boolean getIfNewerToStream( String resourceName, OutputStream stream, long timestamp )
- throws ResourceDoesNotExistException, TransferFailedException, AuthorizationException;
-
- /**
- * @deprecated due to unknown contentLength various http(s) implementation will use a chuncked transfer encoding
- * mode you must take care you http target server supports that (ngnix don't !).
- * <b>So in case of http(s) transport layer avoid using this. Will be remove in 3.0</b>
- * Copy from a local input stream to remote.
- *
- * @param stream the local stream
- * @param destination the remote destination
- * @throws TransferFailedException
- * @throws ResourceDoesNotExistException
- * @throws AuthorizationException
- */
- void putFromStream( InputStream stream, String destination )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;
-
- /**
- * Copy from a local input stream to remote.
- *
- * @param stream the local stream
- * @param destination the remote destination
- * @throws TransferFailedException
- * @throws ResourceDoesNotExistException
- * @throws AuthorizationException
- */
- void putFromStream( InputStream stream, String destination, long contentLength, long lastModified )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.apache.maven.wagon.authorization.AuthorizationException;
+
+/**
+ *
+ */
+public interface StreamingWagon
+ extends Wagon
+{
+ /**
+ * Downloads specified resource from the repository to given output stream.
+ *
+ * @param resourceName
+ * @param stream
+ * @throws TransferFailedException
+ * @throws ResourceDoesNotExistException
+ * @throws AuthorizationException
+ * @throws AuthorizationException
+ */
+ void getToStream( String resourceName, OutputStream stream )
+ throws ResourceDoesNotExistException, TransferFailedException, AuthorizationException;
+
+ /**
+ * Downloads specified resource from the repository if it was modified since specified date. The date is measured in
+ * milliseconds, between the current time and midnight, January 1, 1970 UTC and aligned to GMT timezone.
+ *
+ * @param resourceName
+ * @param stream
+ * @param timestamp
+ * @return <code>true</code> if newer resource has been downloaded, <code>false</code> if resource in the
+ * repository is older or has the same age.
+ * @throws TransferFailedException
+ * @throws ResourceDoesNotExistException
+ * @throws AuthorizationException
+ * @throws AuthorizationException
+ */
+ boolean getIfNewerToStream( String resourceName, OutputStream stream, long timestamp )
+ throws ResourceDoesNotExistException, TransferFailedException, AuthorizationException;
+
+ /**
+ * @deprecated due to unknown contentLength various http(s) implementation will use a chuncked transfer encoding
+ * mode you must take care you http target server supports that (ngnix don't !).
+ * <b>So in case of http(s) transport layer avoid using this. Will be remove in 3.0</b>
+ * Copy from a local input stream to remote.
+ *
+ * @param stream the local stream
+ * @param destination the remote destination
+ * @throws TransferFailedException
+ * @throws ResourceDoesNotExistException
+ * @throws AuthorizationException
+ */
+ void putFromStream( InputStream stream, String destination )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;
+
+ /**
+ * Copy from a local input stream to remote.
+ *
+ * @param stream the local stream
+ * @param destination the remote destination
+ * @throws TransferFailedException
+ * @throws ResourceDoesNotExistException
+ * @throws AuthorizationException
+ */
+ void putFromStream( InputStream stream, String destination, long contentLength, long lastModified )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/Streams.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/Streams.java
index a3d09d8..66be609 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/Streams.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/Streams.java
@@ -1,50 +1,50 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- *
- */
-public class Streams
-{
- private String out = "";
-
- private String err = "";
-
- public String getOut()
- {
- return out;
- }
-
- public void setOut( String out )
- {
- this.out = out;
- }
-
- public String getErr()
- {
- return err;
- }
-
- public void setErr( String err )
- {
- this.err = err;
- }
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ *
+ */
+public class Streams
+{
+ private String out = "";
+
+ private String err = "";
+
+ public String getOut()
+ {
+ return out;
+ }
+
+ public void setOut( String out )
+ {
+ this.out = out;
+ }
+
+ public String getErr()
+ {
+ return err;
+ }
+
+ public void setErr( String err )
+ {
+ this.err = err;
+ }
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/TransferFailedException.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/TransferFailedException.java
index 9f8f9a8..d3c847a 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/TransferFailedException.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/TransferFailedException.java
@@ -1,49 +1,49 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Exception which should be thrown when IO error occurred during
- * a transfer from repository
- *
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class TransferFailedException
- extends WagonException
-{
-
- /**
- * @see org.apache.maven.wagon.WagonException
- */
- public TransferFailedException( final String message )
- {
- super( message );
- }
-
- /**
- * @see org.apache.maven.wagon.WagonException
- */
- public TransferFailedException( final String message, final Throwable cause )
- {
- super( message, cause );
- }
-
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Exception which should be thrown when IO error occurred during
+ * a transfer from repository
+ *
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class TransferFailedException
+ extends WagonException
+{
+
+ /**
+ * @see org.apache.maven.wagon.WagonException
+ */
+ public TransferFailedException( final String message )
+ {
+ super( message );
+ }
+
+ /**
+ * @see org.apache.maven.wagon.WagonException
+ */
+ public TransferFailedException( final String message, final Throwable cause )
+ {
+ super( message, cause );
+ }
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/UnsupportedProtocolException.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/UnsupportedProtocolException.java
index 73b1a88..956895d 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/UnsupportedProtocolException.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/UnsupportedProtocolException.java
@@ -1,50 +1,50 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * This exception is thrown when no Wagon provider is supporting protocol required by some repository
- *
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class UnsupportedProtocolException
- extends WagonException
-{
-
-
- /**
- * @see WagonException
- */
- public UnsupportedProtocolException( final String message )
- {
- super( message );
- }
-
- /**
- * @see WagonException
- */
- public UnsupportedProtocolException( final String message, final Throwable cause )
- {
- super( message, cause );
- }
-
-
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * This exception is thrown when no Wagon provider is supporting protocol required by some repository
+ *
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class UnsupportedProtocolException
+ extends WagonException
+{
+
+
+ /**
+ * @see WagonException
+ */
+ public UnsupportedProtocolException( final String message )
+ {
+ super( message );
+ }
+
+ /**
+ * @see WagonException
+ */
+ public UnsupportedProtocolException( final String message, final Throwable cause )
+ {
+ super( message, cause );
+ }
+
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/Wagon.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/Wagon.java
index 0b76728..1fe86a8 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/Wagon.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/Wagon.java
@@ -1,300 +1,300 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
-import org.apache.maven.wagon.authorization.AuthorizationException;
-import org.apache.maven.wagon.events.SessionListener;
-import org.apache.maven.wagon.events.TransferListener;
-import org.apache.maven.wagon.proxy.ProxyInfo;
-import org.apache.maven.wagon.proxy.ProxyInfoProvider;
-import org.apache.maven.wagon.repository.Repository;
-
-import java.io.File;
-import java.util.List;
-
-/**
- *
- */
-public interface Wagon
-{
- String ROLE = Wagon.class.getName();
-
- /**
- * default 60s approximately 1 minute
- */
- int DEFAULT_CONNECTION_TIMEOUT = 60000;
-
- /**
- * default 1800s approximately 30 minutes
- *
- * @since 2.2
- */
- int DEFAULT_READ_TIMEOUT = 1800000;
-
- // ----------------------------------------------------------------------
- // File/File handling
- // ----------------------------------------------------------------------
-
- /**
- * Downloads specified resource from the repository to given file.
- *
- * @param resourceName
- * @param destination
- * @throws TransferFailedException
- * @throws ResourceDoesNotExistException
- * @throws AuthorizationException
- */
- void get( String resourceName, File destination )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;
-
- /**
- * Downloads specified resource from the repository
- * if it was modified since specified date.
- * The date is measured in milliseconds, between the current time and midnight, January 1, 1970 UTC
- * and aligned to GMT timezone.
- *
- * @param resourceName
- * @param destination
- * @param timestamp
- * @return <code>true</code> if newer resource has been downloaded, <code>false</code> if resource
- * in the repository is older or has the same age.
- * @throws TransferFailedException
- * @throws ResourceDoesNotExistException
- * @throws AuthorizationException
- */
- boolean getIfNewer( String resourceName, File destination, long timestamp )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;
-
- /**
- * Copy a file from local system to remote
- *
- * @param source the local file
- * @param destination the remote destination
- * @throws TransferFailedException
- * @throws ResourceDoesNotExistException
- * @throws AuthorizationException
- */
- void put( File source, String destination )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;
-
- /**
- * Copy a directory from local system to remote
- *
- * @param sourceDirectory the local directory
- * @param destinationDirectory the remote destination
- * @throws TransferFailedException
- * @throws ResourceDoesNotExistException
- * @throws AuthorizationException
- */
- void putDirectory( File sourceDirectory, String destinationDirectory )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;
-
- /**
- * Check if a remote resource exists
- *
- * @param resourceName
- * @return whether the resource exists or not
- * @throws TransferFailedException if there's an error trying to access the remote side
- * @throws AuthorizationException if not authorized to verify the existence of the resource
- */
- boolean resourceExists( String resourceName )
- throws TransferFailedException, AuthorizationException;
-
- /**
- * <p/>
- * Returns a {@link List} of strings naming the files and directories in the directory denoted by
- * this abstract pathname.
- * </p>
- * <p/>
- * If this abstract pathname does not denote a directory, or does not exist, then this method throws
- * {@link ResourceDoesNotExistException}.
- * Otherwise a {@link List} of strings is returned, one for each file or directory in the directory.
- * Names denoting the directory itself and the directory's parent directory are not included in
- * the result. Each string is a file name rather than a complete path.
- * </p>
- * <p/>
- * There is no guarantee that the name strings in the resulting list will appear in any specific
- * order; they are not, in particular, guaranteed to appear in alphabetical order.
- * </p>
- *
- * @param destinationDirectory directory to list contents of
- * @return A {@link List} of strings naming the files and directories in the directory denoted by
- * this abstract pathname. The {@link List} will be empty if the directory is empty.
- * @throws TransferFailedException if there's an error trying to access the remote side
- * @throws ResourceDoesNotExistException if destinationDirectory does not exist or is not a directory
- * @throws AuthorizationException if not authorized to list the contents of the directory
- */
- List<String> getFileList( String destinationDirectory )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;
-
- /**
- * Flag indicating if this wagon supports directory copy operations.
- *
- * @return whether if this wagon supports directory operations
- */
- boolean supportsDirectoryCopy();
-
- Repository getRepository();
-
- // ----------------------------------------------------------------------
- // Connection/Disconnection
- // ----------------------------------------------------------------------
-
- /**
- * Initiate the connection to the repository.
- *
- * @param source the repository to connect to
- * @throws ConnectionException if there is a problem connecting
- * @throws org.apache.maven.wagon.authentication.AuthenticationException
- * if the credentials for connecting are not sufficient
- */
- void connect( Repository source )
- throws ConnectionException, AuthenticationException;
-
- /**
- * Initiate the connection to the repository.
- *
- * @param source the repository to connect to
- * @throws ConnectionException if there is a problem connecting
- * @throws org.apache.maven.wagon.authentication.AuthenticationException
- * if the credentials for connecting are not sufficient
- */
- void connect( Repository source, ProxyInfo proxyInfo )
- throws ConnectionException, AuthenticationException;
-
- /**
- * Initiate the connection to the repository.
- *
- * @param source the repository to connect to
- * @param proxyInfoProvider the provider to obtain a network proxy to use to connect to the remote repository
- * @throws ConnectionException if there is a problem connecting
- * @throws org.apache.maven.wagon.authentication.AuthenticationException
- * if the credentials for connecting are not sufficient
- */
- void connect( Repository source, ProxyInfoProvider proxyInfoProvider )
- throws ConnectionException, AuthenticationException;
-
- /**
- * Initiate the connection to the repository.
- *
- * @param source the repository to connect to
- * @param authenticationInfo authentication credentials for connecting
- * @throws ConnectionException if there is a problem connecting
- * @throws org.apache.maven.wagon.authentication.AuthenticationException
- * if the credentials for connecting are not sufficient
- */
- void connect( Repository source, AuthenticationInfo authenticationInfo )
- throws ConnectionException, AuthenticationException;
-
- /**
- * Initiate the connection to the repository.
- *
- * @param source the repository to connect to
- * @param authenticationInfo authentication credentials for connecting
- * @param proxyInfo the network proxy to use to connect to the remote repository
- * @throws ConnectionException if there is a problem connecting
- * @throws org.apache.maven.wagon.authentication.AuthenticationException
- * if the credentials for connecting are not sufficient
- */
- void connect( Repository source, AuthenticationInfo authenticationInfo, ProxyInfo proxyInfo )
- throws ConnectionException, AuthenticationException;
-
- /**
- * Initiate the connection to the repository.
- *
- * @param source the repository to connect to
- * @param authenticationInfo authentication credentials for connecting
- * @param proxyInfoProvider the provider to obtain a network proxy to use to connect to the remote repository
- * @throws ConnectionException if there is a problem connecting
- * @throws org.apache.maven.wagon.authentication.AuthenticationException
- * if the credentials for connecting are not sufficient
- */
- void connect( Repository source, AuthenticationInfo authenticationInfo, ProxyInfoProvider proxyInfoProvider )
- throws ConnectionException, AuthenticationException;
-
- /**
- * Initiate the connection to the repository.
- *
- * @throws ConnectionException if there is a problem connecting
- * @throws org.apache.maven.wagon.authentication.AuthenticationException
- * if ther credentials for connecting are not sufficient
- * @todo delegate this to a truly internal connection method
- * @deprecated connect using the {@link #connect(org.apache.maven.wagon.repository.Repository)} or related methods
- * - this is an internal method
- */
- void openConnection()
- throws ConnectionException, AuthenticationException;
-
- /**
- * Disconnect from the repository.
- *
- * @throws ConnectionException if there is a problem disconnecting
- */
- void disconnect()
- throws ConnectionException;
-
- /**
- * Set the connection timeout limit in milliseconds
- */
- void setTimeout( int timeoutValue );
-
- /**
- * Get the connection timeout limit in milliseconds
- */
- int getTimeout();
-
- /**
- * Set the read timeout limit in milliseconds
- * @since 2.2
- */
- void setReadTimeout( int timeoutValue );
-
- /**
- * Get the read timeout limit in milliseconds
- * @since 2.2
- */
- int getReadTimeout();
-
- // ----------------------------------------------------------------------
- // Session listener
- // ----------------------------------------------------------------------
-
- void addSessionListener( SessionListener listener );
-
- void removeSessionListener( SessionListener listener );
-
- boolean hasSessionListener( SessionListener listener );
-
- // ----------------------------------------------------------------------
- // Transfer listener
- // ----------------------------------------------------------------------
-
- void addTransferListener( TransferListener listener );
-
- void removeTransferListener( TransferListener listener );
-
- boolean hasTransferListener( TransferListener listener );
-
- boolean isInteractive();
-
- void setInteractive( boolean interactive );
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.events.SessionListener;
+import org.apache.maven.wagon.events.TransferListener;
+import org.apache.maven.wagon.proxy.ProxyInfo;
+import org.apache.maven.wagon.proxy.ProxyInfoProvider;
+import org.apache.maven.wagon.repository.Repository;
+
+import java.io.File;
+import java.util.List;
+
+/**
+ *
+ */
+public interface Wagon
+{
+ String ROLE = Wagon.class.getName();
+
+ /**
+ * default 60s approximately 1 minute
+ */
+ int DEFAULT_CONNECTION_TIMEOUT = 60000;
+
+ /**
+ * default 1800s approximately 30 minutes
+ *
+ * @since 2.2
+ */
+ int DEFAULT_READ_TIMEOUT = 1800000;
+
+ // ----------------------------------------------------------------------
+ // File/File handling
+ // ----------------------------------------------------------------------
+
+ /**
+ * Downloads specified resource from the repository to given file.
+ *
+ * @param resourceName
+ * @param destination
+ * @throws TransferFailedException
+ * @throws ResourceDoesNotExistException
+ * @throws AuthorizationException
+ */
+ void get( String resourceName, File destination )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;
+
+ /**
+ * Downloads specified resource from the repository
+ * if it was modified since specified date.
+ * The date is measured in milliseconds, between the current time and midnight, January 1, 1970 UTC
+ * and aligned to GMT timezone.
+ *
+ * @param resourceName
+ * @param destination
+ * @param timestamp
+ * @return <code>true</code> if newer resource has been downloaded, <code>false</code> if resource
+ * in the repository is older or has the same age.
+ * @throws TransferFailedException
+ * @throws ResourceDoesNotExistException
+ * @throws AuthorizationException
+ */
+ boolean getIfNewer( String resourceName, File destination, long timestamp )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;
+
+ /**
+ * Copy a file from local system to remote
+ *
+ * @param source the local file
+ * @param destination the remote destination
+ * @throws TransferFailedException
+ * @throws ResourceDoesNotExistException
+ * @throws AuthorizationException
+ */
+ void put( File source, String destination )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;
+
+ /**
+ * Copy a directory from local system to remote
+ *
+ * @param sourceDirectory the local directory
+ * @param destinationDirectory the remote destination
+ * @throws TransferFailedException
+ * @throws ResourceDoesNotExistException
+ * @throws AuthorizationException
+ */
+ void putDirectory( File sourceDirectory, String destinationDirectory )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;
+
+ /**
+ * Check if a remote resource exists
+ *
+ * @param resourceName
+ * @return whether the resource exists or not
+ * @throws TransferFailedException if there's an error trying to access the remote side
+ * @throws AuthorizationException if not authorized to verify the existence of the resource
+ */
+ boolean resourceExists( String resourceName )
+ throws TransferFailedException, AuthorizationException;
+
+ /**
+ * <p/>
+ * Returns a {@link List} of strings naming the files and directories in the directory denoted by
+ * this abstract pathname.
+ * </p>
+ * <p/>
+ * If this abstract pathname does not denote a directory, or does not exist, then this method throws
+ * {@link ResourceDoesNotExistException}.
+ * Otherwise a {@link List} of strings is returned, one for each file or directory in the directory.
+ * Names denoting the directory itself and the directory's parent directory are not included in
+ * the result. Each string is a file name rather than a complete path.
+ * </p>
+ * <p/>
+ * There is no guarantee that the name strings in the resulting list will appear in any specific
+ * order; they are not, in particular, guaranteed to appear in alphabetical order.
+ * </p>
+ *
+ * @param destinationDirectory directory to list contents of
+ * @return A {@link List} of strings naming the files and directories in the directory denoted by
+ * this abstract pathname. The {@link List} will be empty if the directory is empty.
+ * @throws TransferFailedException if there's an error trying to access the remote side
+ * @throws ResourceDoesNotExistException if destinationDirectory does not exist or is not a directory
+ * @throws AuthorizationException if not authorized to list the contents of the directory
+ */
+ List<String> getFileList( String destinationDirectory )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException;
+
+ /**
+ * Flag indicating if this wagon supports directory copy operations.
+ *
+ * @return whether if this wagon supports directory operations
+ */
+ boolean supportsDirectoryCopy();
+
+ Repository getRepository();
+
+ // ----------------------------------------------------------------------
+ // Connection/Disconnection
+ // ----------------------------------------------------------------------
+
+ /**
+ * Initiate the connection to the repository.
+ *
+ * @param source the repository to connect to
+ * @throws ConnectionException if there is a problem connecting
+ * @throws org.apache.maven.wagon.authentication.AuthenticationException
+ * if the credentials for connecting are not sufficient
+ */
+ void connect( Repository source )
+ throws ConnectionException, AuthenticationException;
+
+ /**
+ * Initiate the connection to the repository.
+ *
+ * @param source the repository to connect to
+ * @throws ConnectionException if there is a problem connecting
+ * @throws org.apache.maven.wagon.authentication.AuthenticationException
+ * if the credentials for connecting are not sufficient
+ */
+ void connect( Repository source, ProxyInfo proxyInfo )
+ throws ConnectionException, AuthenticationException;
+
+ /**
+ * Initiate the connection to the repository.
+ *
+ * @param source the repository to connect to
+ * @param proxyInfoProvider the provider to obtain a network proxy to use to connect to the remote repository
+ * @throws ConnectionException if there is a problem connecting
+ * @throws org.apache.maven.wagon.authentication.AuthenticationException
+ * if the credentials for connecting are not sufficient
+ */
+ void connect( Repository source, ProxyInfoProvider proxyInfoProvider )
+ throws ConnectionException, AuthenticationException;
+
+ /**
+ * Initiate the connection to the repository.
+ *
+ * @param source the repository to connect to
+ * @param authenticationInfo authentication credentials for connecting
+ * @throws ConnectionException if there is a problem connecting
+ * @throws org.apache.maven.wagon.authentication.AuthenticationException
+ * if the credentials for connecting are not sufficient
+ */
+ void connect( Repository source, AuthenticationInfo authenticationInfo )
+ throws ConnectionException, AuthenticationException;
+
+ /**
+ * Initiate the connection to the repository.
+ *
+ * @param source the repository to connect to
+ * @param authenticationInfo authentication credentials for connecting
+ * @param proxyInfo the network proxy to use to connect to the remote repository
+ * @throws ConnectionException if there is a problem connecting
+ * @throws org.apache.maven.wagon.authentication.AuthenticationException
+ * if the credentials for connecting are not sufficient
+ */
+ void connect( Repository source, AuthenticationInfo authenticationInfo, ProxyInfo proxyInfo )
+ throws ConnectionException, AuthenticationException;
+
+ /**
+ * Initiate the connection to the repository.
+ *
+ * @param source the repository to connect to
+ * @param authenticationInfo authentication credentials for connecting
+ * @param proxyInfoProvider the provider to obtain a network proxy to use to connect to the remote repository
+ * @throws ConnectionException if there is a problem connecting
+ * @throws org.apache.maven.wagon.authentication.AuthenticationException
+ * if the credentials for connecting are not sufficient
+ */
+ void connect( Repository source, AuthenticationInfo authenticationInfo, ProxyInfoProvider proxyInfoProvider )
+ throws ConnectionException, AuthenticationException;
+
+ /**
+ * Initiate the connection to the repository.
+ *
+ * @throws ConnectionException if there is a problem connecting
+ * @throws org.apache.maven.wagon.authentication.AuthenticationException
+ * if ther credentials for connecting are not sufficient
+ * @todo delegate this to a truly internal connection method
+ * @deprecated connect using the {@link #connect(org.apache.maven.wagon.repository.Repository)} or related methods
+ * - this is an internal method
+ */
+ void openConnection()
+ throws ConnectionException, AuthenticationException;
+
+ /**
+ * Disconnect from the repository.
+ *
+ * @throws ConnectionException if there is a problem disconnecting
+ */
+ void disconnect()
+ throws ConnectionException;
+
+ /**
+ * Set the connection timeout limit in milliseconds
+ */
+ void setTimeout( int timeoutValue );
+
+ /**
+ * Get the connection timeout limit in milliseconds
+ */
+ int getTimeout();
+
+ /**
+ * Set the read timeout limit in milliseconds
+ * @since 2.2
+ */
+ void setReadTimeout( int timeoutValue );
+
+ /**
+ * Get the read timeout limit in milliseconds
+ * @since 2.2
+ */
+ int getReadTimeout();
+
+ // ----------------------------------------------------------------------
+ // Session listener
+ // ----------------------------------------------------------------------
+
+ void addSessionListener( SessionListener listener );
+
+ void removeSessionListener( SessionListener listener );
+
+ boolean hasSessionListener( SessionListener listener );
+
+ // ----------------------------------------------------------------------
+ // Transfer listener
+ // ----------------------------------------------------------------------
+
+ void addTransferListener( TransferListener listener );
+
+ void removeTransferListener( TransferListener listener );
+
+ boolean hasTransferListener( TransferListener listener );
+
+ boolean isInteractive();
+
+ void setInteractive( boolean interactive );
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/WagonConstants.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/WagonConstants.java
index 27b66b1..90f20e6 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/WagonConstants.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/WagonConstants.java
@@ -1,39 +1,39 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * This class contains constants used in Wagon API.
- *
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public final class WagonConstants
-{
- /**
- * Indicates that port has not been set.
- */
- public static final int UNKNOWN_PORT = -1;
-
- /**
- * Indicates that length has not been set.
- */
- public static final int UNKNOWN_LENGTH = -1;
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * This class contains constants used in Wagon API.
+ *
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public final class WagonConstants
+{
+ /**
+ * Indicates that port has not been set.
+ */
+ public static final int UNKNOWN_PORT = -1;
+
+ /**
+ * Indicates that length has not been set.
+ */
+ public static final int UNKNOWN_LENGTH = -1;
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/WagonException.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/WagonException.java
index 25dc053..ebf6b6f 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/WagonException.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/WagonException.java
@@ -1,116 +1,116 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Root class for all exception in Wagon API
- *
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public abstract class WagonException
- extends Exception
-{
- /**
- * the throwable that caused this exception to get thrown
- */
- private Throwable cause;
-
-
- /**
- * Constructs a new WagonException with the specified detail message.
- * The cause is not initialized, and may subsequently be initialized by a call to initCause
- *
- * @param message - the detail message (which is saved for later retrieval by the getMessage() method).
- * @param cause - the cause (which is saved for later retrieval by the getCause() method).
- * (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
- */
- public WagonException( final String message, final Throwable cause )
- {
- super( message );
- initCause( cause );
- }
-
- /**
- * Constructs a new WagonException with the specified detail message and cause.
- *
- * @param message - the detail message (which is saved for later retrieval by the getMessage() method).
- */
- public WagonException( final String message )
- {
- super( message );
- }
-
- /**
- * Returns the cause of this throwable or null if the cause is nonexistent or unknown.
- * (The cause is the throwable that caused this exception to get thrown.)
- *
- * @return the cause of this exception or null if the cause is nonexistent or unknown.
- */
- public Throwable getCause()
- {
-// try
-// {
-// Class clazz = getClass().getSuperclass();
-//
-// Method method = clazz.getMethod( "gatCause" , null );
-//
-// Throwable retValue = (Throwable) method.invoke( this, null );
-// return retValue;
-// }
-// catch( Exception e)
-// {
-//
-// }
-
- return cause;
- }
-
-
- /**
- * Initializes the cause of this throwable to the specified value.
- * (The cause is the throwable that caused this throwable to get thrown.)
- * This method can be called at most once.
- * It is generally called from within the constructor, or immediately after creating the throwable.
- * If this throwable was created with WagonException(Throwable) or WagonException(String,Throwable),
- * this method cannot be called even once.
- *
- * @return a reference to this Throwable instance.
- */
- public Throwable initCause( final Throwable cause )
- {
-// try
-// {
-// Class clazz = getClass().getSuperclass();
-// Class[] parameterTypes = new Class[1];
-// parameterTypes[0] = Throwable.class;
-// Method method = clazz.getMethod( "initCause" , parameterTypes);
-// Object[] params = { cause };
-// method.invoke( this, params );
-// }
-// catch( Exception e)
-// {
-//
-// }
- this.cause = cause;
- return this;
- }
-
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Root class for all exception in Wagon API
+ *
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public abstract class WagonException
+ extends Exception
+{
+ /**
+ * the throwable that caused this exception to get thrown
+ */
+ private Throwable cause;
+
+
+ /**
+ * Constructs a new WagonException with the specified detail message.
+ * The cause is not initialized, and may subsequently be initialized by a call to initCause
+ *
+ * @param message - the detail message (which is saved for later retrieval by the getMessage() method).
+ * @param cause - the cause (which is saved for later retrieval by the getCause() method).
+ * (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
+ */
+ public WagonException( final String message, final Throwable cause )
+ {
+ super( message );
+ initCause( cause );
+ }
+
+ /**
+ * Constructs a new WagonException with the specified detail message and cause.
+ *
+ * @param message - the detail message (which is saved for later retrieval by the getMessage() method).
+ */
+ public WagonException( final String message )
+ {
+ super( message );
+ }
+
+ /**
+ * Returns the cause of this throwable or null if the cause is nonexistent or unknown.
+ * (The cause is the throwable that caused this exception to get thrown.)
+ *
+ * @return the cause of this exception or null if the cause is nonexistent or unknown.
+ */
+ public Throwable getCause()
+ {
+// try
+// {
+// Class clazz = getClass().getSuperclass();
+//
+// Method method = clazz.getMethod( "gatCause" , null );
+//
+// Throwable retValue = (Throwable) method.invoke( this, null );
+// return retValue;
+// }
+// catch( Exception e)
+// {
+//
+// }
+
+ return cause;
+ }
+
+
+ /**
+ * Initializes the cause of this throwable to the specified value.
+ * (The cause is the throwable that caused this throwable to get thrown.)
+ * This method can be called at most once.
+ * It is generally called from within the constructor, or immediately after creating the throwable.
+ * If this throwable was created with WagonException(Throwable) or WagonException(String,Throwable),
+ * this method cannot be called even once.
+ *
+ * @return a reference to this Throwable instance.
+ */
+ public Throwable initCause( final Throwable cause )
+ {
+// try
+// {
+// Class clazz = getClass().getSuperclass();
+// Class[] parameterTypes = new Class[1];
+// parameterTypes[0] = Throwable.class;
+// Method method = clazz.getMethod( "initCause" , parameterTypes);
+// Object[] params = { cause };
+// method.invoke( this, params );
+// }
+// catch( Exception e)
+// {
+//
+// }
+ this.cause = cause;
+ return this;
+ }
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/WagonUtils.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/WagonUtils.java
index 4263440..31c5eac 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/WagonUtils.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/WagonUtils.java
@@ -1,122 +1,122 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.authorization.AuthorizationException;
-import org.codehaus.plexus.util.FileUtils;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.LinkedList;
-
-/**
- * @author <a href="mailto:mmaczka at interia.pl">Michal Maczka</a>
- *
- * @deprecated
- */
-public final class WagonUtils
-{
- private WagonUtils()
- {
- }
-
- public static String toString( String resource, Wagon wagon )
- throws IOException, TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
-
- File file = null;
-
- try
- {
- file = File.createTempFile( "wagon", "tmp" );
-
- wagon.get( resource, file );
-
- return FileUtils.fileRead( file );
- }
- finally
- {
- if ( file != null )
- {
- boolean deleted = file.delete();
-
- if ( !deleted )
- {
- file.deleteOnExit();
- }
- }
- }
-
- }
-
-
- public static void putDirectory( File dir, Wagon wagon, boolean includeBasdir )
- throws ResourceDoesNotExistException, TransferFailedException, AuthorizationException
- {
-
- LinkedList queue = new LinkedList();
-
- if ( includeBasdir )
- {
- queue.add( dir.getName() );
- }
- else
- {
- queue.add( "" );
- }
-
- while ( !queue.isEmpty() )
- {
- String path = (String) queue.removeFirst();
-
- File currentDir = new File( dir, path );
-
- File[] files = currentDir.listFiles();
-
- for ( int i = 0; i < files.length; i++ )
- {
- File file = files[i];
-
- String resource;
-
- if ( path.length() > 0 )
- {
- resource = path + "/" + file.getName();
- }
- else
- {
- resource = file.getName();
- }
-
- if ( file.isDirectory() )
- {
- queue.add( resource );
- }
- else
- {
- wagon.put( file, resource );
- }
-
- }
-
- }
-
- }
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.codehaus.plexus.util.FileUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.LinkedList;
+
+/**
+ * @author <a href="mailto:mmaczka at interia.pl">Michal Maczka</a>
+ *
+ * @deprecated
+ */
+public final class WagonUtils
+{
+ private WagonUtils()
+ {
+ }
+
+ public static String toString( String resource, Wagon wagon )
+ throws IOException, TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+
+ File file = null;
+
+ try
+ {
+ file = File.createTempFile( "wagon", "tmp" );
+
+ wagon.get( resource, file );
+
+ return FileUtils.fileRead( file );
+ }
+ finally
+ {
+ if ( file != null )
+ {
+ boolean deleted = file.delete();
+
+ if ( !deleted )
+ {
+ file.deleteOnExit();
+ }
+ }
+ }
+
+ }
+
+
+ public static void putDirectory( File dir, Wagon wagon, boolean includeBasdir )
+ throws ResourceDoesNotExistException, TransferFailedException, AuthorizationException
+ {
+
+ LinkedList queue = new LinkedList();
+
+ if ( includeBasdir )
+ {
+ queue.add( dir.getName() );
+ }
+ else
+ {
+ queue.add( "" );
+ }
+
+ while ( !queue.isEmpty() )
+ {
+ String path = (String) queue.removeFirst();
+
+ File currentDir = new File( dir, path );
+
+ File[] files = currentDir.listFiles();
+
+ for ( int i = 0; i < files.length; i++ )
+ {
+ File file = files[i];
+
+ String resource;
+
+ if ( path.length() > 0 )
+ {
+ resource = path + "/" + file.getName();
+ }
+ else
+ {
+ resource = file.getName();
+ }
+
+ if ( file.isDirectory() )
+ {
+ queue.add( resource );
+ }
+ else
+ {
+ wagon.put( file, resource );
+ }
+
+ }
+
+ }
+
+ }
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/authentication/AuthenticationException.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/authentication/AuthenticationException.java
index 9094c75..2e1400b 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/authentication/AuthenticationException.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/authentication/AuthenticationException.java
@@ -1,53 +1,53 @@
-package org.apache.maven.wagon.authentication;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.WagonException;
-
-/**
- * This exception is thrown when an authentication
- * error occurs while accessing the remote repository.
- * An authentication error can happen, for example,
- * when the credentials supplied by the user are invalid
- *
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class AuthenticationException
- extends WagonException
-{
-
- /**
- * @see org.apache.maven.wagon.WagonException
- */
- public AuthenticationException( final String message )
- {
- super( message );
- }
-
- /**
- * @see org.apache.maven.wagon.WagonException
- */
- public AuthenticationException( final String message, final Throwable cause )
- {
- super( message, cause );
- }
-
-}
+package org.apache.maven.wagon.authentication;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.WagonException;
+
+/**
+ * This exception is thrown when an authentication
+ * error occurs while accessing the remote repository.
+ * An authentication error can happen, for example,
+ * when the credentials supplied by the user are invalid
+ *
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class AuthenticationException
+ extends WagonException
+{
+
+ /**
+ * @see org.apache.maven.wagon.WagonException
+ */
+ public AuthenticationException( final String message )
+ {
+ super( message );
+ }
+
+ /**
+ * @see org.apache.maven.wagon.WagonException
+ */
+ public AuthenticationException( final String message, final Throwable cause )
+ {
+ super( message, cause );
+ }
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/authentication/AuthenticationInfo.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/authentication/AuthenticationInfo.java
index 6e92717..e3444c0 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/authentication/AuthenticationInfo.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/authentication/AuthenticationInfo.java
@@ -1,136 +1,136 @@
-package org.apache.maven.wagon.authentication;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.Serializable;
-
-/**
- * This class holds the set of properties used when instance of the <code>Wagon</code>
- * will use during login operation.
- *
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class AuthenticationInfo
- implements Serializable
-{
-
- /**
- * Username used to login to the host
- */
- private String userName;
-
- /**
- * Password associated with the login
- */
- private String password;
-
- /**
- * Passphrase of the user's private key file
- */
- private String passphrase;
-
- /**
- * The absolute path to private key file
- */
- private String privateKey;
-
- /**
- * Get the passphrase of the private key file. The passphrase is used only
- * when host/protocol supports authentication via exchange of
- * private/public keys and private key was used for authentication.
- *
- * @return passphrase of the private key file
- */
- public String getPassphrase()
- {
- return passphrase;
- }
-
- /**
- * Set the passphrase of the private key file.
- *
- * @param passphrase passphrase of the private key file
- */
- public void setPassphrase( final String passphrase )
- {
- this.passphrase = passphrase;
- }
-
- /**
- * Get the absolute path to the private key file.
- *
- * @return absolute path to private key
- */
- public String getPrivateKey()
- {
- return privateKey;
- }
-
- /**
- * Set the absolute path to private key file.
- *
- * @param privateKey path to private key in local file system
- */
- public void setPrivateKey( final String privateKey )
- {
- this.privateKey = privateKey;
- }
-
- /**
- * Get the user's password which is used when connecting to the repository.
- *
- * @return password of user
- */
- public String getPassword()
- {
- return password;
- }
-
- /**
- * Set the user's password which is used when connecting to the repository.
- *
- * @param password password of the user
- */
- public void setPassword( final String password )
- {
- this.password = password;
- }
-
- /**
- * Get the username used to access the repository.
- *
- * @return username at repository
- */
- public String getUserName()
- {
- return userName;
- }
-
- /**
- * Set username used to access the repository.
- *
- * @param userName the username used to access repository
- */
- public void setUserName( final String userName )
- {
- this.userName = userName;
- }
-}
+package org.apache.maven.wagon.authentication;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.Serializable;
+
+/**
+ * This class holds the set of properties used when instance of the <code>Wagon</code>
+ * will use during login operation.
+ *
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class AuthenticationInfo
+ implements Serializable
+{
+
+ /**
+ * Username used to login to the host
+ */
+ private String userName;
+
+ /**
+ * Password associated with the login
+ */
+ private String password;
+
+ /**
+ * Passphrase of the user's private key file
+ */
+ private String passphrase;
+
+ /**
+ * The absolute path to private key file
+ */
+ private String privateKey;
+
+ /**
+ * Get the passphrase of the private key file. The passphrase is used only
+ * when host/protocol supports authentication via exchange of
+ * private/public keys and private key was used for authentication.
+ *
+ * @return passphrase of the private key file
+ */
+ public String getPassphrase()
+ {
+ return passphrase;
+ }
+
+ /**
+ * Set the passphrase of the private key file.
+ *
+ * @param passphrase passphrase of the private key file
+ */
+ public void setPassphrase( final String passphrase )
+ {
+ this.passphrase = passphrase;
+ }
+
+ /**
+ * Get the absolute path to the private key file.
+ *
+ * @return absolute path to private key
+ */
+ public String getPrivateKey()
+ {
+ return privateKey;
+ }
+
+ /**
+ * Set the absolute path to private key file.
+ *
+ * @param privateKey path to private key in local file system
+ */
+ public void setPrivateKey( final String privateKey )
+ {
+ this.privateKey = privateKey;
+ }
+
+ /**
+ * Get the user's password which is used when connecting to the repository.
+ *
+ * @return password of user
+ */
+ public String getPassword()
+ {
+ return password;
+ }
+
+ /**
+ * Set the user's password which is used when connecting to the repository.
+ *
+ * @param password password of the user
+ */
+ public void setPassword( final String password )
+ {
+ this.password = password;
+ }
+
+ /**
+ * Get the username used to access the repository.
+ *
+ * @return username at repository
+ */
+ public String getUserName()
+ {
+ return userName;
+ }
+
+ /**
+ * Set username used to access the repository.
+ *
+ * @param userName the username used to access repository
+ */
+ public void setUserName( final String userName )
+ {
+ this.userName = userName;
+ }
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/authorization/AuthorizationException.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/authorization/AuthorizationException.java
index a3f9310..e28d4aa 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/authorization/AuthorizationException.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/authorization/AuthorizationException.java
@@ -1,53 +1,53 @@
-package org.apache.maven.wagon.authorization;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.WagonException;
-
-/**
- * This exception is thrown when the user is not entitled to fetch from or deploy to
- * particular place in the repository.
- *
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class AuthorizationException
- extends WagonException
-{
-
-
- /**
- * @see org.apache.maven.wagon.WagonException
- */
- public AuthorizationException( final String message )
- {
- super( message );
- }
-
- /**
- * @see org.apache.maven.wagon.WagonException
- */
- public AuthorizationException( final String message, final Throwable cause )
- {
- super( message, cause );
- }
-
-
-}
+package org.apache.maven.wagon.authorization;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.WagonException;
+
+/**
+ * This exception is thrown when the user is not entitled to fetch from or deploy to
+ * particular place in the repository.
+ *
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class AuthorizationException
+ extends WagonException
+{
+
+
+ /**
+ * @see org.apache.maven.wagon.WagonException
+ */
+ public AuthorizationException( final String message )
+ {
+ super( message );
+ }
+
+ /**
+ * @see org.apache.maven.wagon.WagonException
+ */
+ public AuthorizationException( final String message, final Throwable cause )
+ {
+ super( message, cause );
+ }
+
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionEvent.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionEvent.java
index 712ead6..aca4be4 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionEvent.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionEvent.java
@@ -1,226 +1,226 @@
-package org.apache.maven.wagon.events;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.Wagon;
-
-/**
- * SessionEvent is used for notifying SessionListeners about
- * occurrences of various situations related.
- * <p/>
- * The session event is emitted by <code>Wagon</code> objects when
- * <p/>
- * <ul>
- * <li>Before connection to the repository will be opened</li>
- * <li>After connection to the repository was opened</li>
- * <li>After wagon has logged-in to the repository</li>
- * <li>After wagon has logged-off from the repository</li>
- * <li>Before connection to the repository will be closed</li>
- * <li>After connection to the repository was closed</li>
- * </ul>
- *
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class SessionEvent
- extends WagonEvent
-{
-
- /**
- * A SESSION was closed.
- */
- public static final int SESSION_CLOSED = 1;
-
- /**
- * A SESSION is about to be disconnected.
- */
- public static final int SESSION_DISCONNECTING = 2;
-
- /**
- * A SESSION was disconnected (not currently used).
- */
- public static final int SESSION_DISCONNECTED = 3;
-
- /**
- * A SESSION was refused.
- */
- public static final int SESSION_CONNECTION_REFUSED = 4;
-
- /**
- * A SESSION is about to be opened.
- */
- public static final int SESSION_OPENING = 5;
-
- /**
- * A SESSION was opened.
- */
- public static final int SESSION_OPENED = 6;
-
- /**
- * A SESSION was opened.
- */
- public static final int SESSION_LOGGED_IN = 7;
-
- /**
- * A SESSION was opened.
- */
- public static final int SESSION_LOGGED_OFF = 8;
-
- /**
- * A SESSION was opened.
- */
- public static final int SESSION_ERROR_OCCURRED = 9;
-
- /**
- * The type of the event. One of the SESSSION_XXX constants
- */
- private int eventType;
-
- private Exception exception;
-
- /**
- * Creates new instance of SessionEvent
- *
- * @param wagon <code>Wagon<code> object which created this event
- * @param eventType the type of the event
- */
- public SessionEvent( final Wagon wagon, final int eventType )
- {
- super( wagon );
- this.eventType = eventType;
-
- }
-
- /**
- * Creates new instance of SessionEvent. Sets event type to <code>SESSION_ERROR_OCCURRED</code>
- *
- * @param wagon <code>Wagon<code> object which created this event
- * @param exception the exception
- */
- public SessionEvent( final Wagon wagon, final Exception exception )
- {
- super( wagon );
- this.exception = exception;
- this.eventType = SESSION_ERROR_OCCURRED;
-
- }
-
- /**
- * @return Returns the type.
- */
- public int getEventType()
- {
- return eventType;
- }
-
- /**
- * @return Returns the exception.
- */
- public Exception getException()
- {
- return exception;
- }
-
- /**
- * @param eventType The eventType to set.
- */
- public void setEventType( final int eventType )
- {
- switch ( eventType )
- {
- case SessionEvent.SESSION_CLOSED:
- case SessionEvent.SESSION_DISCONNECTED:
- case SessionEvent.SESSION_DISCONNECTING:
- case SessionEvent.SESSION_ERROR_OCCURRED:
- case SessionEvent.SESSION_LOGGED_IN:
- case SessionEvent.SESSION_LOGGED_OFF:
- case SessionEvent.SESSION_OPENED:
- case SessionEvent.SESSION_OPENING:
- case SessionEvent.SESSION_CONNECTION_REFUSED:
- break;
- default :
- throw new IllegalArgumentException( "Illegal event type: " + eventType );
- }
- this.eventType = eventType;
- }
-
- /**
- * @param exception The exception to set.
- */
- public void setException( final Exception exception )
- {
- this.exception = exception;
- }
-
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( "SessionEvent[" );
-
- switch ( this.eventType )
- {
- case SessionEvent.SESSION_CLOSED:
- sb.append( "CONNECTION_CLOSED" );
- break;
- case SessionEvent.SESSION_DISCONNECTED:
- sb.append( "CONNECTION_DISCONNECTED" );
- break;
- case SessionEvent.SESSION_DISCONNECTING:
- sb.append( "CONNECTION_DISCONNECTING" );
- break;
- case SessionEvent.SESSION_ERROR_OCCURRED:
- sb.append( "CONNECTION_ERROR_OCCURRED" );
- break;
- case SessionEvent.SESSION_LOGGED_IN:
- sb.append( "CONNECTION_LOGGED_IN" );
- break;
- case SessionEvent.SESSION_LOGGED_OFF:
- sb.append( "CONNECTION_LOGGED_OFF" );
- break;
- case SessionEvent.SESSION_OPENED:
- sb.append( "CONNECTION_OPENED" );
- break;
- case SessionEvent.SESSION_OPENING:
- sb.append( "CONNECTION_OPENING" );
- break;
- case SessionEvent.SESSION_CONNECTION_REFUSED:
- sb.append( "CONNECTION_CONNECTION_REFUSED" );
- break;
- default:
- sb.append( eventType );
- }
- sb.append( "|" );
-
- sb.append( this.getWagon().getRepository() ).append( "|" );
- sb.append( this.source );
-
- if ( exception != null )
- {
- sb.append( "|" );
- sb.append( exception.getClass().getName() ).append( ":" );
- sb.append( exception.getMessage() );
- }
-
- sb.append( "]" );
-
- return sb.toString();
- }
-}
+package org.apache.maven.wagon.events;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.Wagon;
+
+/**
+ * SessionEvent is used for notifying SessionListeners about
+ * occurrences of various situations related.
+ * <p/>
+ * The session event is emitted by <code>Wagon</code> objects when
+ * <p/>
+ * <ul>
+ * <li>Before connection to the repository will be opened</li>
+ * <li>After connection to the repository was opened</li>
+ * <li>After wagon has logged-in to the repository</li>
+ * <li>After wagon has logged-off from the repository</li>
+ * <li>Before connection to the repository will be closed</li>
+ * <li>After connection to the repository was closed</li>
+ * </ul>
+ *
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class SessionEvent
+ extends WagonEvent
+{
+
+ /**
+ * A SESSION was closed.
+ */
+ public static final int SESSION_CLOSED = 1;
+
+ /**
+ * A SESSION is about to be disconnected.
+ */
+ public static final int SESSION_DISCONNECTING = 2;
+
+ /**
+ * A SESSION was disconnected (not currently used).
+ */
+ public static final int SESSION_DISCONNECTED = 3;
+
+ /**
+ * A SESSION was refused.
+ */
+ public static final int SESSION_CONNECTION_REFUSED = 4;
+
+ /**
+ * A SESSION is about to be opened.
+ */
+ public static final int SESSION_OPENING = 5;
+
+ /**
+ * A SESSION was opened.
+ */
+ public static final int SESSION_OPENED = 6;
+
+ /**
+ * A SESSION was opened.
+ */
+ public static final int SESSION_LOGGED_IN = 7;
+
+ /**
+ * A SESSION was opened.
+ */
+ public static final int SESSION_LOGGED_OFF = 8;
+
+ /**
+ * A SESSION was opened.
+ */
+ public static final int SESSION_ERROR_OCCURRED = 9;
+
+ /**
+ * The type of the event. One of the SESSSION_XXX constants
+ */
+ private int eventType;
+
+ private Exception exception;
+
+ /**
+ * Creates new instance of SessionEvent
+ *
+ * @param wagon <code>Wagon<code> object which created this event
+ * @param eventType the type of the event
+ */
+ public SessionEvent( final Wagon wagon, final int eventType )
+ {
+ super( wagon );
+ this.eventType = eventType;
+
+ }
+
+ /**
+ * Creates new instance of SessionEvent. Sets event type to <code>SESSION_ERROR_OCCURRED</code>
+ *
+ * @param wagon <code>Wagon<code> object which created this event
+ * @param exception the exception
+ */
+ public SessionEvent( final Wagon wagon, final Exception exception )
+ {
+ super( wagon );
+ this.exception = exception;
+ this.eventType = SESSION_ERROR_OCCURRED;
+
+ }
+
+ /**
+ * @return Returns the type.
+ */
+ public int getEventType()
+ {
+ return eventType;
+ }
+
+ /**
+ * @return Returns the exception.
+ */
+ public Exception getException()
+ {
+ return exception;
+ }
+
+ /**
+ * @param eventType The eventType to set.
+ */
+ public void setEventType( final int eventType )
+ {
+ switch ( eventType )
+ {
+ case SessionEvent.SESSION_CLOSED:
+ case SessionEvent.SESSION_DISCONNECTED:
+ case SessionEvent.SESSION_DISCONNECTING:
+ case SessionEvent.SESSION_ERROR_OCCURRED:
+ case SessionEvent.SESSION_LOGGED_IN:
+ case SessionEvent.SESSION_LOGGED_OFF:
+ case SessionEvent.SESSION_OPENED:
+ case SessionEvent.SESSION_OPENING:
+ case SessionEvent.SESSION_CONNECTION_REFUSED:
+ break;
+ default :
+ throw new IllegalArgumentException( "Illegal event type: " + eventType );
+ }
+ this.eventType = eventType;
+ }
+
+ /**
+ * @param exception The exception to set.
+ */
+ public void setException( final Exception exception )
+ {
+ this.exception = exception;
+ }
+
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "SessionEvent[" );
+
+ switch ( this.eventType )
+ {
+ case SessionEvent.SESSION_CLOSED:
+ sb.append( "CONNECTION_CLOSED" );
+ break;
+ case SessionEvent.SESSION_DISCONNECTED:
+ sb.append( "CONNECTION_DISCONNECTED" );
+ break;
+ case SessionEvent.SESSION_DISCONNECTING:
+ sb.append( "CONNECTION_DISCONNECTING" );
+ break;
+ case SessionEvent.SESSION_ERROR_OCCURRED:
+ sb.append( "CONNECTION_ERROR_OCCURRED" );
+ break;
+ case SessionEvent.SESSION_LOGGED_IN:
+ sb.append( "CONNECTION_LOGGED_IN" );
+ break;
+ case SessionEvent.SESSION_LOGGED_OFF:
+ sb.append( "CONNECTION_LOGGED_OFF" );
+ break;
+ case SessionEvent.SESSION_OPENED:
+ sb.append( "CONNECTION_OPENED" );
+ break;
+ case SessionEvent.SESSION_OPENING:
+ sb.append( "CONNECTION_OPENING" );
+ break;
+ case SessionEvent.SESSION_CONNECTION_REFUSED:
+ sb.append( "CONNECTION_CONNECTION_REFUSED" );
+ break;
+ default:
+ sb.append( eventType );
+ }
+ sb.append( "|" );
+
+ sb.append( this.getWagon().getRepository() ).append( "|" );
+ sb.append( this.source );
+
+ if ( exception != null )
+ {
+ sb.append( "|" );
+ sb.append( exception.getClass().getName() ).append( ":" );
+ sb.append( exception.getMessage() );
+ }
+
+ sb.append( "]" );
+
+ return sb.toString();
+ }
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionEventSupport.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionEventSupport.java
index 4cf5876..effa0b9 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionEventSupport.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionEventSupport.java
@@ -1,224 +1,224 @@
-package org.apache.maven.wagon.events;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * The class allows registration and deregistration of session listeners
- *
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public final class SessionEventSupport
-{
- /**
- * registered listeners
- */
- private final List<SessionListener> listeners = new ArrayList<SessionListener>();
-
- /**
- * Adds the listener to the collection of listeners
- * who will be notified when any session event occurs
- * in this <code>Wagon</code> object.
- * <br/>
- * If listener is <code>null</code>, no exception is thrown and no action is performed
- *
- * @param listener the transfer listener
- * @see #removeSessionListener(SessionListener)
- * @see TransferListener
- */
- public void addSessionListener( final SessionListener listener )
- {
- if ( listener != null )
- {
- listeners.add( listener );
- }
- }
-
- /**
- * Removes the session listener from the collection of listeners so
- * it no longer receives session events.
- * <br/>
- * If listener is <code>null</code> or specified listener was not added
- * to this <code>SessionEventSupport</code> object
- * no exception is thrown and no action is performed
- *
- * @param listener the session listener
- * @see #addSessionListener(org.apache.maven.wagon.events.SessionListener)
- */
- public void removeSessionListener( final SessionListener listener )
- {
- listeners.remove( listener );
- }
-
- /**
- * Returns whether the specified instance of session
- * listener was added to the collection of listeners
- * who will be notified when an session event occurs
- *
- * @param listener the session listener
- * @return <code>true<code>
- * if given listener was added to the collection of listeners
- * <code>false</code> otherwise
- * @see org.apache.maven.wagon.events.SessionListener
- * @see #addSessionListener(org.apache.maven.wagon.events.SessionListener)
- */
- public boolean hasSessionListener( final SessionListener listener )
- {
- return listeners.contains( listener );
- }
-
- /**
- * Dispatches the given <code>SessionEvent</code>
- * to all registered listeners (calls method {@link SessionListener#sessionDisconnected(SessionEvent)} on all of
- * them}. The Event should be of type {@link SessionEvent#SESSION_DISCONNECTED}
- *
- * @param sessionEvent the SessionEvent which will be dispatched to listeners
- */
- public void fireSessionDisconnected( final SessionEvent sessionEvent )
- {
- for ( SessionListener listener : listeners )
- {
- listener.sessionDisconnected( sessionEvent );
- }
- }
-
- /**
- * Dispatches the given <code>SessionEvent</code>
- * to all registered listeners (calls method {@link SessionListener#sessionDisconnecting(SessionEvent)} } on all of
- * them}. The Event should be of type {@link SessionEvent#SESSION_DISCONNECTING}
- *
- * @param sessionEvent the SessionEvent which will be dispatched to listeners
- */
- public void fireSessionDisconnecting( final SessionEvent sessionEvent )
- {
- for ( SessionListener listener : listeners )
- {
- listener.sessionDisconnecting( sessionEvent );
- }
- }
-
- /**
- * Dispatches the given <code>SessionEvent</code>
- * to all registered listeners (calls method {@link SessionListener#sessionLoggedIn(SessionEvent)} on all of them}.
- * The Event should be of type {@link SessionEvent#SESSION_LOGGED_IN}
- *
- * @param sessionEvent the SessionEvent which will be dispatched to listeners
- */
- public void fireSessionLoggedIn( final SessionEvent sessionEvent )
- {
- for ( SessionListener listener : listeners )
- {
- listener.sessionLoggedIn( sessionEvent );
- }
- }
-
- /**
- * Dispatches the given <code>SessionEvent</code>
- * to all registered listeners (calls method {@link SessionListener#sessionLoggedOff(SessionEvent)} on all of
- * them}. The Event should be of type {@link SessionEvent#SESSION_LOGGED_OFF}
- *
- * @param sessionEvent the SessionEvent which will be dispatched to listeners
- */
- public void fireSessionLoggedOff( final SessionEvent sessionEvent )
- {
- for ( SessionListener listener : listeners )
- {
- listener.sessionLoggedOff( sessionEvent );
- }
- }
-
- /**
- * Dispatches the given <code>SessionEvent</code>
- * to all registered listeners (calls method {@link SessionListener#sessionOpened(SessionEvent)} on all of them}.
- * The Event should be of type {@link SessionEvent#SESSION_OPENED}
- *
- * @param sessionEvent the SessionEvent which will be dispatched to listeners
- */
- public void fireSessionOpened( final SessionEvent sessionEvent )
- {
- for ( SessionListener listener : listeners )
- {
- listener.sessionOpened( sessionEvent );
- }
- }
-
- /**
- * Dispatches the given <code>SessionEvent</code>
- * to all registered listeners (calls method {@link SessionListener#sessionOpening(SessionEvent)} on all of them}.
- * The Event should be of type {@link SessionEvent#SESSION_OPENING}
- *
- * @param sessionEvent the SessionEvent which will be dispatched to listeners
- */
- public void fireSessionOpening( final SessionEvent sessionEvent )
- {
- for ( SessionListener listener : listeners )
- {
- listener.sessionOpening( sessionEvent );
- }
- }
-
- /**
- * Dispatches the given <code>SessionEvent</code>
- * to all registered listeners (calls method {@link SessionListener#sessionConnectionRefused(SessionEvent)} on all
- * of them}. The Event should be of type {@link SessionEvent#SESSION_CONNECTION_REFUSED}
- *
- * @param sessionEvent the SessionEvent which will be dispatched to listeners
- */
- public void fireSessionConnectionRefused( final SessionEvent sessionEvent )
- {
- for ( SessionListener listener : listeners )
- {
- listener.sessionConnectionRefused( sessionEvent );
- }
- }
-
- /**
- * Dispatches the given debug message
- * to all registered listeners (calls method {@link SessionListener#debug(String)} on all of them}.
- *
- * @param message the debug message which will be dispatched to listeners
- */
- public void fireDebug( final String message )
- {
- for ( SessionListener listener : listeners )
- {
- listener.debug( message );
- }
- }
-
- /**
- * Dispatches the given <code>SessionEvent</code>
- * to all registered listeners (calls method {@link SessionListener#sessionConnectionRefused(SessionEvent)} on all
- * of them}. The Event should be of type {@link SessionEvent#SESSION_ERROR_OCCURRED} and it is expected that
- * {@link SessionEvent#getException()} method will return not null value
- *
- * @param sessionEvent the SessionEvent which will be dispatched to listeners
- */
- public void fireSessionError( final SessionEvent sessionEvent )
- {
- for ( SessionListener listener : listeners )
- {
- listener.sessionError( sessionEvent );
- }
- }
-}
+package org.apache.maven.wagon.events;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * The class allows registration and deregistration of session listeners
+ *
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public final class SessionEventSupport
+{
+ /**
+ * registered listeners
+ */
+ private final List<SessionListener> listeners = new ArrayList<SessionListener>();
+
+ /**
+ * Adds the listener to the collection of listeners
+ * who will be notified when any session event occurs
+ * in this <code>Wagon</code> object.
+ * <br/>
+ * If listener is <code>null</code>, no exception is thrown and no action is performed
+ *
+ * @param listener the transfer listener
+ * @see #removeSessionListener(SessionListener)
+ * @see TransferListener
+ */
+ public void addSessionListener( final SessionListener listener )
+ {
+ if ( listener != null )
+ {
+ listeners.add( listener );
+ }
+ }
+
+ /**
+ * Removes the session listener from the collection of listeners so
+ * it no longer receives session events.
+ * <br/>
+ * If listener is <code>null</code> or specified listener was not added
+ * to this <code>SessionEventSupport</code> object
+ * no exception is thrown and no action is performed
+ *
+ * @param listener the session listener
+ * @see #addSessionListener(org.apache.maven.wagon.events.SessionListener)
+ */
+ public void removeSessionListener( final SessionListener listener )
+ {
+ listeners.remove( listener );
+ }
+
+ /**
+ * Returns whether the specified instance of session
+ * listener was added to the collection of listeners
+ * who will be notified when an session event occurs
+ *
+ * @param listener the session listener
+ * @return <code>true<code>
+ * if given listener was added to the collection of listeners
+ * <code>false</code> otherwise
+ * @see org.apache.maven.wagon.events.SessionListener
+ * @see #addSessionListener(org.apache.maven.wagon.events.SessionListener)
+ */
+ public boolean hasSessionListener( final SessionListener listener )
+ {
+ return listeners.contains( listener );
+ }
+
+ /**
+ * Dispatches the given <code>SessionEvent</code>
+ * to all registered listeners (calls method {@link SessionListener#sessionDisconnected(SessionEvent)} on all of
+ * them}. The Event should be of type {@link SessionEvent#SESSION_DISCONNECTED}
+ *
+ * @param sessionEvent the SessionEvent which will be dispatched to listeners
+ */
+ public void fireSessionDisconnected( final SessionEvent sessionEvent )
+ {
+ for ( SessionListener listener : listeners )
+ {
+ listener.sessionDisconnected( sessionEvent );
+ }
+ }
+
+ /**
+ * Dispatches the given <code>SessionEvent</code>
+ * to all registered listeners (calls method {@link SessionListener#sessionDisconnecting(SessionEvent)} } on all of
+ * them}. The Event should be of type {@link SessionEvent#SESSION_DISCONNECTING}
+ *
+ * @param sessionEvent the SessionEvent which will be dispatched to listeners
+ */
+ public void fireSessionDisconnecting( final SessionEvent sessionEvent )
+ {
+ for ( SessionListener listener : listeners )
+ {
+ listener.sessionDisconnecting( sessionEvent );
+ }
+ }
+
+ /**
+ * Dispatches the given <code>SessionEvent</code>
+ * to all registered listeners (calls method {@link SessionListener#sessionLoggedIn(SessionEvent)} on all of them}.
+ * The Event should be of type {@link SessionEvent#SESSION_LOGGED_IN}
+ *
+ * @param sessionEvent the SessionEvent which will be dispatched to listeners
+ */
+ public void fireSessionLoggedIn( final SessionEvent sessionEvent )
+ {
+ for ( SessionListener listener : listeners )
+ {
+ listener.sessionLoggedIn( sessionEvent );
+ }
+ }
+
+ /**
+ * Dispatches the given <code>SessionEvent</code>
+ * to all registered listeners (calls method {@link SessionListener#sessionLoggedOff(SessionEvent)} on all of
+ * them}. The Event should be of type {@link SessionEvent#SESSION_LOGGED_OFF}
+ *
+ * @param sessionEvent the SessionEvent which will be dispatched to listeners
+ */
+ public void fireSessionLoggedOff( final SessionEvent sessionEvent )
+ {
+ for ( SessionListener listener : listeners )
+ {
+ listener.sessionLoggedOff( sessionEvent );
+ }
+ }
+
+ /**
+ * Dispatches the given <code>SessionEvent</code>
+ * to all registered listeners (calls method {@link SessionListener#sessionOpened(SessionEvent)} on all of them}.
+ * The Event should be of type {@link SessionEvent#SESSION_OPENED}
+ *
+ * @param sessionEvent the SessionEvent which will be dispatched to listeners
+ */
+ public void fireSessionOpened( final SessionEvent sessionEvent )
+ {
+ for ( SessionListener listener : listeners )
+ {
+ listener.sessionOpened( sessionEvent );
+ }
+ }
+
+ /**
+ * Dispatches the given <code>SessionEvent</code>
+ * to all registered listeners (calls method {@link SessionListener#sessionOpening(SessionEvent)} on all of them}.
+ * The Event should be of type {@link SessionEvent#SESSION_OPENING}
+ *
+ * @param sessionEvent the SessionEvent which will be dispatched to listeners
+ */
+ public void fireSessionOpening( final SessionEvent sessionEvent )
+ {
+ for ( SessionListener listener : listeners )
+ {
+ listener.sessionOpening( sessionEvent );
+ }
+ }
+
+ /**
+ * Dispatches the given <code>SessionEvent</code>
+ * to all registered listeners (calls method {@link SessionListener#sessionConnectionRefused(SessionEvent)} on all
+ * of them}. The Event should be of type {@link SessionEvent#SESSION_CONNECTION_REFUSED}
+ *
+ * @param sessionEvent the SessionEvent which will be dispatched to listeners
+ */
+ public void fireSessionConnectionRefused( final SessionEvent sessionEvent )
+ {
+ for ( SessionListener listener : listeners )
+ {
+ listener.sessionConnectionRefused( sessionEvent );
+ }
+ }
+
+ /**
+ * Dispatches the given debug message
+ * to all registered listeners (calls method {@link SessionListener#debug(String)} on all of them}.
+ *
+ * @param message the debug message which will be dispatched to listeners
+ */
+ public void fireDebug( final String message )
+ {
+ for ( SessionListener listener : listeners )
+ {
+ listener.debug( message );
+ }
+ }
+
+ /**
+ * Dispatches the given <code>SessionEvent</code>
+ * to all registered listeners (calls method {@link SessionListener#sessionConnectionRefused(SessionEvent)} on all
+ * of them}. The Event should be of type {@link SessionEvent#SESSION_ERROR_OCCURRED} and it is expected that
+ * {@link SessionEvent#getException()} method will return not null value
+ *
+ * @param sessionEvent the SessionEvent which will be dispatched to listeners
+ */
+ public void fireSessionError( final SessionEvent sessionEvent )
+ {
+ for ( SessionListener listener : listeners )
+ {
+ listener.sessionError( sessionEvent );
+ }
+ }
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionListener.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionListener.java
index c7c7155..784947d 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionListener.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionListener.java
@@ -1,118 +1,118 @@
-package org.apache.maven.wagon.events;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Interface for classes which wants to receive and respond to any session update events.
- *
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public interface SessionListener
-{
-
- /**
- * This method will be called when Wagon is about to open
- * connection to the repository.
- * The type of the event should
- * be set to {@link SessionEvent.SESSION_OPENING}
- *
- * @param sessionEvent the session event
- */
- void sessionOpening( SessionEvent sessionEvent );
-
- /**
- * This method will be called when Wagon has successfully connected to
- * to the repository.
- * The type of the event should
- * be set to {@link SessionEvent.SESSION_OPENED}
- *
- * @param sessionEvent the session event
- */
- void sessionOpened( SessionEvent sessionEvent );
-
- /**
- * This method will be called when Wagon has closed connection to
- * to the repository.
- * The type of the event should
- * be set to {@link SessionEvent.SESSION_DISCONNECTING}
- *
- * @param sessionEvent the session event
- */
- void sessionDisconnecting( SessionEvent sessionEvent );
-
- /**
- * This method will be called when Wagon has closed connection to
- * the repository.
- * The type of the event should
- * be set to {@link SessionEvent.SESSION_DISCONNECTED}
- *
- * @param sessionEvent the session event
- */
- void sessionDisconnected( SessionEvent sessionEvent );
-
- /**
- * This method will be called when Wagon when connection to
- * the repository was refused.
- * <p/>
- * The type of the event should
- * be set to {@link SessionEvent.SESSION_CONNECTION_REFUSED}
- *
- * @param sessionEvent the session event
- */
- void sessionConnectionRefused( SessionEvent sessionEvent );
-
- /**
- * This method will be called by Wagon when Wagon managed
- * to login to the repository.
- *
- * @param sessionEvent the session event
- */
- void sessionLoggedIn( SessionEvent sessionEvent );
-
- /**
- * This method will be called by Wagon has logged off
- * from the repository.
- * <p/>
- * The type of the event should
- * be set to {@link SessionEvent.SESSION_LOGGED_OFF}
- *
- * @param sessionEvent the session event
- */
- void sessionLoggedOff( SessionEvent sessionEvent );
-
- /**
- * This method will be called by Wagon when an error occurred.
- * <p/>
- * The type of the event should
- * be set to {@link SessionEvent.SESSION_ERROR_OCCURRED}
- *
- * @param sessionEvent the session event
- */
- void sessionError( SessionEvent sessionEvent );
-
- /**
- * This method allows to send arbitrary debug messages.
- *
- * @param message the debug message
- */
- void debug( String message );
-
+package org.apache.maven.wagon.events;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Interface for classes which wants to receive and respond to any session update events.
+ *
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public interface SessionListener
+{
+
+ /**
+ * This method will be called when Wagon is about to open
+ * connection to the repository.
+ * The type of the event should
+ * be set to {@link SessionEvent.SESSION_OPENING}
+ *
+ * @param sessionEvent the session event
+ */
+ void sessionOpening( SessionEvent sessionEvent );
+
+ /**
+ * This method will be called when Wagon has successfully connected to
+ * to the repository.
+ * The type of the event should
+ * be set to {@link SessionEvent.SESSION_OPENED}
+ *
+ * @param sessionEvent the session event
+ */
+ void sessionOpened( SessionEvent sessionEvent );
+
+ /**
+ * This method will be called when Wagon has closed connection to
+ * to the repository.
+ * The type of the event should
+ * be set to {@link SessionEvent.SESSION_DISCONNECTING}
+ *
+ * @param sessionEvent the session event
+ */
+ void sessionDisconnecting( SessionEvent sessionEvent );
+
+ /**
+ * This method will be called when Wagon has closed connection to
+ * the repository.
+ * The type of the event should
+ * be set to {@link SessionEvent.SESSION_DISCONNECTED}
+ *
+ * @param sessionEvent the session event
+ */
+ void sessionDisconnected( SessionEvent sessionEvent );
+
+ /**
+ * This method will be called when Wagon when connection to
+ * the repository was refused.
+ * <p/>
+ * The type of the event should
+ * be set to {@link SessionEvent.SESSION_CONNECTION_REFUSED}
+ *
+ * @param sessionEvent the session event
+ */
+ void sessionConnectionRefused( SessionEvent sessionEvent );
+
+ /**
+ * This method will be called by Wagon when Wagon managed
+ * to login to the repository.
+ *
+ * @param sessionEvent the session event
+ */
+ void sessionLoggedIn( SessionEvent sessionEvent );
+
+ /**
+ * This method will be called by Wagon has logged off
+ * from the repository.
+ * <p/>
+ * The type of the event should
+ * be set to {@link SessionEvent.SESSION_LOGGED_OFF}
+ *
+ * @param sessionEvent the session event
+ */
+ void sessionLoggedOff( SessionEvent sessionEvent );
+
+ /**
+ * This method will be called by Wagon when an error occurred.
+ * <p/>
+ * The type of the event should
+ * be set to {@link SessionEvent.SESSION_ERROR_OCCURRED}
+ *
+ * @param sessionEvent the session event
+ */
+ void sessionError( SessionEvent sessionEvent );
+
+ /**
+ * This method allows to send arbitrary debug messages.
+ *
+ * @param message the debug message
+ */
+ void debug( String message );
+
}
\ No newline at end of file
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEvent.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEvent.java
index ac3a711..ccebbd2 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEvent.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEvent.java
@@ -1,318 +1,318 @@
-package org.apache.maven.wagon.events;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.resource.Resource;
-
-import java.io.File;
-
-/**
- * TransferEvent is used to notify TransferListeners about progress
- * in transfer of resources form/to the repository
- *
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class TransferEvent
- extends WagonEvent
-{
-
- /**
- * A transfer was attempted, but has not yet commenced.
- */
- public static final int TRANSFER_INITIATED = 0;
-
- /**
- * A transfer was started.
- */
- public static final int TRANSFER_STARTED = 1;
-
- /**
- * A transfer is completed.
- */
- public static final int TRANSFER_COMPLETED = 2;
-
- /**
- * A transfer is in progress.
- */
- public static final int TRANSFER_PROGRESS = 3;
-
- /**
- * An error occurred during transfer
- */
- public static final int TRANSFER_ERROR = 4;
-
- /**
- * Indicates GET transfer (from the repository)
- */
- public static final int REQUEST_GET = 5;
-
- /**
- * Indicates PUT transfer (to the repository)
- */
- public static final int REQUEST_PUT = 6;
-
- private Resource resource;
-
- private int eventType;
-
- private int requestType;
-
- private Exception exception;
-
- private File localFile;
-
- public TransferEvent( final Wagon wagon, final Resource resource, final int eventType, final int requestType )
- {
- super( wagon );
-
- this.resource = resource;
-
- setEventType( eventType );
-
- setRequestType( requestType );
-
- }
-
- public TransferEvent( final Wagon wagon, final Resource resource, final Exception exception, final int requestType )
- {
- this( wagon, resource, TRANSFER_ERROR, requestType );
-
- this.exception = exception;
- }
-
- /**
- * @return Returns the resource.
- */
- public Resource getResource()
- {
- return resource;
- }
-
- /**
- * @return Returns the exception.
- */
- public Exception getException()
- {
- return exception;
- }
-
- /**
- * Returns the request type.
- *
- * @return Returns the request type. The Request type is one of
- * <code>TransferEvent.REQUEST_GET<code> or <code>TransferEvent.REQUEST_PUT<code>
- */
- public int getRequestType()
- {
- return requestType;
- }
-
- /**
- * Sets the request type
- *
- * @param requestType The requestType to set.
- * The Request type value should be either
- * <code>TransferEvent.REQUEST_GET<code> or <code>TransferEvent.REQUEST_PUT<code>.
- * @throws IllegalArgumentException when
- */
- public void setRequestType( final int requestType )
- {
- switch ( requestType )
- {
-
- case REQUEST_PUT:
- case REQUEST_GET:
- break;
-
- default :
- throw new IllegalArgumentException( "Illegal request type: " + requestType );
- }
-
- this.requestType = requestType;
- }
-
- /**
- * @return Returns the eventType.
- */
- public int getEventType()
- {
- return eventType;
- }
-
- /**
- * @param eventType The eventType to set.
- */
- public void setEventType( final int eventType )
- {
- switch ( eventType )
- {
-
- case TRANSFER_INITIATED:
- case TRANSFER_STARTED:
- case TRANSFER_COMPLETED:
- case TRANSFER_PROGRESS:
- case TRANSFER_ERROR:
- break;
- default :
- throw new IllegalArgumentException( "Illegal event type: " + eventType );
- }
-
- this.eventType = eventType;
- }
-
- /**
- * @param resource The resource to set.
- */
- public void setResource( final Resource resource )
- {
- this.resource = resource;
- }
-
- /**
- * @return Returns the local file.
- */
- public File getLocalFile()
- {
- return localFile;
- }
-
- /**
- * @param localFile The local file to set.
- */
- public void setLocalFile( File localFile )
- {
- this.localFile = localFile;
- }
-
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( "TransferEvent[" );
-
- switch ( this.getRequestType() )
- {
- case REQUEST_GET:
- sb.append( "GET" );
- break;
- case REQUEST_PUT:
- sb.append( "PUT" );
- break;
- default:
- sb.append( this.getRequestType() );
- break;
- }
-
- sb.append( "|" );
- switch ( this.getEventType() )
- {
- case TRANSFER_COMPLETED:
- sb.append( "COMPLETED" );
- break;
- case TRANSFER_ERROR:
- sb.append( "ERROR" );
- break;
- case TRANSFER_INITIATED:
- sb.append( "INITIATED" );
- break;
- case TRANSFER_PROGRESS:
- sb.append( "PROGRESS" );
- break;
- case TRANSFER_STARTED:
- sb.append( "STARTED" );
- break;
- default:
- sb.append( this.getEventType() );
- break;
- }
-
- sb.append( "|" );
-
- sb.append( this.getWagon().getRepository() ).append( "|" );
- sb.append( this.getLocalFile() ).append( "|" );
- sb.append( this.getResource().inspect() );
- sb.append( "]" );
-
- return sb.toString();
- }
-
- public int hashCode()
- {
- final int prime = 31;
- int result = 1;
- result = prime * result + eventType;
- result = prime * result + ( ( exception == null ) ? 0 : exception.hashCode() );
- result = prime * result + ( ( localFile == null ) ? 0 : localFile.hashCode() );
- result = prime * result + requestType;
- result = prime * result + ( ( resource == null ) ? 0 : resource.hashCode() );
- return result;
- }
-
- public boolean equals( Object obj )
- {
- if ( this == obj )
- {
- return true;
- }
- if ( ( obj == null ) || ( getClass() != obj.getClass() ) )
- {
- return false;
- }
- final TransferEvent other = (TransferEvent) obj;
- if ( eventType != other.eventType )
- {
- return false;
- }
- if ( exception == null )
- {
- if ( other.exception != null )
- {
- return false;
- }
- }
- else if ( !exception.getClass().equals( other.exception.getClass() ) )
- {
- return false;
- }
- if ( requestType != other.requestType )
- {
- return false;
- }
- if ( resource == null )
- {
- if ( other.resource != null )
- {
- return false;
- }
- }
- else if ( !resource.equals( other.resource ) )
- {
- return false;
- }
- else if ( !source.equals( other.source ) )
- {
- return false;
- }
- return true;
- }
-
-}
+package org.apache.maven.wagon.events;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.resource.Resource;
+
+import java.io.File;
+
+/**
+ * TransferEvent is used to notify TransferListeners about progress
+ * in transfer of resources form/to the repository
+ *
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class TransferEvent
+ extends WagonEvent
+{
+
+ /**
+ * A transfer was attempted, but has not yet commenced.
+ */
+ public static final int TRANSFER_INITIATED = 0;
+
+ /**
+ * A transfer was started.
+ */
+ public static final int TRANSFER_STARTED = 1;
+
+ /**
+ * A transfer is completed.
+ */
+ public static final int TRANSFER_COMPLETED = 2;
+
+ /**
+ * A transfer is in progress.
+ */
+ public static final int TRANSFER_PROGRESS = 3;
+
+ /**
+ * An error occurred during transfer
+ */
+ public static final int TRANSFER_ERROR = 4;
+
+ /**
+ * Indicates GET transfer (from the repository)
+ */
+ public static final int REQUEST_GET = 5;
+
+ /**
+ * Indicates PUT transfer (to the repository)
+ */
+ public static final int REQUEST_PUT = 6;
+
+ private Resource resource;
+
+ private int eventType;
+
+ private int requestType;
+
+ private Exception exception;
+
+ private File localFile;
+
+ public TransferEvent( final Wagon wagon, final Resource resource, final int eventType, final int requestType )
+ {
+ super( wagon );
+
+ this.resource = resource;
+
+ setEventType( eventType );
+
+ setRequestType( requestType );
+
+ }
+
+ public TransferEvent( final Wagon wagon, final Resource resource, final Exception exception, final int requestType )
+ {
+ this( wagon, resource, TRANSFER_ERROR, requestType );
+
+ this.exception = exception;
+ }
+
+ /**
+ * @return Returns the resource.
+ */
+ public Resource getResource()
+ {
+ return resource;
+ }
+
+ /**
+ * @return Returns the exception.
+ */
+ public Exception getException()
+ {
+ return exception;
+ }
+
+ /**
+ * Returns the request type.
+ *
+ * @return Returns the request type. The Request type is one of
+ * <code>TransferEvent.REQUEST_GET<code> or <code>TransferEvent.REQUEST_PUT<code>
+ */
+ public int getRequestType()
+ {
+ return requestType;
+ }
+
+ /**
+ * Sets the request type
+ *
+ * @param requestType The requestType to set.
+ * The Request type value should be either
+ * <code>TransferEvent.REQUEST_GET<code> or <code>TransferEvent.REQUEST_PUT<code>.
+ * @throws IllegalArgumentException when
+ */
+ public void setRequestType( final int requestType )
+ {
+ switch ( requestType )
+ {
+
+ case REQUEST_PUT:
+ case REQUEST_GET:
+ break;
+
+ default :
+ throw new IllegalArgumentException( "Illegal request type: " + requestType );
+ }
+
+ this.requestType = requestType;
+ }
+
+ /**
+ * @return Returns the eventType.
+ */
+ public int getEventType()
+ {
+ return eventType;
+ }
+
+ /**
+ * @param eventType The eventType to set.
+ */
+ public void setEventType( final int eventType )
+ {
+ switch ( eventType )
+ {
+
+ case TRANSFER_INITIATED:
+ case TRANSFER_STARTED:
+ case TRANSFER_COMPLETED:
+ case TRANSFER_PROGRESS:
+ case TRANSFER_ERROR:
+ break;
+ default :
+ throw new IllegalArgumentException( "Illegal event type: " + eventType );
+ }
+
+ this.eventType = eventType;
+ }
+
+ /**
+ * @param resource The resource to set.
+ */
+ public void setResource( final Resource resource )
+ {
+ this.resource = resource;
+ }
+
+ /**
+ * @return Returns the local file.
+ */
+ public File getLocalFile()
+ {
+ return localFile;
+ }
+
+ /**
+ * @param localFile The local file to set.
+ */
+ public void setLocalFile( File localFile )
+ {
+ this.localFile = localFile;
+ }
+
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "TransferEvent[" );
+
+ switch ( this.getRequestType() )
+ {
+ case REQUEST_GET:
+ sb.append( "GET" );
+ break;
+ case REQUEST_PUT:
+ sb.append( "PUT" );
+ break;
+ default:
+ sb.append( this.getRequestType() );
+ break;
+ }
+
+ sb.append( "|" );
+ switch ( this.getEventType() )
+ {
+ case TRANSFER_COMPLETED:
+ sb.append( "COMPLETED" );
+ break;
+ case TRANSFER_ERROR:
+ sb.append( "ERROR" );
+ break;
+ case TRANSFER_INITIATED:
+ sb.append( "INITIATED" );
+ break;
+ case TRANSFER_PROGRESS:
+ sb.append( "PROGRESS" );
+ break;
+ case TRANSFER_STARTED:
+ sb.append( "STARTED" );
+ break;
+ default:
+ sb.append( this.getEventType() );
+ break;
+ }
+
+ sb.append( "|" );
+
+ sb.append( this.getWagon().getRepository() ).append( "|" );
+ sb.append( this.getLocalFile() ).append( "|" );
+ sb.append( this.getResource().inspect() );
+ sb.append( "]" );
+
+ return sb.toString();
+ }
+
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + eventType;
+ result = prime * result + ( ( exception == null ) ? 0 : exception.hashCode() );
+ result = prime * result + ( ( localFile == null ) ? 0 : localFile.hashCode() );
+ result = prime * result + requestType;
+ result = prime * result + ( ( resource == null ) ? 0 : resource.hashCode() );
+ return result;
+ }
+
+ public boolean equals( Object obj )
+ {
+ if ( this == obj )
+ {
+ return true;
+ }
+ if ( ( obj == null ) || ( getClass() != obj.getClass() ) )
+ {
+ return false;
+ }
+ final TransferEvent other = (TransferEvent) obj;
+ if ( eventType != other.eventType )
+ {
+ return false;
+ }
+ if ( exception == null )
+ {
+ if ( other.exception != null )
+ {
+ return false;
+ }
+ }
+ else if ( !exception.getClass().equals( other.exception.getClass() ) )
+ {
+ return false;
+ }
+ if ( requestType != other.requestType )
+ {
+ return false;
+ }
+ if ( resource == null )
+ {
+ if ( other.resource != null )
+ {
+ return false;
+ }
+ }
+ else if ( !resource.equals( other.resource ) )
+ {
+ return false;
+ }
+ else if ( !source.equals( other.source ) )
+ {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEventSupport.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEventSupport.java
index cb3d0cb..2783846 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEventSupport.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEventSupport.java
@@ -1,189 +1,189 @@
-package org.apache.maven.wagon.events;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * The class allows registration and removal of event listeners of type
- * TransferListener and dispatch of those events to those listeners
- *
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public final class TransferEventSupport
-{
-
- /**
- * registered listeners
- */
- private final List<TransferListener> listeners = new ArrayList<TransferListener>();
-
- /**
- * Adds the listener to the collection of listeners
- * who will be notified when any transfer event occurs
- * in this <code>Wagon</code> object.
- * <br/>
- * If listener is <code>null</code>, no exception is thrown and no action is performed
- *
- * @param listener the transfer listener
- * @see #removeTransferListener(org.apache.maven.wagon.events.TransferListener)
- * @see TransferListener
- */
- public synchronized void addTransferListener( final TransferListener listener )
- {
- if ( listener != null )
- {
- listeners.add( listener );
- }
- }
-
- /**
- * Removes the transfer listener from the collection of listeners so
- * it no longer receives transfer events.
- * <br/>
- * If listener is <code>null</code> or specified listener was not added
- * to this <code>TransferEventSupport</code> object
- * no exception is thrown and no action is performed
- *
- * @param listener the transfer listener
- * @see #addTransferListener(TransferListener)
- */
- public synchronized void removeTransferListener( final TransferListener listener )
- {
- listeners.remove( listener );
- }
-
- /**
- * Returns whether the specified instance of transfer
- * listener was added to the collection of listeners
- * who will be notified when an transfer event occurs
- *
- * @param listener the transfer listener
- * @return <code>true<code>
- * if given listener was added to the collection of listeners
- * <code>false</code> otherwise
- * @see org.apache.maven.wagon.events.TransferEvent
- * @see #addTransferListener(TransferListener)
- */
- public synchronized boolean hasTransferListener( final TransferListener listener )
- {
- return listeners.contains( listener );
- }
-
-
- /**
- * Dispatches the given <code>TransferEvent</code>
- * to all registered listeners (calls method {@link TransferListener#transferStarted(TransferEvent)} on all of
- * them}. The Event should be of type {@link TransferEvent#TRANSFER_COMPLETED}
- *
- * @param transferEvent the TransferEvent which will be dispatched to listeners
- */
- public synchronized void fireTransferStarted( final TransferEvent transferEvent )
- {
- for ( TransferListener listener : listeners )
- {
- listener.transferStarted( transferEvent );
- }
- }
-
- /**
- * Dispatches the given <code>TransferEvent</code>
- * to all registered listeners (calls method {@link TransferListener#transferProgress(TransferEvent, byte[], int)}
- * on all of them). The Event should be of type {@link TransferEvent#TRANSFER_PROGRESS}.
- *
- * @param transferEvent the TransferEvent which will be dispatched to listeners
- * @param buffer the buffer containing the additional content
- * @param length the length of the content in the buffer
- */
- public synchronized void fireTransferProgress( final TransferEvent transferEvent, byte[] buffer, int length )
- {
- for ( TransferListener listener : listeners )
- {
- listener.transferProgress( transferEvent, buffer, length );
-
- }
- }
-
- /**
- * Dispatches the given <code>TransferEvent</code>
- * to all registered listeners (calls method {@link TransferListener#transferCompleted(TransferEvent)} on all of
- * them}. The Event should be of type {@link TransferEvent#TRANSFER_COMPLETED}
- *
- * @param transferEvent the TransferEvent which will be dispatched to listeners
- */
- public synchronized void fireTransferCompleted( final TransferEvent transferEvent )
- {
- for ( TransferListener listener : listeners )
- {
- listener.transferCompleted( transferEvent );
-
- }
- }
-
- /**
- * Dispatches the given <code>TransferEvent</code>
- * to all registered listeners (calls method {@link TransferListener#transferError(TransferEvent)} on all of them.
- * The Event should be of type {@link TransferEvent#TRANSFER_ERROR} and it is expected that
- * {@link TransferEvent#getException()} } method will return not null value
- *
- * @param transferEvent the TransferEvent which will be dispatched to listeners
- */
- public synchronized void fireTransferError( final TransferEvent transferEvent )
- {
- for ( TransferListener listener : listeners )
- {
- listener.transferError( transferEvent );
-
- }
- }
-
- /**
- * Dispatches the given debug message
- * to all registered listeners (calls method {@link TransferListener#debug(String)} on all of them.
- *
- * @param message the debug message which will be dispatched to listeners
- */
- public synchronized void fireDebug( final String message )
- {
-
- for ( TransferListener listener : listeners )
- {
- listener.debug( message );
-
- }
- }
-
- /**
- * Dispatches the given <code>TransferEvent</code>
- * to all registered listeners (calls method {@link TransferListener#transferInitiated(TransferEvent)} on all of
- * them. The Event should be of type {@link TransferEvent#TRANSFER_INITIATED}.
- *
- * @param transferEvent the TransferEvent which will be dispatched to listeners
- */
- public synchronized void fireTransferInitiated( final TransferEvent transferEvent )
- {
- for ( TransferListener listener : listeners )
- {
- listener.transferInitiated( transferEvent );
- }
- }
-}
+package org.apache.maven.wagon.events;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * The class allows registration and removal of event listeners of type
+ * TransferListener and dispatch of those events to those listeners
+ *
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public final class TransferEventSupport
+{
+
+ /**
+ * registered listeners
+ */
+ private final List<TransferListener> listeners = new ArrayList<TransferListener>();
+
+ /**
+ * Adds the listener to the collection of listeners
+ * who will be notified when any transfer event occurs
+ * in this <code>Wagon</code> object.
+ * <br/>
+ * If listener is <code>null</code>, no exception is thrown and no action is performed
+ *
+ * @param listener the transfer listener
+ * @see #removeTransferListener(org.apache.maven.wagon.events.TransferListener)
+ * @see TransferListener
+ */
+ public synchronized void addTransferListener( final TransferListener listener )
+ {
+ if ( listener != null )
+ {
+ listeners.add( listener );
+ }
+ }
+
+ /**
+ * Removes the transfer listener from the collection of listeners so
+ * it no longer receives transfer events.
+ * <br/>
+ * If listener is <code>null</code> or specified listener was not added
+ * to this <code>TransferEventSupport</code> object
+ * no exception is thrown and no action is performed
+ *
+ * @param listener the transfer listener
+ * @see #addTransferListener(TransferListener)
+ */
+ public synchronized void removeTransferListener( final TransferListener listener )
+ {
+ listeners.remove( listener );
+ }
+
+ /**
+ * Returns whether the specified instance of transfer
+ * listener was added to the collection of listeners
+ * who will be notified when an transfer event occurs
+ *
+ * @param listener the transfer listener
+ * @return <code>true<code>
+ * if given listener was added to the collection of listeners
+ * <code>false</code> otherwise
+ * @see org.apache.maven.wagon.events.TransferEvent
+ * @see #addTransferListener(TransferListener)
+ */
+ public synchronized boolean hasTransferListener( final TransferListener listener )
+ {
+ return listeners.contains( listener );
+ }
+
+
+ /**
+ * Dispatches the given <code>TransferEvent</code>
+ * to all registered listeners (calls method {@link TransferListener#transferStarted(TransferEvent)} on all of
+ * them}. The Event should be of type {@link TransferEvent#TRANSFER_COMPLETED}
+ *
+ * @param transferEvent the TransferEvent which will be dispatched to listeners
+ */
+ public synchronized void fireTransferStarted( final TransferEvent transferEvent )
+ {
+ for ( TransferListener listener : listeners )
+ {
+ listener.transferStarted( transferEvent );
+ }
+ }
+
+ /**
+ * Dispatches the given <code>TransferEvent</code>
+ * to all registered listeners (calls method {@link TransferListener#transferProgress(TransferEvent, byte[], int)}
+ * on all of them). The Event should be of type {@link TransferEvent#TRANSFER_PROGRESS}.
+ *
+ * @param transferEvent the TransferEvent which will be dispatched to listeners
+ * @param buffer the buffer containing the additional content
+ * @param length the length of the content in the buffer
+ */
+ public synchronized void fireTransferProgress( final TransferEvent transferEvent, byte[] buffer, int length )
+ {
+ for ( TransferListener listener : listeners )
+ {
+ listener.transferProgress( transferEvent, buffer, length );
+
+ }
+ }
+
+ /**
+ * Dispatches the given <code>TransferEvent</code>
+ * to all registered listeners (calls method {@link TransferListener#transferCompleted(TransferEvent)} on all of
+ * them}. The Event should be of type {@link TransferEvent#TRANSFER_COMPLETED}
+ *
+ * @param transferEvent the TransferEvent which will be dispatched to listeners
+ */
+ public synchronized void fireTransferCompleted( final TransferEvent transferEvent )
+ {
+ for ( TransferListener listener : listeners )
+ {
+ listener.transferCompleted( transferEvent );
+
+ }
+ }
+
+ /**
+ * Dispatches the given <code>TransferEvent</code>
+ * to all registered listeners (calls method {@link TransferListener#transferError(TransferEvent)} on all of them.
+ * The Event should be of type {@link TransferEvent#TRANSFER_ERROR} and it is expected that
+ * {@link TransferEvent#getException()} } method will return not null value
+ *
+ * @param transferEvent the TransferEvent which will be dispatched to listeners
+ */
+ public synchronized void fireTransferError( final TransferEvent transferEvent )
+ {
+ for ( TransferListener listener : listeners )
+ {
+ listener.transferError( transferEvent );
+
+ }
+ }
+
+ /**
+ * Dispatches the given debug message
+ * to all registered listeners (calls method {@link TransferListener#debug(String)} on all of them.
+ *
+ * @param message the debug message which will be dispatched to listeners
+ */
+ public synchronized void fireDebug( final String message )
+ {
+
+ for ( TransferListener listener : listeners )
+ {
+ listener.debug( message );
+
+ }
+ }
+
+ /**
+ * Dispatches the given <code>TransferEvent</code>
+ * to all registered listeners (calls method {@link TransferListener#transferInitiated(TransferEvent)} on all of
+ * them. The Event should be of type {@link TransferEvent#TRANSFER_INITIATED}.
+ *
+ * @param transferEvent the TransferEvent which will be dispatched to listeners
+ */
+ public synchronized void fireTransferInitiated( final TransferEvent transferEvent )
+ {
+ for ( TransferListener listener : listeners )
+ {
+ listener.transferInitiated( transferEvent );
+ }
+ }
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferListener.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferListener.java
index d254a47..3c3dd99 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferListener.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferListener.java
@@ -1,58 +1,58 @@
-package org.apache.maven.wagon.events;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public interface TransferListener
-{
- /**
- * @param transferEvent
- */
- void transferInitiated( TransferEvent transferEvent );
-
- /**
- * @param transferEvent
- */
- void transferStarted( TransferEvent transferEvent );
-
- /**
- * @param transferEvent
- */
- void transferProgress( TransferEvent transferEvent, byte[] buffer, int length );
-
- /**
- * @param transferEvent
- */
- void transferCompleted( TransferEvent transferEvent );
-
- /**
- * @param transferEvent
- */
- void transferError( TransferEvent transferEvent );
-
- /**
- * @param message
- */
- void debug( String message );
-
-}
+package org.apache.maven.wagon.events;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public interface TransferListener
+{
+ /**
+ * @param transferEvent
+ */
+ void transferInitiated( TransferEvent transferEvent );
+
+ /**
+ * @param transferEvent
+ */
+ void transferStarted( TransferEvent transferEvent );
+
+ /**
+ * @param transferEvent
+ */
+ void transferProgress( TransferEvent transferEvent, byte[] buffer, int length );
+
+ /**
+ * @param transferEvent
+ */
+ void transferCompleted( TransferEvent transferEvent );
+
+ /**
+ * @param transferEvent
+ */
+ void transferError( TransferEvent transferEvent );
+
+ /**
+ * @param message
+ */
+ void debug( String message );
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/WagonEvent.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/WagonEvent.java
index c23a4ea..90102c3 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/WagonEvent.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/WagonEvent.java
@@ -1,78 +1,78 @@
-package org.apache.maven.wagon.events;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.EventObject;
-
-import org.apache.maven.wagon.Wagon;
-
-/**
- * Base class for all events emitted by <code>Wagon</code> objects.
- *
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class WagonEvent
- extends EventObject
-{
- /**
- * The time when event occurred
- */
- protected long timestamp;
-
- /**
- * @param source The Wagon object on which the WagonEvent initially occurred
- */
- public WagonEvent( final Wagon source )
- {
- super( source );
- }
-
- /**
- * Returns The Wagon object on which the WagonEvent initially occurred
- *
- * @return The Wagon object on which the WagonEvent initially occurred
- */
- public Wagon getWagon()
- {
- return (Wagon) getSource();
- }
-
- /**
- * Returns the timestamp which indicated the time when this event has occurred
- *
- * @return Returns the timestamp.
- */
- public long getTimestamp()
- {
- return timestamp;
- }
-
- /**
- * Sets the timestamp which indicated the time when this event has occurred
- *
- * @param timestamp The timestamp to set.
- */
- public void setTimestamp( final long timestamp )
- {
- this.timestamp = timestamp;
- }
-
-}
+package org.apache.maven.wagon.events;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.EventObject;
+
+import org.apache.maven.wagon.Wagon;
+
+/**
+ * Base class for all events emitted by <code>Wagon</code> objects.
+ *
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class WagonEvent
+ extends EventObject
+{
+ /**
+ * The time when event occurred
+ */
+ protected long timestamp;
+
+ /**
+ * @param source The Wagon object on which the WagonEvent initially occurred
+ */
+ public WagonEvent( final Wagon source )
+ {
+ super( source );
+ }
+
+ /**
+ * Returns The Wagon object on which the WagonEvent initially occurred
+ *
+ * @return The Wagon object on which the WagonEvent initially occurred
+ */
+ public Wagon getWagon()
+ {
+ return (Wagon) getSource();
+ }
+
+ /**
+ * Returns the timestamp which indicated the time when this event has occurred
+ *
+ * @return Returns the timestamp.
+ */
+ public long getTimestamp()
+ {
+ return timestamp;
+ }
+
+ /**
+ * Sets the timestamp which indicated the time when this event has occurred
+ *
+ * @param timestamp The timestamp to set.
+ */
+ public void setTimestamp( final long timestamp )
+ {
+ this.timestamp = timestamp;
+ }
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/AbstractTransferListener.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/AbstractTransferListener.java
index 5a550f6..6726911 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/AbstractTransferListener.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/AbstractTransferListener.java
@@ -1,63 +1,63 @@
-package org.apache.maven.wagon.observers;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.events.TransferEvent;
-import org.apache.maven.wagon.events.TransferListener;
-
-/**
- * TransferListeners which computes MD5 checksum on the fly when files are transfered.
- *
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public abstract class AbstractTransferListener
- implements TransferListener
-{
- public void transferInitiated( TransferEvent transferEvent )
- {
- }
-
- /**
- * @see org.apache.maven.wagon.events.TransferListener#transferStarted(org.apache.maven.wagon.events.TransferEvent)
- */
- public void transferStarted( TransferEvent transferEvent )
- {
- }
-
- /**
- * @see org.apache.maven.wagon.events.TransferListener#transferProgress(org.apache.maven.wagon.events.TransferEvent,byte[],int)
- */
- public void transferProgress( TransferEvent transferEvent, byte[] buffer, int length )
- {
- }
-
- public void transferCompleted( TransferEvent transferEvent )
- {
- }
-
- public void transferError( TransferEvent transferEvent )
- {
- }
-
- public void debug( String message )
- {
- }
-}
+package org.apache.maven.wagon.observers;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.events.TransferListener;
+
+/**
+ * TransferListeners which computes MD5 checksum on the fly when files are transfered.
+ *
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public abstract class AbstractTransferListener
+ implements TransferListener
+{
+ public void transferInitiated( TransferEvent transferEvent )
+ {
+ }
+
+ /**
+ * @see org.apache.maven.wagon.events.TransferListener#transferStarted(org.apache.maven.wagon.events.TransferEvent)
+ */
+ public void transferStarted( TransferEvent transferEvent )
+ {
+ }
+
+ /**
+ * @see org.apache.maven.wagon.events.TransferListener#transferProgress(org.apache.maven.wagon.events.TransferEvent,byte[],int)
+ */
+ public void transferProgress( TransferEvent transferEvent, byte[] buffer, int length )
+ {
+ }
+
+ public void transferCompleted( TransferEvent transferEvent )
+ {
+ }
+
+ public void transferError( TransferEvent transferEvent )
+ {
+ }
+
+ public void debug( String message )
+ {
+ }
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/ChecksumObserver.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/ChecksumObserver.java
index 07f62ab..b6ed158 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/ChecksumObserver.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/ChecksumObserver.java
@@ -1,142 +1,142 @@
-package org.apache.maven.wagon.observers;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.events.TransferEvent;
-import org.apache.maven.wagon.events.TransferListener;
-
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
-/**
- * TransferListeners which computes MD5 checksum on the fly when files are transfered.
- *
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class ChecksumObserver
- implements TransferListener
-{
- private MessageDigest digester = null;
-
- private String actualChecksum;
-
- public ChecksumObserver()
- throws NoSuchAlgorithmException
- {
- this( "MD5" );
- }
-
- /**
- * @param algorithm One of the algorithms supported by JDK: MD5, MD2 or SHA-1
- */
- public ChecksumObserver( String algorithm )
- throws NoSuchAlgorithmException
- {
- digester = MessageDigest.getInstance( algorithm );
- }
-
- public void transferInitiated( TransferEvent transferEvent )
- {
- // This space left intentionally blank
- }
-
- /**
- * @see org.apache.maven.wagon.events.TransferListener#transferStarted(org.apache.maven.wagon.events.TransferEvent)
- */
- public void transferStarted( TransferEvent transferEvent )
- {
- actualChecksum = null;
-
- digester.reset();
- }
-
- /**
- * @see org.apache.maven.wagon.events.TransferListener#transferProgress(org.apache.maven.wagon.events.TransferEvent, byte[], int)
- */
- public void transferProgress( TransferEvent transferEvent, byte[] buffer, int length )
- {
- digester.update( buffer, 0, length );
- }
-
- public void transferCompleted( TransferEvent transferEvent )
- {
- actualChecksum = encode( digester.digest() );
- }
-
- public void transferError( TransferEvent transferEvent )
- {
- digester.reset();
-
- actualChecksum = null;
- }
-
- public void debug( String message )
- {
- // left intentionally blank
- }
-
- /**
- * Returns md5 checksum which was computed during transfer
- *
- * @return
- */
- public String getActualChecksum()
- {
- return actualChecksum;
- }
-
- /**
- * Encodes a 128 bit or 160-bit byte array into a String.
- *
- * @param binaryData Array containing the digest
- * @return Encoded hex string, or null if encoding failed
- */
- @SuppressWarnings( "checkstyle:magicnumber" )
- protected String encode( byte[] binaryData )
- {
-
- if ( binaryData.length != 16 && binaryData.length != 20 )
- {
- int bitLength = binaryData.length * 8;
- throw new IllegalArgumentException( "Unrecognised length for binary data: " + bitLength + " bits" );
- }
-
- StringBuilder retValue = new StringBuilder();
-
- for ( byte b : binaryData )
- {
- String t = Integer.toHexString( b & 0xff );
-
- if ( t.length() == 1 )
- {
- retValue.append( '0' ).append( t );
- }
- else
- {
- retValue.append( t );
- }
- }
-
- return retValue.toString().trim();
- }
-
-
-}
+package org.apache.maven.wagon.observers;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.events.TransferListener;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+/**
+ * TransferListeners which computes MD5 checksum on the fly when files are transfered.
+ *
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class ChecksumObserver
+ implements TransferListener
+{
+ private MessageDigest digester = null;
+
+ private String actualChecksum;
+
+ public ChecksumObserver()
+ throws NoSuchAlgorithmException
+ {
+ this( "MD5" );
+ }
+
+ /**
+ * @param algorithm One of the algorithms supported by JDK: MD5, MD2 or SHA-1
+ */
+ public ChecksumObserver( String algorithm )
+ throws NoSuchAlgorithmException
+ {
+ digester = MessageDigest.getInstance( algorithm );
+ }
+
+ public void transferInitiated( TransferEvent transferEvent )
+ {
+ // This space left intentionally blank
+ }
+
+ /**
+ * @see org.apache.maven.wagon.events.TransferListener#transferStarted(org.apache.maven.wagon.events.TransferEvent)
+ */
+ public void transferStarted( TransferEvent transferEvent )
+ {
+ actualChecksum = null;
+
+ digester.reset();
+ }
+
+ /**
+ * @see org.apache.maven.wagon.events.TransferListener#transferProgress(org.apache.maven.wagon.events.TransferEvent, byte[], int)
+ */
+ public void transferProgress( TransferEvent transferEvent, byte[] buffer, int length )
+ {
+ digester.update( buffer, 0, length );
+ }
+
+ public void transferCompleted( TransferEvent transferEvent )
+ {
+ actualChecksum = encode( digester.digest() );
+ }
+
+ public void transferError( TransferEvent transferEvent )
+ {
+ digester.reset();
+
+ actualChecksum = null;
+ }
+
+ public void debug( String message )
+ {
+ // left intentionally blank
+ }
+
+ /**
+ * Returns md5 checksum which was computed during transfer
+ *
+ * @return
+ */
+ public String getActualChecksum()
+ {
+ return actualChecksum;
+ }
+
+ /**
+ * Encodes a 128 bit or 160-bit byte array into a String.
+ *
+ * @param binaryData Array containing the digest
+ * @return Encoded hex string, or null if encoding failed
+ */
+ @SuppressWarnings( "checkstyle:magicnumber" )
+ protected String encode( byte[] binaryData )
+ {
+
+ if ( binaryData.length != 16 && binaryData.length != 20 )
+ {
+ int bitLength = binaryData.length * 8;
+ throw new IllegalArgumentException( "Unrecognised length for binary data: " + bitLength + " bits" );
+ }
+
+ StringBuilder retValue = new StringBuilder();
+
+ for ( byte b : binaryData )
+ {
+ String t = Integer.toHexString( b & 0xff );
+
+ if ( t.length() == 1 )
+ {
+ retValue.append( '0' ).append( t );
+ }
+ else
+ {
+ retValue.append( t );
+ }
+ }
+
+ return retValue.toString().trim();
+ }
+
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/Debug.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/Debug.java
index 521043a..d69ddea 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/Debug.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/Debug.java
@@ -1,206 +1,206 @@
-package org.apache.maven.wagon.observers;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.events.SessionEvent;
-import org.apache.maven.wagon.events.SessionListener;
-import org.apache.maven.wagon.events.TransferEvent;
-import org.apache.maven.wagon.events.TransferListener;
-
-import java.io.PrintStream;
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class Debug
- implements SessionListener, TransferListener
-{
- private PrintStream out;
-
- long timestamp;
-
- long transfer;
-
- public Debug()
- {
- this( System.out );
- }
-
- public Debug( PrintStream out )
- {
- this.out = out;
- }
-
- /**
- * @see SessionListener#sessionOpening(SessionEvent)
- */
- public void sessionOpening( final SessionEvent sessionEvent )
- {
- //out.println( .getUrl() + " - Session: Opening ");
- }
-
- /**
- * @see SessionListener#sessionOpened(SessionEvent)
- */
- public void sessionOpened( final SessionEvent sessionEvent )
- {
- out.println( sessionEvent.getWagon().getRepository().getUrl() + " - Session: Opened " );
- }
-
- /**
- * @see SessionListener#sessionDisconnecting(SessionEvent)
- */
- public void sessionDisconnecting( final SessionEvent sessionEvent )
- {
- out.println( sessionEvent.getWagon().getRepository().getUrl() + " - Session: Disconnecting " );
-
- }
-
- /**
- * @see SessionListener#sessionDisconnected(SessionEvent)
- */
- public void sessionDisconnected( final SessionEvent sessionEvent )
- {
- out.println( sessionEvent.getWagon().getRepository().getUrl() + " - Session: Disconnected" );
- }
-
- /**
- * @see SessionListener#sessionConnectionRefused(SessionEvent)
- */
- public void sessionConnectionRefused( final SessionEvent sessionEvent )
- {
- out.println( sessionEvent.getWagon().getRepository().getUrl() + " - Session: Connection refused" );
-
- }
-
- /**
- * @see SessionListener#sessionLoggedIn(SessionEvent)
- */
- public void sessionLoggedIn( final SessionEvent sessionEvent )
- {
- out.println( sessionEvent.getWagon().getRepository().getUrl() + " - Session: Logged in" );
-
- }
-
- /**
- * @see SessionListener#sessionLoggedOff(SessionEvent)
- */
- public void sessionLoggedOff( final SessionEvent sessionEvent )
- {
- out.println( sessionEvent.getWagon().getRepository().getUrl() + " - Session: Logged off" );
-
- }
-
- /**
- * @see TransferListener#debug(String)
- */
- public void debug( final String message )
- {
- out.println( message );
-
- }
-
- public void transferInitiated( TransferEvent transferEvent )
- {
- // This space left intentionally blank
- }
-
- /**
- * @see TransferListener#transferStarted(TransferEvent)
- */
- public void transferStarted( final TransferEvent transferEvent )
- {
- timestamp = transferEvent.getTimestamp();
-
- transfer = 0;
-
- if ( transferEvent.getRequestType() == TransferEvent.REQUEST_GET )
- {
- final String message = "Downloading: " + transferEvent.getResource().getName() + " from "
- + transferEvent.getWagon().getRepository().getUrl();
-
- out.println( message );
-
- out.println( "" );
- }
- else
- {
- final String message = "Uploading: " + transferEvent.getResource().getName() + " to "
- + transferEvent.getWagon().getRepository().getUrl();
-
- out.println( message );
-
- out.println( "" );
-
- }
- }
-
- /**
- * @see TransferListener#transferProgress(TransferEvent,byte[],int)
- */
- public void transferProgress( final TransferEvent transferEvent, byte[] buffer, int length )
- {
-
- out.print( "#" );
- //String data = new String( transferEvent.getData(),0, transferEvent.getDataLength());
- //out.println(data);
- transfer += length;
- }
-
- /**
- * @see TransferListener#transferCompleted(TransferEvent)
- */
- public void transferCompleted( final TransferEvent transferEvent )
- {
- final double duration = (double) ( transferEvent.getTimestamp() - timestamp ) / 1000;
-
- out.println();
-
- final String message = "Transfer finished. " + transfer + " bytes copied in " + duration + " seconds";
-
- out.println( message );
-
- }
-
- /**
- * @see TransferListener#transferError(TransferEvent)
- */
- public void transferError( final TransferEvent transferEvent )
- {
- out.println( " Transfer error: " + transferEvent.getException() );
-
- }
-
- /**
- * @see SessionListener#sessionError(SessionEvent)
- */
- public void sessionError( final SessionEvent sessionEvent )
- {
- out.println( " Session error: " + sessionEvent.getException() );
-
- }
-
- public PrintStream getOut()
- {
- return out;
- }
-
-}
+package org.apache.maven.wagon.observers;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.events.SessionEvent;
+import org.apache.maven.wagon.events.SessionListener;
+import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.events.TransferListener;
+
+import java.io.PrintStream;
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class Debug
+ implements SessionListener, TransferListener
+{
+ private PrintStream out;
+
+ long timestamp;
+
+ long transfer;
+
+ public Debug()
+ {
+ this( System.out );
+ }
+
+ public Debug( PrintStream out )
+ {
+ this.out = out;
+ }
+
+ /**
+ * @see SessionListener#sessionOpening(SessionEvent)
+ */
+ public void sessionOpening( final SessionEvent sessionEvent )
+ {
+ //out.println( .getUrl() + " - Session: Opening ");
+ }
+
+ /**
+ * @see SessionListener#sessionOpened(SessionEvent)
+ */
+ public void sessionOpened( final SessionEvent sessionEvent )
+ {
+ out.println( sessionEvent.getWagon().getRepository().getUrl() + " - Session: Opened " );
+ }
+
+ /**
+ * @see SessionListener#sessionDisconnecting(SessionEvent)
+ */
+ public void sessionDisconnecting( final SessionEvent sessionEvent )
+ {
+ out.println( sessionEvent.getWagon().getRepository().getUrl() + " - Session: Disconnecting " );
+
+ }
+
+ /**
+ * @see SessionListener#sessionDisconnected(SessionEvent)
+ */
+ public void sessionDisconnected( final SessionEvent sessionEvent )
+ {
+ out.println( sessionEvent.getWagon().getRepository().getUrl() + " - Session: Disconnected" );
+ }
+
+ /**
+ * @see SessionListener#sessionConnectionRefused(SessionEvent)
+ */
+ public void sessionConnectionRefused( final SessionEvent sessionEvent )
+ {
+ out.println( sessionEvent.getWagon().getRepository().getUrl() + " - Session: Connection refused" );
+
+ }
+
+ /**
+ * @see SessionListener#sessionLoggedIn(SessionEvent)
+ */
+ public void sessionLoggedIn( final SessionEvent sessionEvent )
+ {
+ out.println( sessionEvent.getWagon().getRepository().getUrl() + " - Session: Logged in" );
+
+ }
+
+ /**
+ * @see SessionListener#sessionLoggedOff(SessionEvent)
+ */
+ public void sessionLoggedOff( final SessionEvent sessionEvent )
+ {
+ out.println( sessionEvent.getWagon().getRepository().getUrl() + " - Session: Logged off" );
+
+ }
+
+ /**
+ * @see TransferListener#debug(String)
+ */
+ public void debug( final String message )
+ {
+ out.println( message );
+
+ }
+
+ public void transferInitiated( TransferEvent transferEvent )
+ {
+ // This space left intentionally blank
+ }
+
+ /**
+ * @see TransferListener#transferStarted(TransferEvent)
+ */
+ public void transferStarted( final TransferEvent transferEvent )
+ {
+ timestamp = transferEvent.getTimestamp();
+
+ transfer = 0;
+
+ if ( transferEvent.getRequestType() == TransferEvent.REQUEST_GET )
+ {
+ final String message = "Downloading: " + transferEvent.getResource().getName() + " from "
+ + transferEvent.getWagon().getRepository().getUrl();
+
+ out.println( message );
+
+ out.println( "" );
+ }
+ else
+ {
+ final String message = "Uploading: " + transferEvent.getResource().getName() + " to "
+ + transferEvent.getWagon().getRepository().getUrl();
+
+ out.println( message );
+
+ out.println( "" );
+
+ }
+ }
+
+ /**
+ * @see TransferListener#transferProgress(TransferEvent,byte[],int)
+ */
+ public void transferProgress( final TransferEvent transferEvent, byte[] buffer, int length )
+ {
+
+ out.print( "#" );
+ //String data = new String( transferEvent.getData(),0, transferEvent.getDataLength());
+ //out.println(data);
+ transfer += length;
+ }
+
+ /**
+ * @see TransferListener#transferCompleted(TransferEvent)
+ */
+ public void transferCompleted( final TransferEvent transferEvent )
+ {
+ final double duration = (double) ( transferEvent.getTimestamp() - timestamp ) / 1000;
+
+ out.println();
+
+ final String message = "Transfer finished. " + transfer + " bytes copied in " + duration + " seconds";
+
+ out.println( message );
+
+ }
+
+ /**
+ * @see TransferListener#transferError(TransferEvent)
+ */
+ public void transferError( final TransferEvent transferEvent )
+ {
+ out.println( " Transfer error: " + transferEvent.getException() );
+
+ }
+
+ /**
+ * @see SessionListener#sessionError(SessionEvent)
+ */
+ public void sessionError( final SessionEvent sessionEvent )
+ {
+ out.println( " Session error: " + sessionEvent.getException() );
+
+ }
+
+ public PrintStream getOut()
+ {
+ return out;
+ }
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/proxy/ProxyInfo.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/proxy/ProxyInfo.java
index 1b1085a..7a18a3d 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/proxy/ProxyInfo.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/proxy/ProxyInfo.java
@@ -1,218 +1,218 @@
-package org.apache.maven.wagon.proxy;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.WagonConstants;
-
-import java.io.Serializable;
-
-/**
- * Contains set of properties used by <code>Wagon</code> objects
- * while connection to the repository must go thru a proxy server.
- *
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- * @todo Propose standard types of proxy servers (e.g. <i>SOCKSv4</i>),
- * which can be shared between wagon api and providers
- */
-public class ProxyInfo
- implements Serializable
-{
- public static final String PROXY_SOCKS5 = "SOCKS_5";
-
- public static final String PROXY_SOCKS4 = "SOCKS4";
-
- public static final String PROXY_HTTP = "HTTP";
-
- /**
- * Proxy server host
- */
- private String host = null;
-
- /**
- * Username used to access the proxy server
- */
- private String userName = null;
-
- /**
- * Password associated with the proxy server
- */
- private String password = null;
-
- /**
- * Proxy server port
- */
- private int port = WagonConstants.UNKNOWN_PORT;
-
- /**
- * Type of the proxy
- */
- private String type = null;
-
- /**
- * The non-proxy hosts. Follows Java system property format: <code>*.foo.com|localhost</code>.
- */
- private String nonProxyHosts;
-
- /**
- * For NTLM proxies, specifies the NTLM host.
- */
- private String ntlmHost;
-
- /**
- * For NTLM proxies, specifies the NTLM domain.
- */
- private String ntlmDomain;
-
- /**
- * Return proxy server host name.
- *
- * @return proxy server host name
- */
- public String getHost()
- {
- return host;
- }
-
- /**
- * Set proxy host name.
- *
- * @param host proxy server host name
- */
- public void setHost( final String host )
- {
- this.host = host;
- }
-
- /**
- * Get user's password used to login to proxy server.
- *
- * @return user's password at proxy host
- */
- public String getPassword()
- {
- return password;
- }
-
- /**
- * Set the user's password for the proxy server.
- *
- * @param password password to use to login to a proxy server
- */
- public void setPassword( final String password )
- {
- this.password = password;
- }
-
- /**
- * Get the proxy port.
- *
- * @return proxy server port
- */
- public int getPort()
- {
- return port;
- }
-
- /**
- * Set the proxy port.
- *
- * @param port proxy server port
- */
- public void setPort( final int port )
- {
- this.port = port;
- }
-
- /**
- * Get the proxy username.
- *
- * @return username for the proxy server
- */
- public String getUserName()
- {
- return userName;
- }
-
- /**
- * Set the proxy username.
- *
- * @param userName username for the proxy server
- */
- public void setUserName( final String userName )
- {
- this.userName = userName;
- }
-
- /**
- * Get the type of the proxy server.
- *
- * @return the type of the proxy server
- */
- public String getType()
- {
- return type;
- }
-
- /**
- * @param type the type of the proxy server like <i>SOCKSv4</i>
- */
- public void setType( final String type )
- {
- this.type = type;
- }
-
- public String getNonProxyHosts()
- {
- return nonProxyHosts;
- }
-
- public void setNonProxyHosts( String nonProxyHosts )
- {
- this.nonProxyHosts = nonProxyHosts;
- }
-
- public String getNtlmHost()
- {
- return ntlmHost;
- }
-
- public void setNtlmHost( String ntlmHost )
- {
- this.ntlmHost = ntlmHost;
- }
-
- public void setNtlmDomain( String ntlmDomain )
- {
- this.ntlmDomain = ntlmDomain;
- }
-
- public String getNtlmDomain()
- {
- return ntlmDomain;
- }
-
- @Override
- public String toString()
- {
- return "ProxyInfo{" + "host='" + host + '\'' + ", userName='" + userName + '\'' + ", port=" + port + ", type='"
- + type + '\'' + ", nonProxyHosts='" + nonProxyHosts + '\'' + '}';
- }
-}
+package org.apache.maven.wagon.proxy;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.WagonConstants;
+
+import java.io.Serializable;
+
+/**
+ * Contains set of properties used by <code>Wagon</code> objects
+ * while connection to the repository must go thru a proxy server.
+ *
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ * @todo Propose standard types of proxy servers (e.g. <i>SOCKSv4</i>),
+ * which can be shared between wagon api and providers
+ */
+public class ProxyInfo
+ implements Serializable
+{
+ public static final String PROXY_SOCKS5 = "SOCKS_5";
+
+ public static final String PROXY_SOCKS4 = "SOCKS4";
+
+ public static final String PROXY_HTTP = "HTTP";
+
+ /**
+ * Proxy server host
+ */
+ private String host = null;
+
+ /**
+ * Username used to access the proxy server
+ */
+ private String userName = null;
+
+ /**
+ * Password associated with the proxy server
+ */
+ private String password = null;
+
+ /**
+ * Proxy server port
+ */
+ private int port = WagonConstants.UNKNOWN_PORT;
+
+ /**
+ * Type of the proxy
+ */
+ private String type = null;
+
+ /**
+ * The non-proxy hosts. Follows Java system property format: <code>*.foo.com|localhost</code>.
+ */
+ private String nonProxyHosts;
+
+ /**
+ * For NTLM proxies, specifies the NTLM host.
+ */
+ private String ntlmHost;
+
+ /**
+ * For NTLM proxies, specifies the NTLM domain.
+ */
+ private String ntlmDomain;
+
+ /**
+ * Return proxy server host name.
+ *
+ * @return proxy server host name
+ */
+ public String getHost()
+ {
+ return host;
+ }
+
+ /**
+ * Set proxy host name.
+ *
+ * @param host proxy server host name
+ */
+ public void setHost( final String host )
+ {
+ this.host = host;
+ }
+
+ /**
+ * Get user's password used to login to proxy server.
+ *
+ * @return user's password at proxy host
+ */
+ public String getPassword()
+ {
+ return password;
+ }
+
+ /**
+ * Set the user's password for the proxy server.
+ *
+ * @param password password to use to login to a proxy server
+ */
+ public void setPassword( final String password )
+ {
+ this.password = password;
+ }
+
+ /**
+ * Get the proxy port.
+ *
+ * @return proxy server port
+ */
+ public int getPort()
+ {
+ return port;
+ }
+
+ /**
+ * Set the proxy port.
+ *
+ * @param port proxy server port
+ */
+ public void setPort( final int port )
+ {
+ this.port = port;
+ }
+
+ /**
+ * Get the proxy username.
+ *
+ * @return username for the proxy server
+ */
+ public String getUserName()
+ {
+ return userName;
+ }
+
+ /**
+ * Set the proxy username.
+ *
+ * @param userName username for the proxy server
+ */
+ public void setUserName( final String userName )
+ {
+ this.userName = userName;
+ }
+
+ /**
+ * Get the type of the proxy server.
+ *
+ * @return the type of the proxy server
+ */
+ public String getType()
+ {
+ return type;
+ }
+
+ /**
+ * @param type the type of the proxy server like <i>SOCKSv4</i>
+ */
+ public void setType( final String type )
+ {
+ this.type = type;
+ }
+
+ public String getNonProxyHosts()
+ {
+ return nonProxyHosts;
+ }
+
+ public void setNonProxyHosts( String nonProxyHosts )
+ {
+ this.nonProxyHosts = nonProxyHosts;
+ }
+
+ public String getNtlmHost()
+ {
+ return ntlmHost;
+ }
+
+ public void setNtlmHost( String ntlmHost )
+ {
+ this.ntlmHost = ntlmHost;
+ }
+
+ public void setNtlmDomain( String ntlmDomain )
+ {
+ this.ntlmDomain = ntlmDomain;
+ }
+
+ public String getNtlmDomain()
+ {
+ return ntlmDomain;
+ }
+
+ @Override
+ public String toString()
+ {
+ return "ProxyInfo{" + "host='" + host + '\'' + ", userName='" + userName + '\'' + ", port=" + port + ", type='"
+ + type + '\'' + ", nonProxyHosts='" + nonProxyHosts + '\'' + '}';
+ }
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/proxy/ProxyInfoProvider.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/proxy/ProxyInfoProvider.java
index f63e251..5cc228f 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/proxy/ProxyInfoProvider.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/proxy/ProxyInfoProvider.java
@@ -1,33 +1,33 @@
-package org.apache.maven.wagon.proxy;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Interface of an object, which provides the proxy settings. Typically, this is the artifact manager.
- */
-public interface ProxyInfoProvider
-{
- /**
- * Returns the proxy settings for the given protocol.
- *
- * @return Proxy settings or null, if no proxy is configured for this protocol.
- */
- ProxyInfo getProxyInfo( String protocol );
-}
+package org.apache.maven.wagon.proxy;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Interface of an object, which provides the proxy settings. Typically, this is the artifact manager.
+ */
+public interface ProxyInfoProvider
+{
+ /**
+ * Returns the proxy settings for the given protocol.
+ *
+ * @return Proxy settings or null, if no proxy is configured for this protocol.
+ */
+ ProxyInfo getProxyInfo( String protocol );
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/proxy/ProxyUtils.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/proxy/ProxyUtils.java
index dbff052..0a1d8cb 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/proxy/ProxyUtils.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/proxy/ProxyUtils.java
@@ -1,69 +1,69 @@
-package org.apache.maven.wagon.proxy;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.StringTokenizer;
-
-/**
- * @author <a href="mailto:lafeuil at gmail.com">Thomas Champagne</a>
- */
-public final class ProxyUtils
-{
- private ProxyUtils()
- {
- }
-
- /**
- * Check if the specified host is in the list of non proxy hosts.
- *
- * @param proxy the proxy info object contains set of properties.
- * @param targetHost the target hostname
- * @return true if the hostname is in the list of non proxy hosts, false otherwise.
- */
- public static boolean validateNonProxyHosts( ProxyInfo proxy, String targetHost )
- {
- if ( targetHost == null )
- {
- targetHost = new String();
- }
- if ( proxy == null )
- {
- return false;
- }
- String nonProxyHosts = proxy.getNonProxyHosts();
- if ( nonProxyHosts == null )
- {
- return false;
- }
-
- StringTokenizer tokenizer = new StringTokenizer( nonProxyHosts, "|" );
-
- while ( tokenizer.hasMoreTokens() )
- {
- String pattern = tokenizer.nextToken();
- pattern = pattern.replaceAll( "\\.", "\\\\." ).replaceAll( "\\*", ".*" );
- if ( targetHost.matches( pattern ) )
- {
- return true;
- }
- }
- return false;
- }
-}
+package org.apache.maven.wagon.proxy;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.StringTokenizer;
+
+/**
+ * @author <a href="mailto:lafeuil at gmail.com">Thomas Champagne</a>
+ */
+public final class ProxyUtils
+{
+ private ProxyUtils()
+ {
+ }
+
+ /**
+ * Check if the specified host is in the list of non proxy hosts.
+ *
+ * @param proxy the proxy info object contains set of properties.
+ * @param targetHost the target hostname
+ * @return true if the hostname is in the list of non proxy hosts, false otherwise.
+ */
+ public static boolean validateNonProxyHosts( ProxyInfo proxy, String targetHost )
+ {
+ if ( targetHost == null )
+ {
+ targetHost = new String();
+ }
+ if ( proxy == null )
+ {
+ return false;
+ }
+ String nonProxyHosts = proxy.getNonProxyHosts();
+ if ( nonProxyHosts == null )
+ {
+ return false;
+ }
+
+ StringTokenizer tokenizer = new StringTokenizer( nonProxyHosts, "|" );
+
+ while ( tokenizer.hasMoreTokens() )
+ {
+ String pattern = tokenizer.nextToken();
+ pattern = pattern.replaceAll( "\\.", "\\\\." ).replaceAll( "\\*", ".*" );
+ if ( targetHost.matches( pattern ) )
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/repository/Repository.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/repository/Repository.java
index b28dd1a..da81f5c 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/repository/Repository.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/repository/Repository.java
@@ -1,330 +1,330 @@
-package org.apache.maven.wagon.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.PathUtils;
-import org.apache.maven.wagon.WagonConstants;
-import org.codehaus.plexus.util.StringUtils;
-
-import java.io.Serializable;
-import java.util.Properties;
-
-/**
- * This class is an abstraction of the location from/to resources
- * can be transfered.
- *
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- * @todo [BP] some things are specific to certain wagons (eg key stuff in authInfo, permissions)
- */
-public class Repository
- implements Serializable
-{
- private static final long serialVersionUID = 1312227676322136247L;
-
- private String id;
-
- private String name;
-
- private String host;
-
- private int port = WagonConstants.UNKNOWN_PORT;
-
- private String basedir;
-
- private String protocol;
-
- private String url;
-
- private RepositoryPermissions permissions;
-
- /**
- * Properties influencing wagon behaviour
- * which are very specific to particular wagon.
- */
- private Properties parameters = new Properties();
-
- // Username/password are sometimes encoded in the URL
- private String username = null;
-
- private String password = null;
-
- /**
- * @deprecated use {@link #Repository(String, String)}
- */
- public Repository()
- {
-
- }
-
- public Repository( String id, String url )
- {
- if ( id == null )
- {
- throw new NullPointerException( "id can not be null for Repository with url=" + url );
- }
-
- setId( id );
-
- if ( url == null )
- {
- throw new NullPointerException( "url can not be null for Repository with id=" + id );
- }
-
- setUrl( url );
- }
-
- public String getId()
- {
- return id;
- }
-
- public void setId( String id )
- {
- this.id = id;
- }
-
- /**
- * Retrieve the base directory of the repository. This is derived from the full repository URL, and
- * contains the entire path component.
- *
- * @return the base directory
- */
- public String getBasedir()
- {
- return basedir;
- }
-
- public void setBasedir( String basedir )
- {
- this.basedir = basedir;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- public int getPort()
- {
- return port;
- }
-
- public void setPort( int port )
- {
- this.port = port;
- }
-
- public void setUrl( String url )
- {
- this.url = url;
-
- // TODO [BP]: refactor out the PathUtils URL stuff into a class like java.net.URL, so you only parse once
- // can't use URL class as is because it won't recognise our protocols, though perhaps we could attempt to
- // register handlers for scp, etc?
-
- this.protocol = PathUtils.protocol( url );
-
- this.host = PathUtils.host( url );
-
- this.port = PathUtils.port( url );
-
- this.basedir = PathUtils.basedir( url );
-
- String username = PathUtils.user( url );
- this.username = username;
-
- if ( username != null )
- {
- String password = PathUtils.password( url );
-
- if ( password != null )
- {
- this.password = password;
-
- username += ":" + password;
- }
-
- username += "@";
-
- int index = url.indexOf( username );
- this.url = url.substring( 0, index ) + url.substring( index + username.length() );
- }
- }
-
- public String getUrl()
- {
- if ( url != null )
- {
- return url;
- }
-
- StringBuilder sb = new StringBuilder();
-
- sb.append( protocol );
-
- sb.append( "://" );
-
- if ( isIPv6Address() )
- {
- // If this is IPv6 then we have to surround it
- // with brackets '[' and ']'
- sb.append( "[" ).append( getHost() ).append( "]" );
- }
- else
- {
- sb.append( getHost() );
- }
-
- if ( port != WagonConstants.UNKNOWN_PORT )
- {
- sb.append( ":" );
-
- sb.append( port );
- }
-
- sb.append( basedir );
-
- return sb.toString();
- }
-
- /**
- * Checks whtther provided url contains IPv6 format in host portion
- *
- * @return true if provide host part is of IPv6 format
- */
- private boolean isIPv6Address()
- {
- return getHost().contains( ":" );
- }
-
- public String getHost()
- {
- if ( host == null )
- {
- return "localhost";
- }
- return host;
- }
-
- public String getName()
- {
- if ( name == null )
- {
- return getId();
- }
- return name;
- }
-
- public String toString()
- {
- StringBuilder sb = new StringBuilder();
-
- sb.append( "Repository[" );
-
- if ( StringUtils.isNotEmpty( getName() ) )
- {
- sb.append( getName() ).append( "|" );
- }
-
- sb.append( getUrl() );
- sb.append( "]" );
-
- return sb.toString();
- }
-
- public String getProtocol()
- {
- return protocol;
- }
-
- public RepositoryPermissions getPermissions()
- {
- return permissions;
- }
-
- public void setPermissions( RepositoryPermissions permissions )
- {
- this.permissions = permissions;
- }
-
- public String getParameter( String key )
- {
- return parameters.getProperty( key );
- }
-
- public void setParameters( Properties parameters )
- {
- this.parameters = parameters;
- }
-
- public int hashCode()
- {
- final int prime = 31;
- int result = 1;
- result = prime * result + ( ( id == null ) ? 0 : id.hashCode() );
- return result;
- }
-
- public boolean equals( Object obj )
- {
- if ( this == obj )
- {
- return true;
- }
- if ( obj == null )
- {
- return false;
- }
- if ( getClass() != obj.getClass() )
- {
- return false;
- }
- final Repository other = (Repository) obj;
- if ( id == null )
- {
- if ( other.id != null )
- {
- return false;
- }
- }
- else if ( !id.equals( other.id ) )
- {
- return false;
- }
- return true;
- }
-
- public String getUsername()
- {
- return username;
- }
-
- public String getPassword()
- {
- return password;
- }
-
- public void setProtocol( String protocol )
- {
- this.protocol = protocol;
- }
-
-}
+package org.apache.maven.wagon.repository;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.PathUtils;
+import org.apache.maven.wagon.WagonConstants;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.io.Serializable;
+import java.util.Properties;
+
+/**
+ * This class is an abstraction of the location from/to resources
+ * can be transfered.
+ *
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ * @todo [BP] some things are specific to certain wagons (eg key stuff in authInfo, permissions)
+ */
+public class Repository
+ implements Serializable
+{
+ private static final long serialVersionUID = 1312227676322136247L;
+
+ private String id;
+
+ private String name;
+
+ private String host;
+
+ private int port = WagonConstants.UNKNOWN_PORT;
+
+ private String basedir;
+
+ private String protocol;
+
+ private String url;
+
+ private RepositoryPermissions permissions;
+
+ /**
+ * Properties influencing wagon behaviour
+ * which are very specific to particular wagon.
+ */
+ private Properties parameters = new Properties();
+
+ // Username/password are sometimes encoded in the URL
+ private String username = null;
+
+ private String password = null;
+
+ /**
+ * @deprecated use {@link #Repository(String, String)}
+ */
+ public Repository()
+ {
+
+ }
+
+ public Repository( String id, String url )
+ {
+ if ( id == null )
+ {
+ throw new NullPointerException( "id cannot be null" );
+ }
+
+ setId( id );
+
+ if ( url == null )
+ {
+ throw new NullPointerException( "url cannot be null" );
+ }
+
+ setUrl( url );
+ }
+
+ public String getId()
+ {
+ return id;
+ }
+
+ public void setId( String id )
+ {
+ this.id = id;
+ }
+
+ /**
+ * Retrieve the base directory of the repository. This is derived from the full repository URL, and
+ * contains the entire path component.
+ *
+ * @return the base directory
+ */
+ public String getBasedir()
+ {
+ return basedir;
+ }
+
+ public void setBasedir( String basedir )
+ {
+ this.basedir = basedir;
+ }
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ public int getPort()
+ {
+ return port;
+ }
+
+ public void setPort( int port )
+ {
+ this.port = port;
+ }
+
+ public void setUrl( String url )
+ {
+ this.url = url;
+
+ // TODO [BP]: refactor out the PathUtils URL stuff into a class like java.net.URL, so you only parse once
+ // can't use URL class as is because it won't recognise our protocols, though perhaps we could attempt to
+ // register handlers for scp, etc?
+
+ this.protocol = PathUtils.protocol( url );
+
+ this.host = PathUtils.host( url );
+
+ this.port = PathUtils.port( url );
+
+ this.basedir = PathUtils.basedir( url );
+
+ String username = PathUtils.user( url );
+ this.username = username;
+
+ if ( username != null )
+ {
+ String password = PathUtils.password( url );
+
+ if ( password != null )
+ {
+ this.password = password;
+
+ username += ":" + password;
+ }
+
+ username += "@";
+
+ int index = url.indexOf( username );
+ this.url = url.substring( 0, index ) + url.substring( index + username.length() );
+ }
+ }
+
+ public String getUrl()
+ {
+ if ( url != null )
+ {
+ return url;
+ }
+
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( protocol );
+
+ sb.append( "://" );
+
+ if ( isIPv6Address() )
+ {
+ // If this is IPv6 then we have to surround it
+ // with brackets '[' and ']'
+ sb.append( "[" ).append( getHost() ).append( "]" );
+ }
+ else
+ {
+ sb.append( getHost() );
+ }
+
+ if ( port != WagonConstants.UNKNOWN_PORT )
+ {
+ sb.append( ":" );
+
+ sb.append( port );
+ }
+
+ sb.append( basedir );
+
+ return sb.toString();
+ }
+
+ /**
+ * Checks whtther provided url contains IPv6 format in host portion
+ *
+ * @return true if provide host part is of IPv6 format
+ */
+ private boolean isIPv6Address()
+ {
+ return getHost().contains( ":" );
+ }
+
+ public String getHost()
+ {
+ if ( host == null )
+ {
+ return "localhost";
+ }
+ return host;
+ }
+
+ public String getName()
+ {
+ if ( name == null )
+ {
+ return getId();
+ }
+ return name;
+ }
+
+ public String toString()
+ {
+ StringBuilder sb = new StringBuilder();
+
+ sb.append( "Repository[" );
+
+ if ( StringUtils.isNotEmpty( getName() ) )
+ {
+ sb.append( getName() ).append( "|" );
+ }
+
+ sb.append( getUrl() );
+ sb.append( "]" );
+
+ return sb.toString();
+ }
+
+ public String getProtocol()
+ {
+ return protocol;
+ }
+
+ public RepositoryPermissions getPermissions()
+ {
+ return permissions;
+ }
+
+ public void setPermissions( RepositoryPermissions permissions )
+ {
+ this.permissions = permissions;
+ }
+
+ public String getParameter( String key )
+ {
+ return parameters.getProperty( key );
+ }
+
+ public void setParameters( Properties parameters )
+ {
+ this.parameters = parameters;
+ }
+
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ( ( id == null ) ? 0 : id.hashCode() );
+ return result;
+ }
+
+ public boolean equals( Object obj )
+ {
+ if ( this == obj )
+ {
+ return true;
+ }
+ if ( obj == null )
+ {
+ return false;
+ }
+ if ( getClass() != obj.getClass() )
+ {
+ return false;
+ }
+ final Repository other = (Repository) obj;
+ if ( id == null )
+ {
+ if ( other.id != null )
+ {
+ return false;
+ }
+ }
+ else if ( !id.equals( other.id ) )
+ {
+ return false;
+ }
+ return true;
+ }
+
+ public String getUsername()
+ {
+ return username;
+ }
+
+ public String getPassword()
+ {
+ return password;
+ }
+
+ public void setProtocol( String protocol )
+ {
+ this.protocol = protocol;
+ }
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/repository/RepositoryPermissions.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/repository/RepositoryPermissions.java
index 37caa6f..c34a3e7 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/repository/RepositoryPermissions.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/repository/RepositoryPermissions.java
@@ -1,111 +1,111 @@
-package org.apache.maven.wagon.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.Serializable;
-
-/**
- * Describes the permissions to set on files uploaded to the repository.
- *
- * @author Brett Porter
- *
- */
-public class RepositoryPermissions implements Serializable
-{
- /**
- * Repository group name.
- */
- private String group;
-
- /**
- * Repository directory mode. Modes can be in either textual (ugo+rx) or octal (755) form.
- */
- private String directoryMode;
-
- /**
- * Repository file mode. Modes can be in either textual (ugo+rx) or octal (644) form.
- */
- private String fileMode;
-
- /**
- * Get the repository directory mode to which an artifact will belong to after
- * deployment. Not all protocols permit the changing of the mode.
- *
- * @return mode
- */
- public String getDirectoryMode()
- {
- return directoryMode;
- }
-
- /**
- * Set the repository directory mode for the deployed artifact.
- *
- * @param directoryMode repository directory mode for deployed artifacts
- */
- public void setDirectoryMode( final String directoryMode )
- {
- this.directoryMode = directoryMode;
- }
-
- /**
- * Get the repository file mode to which an artifact will belong to after
- * deployment. Not all protocols permit the changing of the artifact mode.
- *
- * @return repository group name
- */
- public String getFileMode()
- {
- return fileMode;
- }
-
- /**
- * Set the repository file mode for the deployed artifact.
- *
- * @param fileMode repository file mode for deployed artifacts
- */
- public void setFileMode( final String fileMode )
- {
- this.fileMode = fileMode;
- }
-
- /**
- * Get the repository group name to which an artifact will belong to after
- * deployment. Not all protocols permit the changing of the artifact
- * group.
- *
- * @return repository group name
- */
- public String getGroup()
- {
- return group;
- }
-
- /**
- * Set the repository group name for the deployed artifact.
- *
- * @param group repository group for deployed artifacts
- */
- public void setGroup( final String group )
- {
- this.group = group;
- }
-
-}
+package org.apache.maven.wagon.repository;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.Serializable;
+
+/**
+ * Describes the permissions to set on files uploaded to the repository.
+ *
+ * @author Brett Porter
+ *
+ */
+public class RepositoryPermissions implements Serializable
+{
+ /**
+ * Repository group name.
+ */
+ private String group;
+
+ /**
+ * Repository directory mode. Modes can be in either textual (ugo+rx) or octal (755) form.
+ */
+ private String directoryMode;
+
+ /**
+ * Repository file mode. Modes can be in either textual (ugo+rx) or octal (644) form.
+ */
+ private String fileMode;
+
+ /**
+ * Get the repository directory mode to which an artifact will belong to after
+ * deployment. Not all protocols permit the changing of the mode.
+ *
+ * @return mode
+ */
+ public String getDirectoryMode()
+ {
+ return directoryMode;
+ }
+
+ /**
+ * Set the repository directory mode for the deployed artifact.
+ *
+ * @param directoryMode repository directory mode for deployed artifacts
+ */
+ public void setDirectoryMode( final String directoryMode )
+ {
+ this.directoryMode = directoryMode;
+ }
+
+ /**
+ * Get the repository file mode to which an artifact will belong to after
+ * deployment. Not all protocols permit the changing of the artifact mode.
+ *
+ * @return repository group name
+ */
+ public String getFileMode()
+ {
+ return fileMode;
+ }
+
+ /**
+ * Set the repository file mode for the deployed artifact.
+ *
+ * @param fileMode repository file mode for deployed artifacts
+ */
+ public void setFileMode( final String fileMode )
+ {
+ this.fileMode = fileMode;
+ }
+
+ /**
+ * Get the repository group name to which an artifact will belong to after
+ * deployment. Not all protocols permit the changing of the artifact
+ * group.
+ *
+ * @return repository group name
+ */
+ public String getGroup()
+ {
+ return group;
+ }
+
+ /**
+ * Set the repository group name for the deployed artifact.
+ *
+ * @param group repository group for deployed artifacts
+ */
+ public void setGroup( final String group )
+ {
+ this.group = group;
+ }
+
+}
diff --git a/wagon-provider-api/src/main/java/org/apache/maven/wagon/resource/Resource.java b/wagon-provider-api/src/main/java/org/apache/maven/wagon/resource/Resource.java
index f575619..b9d4790 100644
--- a/wagon-provider-api/src/main/java/org/apache/maven/wagon/resource/Resource.java
+++ b/wagon-provider-api/src/main/java/org/apache/maven/wagon/resource/Resource.java
@@ -1,146 +1,146 @@
-package org.apache.maven.wagon.resource;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.WagonConstants;
-
-/**
- * Describes resources which can be downloaded from the repository
- * or uploaded to repository.
- * <p/>
- * This class contains minimal set of informations, which
- * are needed to reuse wagon in maven 1.
- *
- * @author <a href="michal at codehaus.org">Michal Maczka</a>
- *
- */
-
-public class Resource
-{
- private String name;
-
- private long lastModified;
-
- private long contentLength = WagonConstants.UNKNOWN_LENGTH;
-
- public Resource()
- {
-
- }
-
- public Resource( String name )
- {
- this.name = name;
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setName( String name )
- {
- this.name = name;
- }
-
- /**
- * Returns the value of the last-modified header field.
- * The result is the number of milliseconds since January 1, 1970 GMT.
- *
- * @return the date the resource was last modified, or WagonConstants.UNKNOWN_LENGTH
- * if not known.
- */
- public long getLastModified()
- {
- return lastModified;
- }
-
- public void setLastModified( long lastModified )
- {
- this.lastModified = lastModified;
- }
-
- public long getContentLength()
- {
- return contentLength;
- }
-
- public void setContentLength( long contentLength )
- {
- this.contentLength = contentLength;
- }
-
- public String toString()
- {
- return name;
- }
-
- public String inspect()
- {
- return name + "[len = " + contentLength + "; mod = " + lastModified + "]";
- }
-
- public int hashCode()
- {
- final int prime = 31;
- int result = 1;
- result = prime * result + (int) ( contentLength ^ ( contentLength >>> 32 ) );
- result = prime * result + (int) ( lastModified ^ ( lastModified >>> 32 ) );
- result = prime * result + ( ( name == null ) ? 0 : name.hashCode() );
- return result;
- }
-
- public boolean equals( Object obj )
- {
- if ( this == obj )
- {
- return true;
- }
- if ( obj == null )
- {
- return false;
- }
- if ( getClass() != obj.getClass() )
- {
- return false;
- }
- final Resource other = (Resource) obj;
- if ( contentLength != other.contentLength )
- {
- return false;
- }
- if ( lastModified != other.lastModified )
- {
- return false;
- }
- if ( name == null )
- {
- if ( other.name != null )
- {
- return false;
- }
- }
- else if ( !name.equals( other.name ) )
- {
- return false;
- }
- return true;
- }
-}
+package org.apache.maven.wagon.resource;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.WagonConstants;
+
+/**
+ * Describes resources which can be downloaded from the repository
+ * or uploaded to repository.
+ * <p/>
+ * This class contains minimal set of informations, which
+ * are needed to reuse wagon in maven 1.
+ *
+ * @author <a href="michal at codehaus.org">Michal Maczka</a>
+ *
+ */
+
+public class Resource
+{
+ private String name;
+
+ private long lastModified;
+
+ private long contentLength = WagonConstants.UNKNOWN_LENGTH;
+
+ public Resource()
+ {
+
+ }
+
+ public Resource( String name )
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ /**
+ * Returns the value of the last-modified header field.
+ * The result is the number of milliseconds since January 1, 1970 GMT.
+ *
+ * @return the date the resource was last modified, or WagonConstants.UNKNOWN_LENGTH
+ * if not known.
+ */
+ public long getLastModified()
+ {
+ return lastModified;
+ }
+
+ public void setLastModified( long lastModified )
+ {
+ this.lastModified = lastModified;
+ }
+
+ public long getContentLength()
+ {
+ return contentLength;
+ }
+
+ public void setContentLength( long contentLength )
+ {
+ this.contentLength = contentLength;
+ }
+
+ public String toString()
+ {
+ return name;
+ }
+
+ public String inspect()
+ {
+ return name + "[len = " + contentLength + "; mod = " + lastModified + "]";
+ }
+
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (int) ( contentLength ^ ( contentLength >>> 32 ) );
+ result = prime * result + (int) ( lastModified ^ ( lastModified >>> 32 ) );
+ result = prime * result + ( ( name == null ) ? 0 : name.hashCode() );
+ return result;
+ }
+
+ public boolean equals( Object obj )
+ {
+ if ( this == obj )
+ {
+ return true;
+ }
+ if ( obj == null )
+ {
+ return false;
+ }
+ if ( getClass() != obj.getClass() )
+ {
+ return false;
+ }
+ final Resource other = (Resource) obj;
+ if ( contentLength != other.contentLength )
+ {
+ return false;
+ }
+ if ( lastModified != other.lastModified )
+ {
+ return false;
+ }
+ if ( name == null )
+ {
+ if ( other.name != null )
+ {
+ return false;
+ }
+ }
+ else if ( !name.equals( other.name ) )
+ {
+ return false;
+ }
+ return true;
+ }
+}
diff --git a/wagon-provider-api/src/site/apt/index.apt b/wagon-provider-api/src/site/apt/index.apt
index af2b67c..5a82901 100644
--- a/wagon-provider-api/src/site/apt/index.apt
+++ b/wagon-provider-api/src/site/apt/index.apt
@@ -1,39 +1,39 @@
- ------
- Maven Wagon API
- ------
- Carlos Sanchez
- ------
- 2006-04-16
- ------
-
- ~~ Licensed to the Apache Software Foundation (ASF) under one
- ~~ or more contributor license agreements. See the NOTICE file
- ~~ distributed with this work for additional information
- ~~ regarding copyright ownership. The ASF licenses this file
- ~~ to you under the Apache License, Version 2.0 (the
- ~~ "License"); you may not use this file except in compliance
- ~~ with the License. You may obtain a copy of the License at
- ~~
- ~~ http://www.apache.org/licenses/LICENSE-2.0
- ~~
- ~~ Unless required by applicable law or agreed to in writing,
- ~~ software distributed under the License is distributed on an
- ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~~ KIND, either express or implied. See the License for the
- ~~ specific language governing permissions and limitations
- ~~ under the License.
-
- ~~ NOTE: For help with the syntax of this file, see:
- ~~ http://maven.apache.org/doxia/references/apt-format.html
-
-Maven Wagon API
-
- The Wagon API component defines {{{./apidocs/}a simple API}} for transferring resources
- (artifacts) to and from repositories. The word repository is used in this context as
- it is commonly used in
- {{{http://maven.apache.org/maven-1.x/reference/glossary.html}Maven}}
- and means a storage of artifacts.
-
- It is also used to deploy the Maven generated site to a server.
-
- Maven Wagon API defines the contract between different Wagon implementations.
+ ------
+ Maven Wagon API
+ ------
+ Carlos Sanchez
+ ------
+ 2006-04-16
+ ------
+
+ ~~ Licensed to the Apache Software Foundation (ASF) under one
+ ~~ or more contributor license agreements. See the NOTICE file
+ ~~ distributed with this work for additional information
+ ~~ regarding copyright ownership. The ASF licenses this file
+ ~~ to you under the Apache License, Version 2.0 (the
+ ~~ "License"); you may not use this file except in compliance
+ ~~ with the License. You may obtain a copy of the License at
+ ~~
+ ~~ http://www.apache.org/licenses/LICENSE-2.0
+ ~~
+ ~~ Unless required by applicable law or agreed to in writing,
+ ~~ software distributed under the License is distributed on an
+ ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~~ KIND, either express or implied. See the License for the
+ ~~ specific language governing permissions and limitations
+ ~~ under the License.
+
+ ~~ NOTE: For help with the syntax of this file, see:
+ ~~ http://maven.apache.org/doxia/references/apt-format.html
+
+Maven Wagon API
+
+ The Wagon API component defines {{{./apidocs/}a simple API}} for transferring resources
+ (artifacts) to and from repositories. The word repository is used in this context as
+ it is commonly used in
+ {{{http://maven.apache.org/maven-1.x/reference/glossary.html}Maven}}
+ and means a storage of artifacts.
+
+ It is also used to deploy the Maven generated site to a server.
+
+ Maven Wagon API defines the contract between different Wagon implementations.
diff --git a/wagon-provider-api/src/site/site.xml b/wagon-provider-api/src/site/site.xml
index cfa32d4..61d352c 100644
--- a/wagon-provider-api/src/site/site.xml
+++ b/wagon-provider-api/src/site/site.xml
@@ -1,38 +1,38 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
- <body>
- <breadcrumbs>
- <item name="API" href="http://maven.apache.org/wagon/wagon-provider-api/index.html" />
- </breadcrumbs>
- <menu name="Overview">
- <item name="Introduction" href="index.html"/>
- <item name="JavaDocs" href="apidocs/index.html"/>
- <item name="Source Xref" href="xref/index.html"/>
- </menu>
-
- <menu ref="parent"/>
- <menu ref="reports"/>
- </body>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
+ <body>
+ <breadcrumbs>
+ <item name="API" href="http://maven.apache.org/wagon/wagon-provider-api/index.html" />
+ </breadcrumbs>
+ <menu name="Overview">
+ <item name="Introduction" href="index.html"/>
+ <item name="JavaDocs" href="apidocs/index.html"/>
+ <item name="Source Xref" href="xref/index.html"/>
+ </menu>
+
+ <menu ref="parent"/>
+ <menu ref="reports"/>
+ </body>
</project>
\ No newline at end of file
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/AbstractWagonTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/AbstractWagonTest.java
index 05f3c5f..d724d9e 100644
--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/AbstractWagonTest.java
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/AbstractWagonTest.java
@@ -1,577 +1,577 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
-import org.apache.maven.wagon.authorization.AuthorizationException;
-import org.apache.maven.wagon.events.SessionEvent;
-import org.apache.maven.wagon.events.SessionListener;
-import org.apache.maven.wagon.events.TransferEvent;
-import org.apache.maven.wagon.events.TransferListener;
-import org.apache.maven.wagon.proxy.ProxyInfo;
-import org.apache.maven.wagon.proxy.ProxyInfoProvider;
-import org.apache.maven.wagon.repository.Repository;
-import org.apache.maven.wagon.repository.RepositoryPermissions;
-import org.apache.maven.wagon.resource.Resource;
-import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.IOUtil;
-import org.easymock.IAnswer;
-
-import static org.easymock.EasyMock.*;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- */
-public class AbstractWagonTest
- extends TestCase
-{
- private static class TestWagon
- extends AbstractWagon
- {
- protected void closeConnection()
- throws ConnectionException
- {
- }
-
- protected void openConnectionInternal()
- throws ConnectionException, AuthenticationException
- {
- }
-
- public void get( String resourceName, File destination )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- }
-
- public boolean getIfNewer( String resourceName, File destination, long timestamp )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- return false;
- }
-
- public void put( File source, String destination )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- }
- }
-
- private String basedir;
-
- private WagonMock wagon = null;
-
- private File destination;
-
- private File source;
-
- private String artifact;
-
- private SessionListener sessionListener = null;
-
- private TransferListener transferListener = null;
-
- protected void setUp()
- throws Exception
- {
- super.setUp();
-
- basedir = System.getProperty( "basedir" );
-
- destination = new File( basedir, "target/folder/subfolder" );
-
- source = new File( basedir, "pom.xml" );
-
- wagon = new WagonMock();
-
- sessionListener = createMock( SessionListener.class );
-
- wagon.addSessionListener( sessionListener );
-
- transferListener = createMock( TransferListener.class );
-
- wagon.addTransferListener( transferListener );
-
- }
-
- public void testSessionListenerRegistration()
- {
- assertTrue( wagon.hasSessionListener( sessionListener ) );
-
- wagon.removeSessionListener( sessionListener );
-
- assertFalse( wagon.hasSessionListener( sessionListener ) );
- }
-
- public void testTransferListenerRegistration()
- {
- assertTrue( wagon.hasTransferListener( transferListener ) );
-
- wagon.removeTransferListener( transferListener );
-
- assertFalse( wagon.hasTransferListener( transferListener ) );
- }
-
- public void testNoProxyConfiguration()
- throws ConnectionException, AuthenticationException
- {
- Repository repository = new Repository();
- wagon.connect( repository );
- assertNull( wagon.getProxyInfo() );
- assertNull( wagon.getProxyInfo( "http", "www.example.com" ) );
- assertNull( wagon.getProxyInfo( "dav", "www.example.com" ) );
- assertNull( wagon.getProxyInfo( "scp", "www.example.com" ) );
- assertNull( wagon.getProxyInfo( "ftp", "www.example.com" ) );
- assertNull( wagon.getProxyInfo( "http", "localhost" ) );
- }
-
- public void testNullProxyConfiguration()
- throws ConnectionException, AuthenticationException
- {
- Repository repository = new Repository();
- wagon.connect( repository, (ProxyInfo) null );
- assertNull( wagon.getProxyInfo() );
- assertNull( wagon.getProxyInfo( "http", "www.example.com" ) );
- assertNull( wagon.getProxyInfo( "dav", "www.example.com" ) );
- assertNull( wagon.getProxyInfo( "scp", "www.example.com" ) );
- assertNull( wagon.getProxyInfo( "ftp", "www.example.com" ) );
- assertNull( wagon.getProxyInfo( "http", "localhost" ) );
-
- wagon.connect( repository );
- assertNull( wagon.getProxyInfo() );
- assertNull( wagon.getProxyInfo( "http", "www.example.com" ) );
- assertNull( wagon.getProxyInfo( "dav", "www.example.com" ) );
- assertNull( wagon.getProxyInfo( "scp", "www.example.com" ) );
- assertNull( wagon.getProxyInfo( "ftp", "www.example.com" ) );
- assertNull( wagon.getProxyInfo( "http", "localhost" ) );
-
- wagon.connect( repository, new AuthenticationInfo() );
- assertNull( wagon.getProxyInfo() );
- assertNull( wagon.getProxyInfo( "http", "www.example.com" ) );
- assertNull( wagon.getProxyInfo( "dav", "www.example.com" ) );
- assertNull( wagon.getProxyInfo( "scp", "www.example.com" ) );
- assertNull( wagon.getProxyInfo( "ftp", "www.example.com" ) );
- assertNull( wagon.getProxyInfo( "http", "localhost" ) );
- }
-
- public void testLegacyProxyConfiguration()
- throws ConnectionException, AuthenticationException
- {
- ProxyInfo proxyInfo = new ProxyInfo();
- proxyInfo.setType( "http" );
-
- Repository repository = new Repository();
- wagon.connect( repository, proxyInfo );
- assertEquals( proxyInfo, wagon.getProxyInfo() );
- assertEquals( proxyInfo, wagon.getProxyInfo( "http", "www.example.com" ) );
- assertNull( wagon.getProxyInfo( "dav", "www.example.com" ) );
- assertNull( wagon.getProxyInfo( "scp", "www.example.com" ) );
- assertNull( wagon.getProxyInfo( "ftp", "www.example.com" ) );
- }
-
- public void testProxyConfiguration()
- throws ConnectionException, AuthenticationException
- {
- final ProxyInfo httpProxyInfo = new ProxyInfo();
- httpProxyInfo.setType( "http" );
-
- final ProxyInfo socksProxyInfo = new ProxyInfo();
- socksProxyInfo.setType( "http" );
-
- ProxyInfoProvider proxyInfoProvider = new ProxyInfoProvider()
- {
- public ProxyInfo getProxyInfo( String protocol )
- {
- if ( "http".equals( protocol ) || "dav".equals( protocol ) )
- {
- return httpProxyInfo;
- }
- else if ( "scp".equals( protocol ) )
- {
- return socksProxyInfo;
- }
- return null;
- }
- };
-
- Repository repository = new Repository();
- wagon.connect( repository, proxyInfoProvider );
- assertNull( wagon.getProxyInfo() );
- assertEquals( httpProxyInfo, wagon.getProxyInfo( "http", "www.example.com" ) );
- assertEquals( httpProxyInfo, wagon.getProxyInfo( "dav", "www.example.com" ) );
- assertEquals( socksProxyInfo, wagon.getProxyInfo( "scp", "www.example.com" ) );
- assertNull( wagon.getProxyInfo( "ftp", "www.example.com" ) );
- }
-
- public void testSessionOpenEvents()
- throws Exception
- {
- Repository repository = new Repository();
-
- sessionListener.sessionOpening( anyObject( SessionEvent.class ) );
- sessionListener.sessionOpened( anyObject( SessionEvent.class ) );
- replay( sessionListener );
-
- wagon.connect( repository );
-
- verify( sessionListener );
-
- assertEquals( repository, wagon.getRepository() );
- }
-
- public void testSessionConnectionRefusedEventConnectionException()
- throws Exception
- {
- final WagonException exception = new ConnectionException( "" );
-
- try
- {
- runTestSessionConnectionRefusedEvent( exception );
- fail();
- }
- catch ( ConnectionException e )
- {
- assertTrue( true );
- }
- }
-
- public void testSessionConnectionRefusedEventAuthenticationException()
- throws Exception
- {
- final WagonException exception = new AuthenticationException( "" );
-
- try
- {
- runTestSessionConnectionRefusedEvent( exception );
- fail();
- }
- catch ( AuthenticationException e )
- {
- assertTrue( true );
- }
- }
-
- private void runTestSessionConnectionRefusedEvent( final WagonException exception )
- throws ConnectionException, AuthenticationException
- {
- Repository repository = new Repository();
-
- sessionListener.sessionOpening( anyObject( SessionEvent.class ) );
- sessionListener.sessionConnectionRefused( anyObject( SessionEvent.class ) );
- replay( sessionListener );
-
- Wagon wagon = new TestWagon()
- {
- protected void openConnectionInternal()
- throws ConnectionException, AuthenticationException
- {
- if ( exception instanceof ConnectionException )
- {
- throw (ConnectionException) exception;
- }
- if ( exception instanceof AuthenticationException )
- {
- throw (AuthenticationException) exception;
- }
- }
- };
- wagon.addSessionListener( sessionListener );
-
- try
- {
- wagon.connect( repository );
- fail();
- }
- finally
- {
- verify( sessionListener );
-
- assertEquals( repository, wagon.getRepository() );
- }
- }
-
- public void testSessionCloseEvents()
- throws Exception
- {
- sessionListener.sessionDisconnecting( anyObject( SessionEvent.class ) );
- sessionListener.sessionDisconnected( anyObject( SessionEvent.class ) );
- replay( sessionListener );
-
- wagon.disconnect();
-
- verify( sessionListener );
- }
-
- public void testSessionCloseRefusedEventConnectionException()
- throws Exception
- {
- Repository repository = new Repository();
-
- sessionListener.sessionDisconnecting( anyObject( SessionEvent.class ) );
- sessionListener.sessionError( anyObject( SessionEvent.class ) );
- replay( sessionListener );
-
- Wagon wagon = new TestWagon()
- {
- protected void closeConnection()
- throws ConnectionException
- {
- throw new ConnectionException( "" );
- }
- };
- wagon.addSessionListener( sessionListener );
-
- try
- {
- wagon.disconnect();
- fail();
- }
- catch ( ConnectionException e )
- {
- assertTrue( true );
- }
- finally
- {
- verify( sessionListener );
- }
- }
-
- public void testGetTransferEvents()
- throws Exception
- {
- transferListener.debug( "fetch debug message" );
- transferListener.transferInitiated( anyObject( TransferEvent.class ) );
- transferListener.transferStarted( anyObject( TransferEvent.class ) );
- transferListener.debug( anyString() );
- expectLastCall().anyTimes();
- transferListener.transferProgress( anyObject( TransferEvent.class ), anyObject( byte[].class ), anyInt() );
- expectLastCall().times( 5 );
- transferListener.transferCompleted( anyObject( TransferEvent.class ) );
- replay( transferListener );
-
- wagon.fireTransferDebug( "fetch debug message" );
-
- Repository repository = new Repository();
- wagon.connect( repository );
-
- wagon.get( artifact, destination );
-
- verify( transferListener );
- }
-
- public void testGetError()
- throws Exception
- {
- transferListener.transferInitiated( anyObject( TransferEvent.class ) );
- transferListener.transferStarted( anyObject( TransferEvent.class ) );
- transferListener.debug( anyString() );
- expectLastCall().anyTimes();
- transferListener.transferError( anyObject( TransferEvent.class ) );
- replay( transferListener );
-
- try
- {
- Repository repository = new Repository();
-
- WagonMock wagon = new WagonMock( true );
-
- wagon.addTransferListener( transferListener );
-
- wagon.connect( repository );
-
- wagon.get( artifact, destination );
-
- fail( "Transfer error was expected during deploy" );
- }
- catch ( TransferFailedException expected )
- {
- assertTrue( true );
- }
-
- verify( transferListener );
- }
-
- public void testPutTransferEvents()
- throws ConnectionException, AuthenticationException, ResourceDoesNotExistException, TransferFailedException,
- AuthorizationException
- {
- transferListener.debug( "deploy debug message" );
- transferListener.transferInitiated( anyObject( TransferEvent.class ) );
- transferListener.transferStarted( anyObject( TransferEvent.class ) );
- transferListener.transferProgress( anyObject( TransferEvent.class ), anyObject( byte[].class ), anyInt() );
- transferListener.transferCompleted( anyObject( TransferEvent.class ) );
- replay( transferListener );
-
- wagon.fireTransferDebug( "deploy debug message" );
-
- Repository repository = new Repository();
-
- wagon.connect( repository );
-
- wagon.put( source, artifact );
-
- verify( transferListener );
- }
-
- public void testStreamShutdown()
- {
- IOUtil.close( (InputStream) null );
-
- IOUtil.close( (OutputStream) null );
-
- InputStreamMock inputStream = new InputStreamMock();
-
- assertFalse( inputStream.isClosed() );
-
- IOUtil.close( inputStream );
-
- assertTrue( inputStream.isClosed() );
-
- OutputStreamMock outputStream = new OutputStreamMock();
-
- assertFalse( outputStream.isClosed() );
-
- IOUtil.close( outputStream );
-
- assertTrue( outputStream.isClosed() );
- }
-
- public void testRepositoryPermissionsOverride()
- throws ConnectionException, AuthenticationException
- {
- Repository repository = new Repository();
-
- RepositoryPermissions original = new RepositoryPermissions();
- original.setFileMode( "664" );
- repository.setPermissions( original );
-
- RepositoryPermissions override = new RepositoryPermissions();
- override.setFileMode( "644" );
- wagon.setPermissionsOverride( override );
-
- wagon.connect( repository );
-
- assertEquals( override, repository.getPermissions() );
- assertEquals( "644", repository.getPermissions().getFileMode() );
- }
-
- public void testRepositoryUserName()
- throws ConnectionException, AuthenticationException
- {
- Repository repository = new Repository( "id", "http://bporter:password@www.example.com/path/to/resource" );
-
- AuthenticationInfo authenticationInfo = new AuthenticationInfo();
- authenticationInfo.setUserName( "brett" );
- authenticationInfo.setPassword( "pass" );
- wagon.connect( repository, authenticationInfo );
-
- assertEquals( authenticationInfo, wagon.getAuthenticationInfo() );
- assertEquals( "brett", authenticationInfo.getUserName() );
- assertEquals( "pass", authenticationInfo.getPassword() );
- }
-
- public void testRepositoryUserNameNotGivenInCredentials()
- throws ConnectionException, AuthenticationException
- {
- Repository repository = new Repository( "id", "http://bporter:password@www.example.com/path/to/resource" );
-
- AuthenticationInfo authenticationInfo = new AuthenticationInfo();
- wagon.connect( repository, authenticationInfo );
-
- assertEquals( authenticationInfo, wagon.getAuthenticationInfo() );
- assertEquals( "bporter", authenticationInfo.getUserName() );
- assertEquals( "password", authenticationInfo.getPassword() );
- }
-
- public void testConnectNullRepository()
- throws ConnectionException, AuthenticationException
- {
- try
- {
- wagon.connect( null );
- fail();
- }
- catch ( IllegalStateException e )
- {
- assertTrue( true );
- }
- }
-
- public void testPostProcessListeners()
- throws TransferFailedException, IOException
- {
- File tempFile = File.createTempFile( "wagon", "tmp" );
- tempFile.deleteOnExit();
- String content = "content";
- FileUtils.fileWrite( tempFile.getAbsolutePath(), content );
-
- Resource resource = new Resource( "resource" );
-
- transferListener.transferInitiated( anyObject( TransferEvent.class ) );
- transferListener.transferStarted( anyObject( TransferEvent.class ) );
- TransferEvent event =
- new TransferEvent( wagon, resource, TransferEvent.TRANSFER_PROGRESS, TransferEvent.REQUEST_PUT );
- event.setLocalFile( tempFile );
- transferListener.transferProgress( eq( event ), anyObject( byte[].class ), eq( content.length() ) );
- ProgressAnswer answer = new ProgressAnswer();
- expectLastCall().andAnswer( answer );
- transferListener.transferCompleted( anyObject( TransferEvent.class ) );
- replay( transferListener );
-
- wagon.postProcessListeners( resource, tempFile, TransferEvent.REQUEST_PUT );
-
- assertEquals( content.length(), answer.getSize() );
- assertEquals( new String( content.getBytes() ), new String( answer.getBytes() ) );
-
- tempFile.delete();
- }
-
- static final class ProgressAnswer implements IAnswer
- {
- private ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- private int size;
-
- public Object answer() throws Throwable
- {
- byte[] buffer = (byte[]) getCurrentArguments()[1];
- int length = (Integer) getCurrentArguments()[2];
- baos.write( buffer, 0, length );
- size += length;
- return null;
- }
-
- public int getSize()
- {
- return size;
- }
-
- public byte[] getBytes()
- {
- return baos.toByteArray();
- }
- }
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.events.SessionEvent;
+import org.apache.maven.wagon.events.SessionListener;
+import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.events.TransferListener;
+import org.apache.maven.wagon.proxy.ProxyInfo;
+import org.apache.maven.wagon.proxy.ProxyInfoProvider;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.repository.RepositoryPermissions;
+import org.apache.maven.wagon.resource.Resource;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
+import org.easymock.IAnswer;
+
+import static org.easymock.EasyMock.*;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ */
+public class AbstractWagonTest
+ extends TestCase
+{
+ private static class TestWagon
+ extends AbstractWagon
+ {
+ protected void closeConnection()
+ throws ConnectionException
+ {
+ }
+
+ protected void openConnectionInternal()
+ throws ConnectionException, AuthenticationException
+ {
+ }
+
+ public void get( String resourceName, File destination )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ }
+
+ public boolean getIfNewer( String resourceName, File destination, long timestamp )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ return false;
+ }
+
+ public void put( File source, String destination )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ }
+ }
+
+ private String basedir;
+
+ private WagonMock wagon = null;
+
+ private File destination;
+
+ private File source;
+
+ private String artifact;
+
+ private SessionListener sessionListener = null;
+
+ private TransferListener transferListener = null;
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ basedir = System.getProperty( "basedir" );
+
+ destination = new File( basedir, "target/folder/subfolder" );
+
+ source = new File( basedir, "pom.xml" );
+
+ wagon = new WagonMock();
+
+ sessionListener = createMock( SessionListener.class );
+
+ wagon.addSessionListener( sessionListener );
+
+ transferListener = createMock( TransferListener.class );
+
+ wagon.addTransferListener( transferListener );
+
+ }
+
+ public void testSessionListenerRegistration()
+ {
+ assertTrue( wagon.hasSessionListener( sessionListener ) );
+
+ wagon.removeSessionListener( sessionListener );
+
+ assertFalse( wagon.hasSessionListener( sessionListener ) );
+ }
+
+ public void testTransferListenerRegistration()
+ {
+ assertTrue( wagon.hasTransferListener( transferListener ) );
+
+ wagon.removeTransferListener( transferListener );
+
+ assertFalse( wagon.hasTransferListener( transferListener ) );
+ }
+
+ public void testNoProxyConfiguration()
+ throws ConnectionException, AuthenticationException
+ {
+ Repository repository = new Repository();
+ wagon.connect( repository );
+ assertNull( wagon.getProxyInfo() );
+ assertNull( wagon.getProxyInfo( "http", "www.example.com" ) );
+ assertNull( wagon.getProxyInfo( "dav", "www.example.com" ) );
+ assertNull( wagon.getProxyInfo( "scp", "www.example.com" ) );
+ assertNull( wagon.getProxyInfo( "ftp", "www.example.com" ) );
+ assertNull( wagon.getProxyInfo( "http", "localhost" ) );
+ }
+
+ public void testNullProxyConfiguration()
+ throws ConnectionException, AuthenticationException
+ {
+ Repository repository = new Repository();
+ wagon.connect( repository, (ProxyInfo) null );
+ assertNull( wagon.getProxyInfo() );
+ assertNull( wagon.getProxyInfo( "http", "www.example.com" ) );
+ assertNull( wagon.getProxyInfo( "dav", "www.example.com" ) );
+ assertNull( wagon.getProxyInfo( "scp", "www.example.com" ) );
+ assertNull( wagon.getProxyInfo( "ftp", "www.example.com" ) );
+ assertNull( wagon.getProxyInfo( "http", "localhost" ) );
+
+ wagon.connect( repository );
+ assertNull( wagon.getProxyInfo() );
+ assertNull( wagon.getProxyInfo( "http", "www.example.com" ) );
+ assertNull( wagon.getProxyInfo( "dav", "www.example.com" ) );
+ assertNull( wagon.getProxyInfo( "scp", "www.example.com" ) );
+ assertNull( wagon.getProxyInfo( "ftp", "www.example.com" ) );
+ assertNull( wagon.getProxyInfo( "http", "localhost" ) );
+
+ wagon.connect( repository, new AuthenticationInfo() );
+ assertNull( wagon.getProxyInfo() );
+ assertNull( wagon.getProxyInfo( "http", "www.example.com" ) );
+ assertNull( wagon.getProxyInfo( "dav", "www.example.com" ) );
+ assertNull( wagon.getProxyInfo( "scp", "www.example.com" ) );
+ assertNull( wagon.getProxyInfo( "ftp", "www.example.com" ) );
+ assertNull( wagon.getProxyInfo( "http", "localhost" ) );
+ }
+
+ public void testLegacyProxyConfiguration()
+ throws ConnectionException, AuthenticationException
+ {
+ ProxyInfo proxyInfo = new ProxyInfo();
+ proxyInfo.setType( "http" );
+
+ Repository repository = new Repository();
+ wagon.connect( repository, proxyInfo );
+ assertEquals( proxyInfo, wagon.getProxyInfo() );
+ assertEquals( proxyInfo, wagon.getProxyInfo( "http", "www.example.com" ) );
+ assertNull( wagon.getProxyInfo( "dav", "www.example.com" ) );
+ assertNull( wagon.getProxyInfo( "scp", "www.example.com" ) );
+ assertNull( wagon.getProxyInfo( "ftp", "www.example.com" ) );
+ }
+
+ public void testProxyConfiguration()
+ throws ConnectionException, AuthenticationException
+ {
+ final ProxyInfo httpProxyInfo = new ProxyInfo();
+ httpProxyInfo.setType( "http" );
+
+ final ProxyInfo socksProxyInfo = new ProxyInfo();
+ socksProxyInfo.setType( "http" );
+
+ ProxyInfoProvider proxyInfoProvider = new ProxyInfoProvider()
+ {
+ public ProxyInfo getProxyInfo( String protocol )
+ {
+ if ( "http".equals( protocol ) || "dav".equals( protocol ) )
+ {
+ return httpProxyInfo;
+ }
+ else if ( "scp".equals( protocol ) )
+ {
+ return socksProxyInfo;
+ }
+ return null;
+ }
+ };
+
+ Repository repository = new Repository();
+ wagon.connect( repository, proxyInfoProvider );
+ assertNull( wagon.getProxyInfo() );
+ assertEquals( httpProxyInfo, wagon.getProxyInfo( "http", "www.example.com" ) );
+ assertEquals( httpProxyInfo, wagon.getProxyInfo( "dav", "www.example.com" ) );
+ assertEquals( socksProxyInfo, wagon.getProxyInfo( "scp", "www.example.com" ) );
+ assertNull( wagon.getProxyInfo( "ftp", "www.example.com" ) );
+ }
+
+ public void testSessionOpenEvents()
+ throws Exception
+ {
+ Repository repository = new Repository();
+
+ sessionListener.sessionOpening( anyObject( SessionEvent.class ) );
+ sessionListener.sessionOpened( anyObject( SessionEvent.class ) );
+ replay( sessionListener );
+
+ wagon.connect( repository );
+
+ verify( sessionListener );
+
+ assertEquals( repository, wagon.getRepository() );
+ }
+
+ public void testSessionConnectionRefusedEventConnectionException()
+ throws Exception
+ {
+ final WagonException exception = new ConnectionException( "" );
+
+ try
+ {
+ runTestSessionConnectionRefusedEvent( exception );
+ fail();
+ }
+ catch ( ConnectionException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+ public void testSessionConnectionRefusedEventAuthenticationException()
+ throws Exception
+ {
+ final WagonException exception = new AuthenticationException( "" );
+
+ try
+ {
+ runTestSessionConnectionRefusedEvent( exception );
+ fail();
+ }
+ catch ( AuthenticationException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+ private void runTestSessionConnectionRefusedEvent( final WagonException exception )
+ throws ConnectionException, AuthenticationException
+ {
+ Repository repository = new Repository();
+
+ sessionListener.sessionOpening( anyObject( SessionEvent.class ) );
+ sessionListener.sessionConnectionRefused( anyObject( SessionEvent.class ) );
+ replay( sessionListener );
+
+ Wagon wagon = new TestWagon()
+ {
+ protected void openConnectionInternal()
+ throws ConnectionException, AuthenticationException
+ {
+ if ( exception instanceof ConnectionException )
+ {
+ throw (ConnectionException) exception;
+ }
+ if ( exception instanceof AuthenticationException )
+ {
+ throw (AuthenticationException) exception;
+ }
+ }
+ };
+ wagon.addSessionListener( sessionListener );
+
+ try
+ {
+ wagon.connect( repository );
+ fail();
+ }
+ finally
+ {
+ verify( sessionListener );
+
+ assertEquals( repository, wagon.getRepository() );
+ }
+ }
+
+ public void testSessionCloseEvents()
+ throws Exception
+ {
+ sessionListener.sessionDisconnecting( anyObject( SessionEvent.class ) );
+ sessionListener.sessionDisconnected( anyObject( SessionEvent.class ) );
+ replay( sessionListener );
+
+ wagon.disconnect();
+
+ verify( sessionListener );
+ }
+
+ public void testSessionCloseRefusedEventConnectionException()
+ throws Exception
+ {
+ Repository repository = new Repository();
+
+ sessionListener.sessionDisconnecting( anyObject( SessionEvent.class ) );
+ sessionListener.sessionError( anyObject( SessionEvent.class ) );
+ replay( sessionListener );
+
+ Wagon wagon = new TestWagon()
+ {
+ protected void closeConnection()
+ throws ConnectionException
+ {
+ throw new ConnectionException( "" );
+ }
+ };
+ wagon.addSessionListener( sessionListener );
+
+ try
+ {
+ wagon.disconnect();
+ fail();
+ }
+ catch ( ConnectionException e )
+ {
+ assertTrue( true );
+ }
+ finally
+ {
+ verify( sessionListener );
+ }
+ }
+
+ public void testGetTransferEvents()
+ throws Exception
+ {
+ transferListener.debug( "fetch debug message" );
+ transferListener.transferInitiated( anyObject( TransferEvent.class ) );
+ transferListener.transferStarted( anyObject( TransferEvent.class ) );
+ transferListener.debug( anyString() );
+ expectLastCall().anyTimes();
+ transferListener.transferProgress( anyObject( TransferEvent.class ), anyObject( byte[].class ), anyInt() );
+ expectLastCall().times( 5 );
+ transferListener.transferCompleted( anyObject( TransferEvent.class ) );
+ replay( transferListener );
+
+ wagon.fireTransferDebug( "fetch debug message" );
+
+ Repository repository = new Repository();
+ wagon.connect( repository );
+
+ wagon.get( artifact, destination );
+
+ verify( transferListener );
+ }
+
+ public void testGetError()
+ throws Exception
+ {
+ transferListener.transferInitiated( anyObject( TransferEvent.class ) );
+ transferListener.transferStarted( anyObject( TransferEvent.class ) );
+ transferListener.debug( anyString() );
+ expectLastCall().anyTimes();
+ transferListener.transferError( anyObject( TransferEvent.class ) );
+ replay( transferListener );
+
+ try
+ {
+ Repository repository = new Repository();
+
+ WagonMock wagon = new WagonMock( true );
+
+ wagon.addTransferListener( transferListener );
+
+ wagon.connect( repository );
+
+ wagon.get( artifact, destination );
+
+ fail( "Transfer error was expected during deploy" );
+ }
+ catch ( TransferFailedException expected )
+ {
+ assertTrue( true );
+ }
+
+ verify( transferListener );
+ }
+
+ public void testPutTransferEvents()
+ throws ConnectionException, AuthenticationException, ResourceDoesNotExistException, TransferFailedException,
+ AuthorizationException
+ {
+ transferListener.debug( "deploy debug message" );
+ transferListener.transferInitiated( anyObject( TransferEvent.class ) );
+ transferListener.transferStarted( anyObject( TransferEvent.class ) );
+ transferListener.transferProgress( anyObject( TransferEvent.class ), anyObject( byte[].class ), anyInt() );
+ transferListener.transferCompleted( anyObject( TransferEvent.class ) );
+ replay( transferListener );
+
+ wagon.fireTransferDebug( "deploy debug message" );
+
+ Repository repository = new Repository();
+
+ wagon.connect( repository );
+
+ wagon.put( source, artifact );
+
+ verify( transferListener );
+ }
+
+ public void testStreamShutdown()
+ {
+ IOUtil.close( (InputStream) null );
+
+ IOUtil.close( (OutputStream) null );
+
+ InputStreamMock inputStream = new InputStreamMock();
+
+ assertFalse( inputStream.isClosed() );
+
+ IOUtil.close( inputStream );
+
+ assertTrue( inputStream.isClosed() );
+
+ OutputStreamMock outputStream = new OutputStreamMock();
+
+ assertFalse( outputStream.isClosed() );
+
+ IOUtil.close( outputStream );
+
+ assertTrue( outputStream.isClosed() );
+ }
+
+ public void testRepositoryPermissionsOverride()
+ throws ConnectionException, AuthenticationException
+ {
+ Repository repository = new Repository();
+
+ RepositoryPermissions original = new RepositoryPermissions();
+ original.setFileMode( "664" );
+ repository.setPermissions( original );
+
+ RepositoryPermissions override = new RepositoryPermissions();
+ override.setFileMode( "644" );
+ wagon.setPermissionsOverride( override );
+
+ wagon.connect( repository );
+
+ assertEquals( override, repository.getPermissions() );
+ assertEquals( "644", repository.getPermissions().getFileMode() );
+ }
+
+ public void testRepositoryUserName()
+ throws ConnectionException, AuthenticationException
+ {
+ Repository repository = new Repository( "id", "http://bporter:password@www.example.com/path/to/resource" );
+
+ AuthenticationInfo authenticationInfo = new AuthenticationInfo();
+ authenticationInfo.setUserName( "brett" );
+ authenticationInfo.setPassword( "pass" );
+ wagon.connect( repository, authenticationInfo );
+
+ assertEquals( authenticationInfo, wagon.getAuthenticationInfo() );
+ assertEquals( "brett", authenticationInfo.getUserName() );
+ assertEquals( "pass", authenticationInfo.getPassword() );
+ }
+
+ public void testRepositoryUserNameNotGivenInCredentials()
+ throws ConnectionException, AuthenticationException
+ {
+ Repository repository = new Repository( "id", "http://bporter:password@www.example.com/path/to/resource" );
+
+ AuthenticationInfo authenticationInfo = new AuthenticationInfo();
+ wagon.connect( repository, authenticationInfo );
+
+ assertEquals( authenticationInfo, wagon.getAuthenticationInfo() );
+ assertEquals( "bporter", authenticationInfo.getUserName() );
+ assertEquals( "password", authenticationInfo.getPassword() );
+ }
+
+ public void testConnectNullRepository()
+ throws ConnectionException, AuthenticationException
+ {
+ try
+ {
+ wagon.connect( null );
+ fail();
+ }
+ catch ( NullPointerException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+ public void testPostProcessListeners()
+ throws TransferFailedException, IOException
+ {
+ File tempFile = File.createTempFile( "wagon", "tmp" );
+ tempFile.deleteOnExit();
+ String content = "content";
+ FileUtils.fileWrite( tempFile.getAbsolutePath(), content );
+
+ Resource resource = new Resource( "resource" );
+
+ transferListener.transferInitiated( anyObject( TransferEvent.class ) );
+ transferListener.transferStarted( anyObject( TransferEvent.class ) );
+ TransferEvent event =
+ new TransferEvent( wagon, resource, TransferEvent.TRANSFER_PROGRESS, TransferEvent.REQUEST_PUT );
+ event.setLocalFile( tempFile );
+ transferListener.transferProgress( eq( event ), anyObject( byte[].class ), eq( content.length() ) );
+ ProgressAnswer answer = new ProgressAnswer();
+ expectLastCall().andAnswer( answer );
+ transferListener.transferCompleted( anyObject( TransferEvent.class ) );
+ replay( transferListener );
+
+ wagon.postProcessListeners( resource, tempFile, TransferEvent.REQUEST_PUT );
+
+ assertEquals( content.length(), answer.getSize() );
+ assertEquals( new String( content.getBytes() ), new String( answer.getBytes() ) );
+
+ tempFile.delete();
+ }
+
+ static final class ProgressAnswer implements IAnswer
+ {
+ private ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ private int size;
+
+ public Object answer() throws Throwable
+ {
+ byte[] buffer = (byte[]) getCurrentArguments()[1];
+ int length = (Integer) getCurrentArguments()[2];
+ baos.write( buffer, 0, length );
+ size += length;
+ return null;
+ }
+
+ public int getSize()
+ {
+ return size;
+ }
+
+ public byte[] getBytes()
+ {
+ return baos.toByteArray();
+ }
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/CannotConnectExceptionTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/CannotConnectExceptionTest.java
index cb798c8..94ce933 100644
--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/CannotConnectExceptionTest.java
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/CannotConnectExceptionTest.java
@@ -1,43 +1,43 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-
-/**
- * @author <a href="mailto:jason at maven.org">Jason van Zyl</a>
- *
- */
-public class CannotConnectExceptionTest
- extends TestCase
-{
- public void testCannotConnectExceptionTest()
- {
- ConnectionException ae = new ConnectionException( "message" );
-
- assertEquals( "message", ae.getMessage() );
-
- ae = new ConnectionException( "full-message", new Throwable( "cause" ) );
-
- assertEquals( "full-message", ae.getMessage() );
-
- assertEquals( "cause", ae.getCause().getMessage() );
- }
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:jason at maven.org">Jason van Zyl</a>
+ *
+ */
+public class CannotConnectExceptionTest
+ extends TestCase
+{
+ public void testCannotConnectExceptionTest()
+ {
+ ConnectionException ae = new ConnectionException( "message" );
+
+ assertEquals( "message", ae.getMessage() );
+
+ ae = new ConnectionException( "full-message", new Throwable( "cause" ) );
+
+ assertEquals( "full-message", ae.getMessage() );
+
+ assertEquals( "cause", ae.getCause().getMessage() );
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/InputStreamMock.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/InputStreamMock.java
index c624764..1c0de14 100644
--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/InputStreamMock.java
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/InputStreamMock.java
@@ -1,80 +1,80 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-import java.io.InputStream;
-
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class InputStreamMock
- extends InputStream
-{
-
- private boolean closed = false;
-
- boolean forcedError = false;
-
- public void close()
- {
- closed = true;
- }
-
- /**
- * @return Returns the closed.
- */
- public boolean isClosed()
- {
- return closed;
- }
-
- /**
- * @return Returns the forcedError.
- */
- public boolean isForcedError()
- {
- return forcedError;
- }
-
- /**
- * @see java.io.InputStream#read()
- */
- public int read()
- throws IOException
- {
- if ( forcedError )
- {
- throw new IOException( "Mock exception" );
- }
- return 0;
- }
-
- /**
- * @param forcedError The forcedError to set.
- */
- public void setForcedError( final boolean forcedError )
- {
- this.forcedError = forcedError;
- }
-
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class InputStreamMock
+ extends InputStream
+{
+
+ private boolean closed = false;
+
+ boolean forcedError = false;
+
+ public void close()
+ {
+ closed = true;
+ }
+
+ /**
+ * @return Returns the closed.
+ */
+ public boolean isClosed()
+ {
+ return closed;
+ }
+
+ /**
+ * @return Returns the forcedError.
+ */
+ public boolean isForcedError()
+ {
+ return forcedError;
+ }
+
+ /**
+ * @see java.io.InputStream#read()
+ */
+ public int read()
+ throws IOException
+ {
+ if ( forcedError )
+ {
+ throw new IOException( "Mock exception" );
+ }
+ return 0;
+ }
+
+ /**
+ * @param forcedError The forcedError to set.
+ */
+ public void setForcedError( final boolean forcedError )
+ {
+ this.forcedError = forcedError;
+ }
+
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/LazyFileOutputStreamTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/LazyFileOutputStreamTest.java
index 006a562..452a55a 100644
--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/LazyFileOutputStreamTest.java
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/LazyFileOutputStreamTest.java
@@ -1,62 +1,62 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-import org.codehaus.plexus.util.FileUtils;
-
-import java.io.File;
-
-/**
- * @author <a href="mailto:mmaczka at interia.pl">Michal Maczka</a>
- *
- */
-public class LazyFileOutputStreamTest
- extends TestCase
-{
-
- public void testFileCreation()
- throws Exception
- {
- File file = File.createTempFile( getName(), null );
-
- file.delete();
-
- assertFalse( file.exists() );
-
- LazyFileOutputStream stream = new LazyFileOutputStream( file );
-
- assertFalse( file.exists() );
-
- String expected = "michal";
-
- stream.write( expected.getBytes() );
-
- stream.close();
-
- assertTrue( file.exists() );
-
- String actual = FileUtils.fileRead( file );
-
- assertEquals( expected, actual );
-
- }
-
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+import org.codehaus.plexus.util.FileUtils;
+
+import java.io.File;
+
+/**
+ * @author <a href="mailto:mmaczka at interia.pl">Michal Maczka</a>
+ *
+ */
+public class LazyFileOutputStreamTest
+ extends TestCase
+{
+
+ public void testFileCreation()
+ throws Exception
+ {
+ File file = File.createTempFile( getName(), null );
+
+ file.delete();
+
+ assertFalse( file.exists() );
+
+ LazyFileOutputStream stream = new LazyFileOutputStream( file );
+
+ assertFalse( file.exists() );
+
+ String expected = "michal";
+
+ stream.write( expected.getBytes() );
+
+ stream.close();
+
+ assertTrue( file.exists() );
+
+ String actual = FileUtils.fileRead( file );
+
+ assertEquals( expected, actual );
+
+ }
+
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/NotAuthorizedExceptionTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/NotAuthorizedExceptionTest.java
index c86e538..1652539 100644
--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/NotAuthorizedExceptionTest.java
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/NotAuthorizedExceptionTest.java
@@ -1,44 +1,44 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-import org.apache.maven.wagon.authorization.AuthorizationException;
-
-/**
- * @author <a href="mailto:jason at maven.org">Jason van Zyl</a>
- *
- */
-public class NotAuthorizedExceptionTest
- extends TestCase
-{
- public void testNotAuthorizedExceptionTest()
- {
- AuthorizationException ae = new AuthorizationException( "message" );
-
- assertEquals( "message", ae.getMessage() );
-
- ae = new AuthorizationException( "full-message", new Throwable( "cause" ) );
-
- assertEquals( "full-message", ae.getMessage() );
-
- assertEquals( "cause", ae.getCause().getMessage() );
- }
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+
+/**
+ * @author <a href="mailto:jason at maven.org">Jason van Zyl</a>
+ *
+ */
+public class NotAuthorizedExceptionTest
+ extends TestCase
+{
+ public void testNotAuthorizedExceptionTest()
+ {
+ AuthorizationException ae = new AuthorizationException( "message" );
+
+ assertEquals( "message", ae.getMessage() );
+
+ ae = new AuthorizationException( "full-message", new Throwable( "cause" ) );
+
+ assertEquals( "full-message", ae.getMessage() );
+
+ assertEquals( "cause", ae.getCause().getMessage() );
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/OutputStreamMock.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/OutputStreamMock.java
index 9266b34..28c5fe7 100644
--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/OutputStreamMock.java
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/OutputStreamMock.java
@@ -1,80 +1,80 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class OutputStreamMock
- extends OutputStream
-{
-
- private boolean closed = false;
-
- private boolean forcedError = false;
-
- public void close()
- {
- closed = true;
- }
-
- /**
- * @see java.io.OutputStream#write(int)
- */
- public void write( final int b )
- throws IOException
- {
- if ( forcedError )
- {
- throw new IOException( "Mock exception" );
- }
-
- }
-
- /**
- * @return Returns the closed.
- */
- public boolean isClosed()
- {
- return closed;
- }
-
-
- /**
- * @return Returns the forcedError.
- */
- public boolean isForcedError()
- {
- return forcedError;
- }
-
- /**
- * @param forcedError The forcedError to set.
- */
- public void setForcedError( final boolean forcedError )
- {
- this.forcedError = forcedError;
- }
-
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class OutputStreamMock
+ extends OutputStream
+{
+
+ private boolean closed = false;
+
+ private boolean forcedError = false;
+
+ public void close()
+ {
+ closed = true;
+ }
+
+ /**
+ * @see java.io.OutputStream#write(int)
+ */
+ public void write( final int b )
+ throws IOException
+ {
+ if ( forcedError )
+ {
+ throw new IOException( "Mock exception" );
+ }
+
+ }
+
+ /**
+ * @return Returns the closed.
+ */
+ public boolean isClosed()
+ {
+ return closed;
+ }
+
+
+ /**
+ * @return Returns the forcedError.
+ */
+ public boolean isForcedError()
+ {
+ return forcedError;
+ }
+
+ /**
+ * @param forcedError The forcedError to set.
+ */
+ public void setForcedError( final boolean forcedError )
+ {
+ this.forcedError = forcedError;
+ }
+
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/PathUtilsTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/PathUtilsTest.java
index 0f09202..a5e5cd3 100644
--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/PathUtilsTest.java
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/PathUtilsTest.java
@@ -1,336 +1,336 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-
-import junit.framework.TestCase;
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class PathUtilsTest
- extends TestCase
-{
- public void testFilenameResolving()
- {
- assertEquals( "filename", PathUtils.filename( "dir/filename" ) );
-
- assertEquals( "filename", PathUtils.filename( "filename" ) );
-
- assertEquals( "filename", PathUtils.filename( "dir1/dir2/filename" ) );
- }
-
- public void testDirResolving()
- {
- assertEquals( "dir", PathUtils.dirname( "dir/filename" ) );
-
- assertEquals( "", PathUtils.dirname( "filename" ) );
-
- assertEquals( "dir1/dir2", PathUtils.dirname( "dir1/dir2/filename" ) );
- }
-
- public void testDirSpliting()
- {
- final String path = "a/b/c";
-
- final String[] dirs = PathUtils.dirnames( path );
-
- assertNotNull( dirs );
-
- assertEquals( 2, dirs.length );
-
- assertEquals( "a", dirs[0] );
-
- assertEquals( "b", dirs[1] );
-
- }
-
- public void testHostResolving()
- {
- assertEquals( "www.codehaus.org", PathUtils.host( "http://www.codehaus.org" ) );
- assertEquals( "www.codehaus.org", PathUtils.host( "HTTP://www.codehaus.org" ) );
-
- assertEquals( "localhost", PathUtils.host( null ) );
- assertEquals( "localhost", PathUtils.host( "file:///c:/temp" ) );
- assertEquals( "localhost", PathUtils.host( "FILE:///c:/temp" ) );
-
- }
-
- public void testScmHostResolving()
- {
- assertEquals( "www.codehaus.org", PathUtils.host( "scm:svn:http://www.codehaus.org" ) );
- assertEquals( "www.codehaus.org", PathUtils.host( "SCM:SVN:HTTP://www.codehaus.org" ) );
- assertEquals( "www.codehaus.org", PathUtils.host( "scm:svn:http://www.codehaus.org/repos/module" ) );
- assertEquals( "www.codehaus.org", PathUtils.host( "SCM:SVN:HTTP://www.codehaus.org/repos/module" ) );
- assertEquals( "www.codehaus.org", PathUtils.host( "scm:cvs:pserver:anoncvs at www.codehaus.org:/root" ) );
- assertEquals( "www.codehaus.org", PathUtils.host( "SCM:CVS:pserver:anoncvs at www.codehaus.org:/root" ) );
- }
-
- public void testProtocolResolving()
- {
- assertEquals( "http", PathUtils.protocol( "http://www.codehause.org" ) );
- assertEquals( "HTTP", PathUtils.protocol( "HTTP://www.codehause.org" ) );
- assertEquals( "file", PathUtils.protocol( "file:///c:/temp" ) );
- assertEquals( "scm", PathUtils.protocol( "scm:svn:http://localhost/repos/module" ) );
- assertEquals( "scm", PathUtils.protocol( "scm:cvs:pserver:anoncvs at cvs.apache.org:/home/cvspublic" ) );
- }
-
- public void testUserInfo()
- {
- String urlWithUsername = "http://brett@www.codehaus.org";
- assertEquals( "brett", PathUtils.user( urlWithUsername ) );
- assertNull( PathUtils.password( urlWithUsername ) );
- assertEquals( "www.codehaus.org", PathUtils.host( urlWithUsername ) );
- assertEquals( "/", PathUtils.basedir( urlWithUsername ) );
-
- String urlWithUsernamePassword = "http://brett:porter@www.codehaus.org";
- assertEquals( "brett", PathUtils.user( urlWithUsernamePassword ) );
- assertEquals( "porter", PathUtils.password( urlWithUsernamePassword ) );
- assertEquals( "www.codehaus.org", PathUtils.host( urlWithUsernamePassword ) );
- assertEquals( "/", PathUtils.basedir( urlWithUsernamePassword ) );
- }
-
- public void testSubversionUserInfo()
- {
- String urlWithUsername = "scm:svn:http://brett@www.codehaus.org";
- assertEquals( "brett", PathUtils.user( urlWithUsername ) );
- assertNull( PathUtils.password( urlWithUsername ) );
- assertEquals( "www.codehaus.org", PathUtils.host( urlWithUsername ) );
- assertEquals( "/", PathUtils.basedir( urlWithUsername ) );
-
- String urlWithUsernamePassword = "scm:svn:http://brett:porter@www.codehaus.org";
- assertEquals( "brett", PathUtils.user( urlWithUsernamePassword ) );
- assertEquals( "porter", PathUtils.password( urlWithUsernamePassword ) );
- assertEquals( "www.codehaus.org", PathUtils.host( urlWithUsernamePassword ) );
- assertEquals( "/", PathUtils.basedir( urlWithUsernamePassword ) );
-
- String urlWithUpperCaseProtocol = "SCM:SVN:HTTP://brett@www.codehaus.org";
- assertEquals( "brett", PathUtils.user( urlWithUpperCaseProtocol ) );
- assertNull( PathUtils.password( urlWithUpperCaseProtocol ) );
- assertEquals( "www.codehaus.org", PathUtils.host( urlWithUpperCaseProtocol ) );
- assertEquals( "/", PathUtils.basedir( urlWithUpperCaseProtocol ) );
- }
-
- public void testCvsUserInfo()
- {
- String urlWithUsername = "scm:cvs:pserver:brett at www.codehaus.org";
- assertEquals( "brett", PathUtils.user( urlWithUsername ) );
- assertNull( PathUtils.password( urlWithUsername ) );
- assertEquals( "www.codehaus.org", PathUtils.host( urlWithUsername ) );
- assertEquals( "/", PathUtils.basedir( urlWithUsername ) );
-
- String urlWithUsernamePassword = "scm:cvs:pserver:brett:porter at www.codehaus.org";
- assertEquals( "brett", PathUtils.user( urlWithUsernamePassword ) );
- assertEquals( "porter", PathUtils.password( urlWithUsernamePassword ) );
- assertEquals( "www.codehaus.org", PathUtils.host( urlWithUsernamePassword ) );
- assertEquals( "/", PathUtils.basedir( urlWithUsernamePassword ) );
-
- String urlWithUpperCaseProtocol = "SCM:CVS:pserver:brett at www.codehaus.org";
- assertEquals( "brett", PathUtils.user( urlWithUpperCaseProtocol ) );
- assertNull( PathUtils.password( urlWithUpperCaseProtocol ) );
- assertEquals( "www.codehaus.org", PathUtils.host( urlWithUpperCaseProtocol ) );
- assertEquals( "/", PathUtils.basedir( urlWithUpperCaseProtocol ) );
- }
-
- public void testFileBasedir()
- {
- // see http://www.mozilla.org/quality/networking/testing/filetests.html
-
- // strict forms
- assertEquals( "c:/temp", PathUtils.basedir( "file:///c|/temp" ) );
- assertEquals( "localhost", PathUtils.host( "file:///c|/temp" ) );
- assertEquals( "c:/temp", PathUtils.basedir( "file://localhost/c|/temp" ) );
- assertEquals( "localhost", PathUtils.host( "file://localhost/c|/temp" ) );
- assertEquals( "/temp", PathUtils.basedir( "file:///temp" ) );
- assertEquals( "localhost", PathUtils.host( "file:///temp" ) );
- assertEquals( "/temp", PathUtils.basedir( "file://localhost/temp" ) );
- assertEquals( "localhost", PathUtils.host( "file://localhost/temp" ) );
-
- // strict form, with : for drive separator
- assertEquals( "c:/temp", PathUtils.basedir( "file:///c:/temp" ) );
- assertEquals( "localhost", PathUtils.host( "file:///c:/temp" ) );
- assertEquals( "c:/temp", PathUtils.basedir( "file://localhost/c:/temp" ) );
- assertEquals( "localhost", PathUtils.host( "file://localhost/c:/temp" ) );
-
- // convenience forms
- assertEquals( "c:/temp", PathUtils.basedir( "file://c:/temp" ) );
- assertEquals( "c:/temp", PathUtils.basedir( "file://c|/temp" ) );
- assertEquals( "c:/temp", PathUtils.basedir( "file:c:/temp" ) );
- assertEquals( "c:/temp", PathUtils.basedir( "file:c|/temp" ) );
- assertEquals( "/temp", PathUtils.basedir( "file:/temp" ) );
-
- // URL decoding
- assertEquals( "c:/my docs", PathUtils.basedir( "file:///c:/my docs" ) );
- assertEquals( "c:/my docs", PathUtils.basedir( "file:///c:/my%20docs" ) );
- assertEquals( "c:/name #%20?{}[]<>.txt", PathUtils.basedir( "file:///c:/name%20%23%2520%3F%7B%7D%5B%5D%3C%3E.txt" ) );
-
- assertEquals( "c:/temp", PathUtils.basedir( "FILE:///c:/temp" ) );
- assertEquals( "localhost", PathUtils.host( "FILE:///c:/temp" ) );
- }
-
- public void testEmptyBasedir()
- {
- assertEquals( "/", PathUtils.basedir( "http://www.codehaus.org:80" ) );
- assertEquals( "/", PathUtils.basedir( "http://www.codehaus.org" ) );
- assertEquals( "/", PathUtils.basedir( "http://www.codehaus.org:80/" ) );
- assertEquals( "/", PathUtils.basedir( "http://www.codehaus.org/" ) );
- assertEquals( "/", PathUtils.basedir( "HTTP://www.codehaus.org/" ) );
- }
-
- public void testEmptyProtocol()
- {
- assertEquals( "", PathUtils.protocol( "placeholder-only" ) );
- assertEquals( "", PathUtils.protocol( "placeholder-only/module-a" ) );
-
- assertEquals( "placeholder-only", PathUtils.authorization( "placeholder-only" ) );
- assertEquals( "placeholder-only", PathUtils.authorization( "placeholder-only/module-a" ) );
-
- assertEquals( -1, PathUtils.port( "placeholder-only" ) );
- assertEquals( -1, PathUtils.port( "placeholder-only/module-a" ) );
-
- assertEquals( "/", PathUtils.basedir( "placeholder-only" ) );
- assertEquals( "/module-a", PathUtils.basedir( "placeholder-only/module-a" ) );
- }
-
- public void testPortResolving()
- {
- assertEquals( 80, PathUtils.port( "http://www.codehause.org:80/maven" ) );
- assertEquals( 80, PathUtils.port( "HTTP://www.codehause.org:80/maven" ) );
- assertEquals( WagonConstants.UNKNOWN_PORT, PathUtils.port( "http://localhost/temp" ) );
-
- assertEquals( 10, PathUtils.port( "ftp://localhost:10" ) );
- assertEquals( 10, PathUtils.port( "FTP://localhost:10" ) );
- }
-
- public void testScmPortResolving()
- {
- assertEquals( 80, PathUtils.port( "scm:svn:http://www.codehaus.org:80/maven" ) );
- assertEquals( 80, PathUtils.port( "SCM:SVN:HTTP://www.codehaus.org:80/maven" ) );
- assertEquals( WagonConstants.UNKNOWN_PORT, PathUtils.port( "scm:cvs:pserver:anoncvs at localhost:/temp:module" ) );
-
- assertEquals( 2402, PathUtils.port( "scm:cvs:pserver:anoncvs at localhost:2402/temp:module" ) );
- assertEquals( 2402, PathUtils.port( "SCM:CVS:pserver:anoncvs at localhost:2402/temp:module" ) );
- }
-
- public void testScmBasedir()
- {
- assertEquals( "/maven", PathUtils.basedir( "scm:svn:http://www.codehause.org/maven" ) );
- assertEquals( "/maven", PathUtils.basedir( "SCM:SVN:HTTP://www.codehause.org/maven" ) );
- assertEquals( "/maven", PathUtils.basedir( "scm:svn:http://www.codehause.org:80/maven" ) );
- assertEquals( "/maven", PathUtils.basedir( "scm:cvs:pserver:anoncvs at www.codehause.org:80/maven" ) );
- assertEquals( "/maven", PathUtils.basedir( "scm:cvs:pserver:anoncvs at www.codehause.org:/maven" ) );
- assertEquals( "/maven/module", PathUtils.basedir( "scm:cvs:pserver:anoncvs at www.codehause.org:80/maven:module" ) );
- assertEquals( "/maven/module", PathUtils.basedir( "scm:cvs:pserver:anoncvs at www.codehause.org:/maven:module" ) );
- assertEquals( "/maven/module", PathUtils.basedir( "SCM:CVS:pserver:anoncvs at www.codehause.org:/maven:module" ) );
- }
-
- public void testPortBasedir()
- {
- assertEquals( "/maven", PathUtils.basedir( "http://www.codehause.org:80/maven" ) );
- assertEquals( "/temp", PathUtils.basedir( "http://localhost/temp" ) );
-
- assertEquals( "c:/temp", PathUtils.basedir( "file://c:/temp" ) );
- assertEquals( "/", PathUtils.basedir( "http://localhost:80/" ) );
- assertEquals( "/", PathUtils.basedir( "http://localhost/" ) );
- }
-
- public void testIpV4()
- {
- assertUrl( "http://127.0.0.1", "http", null, null, "127.0.0.1", -1, "/" );
- assertUrl( "http://127.0.0.1:8080", "http", null, null, "127.0.0.1", 8080, "/" );
- assertUrl( "http://127.0.0.1/oo/rest/users", "http", null, null, "127.0.0.1", -1, "/oo/rest/users" );
- assertUrl( "http://127.0.0.1:8080/oo/rest/users", "http", null, null, "127.0.0.1", 8080, "/oo/rest/users" );
-
- assertUrl( "http://user:password@127.0.0.1", "http", "user", "password", "127.0.0.1", -1, "/" );
- assertUrl( "http://user:password@127.0.0.1:8080", "http", "user", "password", "127.0.0.1", 8080, "/" );
- assertUrl( "http://user:password@127.0.0.1/oo/rest/users", "http", "user", "password", "127.0.0.1", -1,
- "/oo/rest/users" );
- assertUrl( "http://user:password@127.0.0.1:8080/oo/rest/users", "http", "user", "password", "127.0.0.1", 8080,
- "/oo/rest/users" );
-
- assertUrl( "scm:svn:http://user:password@127.0.0.1:8080/oo/rest/users", "scm", "user", "password", "127.0.0.1",
- 8080, "/oo/rest/users" );
- }
-
- public void testIPv6()
- {
- assertUrl( "http://user:password@[fff:::1]:7891/oo/rest/users", "http", "user", "password", "fff:::1", 7891,
- "/oo/rest/users" );
- assertUrl( "http://[fff:::1]:7891/oo/rest/users", "http", null, null, "fff:::1", 7891, "/oo/rest/users" );
- assertUrl( "http://user:password@[fff:::1]/oo/rest/users", "http", "user", "password", "fff:::1", -1,
- "/oo/rest/users" );
- assertUrl( "http://user:password@[fff:::1]:7891", "http", "user", "password", "fff:::1", 7891, "/" );
-
- assertUrl( "http://user:password@[fff:000::222:1111]:7891/oo/rest/users", "http", "user", "password",
- "fff:000::222:1111", 7891, "/oo/rest/users" );
- assertUrl( "http://[fff:000::222:1111]:7891/oo/rest/users", "http", null, null, "fff:000::222:1111", 7891,
- "/oo/rest/users" );
- assertUrl( "http://user:password@[fff:000::222:1111]/oo/rest/users", "http", "user", "password",
- "fff:000::222:1111", -1, "/oo/rest/users" );
- assertUrl( "http://user:password@[fff:000::222:1111]:7891", "http", "user", "password", "fff:000::222:1111",
- 7891, "/" );
-
- assertUrl( "http://user:password@16.60.56.58:7891/oo/rest/users", "http", "user", "password", "16.60.56.58",
- 7891, "/oo/rest/users" );
- assertUrl( "http://16.60.56.58:7891/oo/rest/users", "http", null, null, "16.60.56.58", 7891, "/oo/rest/users" );
- assertUrl( "http://user:password@16.60.56.58/oo/rest/users", "http", "user", "password", "16.60.56.58", -1,
- "/oo/rest/users" );
- assertUrl( "http://user:password@16.60.56.58:7891", "http", "user", "password", "16.60.56.58", 7891, "/" );
-
- assertUrl( "http://user:password@16.60.56.58:7891/oo/rest/users", "http", "user", "password", "16.60.56.58",
- 7891, "/oo/rest/users" );
- assertUrl( "http://16.60.56.58:7891/oo/rest/users", "http", null, null, "16.60.56.58", 7891, "/oo/rest/users" );
- assertUrl( "http://user:password@16.60.56.58/oo/rest/users", "http", "user", "password", "16.60.56.58", -1,
- "/oo/rest/users" );
- assertUrl( "http://user:password@16.60.56.58:7891", "http", "user", "password", "16.60.56.58", 7891, "/" );
- }
-
- private void assertUrl( String url, String protocol, String user, String password, String host, int port,
- String basedir )
- {
- assertEquals( protocol, PathUtils.protocol( url ) );
- assertEquals( user, PathUtils.user( url ) );
- assertEquals( password, PathUtils.password( url ) );
- assertEquals( host, PathUtils.host( url ) );
- assertEquals( port, PathUtils.port( url ) );
- assertEquals( basedir, PathUtils.basedir( url ) );
- }
-
- public void testToRelative()
- {
- assertEquals( "dir", PathUtils.toRelative( new File( "/home/user" ).getAbsoluteFile(),
- new File( "/home/user/dir" ).getAbsolutePath() ) );
- assertEquals( "dir", PathUtils.toRelative( new File( "C:/home/user" ).getAbsoluteFile(),
- new File( "C:/home/user/dir" ).getAbsolutePath() ) );
-
- assertEquals( "dir/subdir", PathUtils.toRelative( new File( "/home/user" ).getAbsoluteFile(),
- new File( "/home/user/dir/subdir" ).getAbsolutePath() ) );
- assertEquals( "dir/subdir", PathUtils.toRelative( new File( "C:/home/user" ).getAbsoluteFile(),
- new File( "C:/home/user/dir/subdir" ).getAbsolutePath() ) );
-
- assertEquals( ".", PathUtils.toRelative( new File( "/home/user" ).getAbsoluteFile(),
- new File( "/home/user" ).getAbsolutePath() ) );
- assertEquals( ".", PathUtils.toRelative( new File( "C:/home/user" ).getAbsoluteFile(),
- new File( "C:/home/user" ).getAbsolutePath() ) );
- }
-
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class PathUtilsTest
+ extends TestCase
+{
+ public void testFilenameResolving()
+ {
+ assertEquals( "filename", PathUtils.filename( "dir/filename" ) );
+
+ assertEquals( "filename", PathUtils.filename( "filename" ) );
+
+ assertEquals( "filename", PathUtils.filename( "dir1/dir2/filename" ) );
+ }
+
+ public void testDirResolving()
+ {
+ assertEquals( "dir", PathUtils.dirname( "dir/filename" ) );
+
+ assertEquals( "", PathUtils.dirname( "filename" ) );
+
+ assertEquals( "dir1/dir2", PathUtils.dirname( "dir1/dir2/filename" ) );
+ }
+
+ public void testDirSpliting()
+ {
+ final String path = "a/b/c";
+
+ final String[] dirs = PathUtils.dirnames( path );
+
+ assertNotNull( dirs );
+
+ assertEquals( 2, dirs.length );
+
+ assertEquals( "a", dirs[0] );
+
+ assertEquals( "b", dirs[1] );
+
+ }
+
+ public void testHostResolving()
+ {
+ assertEquals( "www.codehaus.org", PathUtils.host( "http://www.codehaus.org" ) );
+ assertEquals( "www.codehaus.org", PathUtils.host( "HTTP://www.codehaus.org" ) );
+
+ assertEquals( "localhost", PathUtils.host( null ) );
+ assertEquals( "localhost", PathUtils.host( "file:///c:/temp" ) );
+ assertEquals( "localhost", PathUtils.host( "FILE:///c:/temp" ) );
+
+ }
+
+ public void testScmHostResolving()
+ {
+ assertEquals( "www.codehaus.org", PathUtils.host( "scm:svn:http://www.codehaus.org" ) );
+ assertEquals( "www.codehaus.org", PathUtils.host( "SCM:SVN:HTTP://www.codehaus.org" ) );
+ assertEquals( "www.codehaus.org", PathUtils.host( "scm:svn:http://www.codehaus.org/repos/module" ) );
+ assertEquals( "www.codehaus.org", PathUtils.host( "SCM:SVN:HTTP://www.codehaus.org/repos/module" ) );
+ assertEquals( "www.codehaus.org", PathUtils.host( "scm:cvs:pserver:anoncvs at www.codehaus.org:/root" ) );
+ assertEquals( "www.codehaus.org", PathUtils.host( "SCM:CVS:pserver:anoncvs at www.codehaus.org:/root" ) );
+ }
+
+ public void testProtocolResolving()
+ {
+ assertEquals( "http", PathUtils.protocol( "http://www.codehause.org" ) );
+ assertEquals( "HTTP", PathUtils.protocol( "HTTP://www.codehause.org" ) );
+ assertEquals( "file", PathUtils.protocol( "file:///c:/temp" ) );
+ assertEquals( "scm", PathUtils.protocol( "scm:svn:http://localhost/repos/module" ) );
+ assertEquals( "scm", PathUtils.protocol( "scm:cvs:pserver:anoncvs at cvs.apache.org:/home/cvspublic" ) );
+ }
+
+ public void testUserInfo()
+ {
+ String urlWithUsername = "http://brett@www.codehaus.org";
+ assertEquals( "brett", PathUtils.user( urlWithUsername ) );
+ assertNull( PathUtils.password( urlWithUsername ) );
+ assertEquals( "www.codehaus.org", PathUtils.host( urlWithUsername ) );
+ assertEquals( "/", PathUtils.basedir( urlWithUsername ) );
+
+ String urlWithUsernamePassword = "http://brett:porter@www.codehaus.org";
+ assertEquals( "brett", PathUtils.user( urlWithUsernamePassword ) );
+ assertEquals( "porter", PathUtils.password( urlWithUsernamePassword ) );
+ assertEquals( "www.codehaus.org", PathUtils.host( urlWithUsernamePassword ) );
+ assertEquals( "/", PathUtils.basedir( urlWithUsernamePassword ) );
+ }
+
+ public void testSubversionUserInfo()
+ {
+ String urlWithUsername = "scm:svn:http://brett@www.codehaus.org";
+ assertEquals( "brett", PathUtils.user( urlWithUsername ) );
+ assertNull( PathUtils.password( urlWithUsername ) );
+ assertEquals( "www.codehaus.org", PathUtils.host( urlWithUsername ) );
+ assertEquals( "/", PathUtils.basedir( urlWithUsername ) );
+
+ String urlWithUsernamePassword = "scm:svn:http://brett:porter@www.codehaus.org";
+ assertEquals( "brett", PathUtils.user( urlWithUsernamePassword ) );
+ assertEquals( "porter", PathUtils.password( urlWithUsernamePassword ) );
+ assertEquals( "www.codehaus.org", PathUtils.host( urlWithUsernamePassword ) );
+ assertEquals( "/", PathUtils.basedir( urlWithUsernamePassword ) );
+
+ String urlWithUpperCaseProtocol = "SCM:SVN:HTTP://brett@www.codehaus.org";
+ assertEquals( "brett", PathUtils.user( urlWithUpperCaseProtocol ) );
+ assertNull( PathUtils.password( urlWithUpperCaseProtocol ) );
+ assertEquals( "www.codehaus.org", PathUtils.host( urlWithUpperCaseProtocol ) );
+ assertEquals( "/", PathUtils.basedir( urlWithUpperCaseProtocol ) );
+ }
+
+ public void testCvsUserInfo()
+ {
+ String urlWithUsername = "scm:cvs:pserver:brett at www.codehaus.org";
+ assertEquals( "brett", PathUtils.user( urlWithUsername ) );
+ assertNull( PathUtils.password( urlWithUsername ) );
+ assertEquals( "www.codehaus.org", PathUtils.host( urlWithUsername ) );
+ assertEquals( "/", PathUtils.basedir( urlWithUsername ) );
+
+ String urlWithUsernamePassword = "scm:cvs:pserver:brett:porter at www.codehaus.org";
+ assertEquals( "brett", PathUtils.user( urlWithUsernamePassword ) );
+ assertEquals( "porter", PathUtils.password( urlWithUsernamePassword ) );
+ assertEquals( "www.codehaus.org", PathUtils.host( urlWithUsernamePassword ) );
+ assertEquals( "/", PathUtils.basedir( urlWithUsernamePassword ) );
+
+ String urlWithUpperCaseProtocol = "SCM:CVS:pserver:brett at www.codehaus.org";
+ assertEquals( "brett", PathUtils.user( urlWithUpperCaseProtocol ) );
+ assertNull( PathUtils.password( urlWithUpperCaseProtocol ) );
+ assertEquals( "www.codehaus.org", PathUtils.host( urlWithUpperCaseProtocol ) );
+ assertEquals( "/", PathUtils.basedir( urlWithUpperCaseProtocol ) );
+ }
+
+ public void testFileBasedir()
+ {
+ // see http://www.mozilla.org/quality/networking/testing/filetests.html
+
+ // strict forms
+ assertEquals( "c:/temp", PathUtils.basedir( "file:///c|/temp" ) );
+ assertEquals( "localhost", PathUtils.host( "file:///c|/temp" ) );
+ assertEquals( "c:/temp", PathUtils.basedir( "file://localhost/c|/temp" ) );
+ assertEquals( "localhost", PathUtils.host( "file://localhost/c|/temp" ) );
+ assertEquals( "/temp", PathUtils.basedir( "file:///temp" ) );
+ assertEquals( "localhost", PathUtils.host( "file:///temp" ) );
+ assertEquals( "/temp", PathUtils.basedir( "file://localhost/temp" ) );
+ assertEquals( "localhost", PathUtils.host( "file://localhost/temp" ) );
+
+ // strict form, with : for drive separator
+ assertEquals( "c:/temp", PathUtils.basedir( "file:///c:/temp" ) );
+ assertEquals( "localhost", PathUtils.host( "file:///c:/temp" ) );
+ assertEquals( "c:/temp", PathUtils.basedir( "file://localhost/c:/temp" ) );
+ assertEquals( "localhost", PathUtils.host( "file://localhost/c:/temp" ) );
+
+ // convenience forms
+ assertEquals( "c:/temp", PathUtils.basedir( "file://c:/temp" ) );
+ assertEquals( "c:/temp", PathUtils.basedir( "file://c|/temp" ) );
+ assertEquals( "c:/temp", PathUtils.basedir( "file:c:/temp" ) );
+ assertEquals( "c:/temp", PathUtils.basedir( "file:c|/temp" ) );
+ assertEquals( "/temp", PathUtils.basedir( "file:/temp" ) );
+
+ // URL decoding
+ assertEquals( "c:/my docs", PathUtils.basedir( "file:///c:/my docs" ) );
+ assertEquals( "c:/my docs", PathUtils.basedir( "file:///c:/my%20docs" ) );
+ assertEquals( "c:/name #%20?{}[]<>.txt", PathUtils.basedir( "file:///c:/name%20%23%2520%3F%7B%7D%5B%5D%3C%3E.txt" ) );
+
+ assertEquals( "c:/temp", PathUtils.basedir( "FILE:///c:/temp" ) );
+ assertEquals( "localhost", PathUtils.host( "FILE:///c:/temp" ) );
+ }
+
+ public void testEmptyBasedir()
+ {
+ assertEquals( "/", PathUtils.basedir( "http://www.codehaus.org:80" ) );
+ assertEquals( "/", PathUtils.basedir( "http://www.codehaus.org" ) );
+ assertEquals( "/", PathUtils.basedir( "http://www.codehaus.org:80/" ) );
+ assertEquals( "/", PathUtils.basedir( "http://www.codehaus.org/" ) );
+ assertEquals( "/", PathUtils.basedir( "HTTP://www.codehaus.org/" ) );
+ }
+
+ public void testEmptyProtocol()
+ {
+ assertEquals( "", PathUtils.protocol( "placeholder-only" ) );
+ assertEquals( "", PathUtils.protocol( "placeholder-only/module-a" ) );
+
+ assertEquals( "placeholder-only", PathUtils.authorization( "placeholder-only" ) );
+ assertEquals( "placeholder-only", PathUtils.authorization( "placeholder-only/module-a" ) );
+
+ assertEquals( -1, PathUtils.port( "placeholder-only" ) );
+ assertEquals( -1, PathUtils.port( "placeholder-only/module-a" ) );
+
+ assertEquals( "/", PathUtils.basedir( "placeholder-only" ) );
+ assertEquals( "/module-a", PathUtils.basedir( "placeholder-only/module-a" ) );
+ }
+
+ public void testPortResolving()
+ {
+ assertEquals( 80, PathUtils.port( "http://www.codehause.org:80/maven" ) );
+ assertEquals( 80, PathUtils.port( "HTTP://www.codehause.org:80/maven" ) );
+ assertEquals( WagonConstants.UNKNOWN_PORT, PathUtils.port( "http://localhost/temp" ) );
+
+ assertEquals( 10, PathUtils.port( "ftp://localhost:10" ) );
+ assertEquals( 10, PathUtils.port( "FTP://localhost:10" ) );
+ }
+
+ public void testScmPortResolving()
+ {
+ assertEquals( 80, PathUtils.port( "scm:svn:http://www.codehaus.org:80/maven" ) );
+ assertEquals( 80, PathUtils.port( "SCM:SVN:HTTP://www.codehaus.org:80/maven" ) );
+ assertEquals( WagonConstants.UNKNOWN_PORT, PathUtils.port( "scm:cvs:pserver:anoncvs at localhost:/temp:module" ) );
+
+ assertEquals( 2402, PathUtils.port( "scm:cvs:pserver:anoncvs at localhost:2402/temp:module" ) );
+ assertEquals( 2402, PathUtils.port( "SCM:CVS:pserver:anoncvs at localhost:2402/temp:module" ) );
+ }
+
+ public void testScmBasedir()
+ {
+ assertEquals( "/maven", PathUtils.basedir( "scm:svn:http://www.codehause.org/maven" ) );
+ assertEquals( "/maven", PathUtils.basedir( "SCM:SVN:HTTP://www.codehause.org/maven" ) );
+ assertEquals( "/maven", PathUtils.basedir( "scm:svn:http://www.codehause.org:80/maven" ) );
+ assertEquals( "/maven", PathUtils.basedir( "scm:cvs:pserver:anoncvs at www.codehause.org:80/maven" ) );
+ assertEquals( "/maven", PathUtils.basedir( "scm:cvs:pserver:anoncvs at www.codehause.org:/maven" ) );
+ assertEquals( "/maven/module", PathUtils.basedir( "scm:cvs:pserver:anoncvs at www.codehause.org:80/maven:module" ) );
+ assertEquals( "/maven/module", PathUtils.basedir( "scm:cvs:pserver:anoncvs at www.codehause.org:/maven:module" ) );
+ assertEquals( "/maven/module", PathUtils.basedir( "SCM:CVS:pserver:anoncvs at www.codehause.org:/maven:module" ) );
+ }
+
+ public void testPortBasedir()
+ {
+ assertEquals( "/maven", PathUtils.basedir( "http://www.codehause.org:80/maven" ) );
+ assertEquals( "/temp", PathUtils.basedir( "http://localhost/temp" ) );
+
+ assertEquals( "c:/temp", PathUtils.basedir( "file://c:/temp" ) );
+ assertEquals( "/", PathUtils.basedir( "http://localhost:80/" ) );
+ assertEquals( "/", PathUtils.basedir( "http://localhost/" ) );
+ }
+
+ public void testIpV4()
+ {
+ assertUrl( "http://127.0.0.1", "http", null, null, "127.0.0.1", -1, "/" );
+ assertUrl( "http://127.0.0.1:8080", "http", null, null, "127.0.0.1", 8080, "/" );
+ assertUrl( "http://127.0.0.1/oo/rest/users", "http", null, null, "127.0.0.1", -1, "/oo/rest/users" );
+ assertUrl( "http://127.0.0.1:8080/oo/rest/users", "http", null, null, "127.0.0.1", 8080, "/oo/rest/users" );
+
+ assertUrl( "http://user:password@127.0.0.1", "http", "user", "password", "127.0.0.1", -1, "/" );
+ assertUrl( "http://user:password@127.0.0.1:8080", "http", "user", "password", "127.0.0.1", 8080, "/" );
+ assertUrl( "http://user:password@127.0.0.1/oo/rest/users", "http", "user", "password", "127.0.0.1", -1,
+ "/oo/rest/users" );
+ assertUrl( "http://user:password@127.0.0.1:8080/oo/rest/users", "http", "user", "password", "127.0.0.1", 8080,
+ "/oo/rest/users" );
+
+ assertUrl( "scm:svn:http://user:password@127.0.0.1:8080/oo/rest/users", "scm", "user", "password", "127.0.0.1",
+ 8080, "/oo/rest/users" );
+ }
+
+ public void testIPv6()
+ {
+ assertUrl( "http://user:password@[fff:::1]:7891/oo/rest/users", "http", "user", "password", "fff:::1", 7891,
+ "/oo/rest/users" );
+ assertUrl( "http://[fff:::1]:7891/oo/rest/users", "http", null, null, "fff:::1", 7891, "/oo/rest/users" );
+ assertUrl( "http://user:password@[fff:::1]/oo/rest/users", "http", "user", "password", "fff:::1", -1,
+ "/oo/rest/users" );
+ assertUrl( "http://user:password@[fff:::1]:7891", "http", "user", "password", "fff:::1", 7891, "/" );
+
+ assertUrl( "http://user:password@[fff:000::222:1111]:7891/oo/rest/users", "http", "user", "password",
+ "fff:000::222:1111", 7891, "/oo/rest/users" );
+ assertUrl( "http://[fff:000::222:1111]:7891/oo/rest/users", "http", null, null, "fff:000::222:1111", 7891,
+ "/oo/rest/users" );
+ assertUrl( "http://user:password@[fff:000::222:1111]/oo/rest/users", "http", "user", "password",
+ "fff:000::222:1111", -1, "/oo/rest/users" );
+ assertUrl( "http://user:password@[fff:000::222:1111]:7891", "http", "user", "password", "fff:000::222:1111",
+ 7891, "/" );
+
+ assertUrl( "http://user:password@16.60.56.58:7891/oo/rest/users", "http", "user", "password", "16.60.56.58",
+ 7891, "/oo/rest/users" );
+ assertUrl( "http://16.60.56.58:7891/oo/rest/users", "http", null, null, "16.60.56.58", 7891, "/oo/rest/users" );
+ assertUrl( "http://user:password@16.60.56.58/oo/rest/users", "http", "user", "password", "16.60.56.58", -1,
+ "/oo/rest/users" );
+ assertUrl( "http://user:password@16.60.56.58:7891", "http", "user", "password", "16.60.56.58", 7891, "/" );
+
+ assertUrl( "http://user:password@16.60.56.58:7891/oo/rest/users", "http", "user", "password", "16.60.56.58",
+ 7891, "/oo/rest/users" );
+ assertUrl( "http://16.60.56.58:7891/oo/rest/users", "http", null, null, "16.60.56.58", 7891, "/oo/rest/users" );
+ assertUrl( "http://user:password@16.60.56.58/oo/rest/users", "http", "user", "password", "16.60.56.58", -1,
+ "/oo/rest/users" );
+ assertUrl( "http://user:password@16.60.56.58:7891", "http", "user", "password", "16.60.56.58", 7891, "/" );
+ }
+
+ private void assertUrl( String url, String protocol, String user, String password, String host, int port,
+ String basedir )
+ {
+ assertEquals( protocol, PathUtils.protocol( url ) );
+ assertEquals( user, PathUtils.user( url ) );
+ assertEquals( password, PathUtils.password( url ) );
+ assertEquals( host, PathUtils.host( url ) );
+ assertEquals( port, PathUtils.port( url ) );
+ assertEquals( basedir, PathUtils.basedir( url ) );
+ }
+
+ public void testToRelative()
+ {
+ assertEquals( "dir", PathUtils.toRelative( new File( "/home/user" ).getAbsoluteFile(),
+ new File( "/home/user/dir" ).getAbsolutePath() ) );
+ assertEquals( "dir", PathUtils.toRelative( new File( "C:/home/user" ).getAbsoluteFile(),
+ new File( "C:/home/user/dir" ).getAbsolutePath() ) );
+
+ assertEquals( "dir/subdir", PathUtils.toRelative( new File( "/home/user" ).getAbsoluteFile(),
+ new File( "/home/user/dir/subdir" ).getAbsolutePath() ) );
+ assertEquals( "dir/subdir", PathUtils.toRelative( new File( "C:/home/user" ).getAbsoluteFile(),
+ new File( "C:/home/user/dir/subdir" ).getAbsolutePath() ) );
+
+ assertEquals( ".", PathUtils.toRelative( new File( "/home/user" ).getAbsoluteFile(),
+ new File( "/home/user" ).getAbsolutePath() ) );
+ assertEquals( ".", PathUtils.toRelative( new File( "C:/home/user" ).getAbsoluteFile(),
+ new File( "C:/home/user" ).getAbsolutePath() ) );
+ }
+
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/PermissionModeUtilsTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/PermissionModeUtilsTest.java
index 2dbc36f..dc13e30 100644
--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/PermissionModeUtilsTest.java
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/PermissionModeUtilsTest.java
@@ -1,70 +1,70 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-
-/**
- * Unit test for PermissionModeUtils class
- *
- * @author <a href="mailto:juam at users.sourceforge.net">Juan F. Codagnone</a>
- * @see PermissionModeUtils
- * @since Sep 3, 2005
- */
-public class PermissionModeUtilsTest
- extends TestCase
-{
- /**
- * @throws Exception on error
- */
- public void testNumeric()
- throws Exception
- {
- final String[][] tests = {
- {"0", "777"},
- {"0000", "777"},
- {"770", "7"},
- {"0770", "7"},
- {"0123", "654"},
- {"9", null},
- {"678", null},
- {"ug+rwX,o-rwX", "ug+rwX,o-rwX"},
- {"1770", "7"},
- {"14770", "7"},
-
- };
-
- for ( String[] test : tests )
- {
- String umask = null;
-
- try
- {
- umask = PermissionModeUtils.getUserMaskFor( test[ 0 ] );
- }
- catch ( IllegalArgumentException e )
- {
- // nothing to do
- }
-
- assertEquals( test[ 1 ], umask );
- }
- }
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * Unit test for PermissionModeUtils class
+ *
+ * @author <a href="mailto:juam at users.sourceforge.net">Juan F. Codagnone</a>
+ * @see PermissionModeUtils
+ * @since Sep 3, 2005
+ */
+public class PermissionModeUtilsTest
+ extends TestCase
+{
+ /**
+ * @throws Exception on error
+ */
+ public void testNumeric()
+ throws Exception
+ {
+ final String[][] tests = {
+ {"0", "777"},
+ {"0000", "777"},
+ {"770", "7"},
+ {"0770", "7"},
+ {"0123", "654"},
+ {"9", null},
+ {"678", null},
+ {"ug+rwX,o-rwX", "ug+rwX,o-rwX"},
+ {"1770", "7"},
+ {"14770", "7"},
+
+ };
+
+ for ( String[] test : tests )
+ {
+ String umask = null;
+
+ try
+ {
+ umask = PermissionModeUtils.getUserMaskFor( test[ 0 ] );
+ }
+ catch ( IllegalArgumentException e )
+ {
+ // nothing to do
+ }
+
+ assertEquals( test[ 1 ], umask );
+ }
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/ResourceDoesNotExistExceptionTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/ResourceDoesNotExistExceptionTest.java
index 5123113..dd2ebfe 100644
--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/ResourceDoesNotExistExceptionTest.java
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/ResourceDoesNotExistExceptionTest.java
@@ -1,43 +1,43 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-
-/**
- * @author <a href="mailto:jason at maven.org">Jason van Zyl</a>
- *
- */
-public class ResourceDoesNotExistExceptionTest
- extends TestCase
-{
- public void testResourceDoesNotExistExceptionTest()
- {
- ResourceDoesNotExistException ae = new ResourceDoesNotExistException( "message" );
-
- assertEquals( "message", ae.getMessage() );
-
- ae = new ResourceDoesNotExistException( "full-message", new Throwable( "cause" ) );
-
- assertEquals( "full-message", ae.getMessage() );
-
- assertEquals( "cause", ae.getCause().getMessage() );
- }
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:jason at maven.org">Jason van Zyl</a>
+ *
+ */
+public class ResourceDoesNotExistExceptionTest
+ extends TestCase
+{
+ public void testResourceDoesNotExistExceptionTest()
+ {
+ ResourceDoesNotExistException ae = new ResourceDoesNotExistException( "message" );
+
+ assertEquals( "message", ae.getMessage() );
+
+ ae = new ResourceDoesNotExistException( "full-message", new Throwable( "cause" ) );
+
+ assertEquals( "full-message", ae.getMessage() );
+
+ assertEquals( "cause", ae.getCause().getMessage() );
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/StreamWagonTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/StreamWagonTest.java
index 5904cbd..42d7afd 100644
--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/StreamWagonTest.java
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/StreamWagonTest.java
@@ -1,543 +1,543 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.io.IOException;
-import java.text.SimpleDateFormat;
-
-import junit.framework.TestCase;
-
-import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.authorization.AuthorizationException;
-import org.apache.maven.wagon.events.TransferEvent;
-import org.apache.maven.wagon.events.TransferListener;
-import org.apache.maven.wagon.repository.Repository;
-import org.apache.maven.wagon.resource.Resource;
-import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.StringInputStream;
-import org.codehaus.plexus.util.StringOutputStream;
-
-import static org.easymock.EasyMock.*;
-
-public class StreamWagonTest
- extends TestCase
-{
- private static class TestWagon
- extends StreamWagon
- {
- public void closeConnection()
- throws ConnectionException
- {
- }
-
- public void fillInputData( InputData inputData )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- }
-
- public void fillOutputData( OutputData outputData )
- throws TransferFailedException
- {
- }
-
- protected void openConnectionInternal()
- throws ConnectionException, AuthenticationException
- {
- }
- }
-
- private Repository repository = new Repository( "id", "url" );
-
- public void testNullInputStream()
- throws Exception
- {
- StreamingWagon wagon = new TestWagon()
- {
- public void fillInputData( InputData inputData )
- {
- inputData.setInputStream( null );
- }
- };
-
- TransferListener listener = createMock( TransferListener.class );
- listener.transferInitiated( anyObject( TransferEvent.class ) );
- TransferEvent transferEvent =
- new TransferEvent( wagon, new Resource( "resource" ), new TransferFailedException( "" ),
- TransferEvent.REQUEST_GET );
- listener.transferError( transferEvent );
- replay( listener );
-
- wagon.connect( repository );
- wagon.addTransferListener( listener );
- try
- {
- wagon.getToStream( "resource", new StringOutputStream() );
- fail();
- }
- catch ( TransferFailedException e )
- {
- assertTrue( true );
- }
- finally
- {
- wagon.disconnect();
- }
-
- verify( listener );
- }
-
- public void testNullOutputStream()
- throws Exception
- {
- StreamingWagon wagon = new TestWagon()
- {
- public void fillOutputData( OutputData inputData )
- {
- inputData.setOutputStream( null );
- }
- };
-
- TransferListener listener = createMock( TransferListener.class );
- listener.transferInitiated( anyObject( TransferEvent.class ) );
- TransferEvent transferEvent =
- new TransferEvent( wagon, new Resource( "resource" ), new TransferFailedException( "" ),
- TransferEvent.REQUEST_PUT );
- listener.transferError( transferEvent );
- replay( listener );
-
- wagon.connect( repository );
- wagon.addTransferListener( listener );
- try
- {
- wagon.putFromStream( new StringInputStream( "" ), "resource" );
- fail();
- }
- catch ( TransferFailedException e )
- {
- assertTrue( true );
- }
- finally
- {
- wagon.disconnect();
- }
-
- verify( listener );
- }
-
- public void testTransferFailedExceptionOnInput()
- throws Exception
- {
- try
- {
- runTestTransferError( new TransferFailedException( "" ) );
- fail();
- }
- catch ( TransferFailedException e )
- {
- assertTrue( true );
- }
- }
-
- public void testTransferFailedExceptionOnOutput()
- throws Exception
- {
- StreamingWagon wagon = new TestWagon()
- {
- public void fillOutputData( OutputData inputData )
- throws TransferFailedException
- {
- throw (TransferFailedException) new TransferFailedException( "" );
- }
- };
-
- TransferListener listener = createMock( TransferListener.class );
- listener.transferInitiated( anyObject( TransferEvent.class ) );
- TransferEvent transferEvent =
- new TransferEvent( wagon, new Resource( "resource" ), new TransferFailedException( "" ),
- TransferEvent.REQUEST_PUT );
- listener.transferError( transferEvent );
- replay( listener );
-
- wagon.connect( repository );
- wagon.addTransferListener( listener );
- try
- {
- wagon.putFromStream( new StringInputStream( "" ), "resource" );
- fail();
- }
- catch ( TransferFailedException e )
- {
- assertTrue( true );
- }
- finally
- {
- wagon.disconnect();
- verify( listener );
- }
- }
-
- public void testResourceDoesNotExistException()
- throws Exception
- {
- try
- {
- runTestTransferError( new ResourceDoesNotExistException( "" ) );
- fail();
- }
- catch ( ResourceDoesNotExistException e )
- {
- assertTrue( true );
- }
- }
-
- public void testAuthorizationException()
- throws Exception
- {
- try
- {
- runTestTransferError( new AuthorizationException( "" ) );
- fail();
- }
- catch ( AuthorizationException e )
- {
- assertTrue( true );
- }
- }
-
- private void runTestTransferError( final WagonException exception )
- throws ConnectionException, AuthenticationException, ResourceDoesNotExistException, AuthorizationException,
- TransferFailedException
- {
- StreamingWagon wagon = new TestWagon()
- {
- public void fillInputData( InputData inputData )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- if ( exception instanceof TransferFailedException )
- {
- throw (TransferFailedException) exception;
- }
- if ( exception instanceof ResourceDoesNotExistException )
- {
- throw (ResourceDoesNotExistException) exception;
- }
- if ( exception instanceof AuthorizationException )
- {
- throw (AuthorizationException) exception;
- }
- }
- };
-
- TransferListener listener = createMock( TransferListener.class );
- listener.transferInitiated( anyObject( TransferEvent.class ) );
- TransferEvent transferEvent =
- new TransferEvent( wagon, new Resource( "resource" ), exception, TransferEvent.REQUEST_GET );
- listener.transferError( transferEvent );
- replay( listener );
-
- wagon.connect( repository );
- wagon.addTransferListener( listener );
- try
- {
- wagon.getToStream( "resource", new StringOutputStream() );
- fail();
- }
- finally
- {
- wagon.disconnect();
- verify( listener );
- }
- }
-
- public void testGetIfNewerWithNewerResource()
- throws Exception
- {
- long resourceTime = System.currentTimeMillis();
- long comparisonTime = new SimpleDateFormat( "yyyy-MM-dd" ).parse( "2008-01-01" ).getTime();
- assertTrue( runTestGetIfNewer( resourceTime, comparisonTime ) );
- }
-
- public void testGetIfNewerWithOlderResource()
- throws Exception
- {
- long comparisonTime = System.currentTimeMillis();
- long resourceTime = new SimpleDateFormat( "yyyy-MM-dd" ).parse( "2008-01-01" ).getTime();
- assertFalse( runTestGetIfNewer( resourceTime, comparisonTime ) );
- }
-
- public void testGetIfNewerWithSameTimeResource()
- throws Exception
- {
- long resourceTime = new SimpleDateFormat( "yyyy-MM-dd" ).parse( "2008-01-01" ).getTime();
- assertFalse( runTestGetIfNewer( resourceTime, resourceTime ) );
- }
-
- private boolean runTestGetIfNewer( final long resourceTime, long comparisonTime )
- throws IOException, ConnectionException, AuthenticationException, TransferFailedException,
- ResourceDoesNotExistException, AuthorizationException
- {
- StreamingWagon wagon = new TestWagon()
- {
- public void fillInputData( InputData inputData )
- {
- inputData.setInputStream( new StringInputStream( "" ) );
- inputData.getResource().setLastModified( resourceTime );
- }
- };
-
- File tempFile = File.createTempFile( "wagon", "tmp" );
- tempFile.deleteOnExit();
-
- wagon.connect( repository );
- try
- {
- return wagon.getIfNewer( "resource", tempFile, comparisonTime );
- }
- finally
- {
- wagon.disconnect();
- tempFile.delete();
- }
- }
-
- public void testGetToStream()
- throws Exception
- {
- final String content = "the content to return";
- final long comparisonTime = new SimpleDateFormat( "yyyy-MM-dd" ).parse( "2008-01-01" ).getTime();
- StreamingWagon wagon = new TestWagon()
- {
- public void fillInputData( InputData inputData )
- {
- inputData.setInputStream( new StringInputStream( content ) );
- inputData.getResource().setLastModified( comparisonTime );
- }
- };
-
- wagon.connect( repository );
- try
- {
- StringOutputStream out = new StringOutputStream();
- wagon.getToStream( "resource", out );
- assertEquals( content, out.toString() );
- }
- finally
- {
- wagon.disconnect();
- }
- }
-
- public void testGet()
- throws Exception
- {
- final String content = "the content to return";
- final long comparisonTime = new SimpleDateFormat( "yyyy-MM-dd" ).parse( "2008-01-01" ).getTime();
- StreamingWagon wagon = new TestWagon()
- {
- public void fillInputData( InputData inputData )
- {
- inputData.setInputStream( new StringInputStream( content ) );
- inputData.getResource().setLastModified( comparisonTime );
- }
- };
-
- File tempFile = File.createTempFile( "wagon", "tmp" );
- tempFile.deleteOnExit();
-
- wagon.connect( repository );
- try
- {
- wagon.get( "resource", tempFile );
- assertEquals( content, FileUtils.fileRead( tempFile ) );
- }
- finally
- {
- wagon.disconnect();
- tempFile.delete();
- }
- }
-
- public void testGetIfNewerToStreamWithNewerResource()
- throws Exception
- {
- long resourceTime = System.currentTimeMillis();
- long comparisonTime = new SimpleDateFormat( "yyyy-MM-dd" ).parse( "2008-01-01" ).getTime();
- assertTrue( runTestGetIfNewerToStream( resourceTime, comparisonTime ) );
- }
-
- public void testGetIfNewerToStreamWithOlderResource()
- throws Exception
- {
- long comparisonTime = System.currentTimeMillis();
- long resourceTime = new SimpleDateFormat( "yyyy-MM-dd" ).parse( "2008-01-01" ).getTime();
- assertFalse( runTestGetIfNewerToStream( resourceTime, comparisonTime ) );
- }
-
- public void testGetIfNewerToStreamWithSameTimeResource()
- throws Exception
- {
- long resourceTime = new SimpleDateFormat( "yyyy-MM-dd" ).parse( "2008-01-01" ).getTime();
- assertFalse( runTestGetIfNewerToStream( resourceTime, resourceTime ) );
- }
-
- private boolean runTestGetIfNewerToStream( final long resourceTime, long comparisonTime )
- throws IOException, ConnectionException, AuthenticationException, TransferFailedException,
- ResourceDoesNotExistException, AuthorizationException
- {
- StreamingWagon wagon = new TestWagon()
- {
- public void fillInputData( InputData inputData )
- {
- inputData.setInputStream( new StringInputStream( "" ) );
- inputData.getResource().setLastModified( resourceTime );
- }
- };
-
- wagon.connect( repository );
- try
- {
- return wagon.getIfNewerToStream( "resource", new StringOutputStream(), comparisonTime );
- }
- finally
- {
- wagon.disconnect();
- }
- }
-
- public void testPutFromStream()
- throws Exception
- {
- final String content = "the content to return";
-
- final StringOutputStream out = new StringOutputStream();
- StreamingWagon wagon = new TestWagon()
- {
- public void fillOutputData( OutputData outputData )
- {
- assertEquals( "resource", outputData.getResource().getName() );
- assertEquals( -1, outputData.getResource().getContentLength() );
- assertEquals( 0, outputData.getResource().getLastModified() );
- outputData.setOutputStream( out );
- }
- };
-
- wagon.connect( repository );
- try
- {
- wagon.putFromStream( new StringInputStream( content ), "resource" );
- assertEquals( content, out.toString() );
- }
- finally
- {
- wagon.disconnect();
- }
- }
-
- public void testPutFromStreamWithResourceInformation()
- throws Exception
- {
- final String content = "the content to return";
- final long lastModified = System.currentTimeMillis();
-
- final StringOutputStream out = new StringOutputStream();
- StreamingWagon wagon = new TestWagon()
- {
- public void fillOutputData( OutputData outputData )
- {
- assertEquals( "resource", outputData.getResource().getName() );
- assertEquals( content.length(), outputData.getResource().getContentLength() );
- assertEquals( lastModified, outputData.getResource().getLastModified() );
- outputData.setOutputStream( out );
- }
- };
-
- wagon.connect( repository );
- try
- {
- wagon.putFromStream( new StringInputStream( content ), "resource", content.length(), lastModified );
- assertEquals( content, out.toString() );
- }
- finally
- {
- wagon.disconnect();
- }
- }
-
- public void testPut()
- throws Exception
- {
- final String content = "the content to return";
-
- final File tempFile = File.createTempFile( "wagon", "tmp" );
- FileUtils.fileWrite( tempFile.getAbsolutePath(), content );
- tempFile.deleteOnExit();
-
- final StringOutputStream out = new StringOutputStream();
- Wagon wagon = new TestWagon()
- {
- public void fillOutputData( OutputData outputData )
- {
- assertEquals( "resource", outputData.getResource().getName() );
- assertEquals( content.length(), outputData.getResource().getContentLength() );
- assertEquals( tempFile.lastModified(), outputData.getResource().getLastModified() );
- outputData.setOutputStream( out );
- }
- };
-
- wagon.connect( repository );
- try
- {
- wagon.put( tempFile, "resource" );
- assertEquals( content, out.toString() );
- }
- finally
- {
- wagon.disconnect();
- tempFile.delete();
- }
- }
-
- public void testPutFileDoesntExist()
- throws Exception
- {
- final File tempFile = File.createTempFile( "wagon", "tmp" );
- tempFile.delete();
- assertFalse( tempFile.exists() );
-
- Wagon wagon = new TestWagon();
-
- wagon.connect( repository );
- try
- {
- wagon.put( tempFile, "resource" );
- fail();
- }
- catch ( TransferFailedException e )
- {
- assertTrue( true );
- }
- finally
- {
- wagon.disconnect();
- }
- }
-
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+
+import junit.framework.TestCase;
+
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.events.TransferListener;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.resource.Resource;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.StringInputStream;
+import org.codehaus.plexus.util.StringOutputStream;
+
+import static org.easymock.EasyMock.*;
+
+public class StreamWagonTest
+ extends TestCase
+{
+ private static class TestWagon
+ extends StreamWagon
+ {
+ public void closeConnection()
+ throws ConnectionException
+ {
+ }
+
+ public void fillInputData( InputData inputData )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ }
+
+ public void fillOutputData( OutputData outputData )
+ throws TransferFailedException
+ {
+ }
+
+ protected void openConnectionInternal()
+ throws ConnectionException, AuthenticationException
+ {
+ }
+ }
+
+ private Repository repository = new Repository( "id", "url" );
+
+ public void testNullInputStream()
+ throws Exception
+ {
+ StreamingWagon wagon = new TestWagon()
+ {
+ public void fillInputData( InputData inputData )
+ {
+ inputData.setInputStream( null );
+ }
+ };
+
+ TransferListener listener = createMock( TransferListener.class );
+ listener.transferInitiated( anyObject( TransferEvent.class ) );
+ TransferEvent transferEvent =
+ new TransferEvent( wagon, new Resource( "resource" ), new TransferFailedException( "" ),
+ TransferEvent.REQUEST_GET );
+ listener.transferError( transferEvent );
+ replay( listener );
+
+ wagon.connect( repository );
+ wagon.addTransferListener( listener );
+ try
+ {
+ wagon.getToStream( "resource", new StringOutputStream() );
+ fail();
+ }
+ catch ( TransferFailedException e )
+ {
+ assertTrue( true );
+ }
+ finally
+ {
+ wagon.disconnect();
+ }
+
+ verify( listener );
+ }
+
+ public void testNullOutputStream()
+ throws Exception
+ {
+ StreamingWagon wagon = new TestWagon()
+ {
+ public void fillOutputData( OutputData inputData )
+ {
+ inputData.setOutputStream( null );
+ }
+ };
+
+ TransferListener listener = createMock( TransferListener.class );
+ listener.transferInitiated( anyObject( TransferEvent.class ) );
+ TransferEvent transferEvent =
+ new TransferEvent( wagon, new Resource( "resource" ), new TransferFailedException( "" ),
+ TransferEvent.REQUEST_PUT );
+ listener.transferError( transferEvent );
+ replay( listener );
+
+ wagon.connect( repository );
+ wagon.addTransferListener( listener );
+ try
+ {
+ wagon.putFromStream( new StringInputStream( "" ), "resource" );
+ fail();
+ }
+ catch ( TransferFailedException e )
+ {
+ assertTrue( true );
+ }
+ finally
+ {
+ wagon.disconnect();
+ }
+
+ verify( listener );
+ }
+
+ public void testTransferFailedExceptionOnInput()
+ throws Exception
+ {
+ try
+ {
+ runTestTransferError( new TransferFailedException( "" ) );
+ fail();
+ }
+ catch ( TransferFailedException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+ public void testTransferFailedExceptionOnOutput()
+ throws Exception
+ {
+ StreamingWagon wagon = new TestWagon()
+ {
+ public void fillOutputData( OutputData inputData )
+ throws TransferFailedException
+ {
+ throw (TransferFailedException) new TransferFailedException( "" );
+ }
+ };
+
+ TransferListener listener = createMock( TransferListener.class );
+ listener.transferInitiated( anyObject( TransferEvent.class ) );
+ TransferEvent transferEvent =
+ new TransferEvent( wagon, new Resource( "resource" ), new TransferFailedException( "" ),
+ TransferEvent.REQUEST_PUT );
+ listener.transferError( transferEvent );
+ replay( listener );
+
+ wagon.connect( repository );
+ wagon.addTransferListener( listener );
+ try
+ {
+ wagon.putFromStream( new StringInputStream( "" ), "resource" );
+ fail();
+ }
+ catch ( TransferFailedException e )
+ {
+ assertTrue( true );
+ }
+ finally
+ {
+ wagon.disconnect();
+ verify( listener );
+ }
+ }
+
+ public void testResourceDoesNotExistException()
+ throws Exception
+ {
+ try
+ {
+ runTestTransferError( new ResourceDoesNotExistException( "" ) );
+ fail();
+ }
+ catch ( ResourceDoesNotExistException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+ public void testAuthorizationException()
+ throws Exception
+ {
+ try
+ {
+ runTestTransferError( new AuthorizationException( "" ) );
+ fail();
+ }
+ catch ( AuthorizationException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+ private void runTestTransferError( final WagonException exception )
+ throws ConnectionException, AuthenticationException, ResourceDoesNotExistException, AuthorizationException,
+ TransferFailedException
+ {
+ StreamingWagon wagon = new TestWagon()
+ {
+ public void fillInputData( InputData inputData )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ if ( exception instanceof TransferFailedException )
+ {
+ throw (TransferFailedException) exception;
+ }
+ if ( exception instanceof ResourceDoesNotExistException )
+ {
+ throw (ResourceDoesNotExistException) exception;
+ }
+ if ( exception instanceof AuthorizationException )
+ {
+ throw (AuthorizationException) exception;
+ }
+ }
+ };
+
+ TransferListener listener = createMock( TransferListener.class );
+ listener.transferInitiated( anyObject( TransferEvent.class ) );
+ TransferEvent transferEvent =
+ new TransferEvent( wagon, new Resource( "resource" ), exception, TransferEvent.REQUEST_GET );
+ listener.transferError( transferEvent );
+ replay( listener );
+
+ wagon.connect( repository );
+ wagon.addTransferListener( listener );
+ try
+ {
+ wagon.getToStream( "resource", new StringOutputStream() );
+ fail();
+ }
+ finally
+ {
+ wagon.disconnect();
+ verify( listener );
+ }
+ }
+
+ public void testGetIfNewerWithNewerResource()
+ throws Exception
+ {
+ long resourceTime = System.currentTimeMillis();
+ long comparisonTime = new SimpleDateFormat( "yyyy-MM-dd" ).parse( "2008-01-01" ).getTime();
+ assertTrue( runTestGetIfNewer( resourceTime, comparisonTime ) );
+ }
+
+ public void testGetIfNewerWithOlderResource()
+ throws Exception
+ {
+ long comparisonTime = System.currentTimeMillis();
+ long resourceTime = new SimpleDateFormat( "yyyy-MM-dd" ).parse( "2008-01-01" ).getTime();
+ assertFalse( runTestGetIfNewer( resourceTime, comparisonTime ) );
+ }
+
+ public void testGetIfNewerWithSameTimeResource()
+ throws Exception
+ {
+ long resourceTime = new SimpleDateFormat( "yyyy-MM-dd" ).parse( "2008-01-01" ).getTime();
+ assertFalse( runTestGetIfNewer( resourceTime, resourceTime ) );
+ }
+
+ private boolean runTestGetIfNewer( final long resourceTime, long comparisonTime )
+ throws IOException, ConnectionException, AuthenticationException, TransferFailedException,
+ ResourceDoesNotExistException, AuthorizationException
+ {
+ StreamingWagon wagon = new TestWagon()
+ {
+ public void fillInputData( InputData inputData )
+ {
+ inputData.setInputStream( new StringInputStream( "" ) );
+ inputData.getResource().setLastModified( resourceTime );
+ }
+ };
+
+ File tempFile = File.createTempFile( "wagon", "tmp" );
+ tempFile.deleteOnExit();
+
+ wagon.connect( repository );
+ try
+ {
+ return wagon.getIfNewer( "resource", tempFile, comparisonTime );
+ }
+ finally
+ {
+ wagon.disconnect();
+ tempFile.delete();
+ }
+ }
+
+ public void testGetToStream()
+ throws Exception
+ {
+ final String content = "the content to return";
+ final long comparisonTime = new SimpleDateFormat( "yyyy-MM-dd" ).parse( "2008-01-01" ).getTime();
+ StreamingWagon wagon = new TestWagon()
+ {
+ public void fillInputData( InputData inputData )
+ {
+ inputData.setInputStream( new StringInputStream( content ) );
+ inputData.getResource().setLastModified( comparisonTime );
+ }
+ };
+
+ wagon.connect( repository );
+ try
+ {
+ StringOutputStream out = new StringOutputStream();
+ wagon.getToStream( "resource", out );
+ assertEquals( content, out.toString() );
+ }
+ finally
+ {
+ wagon.disconnect();
+ }
+ }
+
+ public void testGet()
+ throws Exception
+ {
+ final String content = "the content to return";
+ final long comparisonTime = new SimpleDateFormat( "yyyy-MM-dd" ).parse( "2008-01-01" ).getTime();
+ StreamingWagon wagon = new TestWagon()
+ {
+ public void fillInputData( InputData inputData )
+ {
+ inputData.setInputStream( new StringInputStream( content ) );
+ inputData.getResource().setLastModified( comparisonTime );
+ }
+ };
+
+ File tempFile = File.createTempFile( "wagon", "tmp" );
+ tempFile.deleteOnExit();
+
+ wagon.connect( repository );
+ try
+ {
+ wagon.get( "resource", tempFile );
+ assertEquals( content, FileUtils.fileRead( tempFile ) );
+ }
+ finally
+ {
+ wagon.disconnect();
+ tempFile.delete();
+ }
+ }
+
+ public void testGetIfNewerToStreamWithNewerResource()
+ throws Exception
+ {
+ long resourceTime = System.currentTimeMillis();
+ long comparisonTime = new SimpleDateFormat( "yyyy-MM-dd" ).parse( "2008-01-01" ).getTime();
+ assertTrue( runTestGetIfNewerToStream( resourceTime, comparisonTime ) );
+ }
+
+ public void testGetIfNewerToStreamWithOlderResource()
+ throws Exception
+ {
+ long comparisonTime = System.currentTimeMillis();
+ long resourceTime = new SimpleDateFormat( "yyyy-MM-dd" ).parse( "2008-01-01" ).getTime();
+ assertFalse( runTestGetIfNewerToStream( resourceTime, comparisonTime ) );
+ }
+
+ public void testGetIfNewerToStreamWithSameTimeResource()
+ throws Exception
+ {
+ long resourceTime = new SimpleDateFormat( "yyyy-MM-dd" ).parse( "2008-01-01" ).getTime();
+ assertFalse( runTestGetIfNewerToStream( resourceTime, resourceTime ) );
+ }
+
+ private boolean runTestGetIfNewerToStream( final long resourceTime, long comparisonTime )
+ throws IOException, ConnectionException, AuthenticationException, TransferFailedException,
+ ResourceDoesNotExistException, AuthorizationException
+ {
+ StreamingWagon wagon = new TestWagon()
+ {
+ public void fillInputData( InputData inputData )
+ {
+ inputData.setInputStream( new StringInputStream( "" ) );
+ inputData.getResource().setLastModified( resourceTime );
+ }
+ };
+
+ wagon.connect( repository );
+ try
+ {
+ return wagon.getIfNewerToStream( "resource", new StringOutputStream(), comparisonTime );
+ }
+ finally
+ {
+ wagon.disconnect();
+ }
+ }
+
+ public void testPutFromStream()
+ throws Exception
+ {
+ final String content = "the content to return";
+
+ final StringOutputStream out = new StringOutputStream();
+ StreamingWagon wagon = new TestWagon()
+ {
+ public void fillOutputData( OutputData outputData )
+ {
+ assertEquals( "resource", outputData.getResource().getName() );
+ assertEquals( -1, outputData.getResource().getContentLength() );
+ assertEquals( 0, outputData.getResource().getLastModified() );
+ outputData.setOutputStream( out );
+ }
+ };
+
+ wagon.connect( repository );
+ try
+ {
+ wagon.putFromStream( new StringInputStream( content ), "resource" );
+ assertEquals( content, out.toString() );
+ }
+ finally
+ {
+ wagon.disconnect();
+ }
+ }
+
+ public void testPutFromStreamWithResourceInformation()
+ throws Exception
+ {
+ final String content = "the content to return";
+ final long lastModified = System.currentTimeMillis();
+
+ final StringOutputStream out = new StringOutputStream();
+ StreamingWagon wagon = new TestWagon()
+ {
+ public void fillOutputData( OutputData outputData )
+ {
+ assertEquals( "resource", outputData.getResource().getName() );
+ assertEquals( content.length(), outputData.getResource().getContentLength() );
+ assertEquals( lastModified, outputData.getResource().getLastModified() );
+ outputData.setOutputStream( out );
+ }
+ };
+
+ wagon.connect( repository );
+ try
+ {
+ wagon.putFromStream( new StringInputStream( content ), "resource", content.length(), lastModified );
+ assertEquals( content, out.toString() );
+ }
+ finally
+ {
+ wagon.disconnect();
+ }
+ }
+
+ public void testPut()
+ throws Exception
+ {
+ final String content = "the content to return";
+
+ final File tempFile = File.createTempFile( "wagon", "tmp" );
+ FileUtils.fileWrite( tempFile.getAbsolutePath(), content );
+ tempFile.deleteOnExit();
+
+ final StringOutputStream out = new StringOutputStream();
+ Wagon wagon = new TestWagon()
+ {
+ public void fillOutputData( OutputData outputData )
+ {
+ assertEquals( "resource", outputData.getResource().getName() );
+ assertEquals( content.length(), outputData.getResource().getContentLength() );
+ assertEquals( tempFile.lastModified(), outputData.getResource().getLastModified() );
+ outputData.setOutputStream( out );
+ }
+ };
+
+ wagon.connect( repository );
+ try
+ {
+ wagon.put( tempFile, "resource" );
+ assertEquals( content, out.toString() );
+ }
+ finally
+ {
+ wagon.disconnect();
+ tempFile.delete();
+ }
+ }
+
+ public void testPutFileDoesntExist()
+ throws Exception
+ {
+ final File tempFile = File.createTempFile( "wagon", "tmp" );
+ tempFile.delete();
+ assertFalse( tempFile.exists() );
+
+ Wagon wagon = new TestWagon();
+
+ wagon.connect( repository );
+ try
+ {
+ wagon.put( tempFile, "resource" );
+ fail();
+ }
+ catch ( TransferFailedException e )
+ {
+ assertTrue( true );
+ }
+ finally
+ {
+ wagon.disconnect();
+ }
+ }
+
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/TransferFailedExceptionTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/TransferFailedExceptionTest.java
index dd12218..84881a1 100644
--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/TransferFailedExceptionTest.java
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/TransferFailedExceptionTest.java
@@ -1,43 +1,43 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-
-/**
- * @author <a href="mailto:jason at maven.org">Jason van Zyl</a>
- *
- */
-public class TransferFailedExceptionTest
- extends TestCase
-{
- public void testTransferFailedExceptionTest()
- {
- TransferFailedException ae = new TransferFailedException( "message" );
-
- assertEquals( "message", ae.getMessage() );
-
- ae = new TransferFailedException( "full-message", new Throwable( "cause" ) );
-
- assertEquals( "full-message", ae.getMessage() );
-
- assertEquals( "cause", ae.getCause().getMessage() );
- }
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:jason at maven.org">Jason van Zyl</a>
+ *
+ */
+public class TransferFailedExceptionTest
+ extends TestCase
+{
+ public void testTransferFailedExceptionTest()
+ {
+ TransferFailedException ae = new TransferFailedException( "message" );
+
+ assertEquals( "message", ae.getMessage() );
+
+ ae = new TransferFailedException( "full-message", new Throwable( "cause" ) );
+
+ assertEquals( "full-message", ae.getMessage() );
+
+ assertEquals( "cause", ae.getCause().getMessage() );
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/WagonMock.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/WagonMock.java
index 311b21a..390c297 100644
--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/WagonMock.java
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/WagonMock.java
@@ -1,130 +1,130 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Collections;
-import java.util.List;
-
-import org.apache.maven.wagon.authorization.AuthorizationException;
-
-/**
- * @author <a href="mailto:jason at maven.org">Jason van Zyl</a>
- *
- */
-public class WagonMock
- extends StreamWagon
-{
- private boolean errorInputStream;
- private int timeout = 0;
-
- public WagonMock()
- {
- }
-
- public WagonMock( boolean errorInputStream )
- {
- this.errorInputStream = errorInputStream;
- }
-
-
- public void fillInputData( InputData inputData )
- throws TransferFailedException
- {
-
- InputStream is;
-
- if ( errorInputStream )
- {
- InputStreamMock mockInputStream = new InputStreamMock();
-
- mockInputStream.setForcedError( true );
-
- is = mockInputStream;
-
- }
- else
- {
- byte[] buffer = new byte[1024 * 4 * 5];
-
- is = new ByteArrayInputStream( buffer );
- }
-
- inputData.setInputStream( is );
-
- }
-
- public void fillOutputData( OutputData outputData )
- throws TransferFailedException
- {
-
- OutputStream os;
-
- if ( errorInputStream )
- {
- OutputStreamMock mockOutputStream = new OutputStreamMock();
-
- mockOutputStream.setForcedError( true );
-
- os = mockOutputStream;
- }
- else
- {
- os = new ByteArrayOutputStream();
- }
-
- outputData.setOutputStream( os );
-
- }
-
- public void openConnectionInternal()
- {
- }
-
- public void closeConnection()
- {
- }
-
- public void setTimeout( int timeoutValue )
- {
- timeout = timeoutValue;
- }
-
- public int getTimeout()
- {
- return timeout;
- }
-
- public List<String> getFileList( String destinationDirectory )
- throws TransferFailedException, AuthorizationException
- {
- return Collections.<String>emptyList();
- }
-
- public boolean resourceExists( String resourceName )
- throws AuthorizationException
- {
- return false;
- }
-
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.maven.wagon.authorization.AuthorizationException;
+
+/**
+ * @author <a href="mailto:jason at maven.org">Jason van Zyl</a>
+ *
+ */
+public class WagonMock
+ extends StreamWagon
+{
+ private boolean errorInputStream;
+ private int timeout = 0;
+
+ public WagonMock()
+ {
+ }
+
+ public WagonMock( boolean errorInputStream )
+ {
+ this.errorInputStream = errorInputStream;
+ }
+
+
+ public void fillInputData( InputData inputData )
+ throws TransferFailedException
+ {
+
+ InputStream is;
+
+ if ( errorInputStream )
+ {
+ InputStreamMock mockInputStream = new InputStreamMock();
+
+ mockInputStream.setForcedError( true );
+
+ is = mockInputStream;
+
+ }
+ else
+ {
+ byte[] buffer = new byte[1024 * 4 * 5];
+
+ is = new ByteArrayInputStream( buffer );
+ }
+
+ inputData.setInputStream( is );
+
+ }
+
+ public void fillOutputData( OutputData outputData )
+ throws TransferFailedException
+ {
+
+ OutputStream os;
+
+ if ( errorInputStream )
+ {
+ OutputStreamMock mockOutputStream = new OutputStreamMock();
+
+ mockOutputStream.setForcedError( true );
+
+ os = mockOutputStream;
+ }
+ else
+ {
+ os = new ByteArrayOutputStream();
+ }
+
+ outputData.setOutputStream( os );
+
+ }
+
+ public void openConnectionInternal()
+ {
+ }
+
+ public void closeConnection()
+ {
+ }
+
+ public void setTimeout( int timeoutValue )
+ {
+ timeout = timeoutValue;
+ }
+
+ public int getTimeout()
+ {
+ return timeout;
+ }
+
+ public List<String> getFileList( String destinationDirectory )
+ throws TransferFailedException, AuthorizationException
+ {
+ return Collections.<String>emptyList();
+ }
+
+ public boolean resourceExists( String resourceName )
+ throws AuthorizationException
+ {
+ return false;
+ }
+
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/authentication/AuthenticationExceptionTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/authentication/AuthenticationExceptionTest.java
index a8d7e73..a33a04f 100644
--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/authentication/AuthenticationExceptionTest.java
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/authentication/AuthenticationExceptionTest.java
@@ -1,43 +1,43 @@
-package org.apache.maven.wagon.authentication;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-
-/**
- * @author <a href="mailto:jason at maven.org">Jason van Zyl</a>
- *
- */
-public class AuthenticationExceptionTest
- extends TestCase
-{
- public void testAuthenticationExceptionTest()
- {
- AuthenticationException ae = new AuthenticationException( "message" );
-
- assertEquals( "message", ae.getMessage() );
-
- ae = new AuthenticationException( "full-message", new Throwable( "cause" ) );
-
- assertEquals( "full-message", ae.getMessage() );
-
- assertEquals( "cause", ae.getCause().getMessage() );
- }
-}
+package org.apache.maven.wagon.authentication;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:jason at maven.org">Jason van Zyl</a>
+ *
+ */
+public class AuthenticationExceptionTest
+ extends TestCase
+{
+ public void testAuthenticationExceptionTest()
+ {
+ AuthenticationException ae = new AuthenticationException( "message" );
+
+ assertEquals( "message", ae.getMessage() );
+
+ ae = new AuthenticationException( "full-message", new Throwable( "cause" ) );
+
+ assertEquals( "full-message", ae.getMessage() );
+
+ assertEquals( "cause", ae.getCause().getMessage() );
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/authentication/AuthenticationInfoTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/authentication/AuthenticationInfoTest.java
index d65207d..4b306b0 100644
--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/authentication/AuthenticationInfoTest.java
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/authentication/AuthenticationInfoTest.java
@@ -1,69 +1,69 @@
-package org.apache.maven.wagon.authentication;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-
-/**
- * @author <a href="mailto:jvanzyl at maven.org">Jason van Zyl</a>
- *
- * @todo test defaults
- */
-public class AuthenticationInfoTest
- extends TestCase
-{
- public AuthenticationInfoTest( final String name )
- {
- super( name );
- }
-
- public void setUp()
- throws Exception
- {
- super.setUp();
- }
-
- public void tearDown()
- throws Exception
- {
- super.tearDown();
- }
-
- public void testAuthenticationInfoProperties()
- {
- final AuthenticationInfo authenticationInfo = new AuthenticationInfo();
-
- authenticationInfo.setUserName( "username" );
-
- assertEquals( "username", authenticationInfo.getUserName() );
-
- authenticationInfo.setPassword( "password" );
-
- assertEquals( "password", authenticationInfo.getPassword() );
-
- authenticationInfo.setPassphrase( "passphrase" );
-
- assertEquals( "passphrase", authenticationInfo.getPassphrase() );
-
- authenticationInfo.setPrivateKey( "privatekey" );
-
- assertEquals( "privatekey", authenticationInfo.getPrivateKey() );
- }
-}
+package org.apache.maven.wagon.authentication;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:jvanzyl at maven.org">Jason van Zyl</a>
+ *
+ * @todo test defaults
+ */
+public class AuthenticationInfoTest
+ extends TestCase
+{
+ public AuthenticationInfoTest( final String name )
+ {
+ super( name );
+ }
+
+ public void setUp()
+ throws Exception
+ {
+ super.setUp();
+ }
+
+ public void tearDown()
+ throws Exception
+ {
+ super.tearDown();
+ }
+
+ public void testAuthenticationInfoProperties()
+ {
+ final AuthenticationInfo authenticationInfo = new AuthenticationInfo();
+
+ authenticationInfo.setUserName( "username" );
+
+ assertEquals( "username", authenticationInfo.getUserName() );
+
+ authenticationInfo.setPassword( "password" );
+
+ assertEquals( "password", authenticationInfo.getPassword() );
+
+ authenticationInfo.setPassphrase( "passphrase" );
+
+ assertEquals( "passphrase", authenticationInfo.getPassphrase() );
+
+ authenticationInfo.setPrivateKey( "privatekey" );
+
+ assertEquals( "privatekey", authenticationInfo.getPrivateKey() );
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/SessionEventSupportTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/SessionEventSupportTest.java
index eca243a..345cfe7 100644
--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/SessionEventSupportTest.java
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/SessionEventSupportTest.java
@@ -1,257 +1,257 @@
-package org.apache.maven.wagon.events;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-
-import org.apache.maven.wagon.Wagon;
-
-import static org.easymock.EasyMock.*;
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class SessionEventSupportTest
- extends TestCase
-{
-
- private SessionEventSupport eventSupport;
-
- private Wagon wagon;
-
- /**
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp()
- throws Exception
- {
- super.setUp();
-
- eventSupport = new SessionEventSupport();
-
- // TODO: actually test it gets called?
- wagon = createNiceMock( Wagon.class );
- }
-
- public void testSessionListenerRegistration()
- {
- SessionListener mock1 = createMock( SessionListener.class );
-
- eventSupport.addSessionListener( mock1 );
-
- assertTrue( eventSupport.hasSessionListener( mock1 ) );
-
- SessionListener mock2 = createMock( SessionListener.class );
-
- assertFalse( eventSupport.hasSessionListener( mock2 ) );
-
- eventSupport.addSessionListener( mock2 );
-
- assertTrue( eventSupport.hasSessionListener( mock1 ) );
-
- assertTrue( eventSupport.hasSessionListener( mock2 ) );
-
- eventSupport.removeSessionListener( mock2 );
-
- assertTrue( eventSupport.hasSessionListener( mock1 ) );
-
- assertFalse( eventSupport.hasSessionListener( mock2 ) );
-
- eventSupport.removeSessionListener( mock1 );
-
- assertFalse( eventSupport.hasSessionListener( mock1 ) );
- }
-
- public void testFireSessionDisconnected()
- {
- SessionListener mock1 = createMock( SessionListener.class );
-
- eventSupport.addSessionListener( mock1 );
-
- SessionListener mock2 = createMock( SessionListener.class );
-
- eventSupport.addSessionListener( mock2 );
-
- final SessionEvent event = new SessionEvent( wagon, 1 );
-
- mock1.sessionDisconnected( event );
- mock2.sessionDisconnected( event );
-
- replay( mock1, mock2 );
-
- eventSupport.fireSessionDisconnected( event );
-
- verify( mock1, mock2 );
- }
-
- public void testFireSessionDisconneting()
- {
- SessionListener mock1 = createMock( SessionListener.class );
-
- eventSupport.addSessionListener( mock1 );
-
- SessionListener mock2 = createMock( SessionListener.class );
-
- eventSupport.addSessionListener( mock2 );
-
- final SessionEvent event = new SessionEvent( wagon, 1 );
-
- mock1.sessionDisconnecting( event );
- mock2.sessionDisconnecting( event );
-
- replay( mock1, mock2 );
-
- eventSupport.fireSessionDisconnecting( event );
-
- verify( mock1, mock2 );
- }
-
- public void testFireSessionLoggedIn()
- {
- SessionListener mock1 = createMock( SessionListener.class );
-
- eventSupport.addSessionListener( mock1 );
-
- SessionListener mock2 = createMock( SessionListener.class );
-
- eventSupport.addSessionListener( mock2 );
-
- final SessionEvent event = new SessionEvent( wagon, 1 );
-
- mock1.sessionLoggedIn( event );
- mock2.sessionLoggedIn( event );
-
- replay( mock1, mock2 );
-
- eventSupport.fireSessionLoggedIn( event );
-
- verify( mock1, mock2 );
- }
-
- public void testFireSessionLoggedOff()
- {
- SessionListener mock1 = createMock( SessionListener.class );
-
- eventSupport.addSessionListener( mock1 );
-
- SessionListener mock2 = createMock( SessionListener.class );
-
- eventSupport.addSessionListener( mock2 );
-
- final SessionEvent event = new SessionEvent( wagon, 1 );
-
- mock1.sessionLoggedOff( event );
- mock2.sessionLoggedOff( event );
-
- replay( mock1, mock2 );
-
- eventSupport.fireSessionLoggedOff( event );
-
- verify( mock1, mock2 );
- }
-
- public void testFireSessionOpened()
- {
- SessionListener mock1 = createMock( SessionListener.class );
-
- eventSupport.addSessionListener( mock1 );
-
- SessionListener mock2 = createMock( SessionListener.class );
-
- eventSupport.addSessionListener( mock2 );
-
- final SessionEvent event = new SessionEvent( wagon, 1 );
-
- mock1.sessionOpened( event );
- mock2.sessionOpened( event );
-
- replay( mock1, mock2 );
-
- eventSupport.fireSessionOpened( event );
-
- verify( mock1, mock2 );
- }
-
- public void testFireSessionOpenning()
- {
- SessionListener mock1 = createMock( SessionListener.class );
-
- eventSupport.addSessionListener( mock1 );
-
- SessionListener mock2 = createMock( SessionListener.class );
-
- eventSupport.addSessionListener( mock2 );
-
- final SessionEvent event = new SessionEvent( wagon, 1 );
-
- mock1.sessionOpening( event );
- mock2.sessionOpening( event );
-
- replay( mock1, mock2 );
-
- eventSupport.fireSessionOpening( event );
-
- verify( mock1, mock2 );
- }
-
- public void testFireSessionRefused()
- {
- SessionListener mock1 = createMock( SessionListener.class );
-
- eventSupport.addSessionListener( mock1 );
-
- SessionListener mock2 = createMock( SessionListener.class );
-
- eventSupport.addSessionListener( mock2 );
-
- final SessionEvent event = new SessionEvent( wagon, 1 );
-
- mock1.sessionConnectionRefused( event );
- mock2.sessionConnectionRefused( event );
-
- replay( mock1, mock2 );
-
- eventSupport.fireSessionConnectionRefused( event );
-
- verify( mock1, mock2 );
- }
-
- public void testFireDebug()
- {
- SessionListener mock1 = createMock( SessionListener.class );
-
- eventSupport.addSessionListener( mock1 );
-
- SessionListener mock2 = createMock( SessionListener.class );
-
- eventSupport.addSessionListener( mock2 );
-
- mock1.debug( "mm" );
- mock2.debug( "mm" );
-
- replay( mock1, mock2 );
-
- eventSupport.fireDebug( "mm" );
-
- verify( mock1, mock2 );
- }
-
-}
+package org.apache.maven.wagon.events;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+
+import org.apache.maven.wagon.Wagon;
+
+import static org.easymock.EasyMock.*;
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class SessionEventSupportTest
+ extends TestCase
+{
+
+ private SessionEventSupport eventSupport;
+
+ private Wagon wagon;
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ eventSupport = new SessionEventSupport();
+
+ // TODO: actually test it gets called?
+ wagon = createNiceMock( Wagon.class );
+ }
+
+ public void testSessionListenerRegistration()
+ {
+ SessionListener mock1 = createMock( SessionListener.class );
+
+ eventSupport.addSessionListener( mock1 );
+
+ assertTrue( eventSupport.hasSessionListener( mock1 ) );
+
+ SessionListener mock2 = createMock( SessionListener.class );
+
+ assertFalse( eventSupport.hasSessionListener( mock2 ) );
+
+ eventSupport.addSessionListener( mock2 );
+
+ assertTrue( eventSupport.hasSessionListener( mock1 ) );
+
+ assertTrue( eventSupport.hasSessionListener( mock2 ) );
+
+ eventSupport.removeSessionListener( mock2 );
+
+ assertTrue( eventSupport.hasSessionListener( mock1 ) );
+
+ assertFalse( eventSupport.hasSessionListener( mock2 ) );
+
+ eventSupport.removeSessionListener( mock1 );
+
+ assertFalse( eventSupport.hasSessionListener( mock1 ) );
+ }
+
+ public void testFireSessionDisconnected()
+ {
+ SessionListener mock1 = createMock( SessionListener.class );
+
+ eventSupport.addSessionListener( mock1 );
+
+ SessionListener mock2 = createMock( SessionListener.class );
+
+ eventSupport.addSessionListener( mock2 );
+
+ final SessionEvent event = new SessionEvent( wagon, 1 );
+
+ mock1.sessionDisconnected( event );
+ mock2.sessionDisconnected( event );
+
+ replay( mock1, mock2 );
+
+ eventSupport.fireSessionDisconnected( event );
+
+ verify( mock1, mock2 );
+ }
+
+ public void testFireSessionDisconneting()
+ {
+ SessionListener mock1 = createMock( SessionListener.class );
+
+ eventSupport.addSessionListener( mock1 );
+
+ SessionListener mock2 = createMock( SessionListener.class );
+
+ eventSupport.addSessionListener( mock2 );
+
+ final SessionEvent event = new SessionEvent( wagon, 1 );
+
+ mock1.sessionDisconnecting( event );
+ mock2.sessionDisconnecting( event );
+
+ replay( mock1, mock2 );
+
+ eventSupport.fireSessionDisconnecting( event );
+
+ verify( mock1, mock2 );
+ }
+
+ public void testFireSessionLoggedIn()
+ {
+ SessionListener mock1 = createMock( SessionListener.class );
+
+ eventSupport.addSessionListener( mock1 );
+
+ SessionListener mock2 = createMock( SessionListener.class );
+
+ eventSupport.addSessionListener( mock2 );
+
+ final SessionEvent event = new SessionEvent( wagon, 1 );
+
+ mock1.sessionLoggedIn( event );
+ mock2.sessionLoggedIn( event );
+
+ replay( mock1, mock2 );
+
+ eventSupport.fireSessionLoggedIn( event );
+
+ verify( mock1, mock2 );
+ }
+
+ public void testFireSessionLoggedOff()
+ {
+ SessionListener mock1 = createMock( SessionListener.class );
+
+ eventSupport.addSessionListener( mock1 );
+
+ SessionListener mock2 = createMock( SessionListener.class );
+
+ eventSupport.addSessionListener( mock2 );
+
+ final SessionEvent event = new SessionEvent( wagon, 1 );
+
+ mock1.sessionLoggedOff( event );
+ mock2.sessionLoggedOff( event );
+
+ replay( mock1, mock2 );
+
+ eventSupport.fireSessionLoggedOff( event );
+
+ verify( mock1, mock2 );
+ }
+
+ public void testFireSessionOpened()
+ {
+ SessionListener mock1 = createMock( SessionListener.class );
+
+ eventSupport.addSessionListener( mock1 );
+
+ SessionListener mock2 = createMock( SessionListener.class );
+
+ eventSupport.addSessionListener( mock2 );
+
+ final SessionEvent event = new SessionEvent( wagon, 1 );
+
+ mock1.sessionOpened( event );
+ mock2.sessionOpened( event );
+
+ replay( mock1, mock2 );
+
+ eventSupport.fireSessionOpened( event );
+
+ verify( mock1, mock2 );
+ }
+
+ public void testFireSessionOpenning()
+ {
+ SessionListener mock1 = createMock( SessionListener.class );
+
+ eventSupport.addSessionListener( mock1 );
+
+ SessionListener mock2 = createMock( SessionListener.class );
+
+ eventSupport.addSessionListener( mock2 );
+
+ final SessionEvent event = new SessionEvent( wagon, 1 );
+
+ mock1.sessionOpening( event );
+ mock2.sessionOpening( event );
+
+ replay( mock1, mock2 );
+
+ eventSupport.fireSessionOpening( event );
+
+ verify( mock1, mock2 );
+ }
+
+ public void testFireSessionRefused()
+ {
+ SessionListener mock1 = createMock( SessionListener.class );
+
+ eventSupport.addSessionListener( mock1 );
+
+ SessionListener mock2 = createMock( SessionListener.class );
+
+ eventSupport.addSessionListener( mock2 );
+
+ final SessionEvent event = new SessionEvent( wagon, 1 );
+
+ mock1.sessionConnectionRefused( event );
+ mock2.sessionConnectionRefused( event );
+
+ replay( mock1, mock2 );
+
+ eventSupport.fireSessionConnectionRefused( event );
+
+ verify( mock1, mock2 );
+ }
+
+ public void testFireDebug()
+ {
+ SessionListener mock1 = createMock( SessionListener.class );
+
+ eventSupport.addSessionListener( mock1 );
+
+ SessionListener mock2 = createMock( SessionListener.class );
+
+ eventSupport.addSessionListener( mock2 );
+
+ mock1.debug( "mm" );
+ mock2.debug( "mm" );
+
+ replay( mock1, mock2 );
+
+ eventSupport.fireDebug( "mm" );
+
+ verify( mock1, mock2 );
+ }
+
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/SessionEventTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/SessionEventTest.java
index 8815587..172dd75 100644
--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/SessionEventTest.java
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/SessionEventTest.java
@@ -1,132 +1,132 @@
-package org.apache.maven.wagon.events;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-import org.apache.maven.wagon.ConnectionException;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.repository.Repository;
-import org.easymock.EasyMock;
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class SessionEventTest
- extends TestCase
-{
- /*
- * Class to test for void SESSIONEvent(Wagon, Repository, String, int,
- * int)
- */
- public void testSessionEventProperties()
- throws ConnectionException, AuthenticationException
- {
-
- final Wagon wagon = EasyMock.createMock( Wagon.class );
- final Repository repo = new Repository();
-
- wagon.connect( repo );
-
- final long timestamp = System.currentTimeMillis();
- final Exception exception = new AuthenticationException( "dummy" );
-
- SessionEvent event = new SessionEvent( wagon, SessionEvent.SESSION_CLOSED );
-
- assertEquals( wagon, event.getWagon() );
-
- assertEquals( SessionEvent.SESSION_CLOSED, event.getEventType() );
-
- event = new SessionEvent( wagon, exception );
-
- assertEquals( wagon, event.getWagon() );
- assertEquals( SessionEvent.SESSION_ERROR_OCCURRED, event.getEventType() );
- assertEquals( exception, event.getException() );
-
- event.setException( null );
- assertEquals( null, event.getException() );
-
- event.setException( exception );
- assertEquals( exception, event.getException() );
-
- event.setTimestamp( timestamp );
- assertEquals( timestamp, event.getTimestamp() );
-
- event.setEventType( SessionEvent.SESSION_CLOSED );
- assertEquals( SessionEvent.SESSION_CLOSED, event.getEventType() );
-
- event.setEventType( SessionEvent.SESSION_DISCONNECTED );
- assertEquals( SessionEvent.SESSION_DISCONNECTED, event.getEventType() );
-
- event.setEventType( SessionEvent.SESSION_DISCONNECTING );
- assertEquals( SessionEvent.SESSION_DISCONNECTING, event.getEventType() );
-
- event.setEventType( SessionEvent.SESSION_ERROR_OCCURRED );
- assertEquals( SessionEvent.SESSION_ERROR_OCCURRED, event.getEventType() );
-
- event.setEventType( SessionEvent.SESSION_LOGGED_IN );
- assertEquals( SessionEvent.SESSION_LOGGED_IN, event.getEventType() );
-
- event.setEventType( SessionEvent.SESSION_LOGGED_OFF );
- assertEquals( SessionEvent.SESSION_LOGGED_OFF, event.getEventType() );
-
- event.setEventType( SessionEvent.SESSION_OPENED );
- assertEquals( SessionEvent.SESSION_OPENED, event.getEventType() );
-
- event.setEventType( SessionEvent.SESSION_OPENING );
- assertEquals( SessionEvent.SESSION_OPENING, event.getEventType() );
-
- event.setEventType( SessionEvent.SESSION_CONNECTION_REFUSED );
- assertEquals( SessionEvent.SESSION_CONNECTION_REFUSED, event.getEventType() );
-
- try
- {
- event.setEventType( -1 );
- fail( "Exception expected" );
- }
- catch ( IllegalArgumentException e )
- {
- assertTrue( true );
- }
-
- }
-
- public void testConstantValueConflict()
- {
- final int[] values = {SessionEvent.SESSION_CLOSED, SessionEvent.SESSION_DISCONNECTED,
- SessionEvent.SESSION_DISCONNECTING, SessionEvent.SESSION_ERROR_OCCURRED,
- SessionEvent.SESSION_LOGGED_IN, SessionEvent.SESSION_LOGGED_OFF,
- SessionEvent.SESSION_OPENED, SessionEvent.SESSION_OPENING,
- SessionEvent.SESSION_CONNECTION_REFUSED};
-
- for ( int i = 0; i < values.length; i++ )
- {
- for ( int j = i + 1; j < values.length; j++ )
- {
-
- final String msg = "Value confict at [i,j]=[" + i + "," + j + "]";
- assertTrue( msg, values[i] != values[j] );
- }
- }
-
- }
-
-}
+package org.apache.maven.wagon.events;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+import org.apache.maven.wagon.ConnectionException;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.repository.Repository;
+import org.easymock.EasyMock;
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class SessionEventTest
+ extends TestCase
+{
+ /*
+ * Class to test for void SESSIONEvent(Wagon, Repository, String, int,
+ * int)
+ */
+ public void testSessionEventProperties()
+ throws ConnectionException, AuthenticationException
+ {
+
+ final Wagon wagon = EasyMock.createMock( Wagon.class );
+ final Repository repo = new Repository();
+
+ wagon.connect( repo );
+
+ final long timestamp = System.currentTimeMillis();
+ final Exception exception = new AuthenticationException( "dummy" );
+
+ SessionEvent event = new SessionEvent( wagon, SessionEvent.SESSION_CLOSED );
+
+ assertEquals( wagon, event.getWagon() );
+
+ assertEquals( SessionEvent.SESSION_CLOSED, event.getEventType() );
+
+ event = new SessionEvent( wagon, exception );
+
+ assertEquals( wagon, event.getWagon() );
+ assertEquals( SessionEvent.SESSION_ERROR_OCCURRED, event.getEventType() );
+ assertEquals( exception, event.getException() );
+
+ event.setException( null );
+ assertEquals( null, event.getException() );
+
+ event.setException( exception );
+ assertEquals( exception, event.getException() );
+
+ event.setTimestamp( timestamp );
+ assertEquals( timestamp, event.getTimestamp() );
+
+ event.setEventType( SessionEvent.SESSION_CLOSED );
+ assertEquals( SessionEvent.SESSION_CLOSED, event.getEventType() );
+
+ event.setEventType( SessionEvent.SESSION_DISCONNECTED );
+ assertEquals( SessionEvent.SESSION_DISCONNECTED, event.getEventType() );
+
+ event.setEventType( SessionEvent.SESSION_DISCONNECTING );
+ assertEquals( SessionEvent.SESSION_DISCONNECTING, event.getEventType() );
+
+ event.setEventType( SessionEvent.SESSION_ERROR_OCCURRED );
+ assertEquals( SessionEvent.SESSION_ERROR_OCCURRED, event.getEventType() );
+
+ event.setEventType( SessionEvent.SESSION_LOGGED_IN );
+ assertEquals( SessionEvent.SESSION_LOGGED_IN, event.getEventType() );
+
+ event.setEventType( SessionEvent.SESSION_LOGGED_OFF );
+ assertEquals( SessionEvent.SESSION_LOGGED_OFF, event.getEventType() );
+
+ event.setEventType( SessionEvent.SESSION_OPENED );
+ assertEquals( SessionEvent.SESSION_OPENED, event.getEventType() );
+
+ event.setEventType( SessionEvent.SESSION_OPENING );
+ assertEquals( SessionEvent.SESSION_OPENING, event.getEventType() );
+
+ event.setEventType( SessionEvent.SESSION_CONNECTION_REFUSED );
+ assertEquals( SessionEvent.SESSION_CONNECTION_REFUSED, event.getEventType() );
+
+ try
+ {
+ event.setEventType( -1 );
+ fail( "Exception expected" );
+ }
+ catch ( IllegalArgumentException e )
+ {
+ assertTrue( true );
+ }
+
+ }
+
+ public void testConstantValueConflict()
+ {
+ final int[] values = {SessionEvent.SESSION_CLOSED, SessionEvent.SESSION_DISCONNECTED,
+ SessionEvent.SESSION_DISCONNECTING, SessionEvent.SESSION_ERROR_OCCURRED,
+ SessionEvent.SESSION_LOGGED_IN, SessionEvent.SESSION_LOGGED_OFF,
+ SessionEvent.SESSION_OPENED, SessionEvent.SESSION_OPENING,
+ SessionEvent.SESSION_CONNECTION_REFUSED};
+
+ for ( int i = 0; i < values.length; i++ )
+ {
+ for ( int j = i + 1; j < values.length; j++ )
+ {
+
+ final String msg = "Value confict at [i,j]=[" + i + "," + j + "]";
+ assertTrue( msg, values[i] != values[j] );
+ }
+ }
+
+ }
+
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/TransferEventSupportTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/TransferEventSupportTest.java
index 79f83fa..0868232 100644
--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/TransferEventSupportTest.java
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/TransferEventSupportTest.java
@@ -1,190 +1,190 @@
-package org.apache.maven.wagon.events;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.resource.Resource;
-import org.easymock.EasyMock;
-
-import static org.easymock.EasyMock.*;
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- */
-public class TransferEventSupportTest
- extends TestCase
-{
- private TransferEventSupport eventSupport;
-
- private Wagon wagon;
-
- /**
- * @see junit.framework.TestCase#setUp()
- */
- protected void setUp()
- throws Exception
- {
- super.setUp();
-
- eventSupport = new TransferEventSupport();
-
- // TODO: actually test it gets called?
- wagon = EasyMock.createNiceMock( Wagon.class );
- }
-
- public void testTransferListenerRegistration()
- {
- TransferListener mock1 = createMock( TransferListener.class );
- eventSupport.addTransferListener( mock1 );
-
- assertTrue( eventSupport.hasTransferListener( mock1 ) );
- TransferListener mock2 = createMock( TransferListener.class );
-
- assertFalse( eventSupport.hasTransferListener( mock2 ) );
-
- eventSupport.addTransferListener( mock2 );
-
- assertTrue( eventSupport.hasTransferListener( mock1 ) );
- assertTrue( eventSupport.hasTransferListener( mock2 ) );
-
- eventSupport.removeTransferListener( mock2 );
-
- assertTrue( eventSupport.hasTransferListener( mock1 ) );
- assertFalse( eventSupport.hasTransferListener( mock2 ) );
-
- eventSupport.removeTransferListener( mock1 );
- assertFalse( eventSupport.hasTransferListener( mock1 ) );
- }
-
- public void testFireTransferStarted()
- {
- TransferListener mock1 = createMock( TransferListener.class );
- eventSupport.addTransferListener( mock1 );
-
- TransferListener mock2 = createMock( TransferListener.class );
- eventSupport.addTransferListener( mock2 );
-
- final TransferEvent event = getEvent( wagon );
-
- mock1.transferStarted( event );
- mock2.transferStarted( event );
-
- replay( mock1, mock2 );
-
- eventSupport.fireTransferStarted( event );
-
- verify( mock1, mock2 );
- }
-
- public void testFireTransferProgress()
- {
- TransferListener mock1 = createMock( TransferListener.class );
-
- eventSupport.addTransferListener( mock1 );
-
- TransferListener mock2 = createMock( TransferListener.class );
-
- eventSupport.addTransferListener( mock2 );
-
- final TransferEvent event = getEvent( wagon );
- final byte[] buffer = "content".getBytes();
-
- mock1.transferProgress( event, buffer, 0 );
- mock2.transferProgress( event, buffer, 0 );
-
- replay( mock1, mock2 );
-
- eventSupport.fireTransferProgress( event, buffer , 0 );
-
- verify( mock1, mock2 );
- }
-
- public void testFireTransferCompleted()
- {
- TransferListener mock1 = createMock( TransferListener.class );
-
- eventSupport.addTransferListener( mock1 );
-
- TransferListener mock2 = createMock( TransferListener.class );
-
- eventSupport.addTransferListener( mock2 );
-
- final TransferEvent event = getEvent( wagon );
-
- mock1.transferCompleted( event );
- mock2.transferCompleted( event );
-
- replay( mock1, mock2 );
-
- eventSupport.fireTransferCompleted( event );
-
- verify( mock1, mock2 );
- }
-
- public void testFireTransferError()
- {
- TransferListener mock1 = createMock( TransferListener.class );
-
- eventSupport.addTransferListener( mock1 );
-
- TransferListener mock2 = createMock( TransferListener.class );
-
- eventSupport.addTransferListener( mock2 );
-
- final TransferEvent event = getEvent( wagon );
-
- mock1.transferError( event );
- mock2.transferError( event );
-
- replay( mock1, mock2 );
-
- eventSupport.fireTransferError( event );
-
- verify( mock1, mock2 );
- }
-
- public void testFireDebug()
- {
- TransferListener mock1 = createMock( TransferListener.class );
-
- eventSupport.addTransferListener( mock1 );
-
- TransferListener mock2 = createMock( TransferListener.class );
-
- eventSupport.addTransferListener( mock2 );
-
- mock1.debug( "mm" );
- mock2.debug( "mm" );
-
- replay( mock1, mock2 );
-
- eventSupport.fireDebug( "mm" );
-
- verify( mock1, mock2 );
- }
-
- private TransferEvent getEvent( final Wagon wagon )
- {
- return new TransferEvent( wagon, new Resource(), TransferEvent.TRANSFER_COMPLETED,
- TransferEvent.REQUEST_GET );
- }
-
-}
+package org.apache.maven.wagon.events;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.resource.Resource;
+import org.easymock.EasyMock;
+
+import static org.easymock.EasyMock.*;
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ */
+public class TransferEventSupportTest
+ extends TestCase
+{
+ private TransferEventSupport eventSupport;
+
+ private Wagon wagon;
+
+ /**
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ eventSupport = new TransferEventSupport();
+
+ // TODO: actually test it gets called?
+ wagon = EasyMock.createNiceMock( Wagon.class );
+ }
+
+ public void testTransferListenerRegistration()
+ {
+ TransferListener mock1 = createMock( TransferListener.class );
+ eventSupport.addTransferListener( mock1 );
+
+ assertTrue( eventSupport.hasTransferListener( mock1 ) );
+ TransferListener mock2 = createMock( TransferListener.class );
+
+ assertFalse( eventSupport.hasTransferListener( mock2 ) );
+
+ eventSupport.addTransferListener( mock2 );
+
+ assertTrue( eventSupport.hasTransferListener( mock1 ) );
+ assertTrue( eventSupport.hasTransferListener( mock2 ) );
+
+ eventSupport.removeTransferListener( mock2 );
+
+ assertTrue( eventSupport.hasTransferListener( mock1 ) );
+ assertFalse( eventSupport.hasTransferListener( mock2 ) );
+
+ eventSupport.removeTransferListener( mock1 );
+ assertFalse( eventSupport.hasTransferListener( mock1 ) );
+ }
+
+ public void testFireTransferStarted()
+ {
+ TransferListener mock1 = createMock( TransferListener.class );
+ eventSupport.addTransferListener( mock1 );
+
+ TransferListener mock2 = createMock( TransferListener.class );
+ eventSupport.addTransferListener( mock2 );
+
+ final TransferEvent event = getEvent( wagon );
+
+ mock1.transferStarted( event );
+ mock2.transferStarted( event );
+
+ replay( mock1, mock2 );
+
+ eventSupport.fireTransferStarted( event );
+
+ verify( mock1, mock2 );
+ }
+
+ public void testFireTransferProgress()
+ {
+ TransferListener mock1 = createMock( TransferListener.class );
+
+ eventSupport.addTransferListener( mock1 );
+
+ TransferListener mock2 = createMock( TransferListener.class );
+
+ eventSupport.addTransferListener( mock2 );
+
+ final TransferEvent event = getEvent( wagon );
+ final byte[] buffer = "content".getBytes();
+
+ mock1.transferProgress( event, buffer, 0 );
+ mock2.transferProgress( event, buffer, 0 );
+
+ replay( mock1, mock2 );
+
+ eventSupport.fireTransferProgress( event, buffer , 0 );
+
+ verify( mock1, mock2 );
+ }
+
+ public void testFireTransferCompleted()
+ {
+ TransferListener mock1 = createMock( TransferListener.class );
+
+ eventSupport.addTransferListener( mock1 );
+
+ TransferListener mock2 = createMock( TransferListener.class );
+
+ eventSupport.addTransferListener( mock2 );
+
+ final TransferEvent event = getEvent( wagon );
+
+ mock1.transferCompleted( event );
+ mock2.transferCompleted( event );
+
+ replay( mock1, mock2 );
+
+ eventSupport.fireTransferCompleted( event );
+
+ verify( mock1, mock2 );
+ }
+
+ public void testFireTransferError()
+ {
+ TransferListener mock1 = createMock( TransferListener.class );
+
+ eventSupport.addTransferListener( mock1 );
+
+ TransferListener mock2 = createMock( TransferListener.class );
+
+ eventSupport.addTransferListener( mock2 );
+
+ final TransferEvent event = getEvent( wagon );
+
+ mock1.transferError( event );
+ mock2.transferError( event );
+
+ replay( mock1, mock2 );
+
+ eventSupport.fireTransferError( event );
+
+ verify( mock1, mock2 );
+ }
+
+ public void testFireDebug()
+ {
+ TransferListener mock1 = createMock( TransferListener.class );
+
+ eventSupport.addTransferListener( mock1 );
+
+ TransferListener mock2 = createMock( TransferListener.class );
+
+ eventSupport.addTransferListener( mock2 );
+
+ mock1.debug( "mm" );
+ mock2.debug( "mm" );
+
+ replay( mock1, mock2 );
+
+ eventSupport.fireDebug( "mm" );
+
+ verify( mock1, mock2 );
+ }
+
+ private TransferEvent getEvent( final Wagon wagon )
+ {
+ return new TransferEvent( wagon, new Resource(), TransferEvent.TRANSFER_COMPLETED,
+ TransferEvent.REQUEST_GET );
+ }
+
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/TransferEventTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/TransferEventTest.java
index 5df120b..72cae49 100644
--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/TransferEventTest.java
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/TransferEventTest.java
@@ -1,166 +1,166 @@
-package org.apache.maven.wagon.events;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-import org.apache.maven.wagon.ConnectionException;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.repository.Repository;
-import org.apache.maven.wagon.resource.Resource;
-import org.easymock.EasyMock;
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class TransferEventTest
- extends TestCase
-{
- /*
- * Class to test for void TransferEvent(Wagon, Repository, String, int,
- * int)
- */
- public void testTransferEventProperties()
- throws ConnectionException, AuthenticationException
- {
- final Wagon wagon = EasyMock.createMock( Wagon.class );
-
- final Repository repo = new Repository();
-
- wagon.connect( repo );
-
- final long timestamp = System.currentTimeMillis();
-
- final Exception exception = new AuthenticationException( "dummy" );
-
- Resource resource = new Resource();
-
- resource.setName( "mm" );
-
- TransferEvent event = new TransferEvent( wagon, resource, TransferEvent.TRANSFER_COMPLETED,
- TransferEvent.REQUEST_GET );
-
- assertEquals( wagon, event.getWagon() );
-
- assertEquals( "mm", event.getResource().getName() );
-
- assertEquals( TransferEvent.TRANSFER_COMPLETED, event.getEventType() );
-
- assertEquals( TransferEvent.REQUEST_GET, event.getRequestType() );
-
- Resource res = new Resource();
-
- res.setName( "mm" );
-
- event = new TransferEvent( wagon, res, exception, TransferEvent.REQUEST_GET );
-
- assertEquals( wagon, event.getWagon() );
-
- assertEquals( "mm", event.getResource().getName() );
-
- assertEquals( TransferEvent.TRANSFER_ERROR, event.getEventType() );
-
- assertEquals( TransferEvent.REQUEST_GET, event.getRequestType() );
-
- assertEquals( exception, event.getException() );
-
- event.setResource( null );
-
- assertEquals( null, event.getResource() );
-
- res.setName( "/foo/baa" );
-
- event.setResource( res );
-
- assertEquals( "/foo/baa", event.getResource().getName() );
-
- event.setTimestamp( timestamp );
-
- assertEquals( timestamp, event.getTimestamp() );
-
- event.setRequestType( TransferEvent.REQUEST_PUT );
-
- assertEquals( TransferEvent.REQUEST_PUT, event.getRequestType() );
-
- event.setRequestType( TransferEvent.REQUEST_GET );
-
- assertEquals( TransferEvent.REQUEST_GET, event.getRequestType() );
-
- try
- {
- event.setRequestType( -1 );
-
- fail( "Exception expected" );
- }
- catch ( IllegalArgumentException e )
- {
- assertTrue( true );
- }
-
- event.setEventType( TransferEvent.TRANSFER_COMPLETED );
-
- assertEquals( TransferEvent.TRANSFER_COMPLETED, event.getEventType() );
-
- event.setEventType( TransferEvent.TRANSFER_ERROR );
-
- assertEquals( TransferEvent.TRANSFER_ERROR, event.getEventType() );
-
- event.setEventType( TransferEvent.TRANSFER_STARTED );
-
- assertEquals( TransferEvent.TRANSFER_STARTED, event.getEventType() );
-
- event.setEventType( TransferEvent.TRANSFER_PROGRESS );
-
- assertEquals( TransferEvent.TRANSFER_PROGRESS, event.getEventType() );
-
- try
- {
- event.setEventType( -1 );
-
- fail( "Exception expected" );
- }
- catch ( IllegalArgumentException e )
- {
- assertTrue( true );
- }
-
- }
-
- public void testConstantValueConflict()
- {
- final int[] values = {TransferEvent.TRANSFER_COMPLETED, TransferEvent.TRANSFER_ERROR,
- TransferEvent.TRANSFER_STARTED, TransferEvent.TRANSFER_PROGRESS,
- TransferEvent.REQUEST_GET, TransferEvent.REQUEST_PUT};
-
- for ( int i = 0; i < values.length; i++ )
- {
- for ( int j = i + 1; j < values.length; j++ )
- {
-
- final String msg = "Value confict at [i,j]=[" + i + "," + j + "]";
-
- assertTrue( msg, values[i] != values[j] );
- }
- }
-
- }
-
-}
+package org.apache.maven.wagon.events;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+import org.apache.maven.wagon.ConnectionException;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.resource.Resource;
+import org.easymock.EasyMock;
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class TransferEventTest
+ extends TestCase
+{
+ /*
+ * Class to test for void TransferEvent(Wagon, Repository, String, int,
+ * int)
+ */
+ public void testTransferEventProperties()
+ throws ConnectionException, AuthenticationException
+ {
+ final Wagon wagon = EasyMock.createMock( Wagon.class );
+
+ final Repository repo = new Repository();
+
+ wagon.connect( repo );
+
+ final long timestamp = System.currentTimeMillis();
+
+ final Exception exception = new AuthenticationException( "dummy" );
+
+ Resource resource = new Resource();
+
+ resource.setName( "mm" );
+
+ TransferEvent event = new TransferEvent( wagon, resource, TransferEvent.TRANSFER_COMPLETED,
+ TransferEvent.REQUEST_GET );
+
+ assertEquals( wagon, event.getWagon() );
+
+ assertEquals( "mm", event.getResource().getName() );
+
+ assertEquals( TransferEvent.TRANSFER_COMPLETED, event.getEventType() );
+
+ assertEquals( TransferEvent.REQUEST_GET, event.getRequestType() );
+
+ Resource res = new Resource();
+
+ res.setName( "mm" );
+
+ event = new TransferEvent( wagon, res, exception, TransferEvent.REQUEST_GET );
+
+ assertEquals( wagon, event.getWagon() );
+
+ assertEquals( "mm", event.getResource().getName() );
+
+ assertEquals( TransferEvent.TRANSFER_ERROR, event.getEventType() );
+
+ assertEquals( TransferEvent.REQUEST_GET, event.getRequestType() );
+
+ assertEquals( exception, event.getException() );
+
+ event.setResource( null );
+
+ assertEquals( null, event.getResource() );
+
+ res.setName( "/foo/baa" );
+
+ event.setResource( res );
+
+ assertEquals( "/foo/baa", event.getResource().getName() );
+
+ event.setTimestamp( timestamp );
+
+ assertEquals( timestamp, event.getTimestamp() );
+
+ event.setRequestType( TransferEvent.REQUEST_PUT );
+
+ assertEquals( TransferEvent.REQUEST_PUT, event.getRequestType() );
+
+ event.setRequestType( TransferEvent.REQUEST_GET );
+
+ assertEquals( TransferEvent.REQUEST_GET, event.getRequestType() );
+
+ try
+ {
+ event.setRequestType( -1 );
+
+ fail( "Exception expected" );
+ }
+ catch ( IllegalArgumentException e )
+ {
+ assertTrue( true );
+ }
+
+ event.setEventType( TransferEvent.TRANSFER_COMPLETED );
+
+ assertEquals( TransferEvent.TRANSFER_COMPLETED, event.getEventType() );
+
+ event.setEventType( TransferEvent.TRANSFER_ERROR );
+
+ assertEquals( TransferEvent.TRANSFER_ERROR, event.getEventType() );
+
+ event.setEventType( TransferEvent.TRANSFER_STARTED );
+
+ assertEquals( TransferEvent.TRANSFER_STARTED, event.getEventType() );
+
+ event.setEventType( TransferEvent.TRANSFER_PROGRESS );
+
+ assertEquals( TransferEvent.TRANSFER_PROGRESS, event.getEventType() );
+
+ try
+ {
+ event.setEventType( -1 );
+
+ fail( "Exception expected" );
+ }
+ catch ( IllegalArgumentException e )
+ {
+ assertTrue( true );
+ }
+
+ }
+
+ public void testConstantValueConflict()
+ {
+ final int[] values = {TransferEvent.TRANSFER_COMPLETED, TransferEvent.TRANSFER_ERROR,
+ TransferEvent.TRANSFER_STARTED, TransferEvent.TRANSFER_PROGRESS,
+ TransferEvent.REQUEST_GET, TransferEvent.REQUEST_PUT};
+
+ for ( int i = 0; i < values.length; i++ )
+ {
+ for ( int j = i + 1; j < values.length; j++ )
+ {
+
+ final String msg = "Value confict at [i,j]=[" + i + "," + j + "]";
+
+ assertTrue( msg, values[i] != values[j] );
+ }
+ }
+
+ }
+
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/observers/ChecksumObserverTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/observers/ChecksumObserverTest.java
index d2c17db..20f6ab8 100644
--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/observers/ChecksumObserverTest.java
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/observers/ChecksumObserverTest.java
@@ -1,123 +1,123 @@
-package org.apache.maven.wagon.observers;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.io.IOException;
-import java.security.NoSuchAlgorithmException;
-
-import junit.framework.TestCase;
-
-import org.apache.maven.wagon.ConnectionException;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
-import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.WagonMock;
-import org.apache.maven.wagon.authorization.AuthorizationException;
-import org.apache.maven.wagon.events.TransferEvent;
-import org.apache.maven.wagon.events.TransferListener;
-import org.apache.maven.wagon.repository.Repository;
-import org.apache.maven.wagon.resource.Resource;
-
-public class ChecksumObserverTest
- extends TestCase
-{
- private Wagon wagon;
-
- public void setUp()
- throws Exception
- {
- super.setUp();
-
- wagon = new WagonMock( true );
-
- Repository repository = new Repository();
- wagon.connect( repository );
- }
-
- public void tearDown()
- throws Exception
- {
- wagon.disconnect();
-
- super.tearDown();
- }
-
- public void testSubsequentTransfersAfterTransferError()
- throws NoSuchAlgorithmException, ResourceDoesNotExistException, AuthorizationException, IOException
- {
- TransferListener listener = new ChecksumObserver();
-
- wagon.addTransferListener( listener );
-
- File testFile = File.createTempFile( "wagon", "tmp" );
- testFile.deleteOnExit();
-
- try
- {
- wagon.get( "resource", testFile );
- fail();
- }
- catch ( TransferFailedException e )
- {
- assertTrue( true );
- }
-
- try
- {
- wagon.get( "resource", testFile );
- fail();
- }
- catch ( TransferFailedException e )
- {
- assertTrue( true );
- }
-
- testFile.delete();
- }
-
- public void testChecksum()
- throws NoSuchAlgorithmException
- {
- ChecksumObserver listener = new ChecksumObserver( "SHA-1" );
-
- Resource resource = new Resource( "resource" );
-
- TransferEvent transferEvent =
- new TransferEvent( wagon, resource, TransferEvent.TRANSFER_INITIATED, TransferEvent.REQUEST_GET );
-
- listener.transferInitiated( transferEvent );
-
- transferEvent = new TransferEvent( wagon, resource, TransferEvent.TRANSFER_STARTED, TransferEvent.REQUEST_GET );
-
- listener.transferStarted( transferEvent );
-
- transferEvent = new TransferEvent( wagon, resource, TransferEvent.TRANSFER_PROGRESS, TransferEvent.REQUEST_GET );
-
- listener.transferProgress( transferEvent, "checksum\n".getBytes(), 9 );
-
- transferEvent =
- new TransferEvent( wagon, resource, TransferEvent.TRANSFER_COMPLETED, TransferEvent.REQUEST_GET );
-
- listener.transferCompleted( transferEvent );
-
- assertEquals( "2e5daf0201ddeb068a62d5e08da18657ab2c6be9", listener.getActualChecksum() );
- }
-}
+package org.apache.maven.wagon.observers;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.security.NoSuchAlgorithmException;
+
+import junit.framework.TestCase;
+
+import org.apache.maven.wagon.ConnectionException;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.WagonMock;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.events.TransferListener;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.resource.Resource;
+
+public class ChecksumObserverTest
+ extends TestCase
+{
+ private Wagon wagon;
+
+ public void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ wagon = new WagonMock( true );
+
+ Repository repository = new Repository();
+ wagon.connect( repository );
+ }
+
+ public void tearDown()
+ throws Exception
+ {
+ wagon.disconnect();
+
+ super.tearDown();
+ }
+
+ public void testSubsequentTransfersAfterTransferError()
+ throws NoSuchAlgorithmException, ResourceDoesNotExistException, AuthorizationException, IOException
+ {
+ TransferListener listener = new ChecksumObserver();
+
+ wagon.addTransferListener( listener );
+
+ File testFile = File.createTempFile( "wagon", "tmp" );
+ testFile.deleteOnExit();
+
+ try
+ {
+ wagon.get( "resource", testFile );
+ fail();
+ }
+ catch ( TransferFailedException e )
+ {
+ assertTrue( true );
+ }
+
+ try
+ {
+ wagon.get( "resource", testFile );
+ fail();
+ }
+ catch ( TransferFailedException e )
+ {
+ assertTrue( true );
+ }
+
+ testFile.delete();
+ }
+
+ public void testChecksum()
+ throws NoSuchAlgorithmException
+ {
+ ChecksumObserver listener = new ChecksumObserver( "SHA-1" );
+
+ Resource resource = new Resource( "resource" );
+
+ TransferEvent transferEvent =
+ new TransferEvent( wagon, resource, TransferEvent.TRANSFER_INITIATED, TransferEvent.REQUEST_GET );
+
+ listener.transferInitiated( transferEvent );
+
+ transferEvent = new TransferEvent( wagon, resource, TransferEvent.TRANSFER_STARTED, TransferEvent.REQUEST_GET );
+
+ listener.transferStarted( transferEvent );
+
+ transferEvent = new TransferEvent( wagon, resource, TransferEvent.TRANSFER_PROGRESS, TransferEvent.REQUEST_GET );
+
+ listener.transferProgress( transferEvent, "checksum\n".getBytes(), 9 );
+
+ transferEvent =
+ new TransferEvent( wagon, resource, TransferEvent.TRANSFER_COMPLETED, TransferEvent.REQUEST_GET );
+
+ listener.transferCompleted( transferEvent );
+
+ assertEquals( "2e5daf0201ddeb068a62d5e08da18657ab2c6be9", listener.getActualChecksum() );
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/proxy/ProxyInfoTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/proxy/ProxyInfoTest.java
index fbece38..3c2c989 100644
--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/proxy/ProxyInfoTest.java
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/proxy/ProxyInfoTest.java
@@ -1,73 +1,73 @@
-package org.apache.maven.wagon.proxy;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-
-/**
- * @author <a href="mailto:jvanzyl at maven.org">Jason van Zyl</a>
- *
- */
-public class ProxyInfoTest
- extends TestCase
-{
- public ProxyInfoTest( final String name )
- {
- super( name );
- }
-
- public void setUp()
- throws Exception
- {
- super.setUp();
- }
-
- public void tearDown()
- throws Exception
- {
- super.tearDown();
- }
-
- public void testProxyInfoProperties()
-
- {
- final ProxyInfo proxyInfo = new ProxyInfo();
-
- proxyInfo.setUserName( "username" );
-
- assertEquals( "username", proxyInfo.getUserName() );
-
- proxyInfo.setPassword( "password" );
-
- assertEquals( "password", proxyInfo.getPassword() );
-
- proxyInfo.setHost( "http://www.ibiblio.org" );
-
- assertEquals( "http://www.ibiblio.org", proxyInfo.getHost() );
-
- proxyInfo.setPort( 0 );
-
- assertEquals( 0, proxyInfo.getPort() );
-
- proxyInfo.setType( "SOCKSv4" );
-
- assertEquals( "SOCKSv4", proxyInfo.getType() );
- }
-}
+package org.apache.maven.wagon.proxy;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:jvanzyl at maven.org">Jason van Zyl</a>
+ *
+ */
+public class ProxyInfoTest
+ extends TestCase
+{
+ public ProxyInfoTest( final String name )
+ {
+ super( name );
+ }
+
+ public void setUp()
+ throws Exception
+ {
+ super.setUp();
+ }
+
+ public void tearDown()
+ throws Exception
+ {
+ super.tearDown();
+ }
+
+ public void testProxyInfoProperties()
+
+ {
+ final ProxyInfo proxyInfo = new ProxyInfo();
+
+ proxyInfo.setUserName( "username" );
+
+ assertEquals( "username", proxyInfo.getUserName() );
+
+ proxyInfo.setPassword( "password" );
+
+ assertEquals( "password", proxyInfo.getPassword() );
+
+ proxyInfo.setHost( "http://www.ibiblio.org" );
+
+ assertEquals( "http://www.ibiblio.org", proxyInfo.getHost() );
+
+ proxyInfo.setPort( 0 );
+
+ assertEquals( 0, proxyInfo.getPort() );
+
+ proxyInfo.setType( "SOCKSv4" );
+
+ assertEquals( "SOCKSv4", proxyInfo.getType() );
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/proxy/ProxyInfoUtilsTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/proxy/ProxyInfoUtilsTest.java
index e506999..8cdd9b2 100644
--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/proxy/ProxyInfoUtilsTest.java
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/proxy/ProxyInfoUtilsTest.java
@@ -1,92 +1,92 @@
-package org.apache.maven.wagon.proxy;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-
-/**
- * @author <a href="mailto:lafeuil at gmail.com">Thomas Champagne</a>
- */
-public class ProxyInfoUtilsTest
- extends TestCase
-{
- public ProxyInfoUtilsTest( final String name )
- {
- super( name );
- }
-
- public void setUp()
- throws Exception
- {
- super.setUp();
- }
-
- public void tearDown()
- throws Exception
- {
- super.tearDown();
- }
-
- public void testValidateNonProxyHostsWithNullProxy()
- {
- assertFalse( "www.ibiblio.org", ProxyUtils.validateNonProxyHosts( null, "maven.apache.org" ) );
- }
-
- public void testValidateNonProxyHostsWithUniqueHost()
-
- {
- final ProxyInfo proxyInfo = new ProxyInfo();
- proxyInfo.setUserName( "username" );
- proxyInfo.setPassword( "password" );
- proxyInfo.setHost( "http://www.ibiblio.org" );
- proxyInfo.setPort( 0 );
- proxyInfo.setType( "SOCKSv4" );
- proxyInfo.setNonProxyHosts( "*.apache.org" );
-
- assertTrue( "maven.apache.org", ProxyUtils.validateNonProxyHosts( proxyInfo, "maven.apache.org" ) );
-
- assertFalse( "www.ibiblio.org", ProxyUtils.validateNonProxyHosts( proxyInfo, "www.ibiblio.org" ) );
-
- assertFalse( "null", ProxyUtils.validateNonProxyHosts( proxyInfo, null ) );
-
- proxyInfo.setNonProxyHosts( null );
- assertFalse( "NonProxyHosts = null", ProxyUtils.validateNonProxyHosts( proxyInfo, "maven.apache.org" ) );
-
- proxyInfo.setNonProxyHosts( "" );
- assertFalse( "NonProxyHosts = \"\"", ProxyUtils.validateNonProxyHosts( proxyInfo, "maven.apache.org" ) );
- }
-
- public void testValidateNonProxyHostsWithMultipleHost()
-
- {
- final ProxyInfo proxyInfo = new ProxyInfo();
- proxyInfo.setUserName( "username" );
- proxyInfo.setPassword( "password" );
- proxyInfo.setHost( "http://www.ibiblio.org" );
- proxyInfo.setPort( 0 );
- proxyInfo.setType( "SOCKSv4" );
- proxyInfo.setNonProxyHosts( "*.apache.org|*.codehaus.org" );
-
- assertTrue( "maven.apache.org", ProxyUtils.validateNonProxyHosts( proxyInfo, "maven.apache.org" ) );
- assertTrue( "wiki.codehaus.org", ProxyUtils.validateNonProxyHosts( proxyInfo, "wiki.codehaus.org" ) );
-
- assertFalse( "www.ibiblio.org", ProxyUtils.validateNonProxyHosts( proxyInfo, "www.ibiblio.org" ) );
- }
-}
+package org.apache.maven.wagon.proxy;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:lafeuil at gmail.com">Thomas Champagne</a>
+ */
+public class ProxyInfoUtilsTest
+ extends TestCase
+{
+ public ProxyInfoUtilsTest( final String name )
+ {
+ super( name );
+ }
+
+ public void setUp()
+ throws Exception
+ {
+ super.setUp();
+ }
+
+ public void tearDown()
+ throws Exception
+ {
+ super.tearDown();
+ }
+
+ public void testValidateNonProxyHostsWithNullProxy()
+ {
+ assertFalse( "www.ibiblio.org", ProxyUtils.validateNonProxyHosts( null, "maven.apache.org" ) );
+ }
+
+ public void testValidateNonProxyHostsWithUniqueHost()
+
+ {
+ final ProxyInfo proxyInfo = new ProxyInfo();
+ proxyInfo.setUserName( "username" );
+ proxyInfo.setPassword( "password" );
+ proxyInfo.setHost( "http://www.ibiblio.org" );
+ proxyInfo.setPort( 0 );
+ proxyInfo.setType( "SOCKSv4" );
+ proxyInfo.setNonProxyHosts( "*.apache.org" );
+
+ assertTrue( "maven.apache.org", ProxyUtils.validateNonProxyHosts( proxyInfo, "maven.apache.org" ) );
+
+ assertFalse( "www.ibiblio.org", ProxyUtils.validateNonProxyHosts( proxyInfo, "www.ibiblio.org" ) );
+
+ assertFalse( "null", ProxyUtils.validateNonProxyHosts( proxyInfo, null ) );
+
+ proxyInfo.setNonProxyHosts( null );
+ assertFalse( "NonProxyHosts = null", ProxyUtils.validateNonProxyHosts( proxyInfo, "maven.apache.org" ) );
+
+ proxyInfo.setNonProxyHosts( "" );
+ assertFalse( "NonProxyHosts = \"\"", ProxyUtils.validateNonProxyHosts( proxyInfo, "maven.apache.org" ) );
+ }
+
+ public void testValidateNonProxyHostsWithMultipleHost()
+
+ {
+ final ProxyInfo proxyInfo = new ProxyInfo();
+ proxyInfo.setUserName( "username" );
+ proxyInfo.setPassword( "password" );
+ proxyInfo.setHost( "http://www.ibiblio.org" );
+ proxyInfo.setPort( 0 );
+ proxyInfo.setType( "SOCKSv4" );
+ proxyInfo.setNonProxyHosts( "*.apache.org|*.codehaus.org" );
+
+ assertTrue( "maven.apache.org", ProxyUtils.validateNonProxyHosts( proxyInfo, "maven.apache.org" ) );
+ assertTrue( "wiki.codehaus.org", ProxyUtils.validateNonProxyHosts( proxyInfo, "wiki.codehaus.org" ) );
+
+ assertFalse( "www.ibiblio.org", ProxyUtils.validateNonProxyHosts( proxyInfo, "www.ibiblio.org" ) );
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/repository/RepositoryPermissionsTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/repository/RepositoryPermissionsTest.java
index 36d8ced..cd11884 100644
--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/repository/RepositoryPermissionsTest.java
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/repository/RepositoryPermissionsTest.java
@@ -1,66 +1,66 @@
-package org.apache.maven.wagon.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-
-/**
- * @author <a href="mailto:brett at apache.org">Brett Porter</a>
- *
- * @todo test defaults
- */
-public class RepositoryPermissionsTest
- extends TestCase
-{
- public RepositoryPermissionsTest( final String name )
- {
- super( name );
- }
-
- public void setUp()
- throws Exception
- {
- super.setUp();
- }
-
- public void tearDown()
- throws Exception
- {
- super.tearDown();
- }
-
- public void testAuthenticationInfoProperties()
- {
- final RepositoryPermissions repositoryPermissions = new RepositoryPermissions();
-
- repositoryPermissions.setDirectoryMode( "directoryMode" );
-
- assertEquals( "directoryMode", repositoryPermissions.getDirectoryMode() );
-
- repositoryPermissions.setFileMode( "fileMode" );
-
- assertEquals( "fileMode", repositoryPermissions.getFileMode() );
-
- repositoryPermissions.setGroup( "group" );
-
- assertEquals( "group", repositoryPermissions.getGroup() );
-
- }
-}
+package org.apache.maven.wagon.repository;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:brett at apache.org">Brett Porter</a>
+ *
+ * @todo test defaults
+ */
+public class RepositoryPermissionsTest
+ extends TestCase
+{
+ public RepositoryPermissionsTest( final String name )
+ {
+ super( name );
+ }
+
+ public void setUp()
+ throws Exception
+ {
+ super.setUp();
+ }
+
+ public void tearDown()
+ throws Exception
+ {
+ super.tearDown();
+ }
+
+ public void testAuthenticationInfoProperties()
+ {
+ final RepositoryPermissions repositoryPermissions = new RepositoryPermissions();
+
+ repositoryPermissions.setDirectoryMode( "directoryMode" );
+
+ assertEquals( "directoryMode", repositoryPermissions.getDirectoryMode() );
+
+ repositoryPermissions.setFileMode( "fileMode" );
+
+ assertEquals( "fileMode", repositoryPermissions.getFileMode() );
+
+ repositoryPermissions.setGroup( "group" );
+
+ assertEquals( "group", repositoryPermissions.getGroup() );
+
+ }
+}
diff --git a/wagon-provider-api/src/test/java/org/apache/maven/wagon/repository/RepositoryTest.java b/wagon-provider-api/src/test/java/org/apache/maven/wagon/repository/RepositoryTest.java
index bb85df0..bc9b5b4 100644
--- a/wagon-provider-api/src/test/java/org/apache/maven/wagon/repository/RepositoryTest.java
+++ b/wagon-provider-api/src/test/java/org/apache/maven/wagon/repository/RepositoryTest.java
@@ -1,164 +1,164 @@
-package org.apache.maven.wagon.repository;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-
-import org.apache.maven.wagon.WagonConstants;
-
-/**
- * @author <a href="mailto:jvanzyl at maven.org">Jason van Zyl</a>
- *
- */
-public class RepositoryTest
- extends TestCase
-{
- public RepositoryTest( final String name )
- {
- super( name );
- }
-
- public void setUp()
- throws Exception
- {
- super.setUp();
- }
-
- public void tearDown()
- throws Exception
- {
- super.tearDown();
- }
-
- public void testRepositoryProperties()
- throws Exception
- {
- Repository repository = new Repository();
-
- repository.setBasedir( "directory" );
-
- assertEquals( "directory", repository.getBasedir() );
-
- repository.setName( "name" );
-
- assertEquals( "name", repository.getName() );
-
- repository.setPort( 0 );
-
- assertEquals( 0, repository.getPort() );
-
- assertEquals( "localhost", repository.getHost() );
-
- repository.setUrl( "http://www.ibiblio.org" );
-
- assertEquals( "http://www.ibiblio.org", repository.getUrl() );
-
- assertEquals( "http", repository.getProtocol() );
-
- assertEquals( "www.ibiblio.org", repository.getHost() );
-
- assertEquals( "/", repository.getBasedir() );
-
- assertEquals( WagonConstants.UNKNOWN_PORT, repository.getPort() );
-
- repository.setUrl( "https://www.ibiblio.org:100/maven" );
-
- assertEquals( "https://www.ibiblio.org:100/maven", repository.getUrl() );
-
- assertEquals( "https", repository.getProtocol() );
-
- assertEquals( "www.ibiblio.org", repository.getHost() );
-
- assertEquals( "/maven", repository.getBasedir() );
-
- assertEquals( 100, repository.getPort() );
-
- assertEquals( "www.ibiblio.org", repository.getHost() );
-
- repository.setBasedir( "basedir" );
-
- assertEquals( "basedir", repository.getBasedir() );
-
- repository.setUrl( "http://brett:porter@www.ibiblio.org" );
-
- assertEquals( "http://www.ibiblio.org", repository.getUrl() );
-
- repository.setUrl( "http://brett@www.ibiblio.org" );
-
- assertEquals( "http://www.ibiblio.org", repository.getUrl() );
-
- }
-
- public void testIPv6()
- {
- assertRepository( "http://user:password@[fff:::1]:7891/oo/rest/users", "http://[fff:::1]:7891/oo/rest/users",
- "/oo/rest/users", "user", "password", "fff:::1", 7891 );
- assertRepository( "http://[fff:::1]:7891/oo/rest/users", "http://[fff:::1]:7891/oo/rest/users",
- "/oo/rest/users", null, null, "fff:::1", 7891 );
- assertRepository( "http://user:password@[fff:::1]/oo/rest/users", "http://[fff:::1]/oo/rest/users",
- "/oo/rest/users", "user", "password", "fff:::1", -1 );
- assertRepository( "http://user:password@[fff:::1]:7891", "http://[fff:::1]:7891", "/", "user", "password",
- "fff:::1", 7891 );
-
- assertRepository( "http://user:password@[fff:000::222:1111]:7891/oo/rest/users",
- "http://[fff:000::222:1111]:7891/oo/rest/users", "/oo/rest/users", "user", "password",
- "fff:000::222:1111", 7891 );
- assertRepository( "http://[fff:000::222:1111]:7891/oo/rest/users",
- "http://[fff:000::222:1111]:7891/oo/rest/users", "/oo/rest/users", null, null,
- "fff:000::222:1111", 7891 );
- assertRepository( "http://user:password@[fff:000::222:1111]/oo/rest/users",
- "http://[fff:000::222:1111]/oo/rest/users", "/oo/rest/users", "user", "password",
- "fff:000::222:1111", -1 );
- assertRepository( "http://user:password@[fff:000::222:1111]:7891", "http://[fff:000::222:1111]:7891", "/",
- "user", "password", "fff:000::222:1111", 7891 );
-
- assertRepository( "http://user:password@16.60.56.58:7891/oo/rest/users",
- "http://16.60.56.58:7891/oo/rest/users", "/oo/rest/users", "user", "password", "16.60.56.58",
- 7891 );
- assertRepository( "http://16.60.56.58:7891/oo/rest/users", "http://16.60.56.58:7891/oo/rest/users",
- "/oo/rest/users", null, null, "16.60.56.58", 7891 );
- assertRepository( "http://user:password@16.60.56.58/oo/rest/users", "http://16.60.56.58/oo/rest/users",
- "/oo/rest/users", "user", "password", "16.60.56.58", -1 );
- assertRepository( "http://user:password@16.60.56.58:7891", "http://16.60.56.58:7891", "/", "user", "password",
- "16.60.56.58", 7891 );
-
- assertRepository( "http://user:password@16.60.56.58:7891/oo/rest/users",
- "http://16.60.56.58:7891/oo/rest/users", "/oo/rest/users", "user", "password", "16.60.56.58",
- 7891 );
- assertRepository( "http://16.60.56.58:7891/oo/rest/users", "http://16.60.56.58:7891/oo/rest/users",
- "/oo/rest/users", null, null, "16.60.56.58", 7891 );
- assertRepository( "http://user:password@16.60.56.58/oo/rest/users", "http://16.60.56.58/oo/rest/users",
- "/oo/rest/users", "user", "password", "16.60.56.58", -1 );
- assertRepository( "http://user:password@16.60.56.58:7891", "http://16.60.56.58:7891", "/", "user", "password",
- "16.60.56.58", 7891 );
- }
-
- private void assertRepository( String url, String repoUrl, String baseDir, String user, String password,
- String host, int port )
- {
- Repository repo = new Repository( String.valueOf( System.currentTimeMillis() ), url );
- assertEquals( repoUrl, repo.getUrl() );
- assertEquals( baseDir, repo.getBasedir() );
- assertEquals( host, repo.getHost() );
- assertEquals( user, repo.getUsername() );
- assertEquals( password, repo.getPassword() );
- assertEquals( port, repo.getPort() );
- }
-}
+package org.apache.maven.wagon.repository;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+
+import org.apache.maven.wagon.WagonConstants;
+
+/**
+ * @author <a href="mailto:jvanzyl at maven.org">Jason van Zyl</a>
+ *
+ */
+public class RepositoryTest
+ extends TestCase
+{
+ public RepositoryTest( final String name )
+ {
+ super( name );
+ }
+
+ public void setUp()
+ throws Exception
+ {
+ super.setUp();
+ }
+
+ public void tearDown()
+ throws Exception
+ {
+ super.tearDown();
+ }
+
+ public void testRepositoryProperties()
+ throws Exception
+ {
+ Repository repository = new Repository();
+
+ repository.setBasedir( "directory" );
+
+ assertEquals( "directory", repository.getBasedir() );
+
+ repository.setName( "name" );
+
+ assertEquals( "name", repository.getName() );
+
+ repository.setPort( 0 );
+
+ assertEquals( 0, repository.getPort() );
+
+ assertEquals( "localhost", repository.getHost() );
+
+ repository.setUrl( "http://www.ibiblio.org" );
+
+ assertEquals( "http://www.ibiblio.org", repository.getUrl() );
+
+ assertEquals( "http", repository.getProtocol() );
+
+ assertEquals( "www.ibiblio.org", repository.getHost() );
+
+ assertEquals( "/", repository.getBasedir() );
+
+ assertEquals( WagonConstants.UNKNOWN_PORT, repository.getPort() );
+
+ repository.setUrl( "https://www.ibiblio.org:100/maven" );
+
+ assertEquals( "https://www.ibiblio.org:100/maven", repository.getUrl() );
+
+ assertEquals( "https", repository.getProtocol() );
+
+ assertEquals( "www.ibiblio.org", repository.getHost() );
+
+ assertEquals( "/maven", repository.getBasedir() );
+
+ assertEquals( 100, repository.getPort() );
+
+ assertEquals( "www.ibiblio.org", repository.getHost() );
+
+ repository.setBasedir( "basedir" );
+
+ assertEquals( "basedir", repository.getBasedir() );
+
+ repository.setUrl( "http://brett:porter@www.ibiblio.org" );
+
+ assertEquals( "http://www.ibiblio.org", repository.getUrl() );
+
+ repository.setUrl( "http://brett@www.ibiblio.org" );
+
+ assertEquals( "http://www.ibiblio.org", repository.getUrl() );
+
+ }
+
+ public void testIPv6()
+ {
+ assertRepository( "http://user:password@[fff:::1]:7891/oo/rest/users", "http://[fff:::1]:7891/oo/rest/users",
+ "/oo/rest/users", "user", "password", "fff:::1", 7891 );
+ assertRepository( "http://[fff:::1]:7891/oo/rest/users", "http://[fff:::1]:7891/oo/rest/users",
+ "/oo/rest/users", null, null, "fff:::1", 7891 );
+ assertRepository( "http://user:password@[fff:::1]/oo/rest/users", "http://[fff:::1]/oo/rest/users",
+ "/oo/rest/users", "user", "password", "fff:::1", -1 );
+ assertRepository( "http://user:password@[fff:::1]:7891", "http://[fff:::1]:7891", "/", "user", "password",
+ "fff:::1", 7891 );
+
+ assertRepository( "http://user:password@[fff:000::222:1111]:7891/oo/rest/users",
+ "http://[fff:000::222:1111]:7891/oo/rest/users", "/oo/rest/users", "user", "password",
+ "fff:000::222:1111", 7891 );
+ assertRepository( "http://[fff:000::222:1111]:7891/oo/rest/users",
+ "http://[fff:000::222:1111]:7891/oo/rest/users", "/oo/rest/users", null, null,
+ "fff:000::222:1111", 7891 );
+ assertRepository( "http://user:password@[fff:000::222:1111]/oo/rest/users",
+ "http://[fff:000::222:1111]/oo/rest/users", "/oo/rest/users", "user", "password",
+ "fff:000::222:1111", -1 );
+ assertRepository( "http://user:password@[fff:000::222:1111]:7891", "http://[fff:000::222:1111]:7891", "/",
+ "user", "password", "fff:000::222:1111", 7891 );
+
+ assertRepository( "http://user:password@16.60.56.58:7891/oo/rest/users",
+ "http://16.60.56.58:7891/oo/rest/users", "/oo/rest/users", "user", "password", "16.60.56.58",
+ 7891 );
+ assertRepository( "http://16.60.56.58:7891/oo/rest/users", "http://16.60.56.58:7891/oo/rest/users",
+ "/oo/rest/users", null, null, "16.60.56.58", 7891 );
+ assertRepository( "http://user:password@16.60.56.58/oo/rest/users", "http://16.60.56.58/oo/rest/users",
+ "/oo/rest/users", "user", "password", "16.60.56.58", -1 );
+ assertRepository( "http://user:password@16.60.56.58:7891", "http://16.60.56.58:7891", "/", "user", "password",
+ "16.60.56.58", 7891 );
+
+ assertRepository( "http://user:password@16.60.56.58:7891/oo/rest/users",
+ "http://16.60.56.58:7891/oo/rest/users", "/oo/rest/users", "user", "password", "16.60.56.58",
+ 7891 );
+ assertRepository( "http://16.60.56.58:7891/oo/rest/users", "http://16.60.56.58:7891/oo/rest/users",
+ "/oo/rest/users", null, null, "16.60.56.58", 7891 );
+ assertRepository( "http://user:password@16.60.56.58/oo/rest/users", "http://16.60.56.58/oo/rest/users",
+ "/oo/rest/users", "user", "password", "16.60.56.58", -1 );
+ assertRepository( "http://user:password@16.60.56.58:7891", "http://16.60.56.58:7891", "/", "user", "password",
+ "16.60.56.58", 7891 );
+ }
+
+ private void assertRepository( String url, String repoUrl, String baseDir, String user, String password,
+ String host, int port )
+ {
+ Repository repo = new Repository( String.valueOf( System.currentTimeMillis() ), url );
+ assertEquals( repoUrl, repo.getUrl() );
+ assertEquals( baseDir, repo.getBasedir() );
+ assertEquals( host, repo.getHost() );
+ assertEquals( user, repo.getUsername() );
+ assertEquals( password, repo.getPassword() );
+ assertEquals( port, repo.getPort() );
+ }
+}
diff --git a/wagon-provider-api/src/test/resources/org/apache/maven/wagon/manager/DefaultWagonManagerTest.xml b/wagon-provider-api/src/test/resources/org/apache/maven/wagon/manager/DefaultWagonManagerTest.xml
index b24649c..92f54fa 100644
--- a/wagon-provider-api/src/test/resources/org/apache/maven/wagon/manager/DefaultWagonManagerTest.xml
+++ b/wagon-provider-api/src/test/resources/org/apache/maven/wagon/manager/DefaultWagonManagerTest.xml
@@ -1,43 +1,43 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<plexus>
- <components>
- <component>
- <role>org.apache.maven.wagon.Wagon</role>
- <role-hint>a</role-hint>
- <implementation>org.apache.maven.wagon.manager.WagonA</implementation>
- </component>
- <component>
- <role>org.apache.maven.wagon.Wagon</role>
- <role-hint>b1</role-hint>
- <implementation>org.apache.maven.wagon.manager.WagonB</implementation>
- </component>
- <component>
- <role>org.apache.maven.wagon.Wagon</role>
- <role-hint>b2</role-hint>
- <implementation>org.apache.maven.wagon.manager.WagonB</implementation>
- </component>
- <component>
- <role>org.apache.maven.wagon.Wagon</role>
- <role-hint>c</role-hint>
- <implementation>org.apache.maven.wagon.manager.WagonC</implementation>
- </component>
- </components>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<plexus>
+ <components>
+ <component>
+ <role>org.apache.maven.wagon.Wagon</role>
+ <role-hint>a</role-hint>
+ <implementation>org.apache.maven.wagon.manager.WagonA</implementation>
+ </component>
+ <component>
+ <role>org.apache.maven.wagon.Wagon</role>
+ <role-hint>b1</role-hint>
+ <implementation>org.apache.maven.wagon.manager.WagonB</implementation>
+ </component>
+ <component>
+ <role>org.apache.maven.wagon.Wagon</role>
+ <role-hint>b2</role-hint>
+ <implementation>org.apache.maven.wagon.manager.WagonB</implementation>
+ </component>
+ <component>
+ <role>org.apache.maven.wagon.Wagon</role>
+ <role-hint>c</role-hint>
+ <implementation>org.apache.maven.wagon.manager.WagonC</implementation>
+ </component>
+ </components>
</plexus>
\ No newline at end of file
diff --git a/wagon-provider-test/pom.xml b/wagon-provider-test/pom.xml
index 24aea91..4bffb3b 100644
--- a/wagon-provider-test/pom.xml
+++ b/wagon-provider-test/pom.xml
@@ -1,59 +1,71 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon</artifactId>
- <version>2.10</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>wagon-provider-test</artifactId>
- <name>Apache Maven Wagon :: Provider Test</name>
- <description>Suite of tests for Wagon implementations</description>
-
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-provider-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-container-default</artifactId>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty</artifactId>
- </dependency>
-
- </dependencies>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon</artifactId>
+ <version>2.12</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>wagon-provider-test</artifactId>
+ <name>Apache Maven Wagon :: Provider Test</name>
+ <description>Suite of tests for Wagon implementations</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-provider-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty.aggregate</groupId>
+ <artifactId>jetty-all</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/wagon-provider-test/src/main/java/org/apache/maven/wagon/CommandExecutorTestCase.java b/wagon-provider-test/src/main/java/org/apache/maven/wagon/CommandExecutorTestCase.java
index fd3b401..e44cba4 100644
--- a/wagon-provider-test/src/main/java/org/apache/maven/wagon/CommandExecutorTestCase.java
+++ b/wagon-provider-test/src/main/java/org/apache/maven/wagon/CommandExecutorTestCase.java
@@ -1,109 +1,109 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.codehaus.plexus.PlexusTestCase;
-import org.apache.maven.wagon.repository.Repository;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
-
-/**
- * Base class for command executor tests.
- *
- * @author <a href="mailto:brett at apache.org">Brett Porter</a>
- *
- */
-public abstract class CommandExecutorTestCase
- extends PlexusTestCase
-{
- public void testErrorInCommandExecuted()
- throws Exception
- {
- CommandExecutor exec = (CommandExecutor) lookup( CommandExecutor.ROLE );
-
- Repository repository = getTestRepository();
-
- AuthenticationInfo authenticationInfo = new AuthenticationInfo();
- authenticationInfo.setUserName( System.getProperty( "user.name" ) );
-
- exec.connect( repository, authenticationInfo );
-
- try
- {
- exec.executeCommand( "fail" );
- fail( "Command should have failed" );
- }
- catch ( CommandExecutionException e )
- {
- assertTrue( e.getMessage().trim().endsWith( "fail: command not found" ) );
- }
- finally
- {
- exec.disconnect();
- }
- }
-
- public void testIgnoreFailuresInCommandExecuted()
- throws Exception
- {
- CommandExecutor exec = (CommandExecutor) lookup( CommandExecutor.ROLE );
-
- Repository repository = getTestRepository();
-
- AuthenticationInfo authenticationInfo = new AuthenticationInfo();
- authenticationInfo.setUserName( System.getProperty( "user.name" ) );
-
- exec.connect( repository, authenticationInfo );
-
- try
- {
- Streams streams = exec.executeCommand( "fail", true );
- //expect no exception, and stderr has something.
- assertTrue( streams.getErr().length() > 0 );
- }
- finally
- {
- exec.disconnect();
- }
- }
-
- public void testExecuteSuccessfulCommand()
- throws Exception
- {
- CommandExecutor exec = (CommandExecutor) lookup( CommandExecutor.ROLE );
-
- Repository repository = getTestRepository();
-
- AuthenticationInfo authenticationInfo = new AuthenticationInfo();
- authenticationInfo.setUserName( System.getProperty( "user.name" ) );
-
- exec.connect( repository, authenticationInfo );
-
- try
- {
- exec.executeCommand( "ls" );
- }
- finally
- {
- exec.disconnect();
- }
- }
-
- protected abstract Repository getTestRepository();
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.codehaus.plexus.PlexusTestCase;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+
+/**
+ * Base class for command executor tests.
+ *
+ * @author <a href="mailto:brett at apache.org">Brett Porter</a>
+ *
+ */
+public abstract class CommandExecutorTestCase
+ extends PlexusTestCase
+{
+ public void testErrorInCommandExecuted()
+ throws Exception
+ {
+ CommandExecutor exec = (CommandExecutor) lookup( CommandExecutor.ROLE );
+
+ Repository repository = getTestRepository();
+
+ AuthenticationInfo authenticationInfo = new AuthenticationInfo();
+ authenticationInfo.setUserName( System.getProperty( "user.name" ) );
+
+ exec.connect( repository, authenticationInfo );
+
+ try
+ {
+ exec.executeCommand( "fail" );
+ fail( "Command should have failed" );
+ }
+ catch ( CommandExecutionException e )
+ {
+ assertTrue( e.getMessage().trim().endsWith( "fail: command not found" ) );
+ }
+ finally
+ {
+ exec.disconnect();
+ }
+ }
+
+ public void testIgnoreFailuresInCommandExecuted()
+ throws Exception
+ {
+ CommandExecutor exec = (CommandExecutor) lookup( CommandExecutor.ROLE );
+
+ Repository repository = getTestRepository();
+
+ AuthenticationInfo authenticationInfo = new AuthenticationInfo();
+ authenticationInfo.setUserName( System.getProperty( "user.name" ) );
+
+ exec.connect( repository, authenticationInfo );
+
+ try
+ {
+ Streams streams = exec.executeCommand( "fail", true );
+ //expect no exception, and stderr has something.
+ assertTrue( streams.getErr().length() > 0 );
+ }
+ finally
+ {
+ exec.disconnect();
+ }
+ }
+
+ public void testExecuteSuccessfulCommand()
+ throws Exception
+ {
+ CommandExecutor exec = (CommandExecutor) lookup( CommandExecutor.ROLE );
+
+ Repository repository = getTestRepository();
+
+ AuthenticationInfo authenticationInfo = new AuthenticationInfo();
+ authenticationInfo.setUserName( System.getProperty( "user.name" ) );
+
+ exec.connect( repository, authenticationInfo );
+
+ try
+ {
+ exec.executeCommand( "ls" );
+ }
+ finally
+ {
+ exec.disconnect();
+ }
+ }
+
+ protected abstract Repository getTestRepository();
+}
diff --git a/wagon-provider-test/src/main/java/org/apache/maven/wagon/FileTestUtils.java b/wagon-provider-test/src/main/java/org/apache/maven/wagon/FileTestUtils.java
index 75aa3f0..ac95e14 100644
--- a/wagon-provider-test/src/main/java/org/apache/maven/wagon/FileTestUtils.java
+++ b/wagon-provider-test/src/main/java/org/apache/maven/wagon/FileTestUtils.java
@@ -1,121 +1,121 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.codehaus.plexus.util.FileUtils;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.Writer;
-
-/**
- * @author <a href="michal at apache.org>Michal Maczka</a>
- *
- */
-public class FileTestUtils
-{
-
- public static File createUniqueFile( final String dirname, final String name )
- throws IOException
- {
-
- final File dir = createDir( dirname );
-
- final File retValue = new File( dir, name );
-
- return retValue;
-
- }
-
-
- public static File createUniqueDir( final String name )
- throws IOException
- {
-
- String filename = name + System.currentTimeMillis();
-
- return createDir( filename );
-
- }
-
-
- public static File createDir( final String name )
- throws IOException
- {
-
- final File baseDirectory = getTestOutputDir();
-
- final File retValue = new File( baseDirectory, name );
-
- if ( retValue.exists() )
- {
- FileUtils.cleanDirectory( retValue );
- return retValue;
- }
-
- retValue.mkdirs();
-
- if ( !retValue.exists() )
- {
- throw new IOException( "Unable to create the directory for testdata " + retValue.getPath() );
- }
-
- return retValue;
- }
-
- public static File getTestOutputDir()
- {
- final String tempDir = System.getProperty( "java.io.tmpdir" );
-
- final String baseDir = System.getProperty( "basedir", tempDir );
-
- final File base = new File( baseDir ).getAbsoluteFile();
-
- final String pathname = base + File.separator + "target" + File.separator + "test-output";
-
- final File retValue = new File( pathname );
-
- retValue.mkdirs();
-
- return retValue;
- }
-
- public static File generateFile( String file, String content )
- throws IOException
- {
- File f = new File( file );
-
- f.getParentFile().mkdirs();
-
- Writer writer = new FileWriter( f );
-
- try
- {
- writer.write( content );
- }
- finally
- {
- writer.close();
- }
-
- return f;
- }
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.codehaus.plexus.util.FileUtils;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+
+/**
+ * @author <a href="michal at apache.org>Michal Maczka</a>
+ *
+ */
+public class FileTestUtils
+{
+
+ public static File createUniqueFile( final String dirname, final String name )
+ throws IOException
+ {
+
+ final File dir = createDir( dirname );
+
+ final File retValue = new File( dir, name );
+
+ return retValue;
+
+ }
+
+
+ public static File createUniqueDir( final String name )
+ throws IOException
+ {
+
+ String filename = name + System.currentTimeMillis();
+
+ return createDir( filename );
+
+ }
+
+
+ public static File createDir( final String name )
+ throws IOException
+ {
+
+ final File baseDirectory = getTestOutputDir();
+
+ final File retValue = new File( baseDirectory, name );
+
+ if ( retValue.exists() )
+ {
+ FileUtils.cleanDirectory( retValue );
+ return retValue;
+ }
+
+ retValue.mkdirs();
+
+ if ( !retValue.exists() )
+ {
+ throw new IOException( "Unable to create the directory for testdata " + retValue.getPath() );
+ }
+
+ return retValue;
+ }
+
+ public static File getTestOutputDir()
+ {
+ final String tempDir = System.getProperty( "java.io.tmpdir" );
+
+ final String baseDir = System.getProperty( "basedir", tempDir );
+
+ final File base = new File( baseDir ).getAbsoluteFile();
+
+ final String pathname = base + File.separator + "target" + File.separator + "test-output";
+
+ final File retValue = new File( pathname );
+
+ retValue.mkdirs();
+
+ return retValue;
+ }
+
+ public static File generateFile( String file, String content )
+ throws IOException
+ {
+ File f = new File( file );
+
+ f.getParentFile().mkdirs();
+
+ Writer writer = new FileWriter( f );
+
+ try
+ {
+ writer.write( content );
+ }
+ finally
+ {
+ writer.close();
+ }
+
+ return f;
+ }
+}
diff --git a/wagon-provider-test/src/main/java/org/apache/maven/wagon/StreamingWagonTestCase.java b/wagon-provider-test/src/main/java/org/apache/maven/wagon/StreamingWagonTestCase.java
index 18314b0..f70c85e 100644
--- a/wagon-provider-test/src/main/java/org/apache/maven/wagon/StreamingWagonTestCase.java
+++ b/wagon-provider-test/src/main/java/org/apache/maven/wagon/StreamingWagonTestCase.java
@@ -1,308 +1,316 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.observers.ChecksumObserver;
-import org.apache.maven.wagon.resource.Resource;
-import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.IOUtil;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.text.SimpleDateFormat;
-
-/**
- * @author <a href="mailto:brett at apache.org">Brett Porter</a>
- */
-public abstract class StreamingWagonTestCase
- extends WagonTestCase
-{
- public void testStreamingWagon()
- throws Exception
- {
- if ( supportsGetIfNewer() )
- {
- setupRepositories();
-
- setupWagonTestingFixtures();
-
- streamRoundTripTesting();
-
- tearDownWagonTestingFixtures();
- }
- }
-
- public void testFailedGetToStream()
- throws Exception
- {
- setupRepositories();
-
- setupWagonTestingFixtures();
-
- message( "Getting test artifact from test repository " + testRepository );
-
- StreamingWagon wagon = (StreamingWagon) getWagon();
-
- wagon.addTransferListener( checksumObserver );
-
- wagon.connect( testRepository, getAuthInfo() );
-
- destFile = FileTestUtils.createUniqueFile( getName(), getName() );
-
- destFile.deleteOnExit();
-
- OutputStream stream = null;
-
- try
- {
- stream = new FileOutputStream( destFile );
- wagon.getToStream( "fubar.txt", stream );
- fail( "File was found when it shouldn't have been" );
- }
- catch ( ResourceDoesNotExistException e )
- {
- // expected
- assertTrue( true );
- }
- finally
- {
- wagon.removeTransferListener( checksumObserver );
-
- wagon.disconnect();
-
- IOUtil.close( stream );
-
- tearDownWagonTestingFixtures();
- }
- }
-
- public void testWagonGetIfNewerToStreamIsNewer()
- throws Exception
- {
- if ( supportsGetIfNewer() )
- {
- setupRepositories();
- setupWagonTestingFixtures();
- int expectedSize = putFile();
- // CHECKSTYLE_OFF: MagicNumber
- getIfNewerToStream( getExpectedLastModifiedOnGet( testRepository, new Resource( resource ) ) + 30000, false,
- expectedSize );
- // CHECKSTYLE_ON: MagicNumber
- }
- }
-
- public void testWagonGetIfNewerToStreamIsOlder()
- throws Exception
- {
- if ( supportsGetIfNewer() )
- {
- setupRepositories();
- setupWagonTestingFixtures();
- int expectedSize = putFile();
- getIfNewerToStream( new SimpleDateFormat( "yyyy-MM-dd" ).parse( "2006-01-01" ).getTime(), true,
- expectedSize );
- }
- }
-
- public void testWagonGetIfNewerToStreamIsSame()
- throws Exception
- {
- if ( supportsGetIfNewer() )
- {
- setupRepositories();
- setupWagonTestingFixtures();
- int expectedSize = putFile();
- getIfNewerToStream( getExpectedLastModifiedOnGet( testRepository, new Resource( resource ) ), false,
- expectedSize );
- }
- }
-
- private void getIfNewerToStream( long timestamp, boolean expectedResult, int expectedSize )
- throws Exception
- {
- StreamingWagon wagon = (StreamingWagon) getWagon();
-
- ProgressAnswer progressAnswer = setupGetIfNewerTest( wagon, expectedResult, expectedSize );
-
- connectWagon( wagon );
-
- OutputStream stream = new LazyFileOutputStream( destFile );
-
- try
- {
- boolean result = wagon.getIfNewerToStream( this.resource, stream, timestamp );
- assertEquals( expectedResult, result );
- }
- finally
- {
- IOUtil.close( stream );
- }
-
- disconnectWagon( wagon );
-
- assertGetIfNewerTest( progressAnswer, expectedResult, expectedSize );
-
- tearDownWagonTestingFixtures();
- }
-
- public void testFailedGetIfNewerToStream()
- throws Exception
- {
- if ( supportsGetIfNewer() )
- {
- setupRepositories();
- setupWagonTestingFixtures();
- message( "Getting test artifact from test repository " + testRepository );
- StreamingWagon wagon = (StreamingWagon) getWagon();
- wagon.addTransferListener( checksumObserver );
- wagon.connect( testRepository, getAuthInfo() );
- destFile = FileTestUtils.createUniqueFile( getName(), getName() );
- destFile.deleteOnExit();
- OutputStream stream = null;
- try
- {
- stream = new FileOutputStream( destFile );
- wagon.getIfNewerToStream( "fubar.txt", stream, 0 );
- fail( "File was found when it shouldn't have been" );
- }
- catch ( ResourceDoesNotExistException e )
- {
- // expected
- assertTrue( true );
- }
- finally
- {
- wagon.removeTransferListener( checksumObserver );
-
- wagon.disconnect();
-
- IOUtil.close( stream );
-
- tearDownWagonTestingFixtures();
- }
- }
- }
-
- protected void streamRoundTripTesting()
- throws Exception
- {
- message( "Stream round trip testing ..." );
-
- int expectedSize = putStream();
-
- assertNotNull( "check checksum is not null", checksumObserver.getActualChecksum() );
-
- assertEquals( "compare checksums", "6b144b7285ffd6b0bc8300da162120b9", checksumObserver.getActualChecksum() );
-
- checksumObserver = new ChecksumObserver();
-
- getStream( expectedSize );
-
- assertNotNull( "check checksum is not null", checksumObserver.getActualChecksum() );
-
- assertEquals( "compare checksums", "6b144b7285ffd6b0bc8300da162120b9", checksumObserver.getActualChecksum() );
-
- // Now compare the conents of the artifact that was placed in
- // the repository with the contents of the artifact that was
- // retrieved from the repository.
-
- String sourceContent = FileUtils.fileRead( sourceFile );
-
- String destContent = FileUtils.fileRead( destFile );
-
- assertEquals( sourceContent, destContent );
- }
-
- private int putStream()
- throws Exception
- {
- String content = "test-resource.txt\n";
- sourceFile = new File( FileTestUtils.getTestOutputDir(), "test-resource" );
- sourceFile.getParentFile().mkdirs();
- FileUtils.fileWrite( sourceFile.getAbsolutePath(), content );
-
- StreamingWagon wagon = (StreamingWagon) getWagon();
-
- ProgressAnswer progressAnswer = replayMockForPut( resource, content, wagon );
-
- message( "Putting test artifact: " + resource + " into test repository " + testRepository );
-
- connectWagon( wagon );
-
- InputStream stream = null;
-
- try
- {
- stream = new FileInputStream( sourceFile );
- wagon.putFromStream( stream, resource, sourceFile.length(), sourceFile.lastModified() );
- }
- catch ( Exception e )
- {
- logger.error( "error while putting resources to the FTP Server", e );
- }
- finally
- {
- IOUtil.close( stream );
- }
-
- disconnectWagon( wagon );
-
- verifyMock( progressAnswer, content.length() );
- return content.length();
- }
-
- private void getStream( int expectedSize )
- throws Exception
- {
- destFile = FileTestUtils.createUniqueFile( getName(), getName() );
- destFile.deleteOnExit();
-
- StreamingWagon wagon = (StreamingWagon) getWagon();
-
- ProgressAnswer progressAnswer = replaceMockForGet( wagon, expectedSize );
-
- message( "Getting test artifact from test repository " + testRepository );
-
- connectWagon( wagon );
-
- OutputStream stream = null;
-
- try
- {
- stream = new FileOutputStream( destFile );
- wagon.getToStream( this.resource, stream );
- }
- catch ( Exception e )
- {
- logger.error( "error while reading resources from the FTP Server", e );
- }
- finally
- {
- IOUtil.close( stream );
- }
-
- disconnectWagon( wagon );
-
- verifyMock( progressAnswer, expectedSize );
- }
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.observers.ChecksumObserver;
+import org.apache.maven.wagon.resource.Resource;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.text.SimpleDateFormat;
+
+/**
+ * @author <a href="mailto:brett at apache.org">Brett Porter</a>
+ */
+public abstract class StreamingWagonTestCase
+ extends WagonTestCase
+{
+ public void testStreamingWagon()
+ throws Exception
+ {
+ if ( supportsGetIfNewer() )
+ {
+ setupRepositories();
+
+ setupWagonTestingFixtures();
+
+ streamRoundTripTesting();
+
+ tearDownWagonTestingFixtures();
+ }
+ }
+
+ public void testFailedGetToStream()
+ throws Exception
+ {
+ setupRepositories();
+
+ setupWagonTestingFixtures();
+
+ message( "Getting test artifact from test repository " + testRepository );
+
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+
+ wagon.addTransferListener( checksumObserver );
+
+ wagon.connect( testRepository, getAuthInfo() );
+
+ destFile = FileTestUtils.createUniqueFile( getName(), getName() );
+
+ destFile.deleteOnExit();
+
+ OutputStream stream = null;
+
+ try
+ {
+ stream = new FileOutputStream( destFile );
+ wagon.getToStream( "fubar.txt", stream );
+ fail( "File was found when it shouldn't have been" );
+ stream.close();
+ stream = null;
+ }
+ catch ( ResourceDoesNotExistException e )
+ {
+ // expected
+ assertTrue( true );
+ }
+ finally
+ {
+ wagon.removeTransferListener( checksumObserver );
+
+ wagon.disconnect();
+
+ IOUtil.close( stream );
+
+ tearDownWagonTestingFixtures();
+ }
+ }
+
+ public void testWagonGetIfNewerToStreamIsNewer()
+ throws Exception
+ {
+ if ( supportsGetIfNewer() )
+ {
+ setupRepositories();
+ setupWagonTestingFixtures();
+ int expectedSize = putFile();
+ // CHECKSTYLE_OFF: MagicNumber
+ getIfNewerToStream( getExpectedLastModifiedOnGet( testRepository, new Resource( resource ) ) + 30000, false,
+ expectedSize );
+ // CHECKSTYLE_ON: MagicNumber
+ }
+ }
+
+ public void testWagonGetIfNewerToStreamIsOlder()
+ throws Exception
+ {
+ if ( supportsGetIfNewer() )
+ {
+ setupRepositories();
+ setupWagonTestingFixtures();
+ int expectedSize = putFile();
+ getIfNewerToStream( new SimpleDateFormat( "yyyy-MM-dd" ).parse( "2006-01-01" ).getTime(), true,
+ expectedSize );
+ }
+ }
+
+ public void testWagonGetIfNewerToStreamIsSame()
+ throws Exception
+ {
+ if ( supportsGetIfNewer() )
+ {
+ setupRepositories();
+ setupWagonTestingFixtures();
+ int expectedSize = putFile();
+ getIfNewerToStream( getExpectedLastModifiedOnGet( testRepository, new Resource( resource ) ), false,
+ expectedSize );
+ }
+ }
+
+ private void getIfNewerToStream( long timestamp, boolean expectedResult, int expectedSize )
+ throws Exception
+ {
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+
+ ProgressAnswer progressAnswer = setupGetIfNewerTest( wagon, expectedResult, expectedSize );
+
+ connectWagon( wagon );
+
+ OutputStream stream = new LazyFileOutputStream( destFile );
+
+ try
+ {
+ boolean result = wagon.getIfNewerToStream( this.resource, stream, timestamp );
+ assertEquals( expectedResult, result );
+ }
+ finally
+ {
+ stream.close();
+ }
+
+ disconnectWagon( wagon );
+
+ assertGetIfNewerTest( progressAnswer, expectedResult, expectedSize );
+
+ tearDownWagonTestingFixtures();
+ }
+
+ public void testFailedGetIfNewerToStream()
+ throws Exception
+ {
+ if ( supportsGetIfNewer() )
+ {
+ setupRepositories();
+ setupWagonTestingFixtures();
+ message( "Getting test artifact from test repository " + testRepository );
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+ wagon.addTransferListener( checksumObserver );
+ wagon.connect( testRepository, getAuthInfo() );
+ destFile = FileTestUtils.createUniqueFile( getName(), getName() );
+ destFile.deleteOnExit();
+ OutputStream stream = null;
+ try
+ {
+ stream = new FileOutputStream( destFile );
+ wagon.getIfNewerToStream( "fubar.txt", stream, 0 );
+ fail( "File was found when it shouldn't have been" );
+ stream.close();
+ stream = null;
+ }
+ catch ( ResourceDoesNotExistException e )
+ {
+ // expected
+ assertTrue( true );
+ }
+ finally
+ {
+ wagon.removeTransferListener( checksumObserver );
+
+ wagon.disconnect();
+
+ IOUtil.close( stream );
+
+ tearDownWagonTestingFixtures();
+ }
+ }
+ }
+
+ protected void streamRoundTripTesting()
+ throws Exception
+ {
+ message( "Stream round trip testing ..." );
+
+ int expectedSize = putStream();
+
+ assertNotNull( "check checksum is not null", checksumObserver.getActualChecksum() );
+
+ assertEquals( "compare checksums", "6b144b7285ffd6b0bc8300da162120b9", checksumObserver.getActualChecksum() );
+
+ checksumObserver = new ChecksumObserver();
+
+ getStream( expectedSize );
+
+ assertNotNull( "check checksum is not null", checksumObserver.getActualChecksum() );
+
+ assertEquals( "compare checksums", "6b144b7285ffd6b0bc8300da162120b9", checksumObserver.getActualChecksum() );
+
+ // Now compare the conents of the artifact that was placed in
+ // the repository with the contents of the artifact that was
+ // retrieved from the repository.
+
+ String sourceContent = FileUtils.fileRead( sourceFile );
+
+ String destContent = FileUtils.fileRead( destFile );
+
+ assertEquals( sourceContent, destContent );
+ }
+
+ private int putStream()
+ throws Exception
+ {
+ String content = "test-resource.txt\n";
+ sourceFile = new File( FileTestUtils.getTestOutputDir(), "test-resource" );
+ sourceFile.getParentFile().mkdirs();
+ FileUtils.fileWrite( sourceFile.getAbsolutePath(), content );
+
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+
+ ProgressAnswer progressAnswer = replayMockForPut( resource, content, wagon );
+
+ message( "Putting test artifact: " + resource + " into test repository " + testRepository );
+
+ connectWagon( wagon );
+
+ InputStream stream = null;
+
+ try
+ {
+ stream = new FileInputStream( sourceFile );
+ wagon.putFromStream( stream, resource, sourceFile.length(), sourceFile.lastModified() );
+ stream.close();
+ stream = null;
+ }
+ catch ( Exception e )
+ {
+ logger.error( "error while putting resources to the FTP Server", e );
+ }
+ finally
+ {
+ IOUtil.close( stream );
+ }
+
+ disconnectWagon( wagon );
+
+ verifyMock( progressAnswer, content.length() );
+ return content.length();
+ }
+
+ private void getStream( int expectedSize )
+ throws Exception
+ {
+ destFile = FileTestUtils.createUniqueFile( getName(), getName() );
+ destFile.deleteOnExit();
+
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+
+ ProgressAnswer progressAnswer = replaceMockForGet( wagon, expectedSize );
+
+ message( "Getting test artifact from test repository " + testRepository );
+
+ connectWagon( wagon );
+
+ OutputStream stream = null;
+
+ try
+ {
+ stream = new FileOutputStream( destFile );
+ wagon.getToStream( this.resource, stream );
+ stream.close();
+ stream = null;
+ }
+ catch ( Exception e )
+ {
+ logger.error( "error while reading resources from the FTP Server", e );
+ }
+ finally
+ {
+ IOUtil.close( stream );
+ }
+
+ disconnectWagon( wagon );
+
+ verifyMock( progressAnswer, expectedSize );
+ }
+}
diff --git a/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java b/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java
index d79c187..4e92a44 100644
--- a/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java
+++ b/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java
@@ -1,1088 +1,1090 @@
-package org.apache.maven.wagon;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.log4j.Logger;
-import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
-import org.apache.maven.wagon.authorization.AuthorizationException;
-import org.apache.maven.wagon.events.TransferEvent;
-import org.apache.maven.wagon.events.TransferListener;
-import org.apache.maven.wagon.observers.ChecksumObserver;
-import org.apache.maven.wagon.observers.Debug;
-import org.apache.maven.wagon.repository.Repository;
-import org.apache.maven.wagon.repository.RepositoryPermissions;
-import org.apache.maven.wagon.resource.Resource;
-import org.codehaus.plexus.PlexusTestCase;
-import org.codehaus.plexus.util.FileUtils;
-import org.easymock.IAnswer;
-
-// CHECKSTYLE_OFF: AvoidStarImport
-import static org.easymock.EasyMock.*;
-//CHECKSTYLE_ON: AvoidStarImport
-
-import java.io.File;
-import java.io.IOException;
-import java.security.NoSuchAlgorithmException;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @author <a href="mailto:jason at maven.org">Jason van Zyl</a>
- */
-public abstract class WagonTestCase
- extends PlexusTestCase
-{
- protected static Logger logger = Logger.getLogger( WagonTestCase.class );
-
-
- static final class ProgressAnswer implements IAnswer
- {
- private int size;
-
- public Object answer() throws Throwable
- {
- int length = (Integer) getCurrentArguments()[2];
- size += length;
- return null;
- }
-
- public int getSize()
- {
- return size;
- }
- }
-
- protected static final String POM = "pom.xml";
-
- protected Repository localRepository;
-
- protected Repository testRepository;
-
- protected String localRepositoryPath;
-
- protected File sourceFile;
-
- protected File destFile;
-
- protected String resource;
-
- protected File artifactSourceFile;
-
- protected File artifactDestFile;
-
- protected ChecksumObserver checksumObserver;
-
- protected TransferListener mockTransferListener;
-
- // ----------------------------------------------------------------------
- // Constructors
- // ----------------------------------------------------------------------
-
- protected void setUp()
- throws Exception
- {
- checksumObserver = new ChecksumObserver();
-
- mockTransferListener = createMock( TransferListener.class );
-
- super.setUp();
- }
-
- // ----------------------------------------------------------------------
- // Methods that should be provided by subclasses for proper testing
- // ----------------------------------------------------------------------
-
- /**
- * URL of the repository. For a complete test it should point to a non existing folder so we also check for the
- * creation of new folders in the remote site. <p/> return the URL of the repository as specified by Wagon syntax
- */
- protected abstract String getTestRepositoryUrl()
- throws IOException;
-
- /**
- * Protocol id of the Wagon to use, eg. <code>scp</code>, <code>ftp</code>
- *
- * @return the protocol id
- */
- protected abstract String getProtocol();
-
- /**
- * The number of the port which should get used to start the test server
- *
- * @return the port number for the test server
- */
- protected abstract int getTestRepositoryPort();
-
- // ----------------------------------------------------------------------
- // 1. Create a local file repository which mimic a users local file
- // Repository.
- //
- // 2. Create a test repository for the type of wagon we are testing. So,
- // for example, for testing the file wagon we might have a test
- // repository url of file://${basedir}/target/file-repository.
- // ----------------------------------------------------------------------
-
- protected void setupRepositories()
- throws Exception
- {
- resource = "test-resource";
-
- // ----------------------------------------------------------------------
- // Create the test repository for the wagon we are testing.
- // ----------------------------------------------------------------------
-
- testRepository = new Repository();
-
- testRepository.setUrl( getTestRepositoryUrl() );
-
- testRepository.setPermissions( getPermissions() );
-
- // ----------------------------------------------------------------------
- // Create a test local repository.
- // ----------------------------------------------------------------------
-
- localRepositoryPath = FileTestUtils.createDir( "local-repository" ).getPath();
-
- localRepository = createFileRepository( "file://" + localRepositoryPath );
-
- message( "Local repository: " + localRepository );
-
- File f = new File( localRepositoryPath );
-
- if ( !f.exists() )
- {
- f.mkdirs();
- }
- }
-
- protected void customizeContext()
- throws Exception
- {
- getContainer().addContextValue( "test.repository", localRepositoryPath );
- }
-
- protected void setupWagonTestingFixtures()
- throws Exception
- {
- }
-
- protected void tearDownWagonTestingFixtures()
- throws Exception
- {
- }
-
- // ----------------------------------------------------------------------
- //
- // ----------------------------------------------------------------------
-
- protected AuthenticationInfo getAuthInfo()
- {
- return new AuthenticationInfo();
- }
-
- protected RepositoryPermissions getPermissions()
- {
- return new RepositoryPermissions();
- }
-
- protected Wagon getWagon()
- throws Exception
- {
- Wagon wagon = (Wagon) lookup( Wagon.ROLE, getProtocol() );
-
- Debug debug = new Debug();
-
- wagon.addSessionListener( debug );
-
- wagon.addTransferListener( debug );
-
- return wagon;
- }
-
- protected void message( String message )
- {
- logger.info( message );
- }
-
- // ----------------------------------------------------------------------
- //
- // ----------------------------------------------------------------------
-
- public void testWagon()
- throws Exception
- {
- if ( supportsGetIfNewer() )
- {
- setupRepositories();
-
- setupWagonTestingFixtures();
-
- fileRoundTripTesting();
-
- tearDownWagonTestingFixtures();
- }
- }
-
- public void testWagonGetIfNewerIsNewer()
- throws Exception
- {
- if ( supportsGetIfNewer() )
- {
- setupRepositories();
- setupWagonTestingFixtures();
- int expectedSize = putFile();
- // CHECKSTYLE_OFF: MagicNumber
- getIfNewer( getExpectedLastModifiedOnGet( testRepository, new Resource( resource ) ) + 30000, false,
- expectedSize );
- // CHECKSTYLE_ON: MagicNumber
- }
- }
-
- protected boolean supportsGetIfNewer()
- {
- return true;
- }
-
-
- public void testWagonGetIfNewerIsSame()
- throws Exception
- {
- if ( supportsGetIfNewer() )
- {
- setupRepositories();
- setupWagonTestingFixtures();
- int expectedSize = putFile();
- getIfNewer( getExpectedLastModifiedOnGet( testRepository, new Resource( resource ) ), false, expectedSize );
- }
- }
-
- public void testWagonGetIfNewerIsOlder()
- throws Exception
- {
- if ( supportsGetIfNewer() )
- {
- setupRepositories();
- setupWagonTestingFixtures();
- int expectedSize = putFile();
- getIfNewer( new SimpleDateFormat( "yyyy-MM-dd" ).parse( "2006-01-01" ).getTime(), true, expectedSize );
- }
- }
-
- private void getIfNewer( long timestamp, boolean expectedResult, int expectedSize )
- throws Exception
- {
- Wagon wagon = getWagon();
-
- ProgressAnswer progressAnswer = setupGetIfNewerTest( wagon, expectedResult, expectedSize );
-
- connectWagon( wagon );
-
- boolean result = wagon.getIfNewer( this.resource, destFile, timestamp );
- assertEquals( expectedResult, result );
-
- disconnectWagon( wagon );
-
- assertGetIfNewerTest( progressAnswer, expectedResult, expectedSize );
-
- tearDownWagonTestingFixtures();
- }
-
- protected ProgressAnswer setupGetIfNewerTest( Wagon wagon, boolean expectedResult, int expectedSize )
- throws NoSuchAlgorithmException, IOException
- {
- checksumObserver = new ChecksumObserver();
-
- destFile = FileTestUtils.createUniqueFile( getName(), getName() );
- destFile.delete();
- assertFalse( destFile.exists() );
- destFile.deleteOnExit();
-
- ProgressAnswer progressAnswer = null;
- if ( expectedResult )
- {
- progressAnswer = replaceMockForGet( wagon, expectedSize );
- }
- else
- {
- replaceMockForSkippedGetIfNewer( wagon, expectedSize );
- }
- return progressAnswer;
- }
-
- protected void assertGetIfNewerTest( ProgressAnswer progressAnswer, boolean expectedResult,
- int expectedSize )
- throws IOException
- {
- if ( expectedResult )
- {
- verifyMock( progressAnswer, expectedSize );
-
- assertNotNull( "check checksum is not null", checksumObserver.getActualChecksum() );
-
- assertEquals( "compare checksums", "6b144b7285ffd6b0bc8300da162120b9",
- checksumObserver.getActualChecksum() );
-
- // Now compare the contents of the artifact that was placed in
- // the repository with the contents of the artifact that was
- // retrieved from the repository.
-
- String sourceContent = FileUtils.fileRead( sourceFile );
- String destContent = FileUtils.fileRead( destFile );
- assertEquals( sourceContent, destContent );
- }
- else
- {
- verify( mockTransferListener );
-
- reset( mockTransferListener );
-
- assertNull( "check checksum is null", checksumObserver.getActualChecksum() );
-
- assertFalse( destFile.exists() );
- }
- }
-
-
- private void replaceMockForSkippedGetIfNewer( Wagon wagon, int expectedSize )
- {
- Resource resource = new Resource( this.resource );
- mockTransferListener.transferInitiated(
- createTransferEvent( wagon, resource, TransferEvent.TRANSFER_INITIATED, TransferEvent.REQUEST_GET,
- destFile ) );
- resource = new Resource( this.resource );
- resource.setContentLength( getExpectedContentLengthOnGet( expectedSize ) );
- resource.setLastModified( getExpectedLastModifiedOnGet( testRepository, resource ) );
- // TODO: transfer skipped event?
- // mockTransferListener.transferSkipped( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_STARTED,
- // TransferEvent.REQUEST_GET, destFile ) );
-
- mockTransferListener.debug( anyString() );
- expectLastCall().anyTimes();
-
- replay( mockTransferListener );
- }
-
- public void testWagonPutDirectory()
- throws Exception
- {
- setupRepositories();
-
- setupWagonTestingFixtures();
-
- Wagon wagon = getWagon();
-
- if ( wagon.supportsDirectoryCopy() )
- {
- sourceFile = new File( FileTestUtils.getTestOutputDir(), "directory-copy" );
-
- FileUtils.deleteDirectory( sourceFile );
-
- writeTestFile( "test-resource-1.txt" );
- writeTestFile( "a/test-resource-2.txt" );
- writeTestFile( "a/b/test-resource-3.txt" );
- writeTestFile( "c/test-resource-4.txt" );
- writeTestFile( "d/e/f/test-resource-5.txt" );
-
- wagon.connect( testRepository, getAuthInfo() );
-
- wagon.putDirectory( sourceFile, "directory-copy" );
-
- destFile = FileTestUtils.createUniqueFile( getName(), getName() );
-
- destFile.deleteOnExit();
-
- wagon.get( "directory-copy/test-resource-1.txt", destFile );
- wagon.get( "directory-copy/a/test-resource-2.txt", destFile );
- wagon.get( "directory-copy/a/b/test-resource-3.txt", destFile );
- wagon.get( "directory-copy/c/test-resource-4.txt", destFile );
- wagon.get( "directory-copy/d/e/f/test-resource-5.txt", destFile );
-
- wagon.disconnect();
- }
-
- tearDownWagonTestingFixtures();
- }
-
- /**
- * Test for putting a directory with a destination that multiple directories deep, all of which haven't been
- * created.
- *
- * @throws Exception
- * @since 1.0-beta-2
- */
- public void testWagonPutDirectoryDeepDestination()
- throws Exception
- {
- setupRepositories();
-
- setupWagonTestingFixtures();
-
- Wagon wagon = getWagon();
-
- if ( wagon.supportsDirectoryCopy() )
- {
- sourceFile = new File( FileTestUtils.getTestOutputDir(), "deep0/deep1/deep2" );
-
- FileUtils.deleteDirectory( sourceFile );
-
- writeTestFile( "test-resource-1.txt" );
- writeTestFile( "a/test-resource-2.txt" );
- writeTestFile( "a/b/test-resource-3.txt" );
- writeTestFile( "c/test-resource-4.txt" );
- writeTestFile( "d/e/f/test-resource-5.txt" );
-
- wagon.connect( testRepository, getAuthInfo() );
-
- wagon.putDirectory( sourceFile, "deep0/deep1/deep2" );
-
- destFile = FileTestUtils.createUniqueFile( getName(), getName() );
-
- destFile.deleteOnExit();
-
- wagon.get( "deep0/deep1/deep2/test-resource-1.txt", destFile );
- wagon.get( "deep0/deep1/deep2/a/test-resource-2.txt", destFile );
- wagon.get( "deep0/deep1/deep2/a/b/test-resource-3.txt", destFile );
- wagon.get( "deep0/deep1/deep2/c/test-resource-4.txt", destFile );
- wagon.get( "deep0/deep1/deep2/d/e/f/test-resource-5.txt", destFile );
-
- wagon.disconnect();
- }
-
- tearDownWagonTestingFixtures();
- }
-
- /**
- * Test that when putting a directory that already exists new files get also copied
- *
- * @throws Exception
- * @since 1.0-beta-1
- */
- public void testWagonPutDirectoryWhenDirectoryAlreadyExists()
- throws Exception
- {
-
- final String dirName = "directory-copy-existing";
-
- final String resourceToCreate = "test-resource-1.txt";
-
- final String[] resources = { "a/test-resource-2.txt", "a/b/test-resource-3.txt", "c/test-resource-4.txt" };
-
- setupRepositories();
-
- setupWagonTestingFixtures();
-
- Wagon wagon = getWagon();
-
- if ( wagon.supportsDirectoryCopy() )
- {
- sourceFile = new File( FileTestUtils.getTestOutputDir(), dirName );
-
- FileUtils.deleteDirectory( sourceFile );
-
- createDirectory( wagon, resourceToCreate, dirName );
-
- for ( String resource : resources )
- {
- writeTestFile( resource );
- }
-
- wagon.connect( testRepository, getAuthInfo() );
-
- wagon.putDirectory( sourceFile, dirName );
-
- List<String> resourceNames = new ArrayList<String>( resources.length + 1 );
-
- resourceNames.add( dirName + "/" + resourceToCreate );
- for ( String resource : resources )
- {
- resourceNames.add( dirName + "/" + resource );
- }
-
- assertResourcesAreInRemoteSide( wagon, resourceNames );
-
- wagon.disconnect();
- }
-
- tearDownWagonTestingFixtures();
- }
-
- /**
- * Test that when putting a directory that already exists new files get also copied and destination is "."
- *
- * @throws Exception
- * @since 1.0-beta-1
- */
- public void testWagonPutDirectoryForDot()
- throws Exception
- {
- final String resourceToCreate = "test-resource-1.txt";
-
- final String[] resources = { "a/test-resource-2.txt", "a/b/test-resource-3.txt", "c/test-resource-4.txt" };
-
- setupRepositories();
-
- setupWagonTestingFixtures();
-
- Wagon wagon = getWagon();
-
- if ( wagon.supportsDirectoryCopy() )
- {
- sourceFile = new File( FileTestUtils.getTestOutputDir(), "dot-repo" );
-
- FileUtils.deleteDirectory( sourceFile );
-
- createDirectory( wagon, resourceToCreate, "." );
-
- for ( String resource : resources )
- {
- writeTestFile( resource );
- }
-
- wagon.connect( testRepository, getAuthInfo() );
-
- wagon.putDirectory( sourceFile, "." );
-
- List<String> resourceNames = new ArrayList<String>( resources.length + 1 );
-
- resourceNames.add( resourceToCreate );
- Collections.addAll( resourceNames, resources );
-
- assertResourcesAreInRemoteSide( wagon, resourceNames );
-
- wagon.disconnect();
- }
-
- tearDownWagonTestingFixtures();
- }
-
- /**
- * Create a directory with a resource and check that the other ones don't exist
- *
- * @param wagon
- * @param resourceToCreate name of the resource to be created
- * @param dirName directory name to create
- * @throws Exception
- */
- protected void createDirectory( Wagon wagon, String resourceToCreate, String dirName )
- throws Exception
- {
- writeTestFile( resourceToCreate );
- }
-
- protected void assertResourcesAreInRemoteSide( Wagon wagon, List<String> resourceNames )
- throws IOException, TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- for ( String resourceName : resourceNames )
- {
- File destFile = FileTestUtils.createUniqueFile( getName(), resourceName );
-
- destFile.deleteOnExit();
-
- wagon.get( resourceName, destFile );
- }
- }
-
- /**
- * Assert that a resource does not exist in the remote wagon system
- *
- * @param wagon wagon to get the resource from
- * @param resourceName name of the resource
- * @throws IOException if a temp file can't be created
- * @throws AuthorizationException
- * @throws TransferFailedException
- * @since 1.0-beta-1
- */
- protected void assertNotExists( Wagon wagon, String resourceName )
- throws IOException, TransferFailedException, AuthorizationException
- {
- File tmpFile = File.createTempFile( "wagon", null );
- try
- {
- wagon.get( resourceName, tmpFile );
- fail( "Resource exists: " + resourceName );
- }
- catch ( ResourceDoesNotExistException e )
- {
- // ok
- }
- finally
- {
- tmpFile.delete();
- }
- }
-
- private void writeTestFile( String child )
- throws IOException
- {
- File dir = new File( sourceFile, child );
- dir.getParentFile().mkdirs();
- FileUtils.fileWrite( dir.getAbsolutePath(), child );
- }
-
- public void testFailedGet()
- throws Exception
- {
- setupRepositories();
-
- setupWagonTestingFixtures();
-
- message( "Getting test artifact from test repository " + testRepository );
-
- Wagon wagon = getWagon();
-
- wagon.addTransferListener( checksumObserver );
-
- wagon.connect( testRepository, getAuthInfo() );
-
- destFile = FileTestUtils.createUniqueFile( getName(), getName() );
-
- destFile.deleteOnExit();
-
- try
- {
- wagon.get( "fubar.txt", destFile );
- fail( "File was found when it shouldn't have been" );
- }
- catch ( ResourceDoesNotExistException e )
- {
- // expected
- assertTrue( true );
- }
- finally
- {
- wagon.removeTransferListener( checksumObserver );
-
- wagon.disconnect();
-
- tearDownWagonTestingFixtures();
- }
- }
-
- public void testFailedGetIfNewer()
- throws Exception
- {
- if ( supportsGetIfNewer() )
- {
- setupRepositories();
- setupWagonTestingFixtures();
- message( "Getting test artifact from test repository " + testRepository );
- Wagon wagon = getWagon();
- wagon.addTransferListener( checksumObserver );
- wagon.connect( testRepository, getAuthInfo() );
- destFile = FileTestUtils.createUniqueFile( getName(), getName() );
- destFile.deleteOnExit();
- try
- {
- wagon.getIfNewer( "fubar.txt", destFile, 0 );
- fail( "File was found when it shouldn't have been" );
- }
- catch ( ResourceDoesNotExistException e )
- {
- // expected
- assertTrue( true );
- }
- finally
- {
- wagon.removeTransferListener( checksumObserver );
-
- wagon.disconnect();
-
- tearDownWagonTestingFixtures();
- }
- }
- }
-
- /**
- * Test {@link Wagon#getFileList(String)}.
- *
- * @throws Exception
- * @since 1.0-beta-2
- */
- public void testWagonGetFileList()
- throws Exception
- {
- setupRepositories();
-
- setupWagonTestingFixtures();
-
- String dirName = "file-list";
-
- String filenames[] =
- new String[]{ "test-resource.txt", "test-resource.pom", "test-resource b.txt", "more-resources.dat",
- ".index.txt" };
-
- for ( String filename : filenames )
- {
- putFile( dirName + "/" + filename, dirName + "/" + filename, filename + "\n" );
- }
-
- Wagon wagon = getWagon();
-
- wagon.connect( testRepository, getAuthInfo() );
-
- List<String> list = wagon.getFileList( dirName );
- assertNotNull( "file list should not be null.", list );
- assertTrue( "file list should contain more items (actually contains '" + list + "').",
- list.size() >= filenames.length );
-
- for ( String filename : filenames )
- {
- assertTrue( "Filename '" + filename + "' should be in list.", list.contains( filename ) );
- }
-
- // WAGON-250
- list = wagon.getFileList( "" );
- assertNotNull( "file list should not be null.", list );
- assertTrue( "file list should contain items (actually contains '" + list + "').", !list.isEmpty() );
- assertTrue( list.contains( "file-list/" ) );
- assertFalse( list.contains( "file-list" ) );
- assertFalse( list.contains( "." ) );
- assertFalse( list.contains( ".." ) );
- assertFalse( list.contains( "./" ) );
- assertFalse( list.contains( "../" ) );
-
- wagon.disconnect();
-
- tearDownWagonTestingFixtures();
- }
-
- /**
- * Test {@link Wagon#getFileList(String)} when the directory does not exist.
- *
- * @throws Exception
- * @since 1.0-beta-2
- */
- public void testWagonGetFileListWhenDirectoryDoesNotExist()
- throws Exception
- {
- setupRepositories();
-
- setupWagonTestingFixtures();
-
- String dirName = "file-list-unexisting";
-
- Wagon wagon = getWagon();
-
- wagon.connect( testRepository, getAuthInfo() );
-
- try
- {
- wagon.getFileList( dirName );
- fail( "getFileList on unexisting directory must throw ResourceDoesNotExistException" );
- }
- catch ( ResourceDoesNotExistException e )
- {
- // expected
- }
- finally
- {
- wagon.disconnect();
-
- tearDownWagonTestingFixtures();
- }
- }
-
- /**
- * Test for an existing resource.
- *
- * @throws Exception
- * @since 1.0-beta-2
- */
- public void testWagonResourceExists()
- throws Exception
- {
- setupRepositories();
-
- setupWagonTestingFixtures();
-
- Wagon wagon = getWagon();
-
- putFile();
-
- wagon.connect( testRepository, getAuthInfo() );
-
- assertTrue( sourceFile.getName() + " does not exist", wagon.resourceExists( sourceFile.getName() ) );
-
- wagon.disconnect();
-
- tearDownWagonTestingFixtures();
- }
-
- /**
- * Test for an invalid resource.
- *
- * @throws Exception
- * @since 1.0-beta-2
- */
- public void testWagonResourceNotExists()
- throws Exception
- {
- setupRepositories();
-
- setupWagonTestingFixtures();
-
- Wagon wagon = getWagon();
-
- wagon.connect( testRepository, getAuthInfo() );
-
- assertFalse( wagon.resourceExists( "a/bad/resource/name/that/should/not/exist.txt" ) );
-
- wagon.disconnect();
-
- tearDownWagonTestingFixtures();
- }
-
- // ----------------------------------------------------------------------
- // File <--> File round trip testing
- // ----------------------------------------------------------------------
- // We are testing taking a file, our sourcefile, and placing it into the
- // test repository that we have setup.
- // ----------------------------------------------------------------------
-
- protected void putFile( String resourceName, String testFileName, String content )
- throws Exception
- {
- sourceFile = new File( FileTestUtils.getTestOutputDir(), testFileName );
- sourceFile.getParentFile().mkdirs();
- FileUtils.fileWrite( sourceFile.getAbsolutePath(), content );
-
- Wagon wagon = getWagon();
-
- ProgressAnswer progressAnswer = replayMockForPut( resourceName, content, wagon );
-
- message( "Putting test artifact: " + resourceName + " into test repository " + testRepository );
-
- connectWagon( wagon );
-
- wagon.put( sourceFile, resourceName );
-
- disconnectWagon( wagon );
-
- verifyMock( progressAnswer, content.length() );
- }
-
- protected ProgressAnswer replayMockForPut( String resourceName, String content, Wagon wagon )
- {
- Resource resource = new Resource( resourceName );
- mockTransferListener.transferInitiated(
- createTransferEvent( wagon, resource, TransferEvent.TRANSFER_INITIATED, TransferEvent.REQUEST_PUT,
- sourceFile ) );
- resource = new Resource( resourceName );
- resource.setContentLength( content.length() );
- resource.setLastModified( sourceFile.lastModified() );
- mockTransferListener.transferStarted(
- createTransferEvent( wagon, resource, TransferEvent.TRANSFER_STARTED, TransferEvent.REQUEST_PUT,
- sourceFile ) );
- mockTransferListener.transferProgress(
- eq( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_PROGRESS, TransferEvent.REQUEST_PUT,
- sourceFile ) ), anyObject( byte[].class ), anyInt() );
- ProgressAnswer progressAnswer = new ProgressAnswer();
- expectLastCall().andStubAnswer( progressAnswer );
-
- mockTransferListener.debug( anyString() );
- expectLastCall().anyTimes();
-
- mockTransferListener.transferCompleted(
- createTransferEvent( wagon, resource, TransferEvent.TRANSFER_COMPLETED, TransferEvent.REQUEST_PUT,
- sourceFile ) );
-
- replay( mockTransferListener );
- return progressAnswer;
- }
-
- protected TransferEvent createTransferEvent( Wagon wagon, Resource resource, int eventType, int requestType,
- File file )
- {
- TransferEvent transferEvent = new TransferEvent( wagon, resource, eventType, requestType );
- transferEvent.setLocalFile( file );
- return transferEvent;
- }
-
- protected int putFile()
- throws Exception
- {
- String content = "test-resource.txt\n";
- putFile( resource, "test-resource", content );
- return content.length();
- }
-
- protected void getFile( int expectedSize )
- throws Exception
- {
- destFile = FileTestUtils.createUniqueFile( getName(), getName() );
- destFile.deleteOnExit();
-
- Wagon wagon = getWagon();
-
- ProgressAnswer progressAnswer = replaceMockForGet( wagon, expectedSize );
-
- message( "Getting test artifact from test repository " + testRepository );
-
- connectWagon( wagon );
-
- wagon.get( this.resource, destFile );
-
- disconnectWagon( wagon );
-
- verifyMock( progressAnswer, expectedSize );
- }
-
-
- protected void verifyMock( ProgressAnswer progressAnswer, int length )
- {
- verify( mockTransferListener );
-
- assertEquals( length, progressAnswer.getSize() );
-
- reset( mockTransferListener );
- }
-
- protected void disconnectWagon( Wagon wagon )
- throws ConnectionException
- {
- wagon.removeTransferListener( mockTransferListener );
-
- wagon.removeTransferListener( checksumObserver );
-
- wagon.disconnect();
- }
-
- protected void connectWagon( Wagon wagon )
- throws ConnectionException, AuthenticationException
- {
- wagon.addTransferListener( checksumObserver );
-
- wagon.addTransferListener( mockTransferListener );
-
- wagon.connect( testRepository, getAuthInfo() );
- }
-
- /**
- *
- * some test (mock on transfertprogress call) relies on the fact that InputStream #read(byte[] b, int off, int len)
- * read all bytes. But javadoc says: ""
- */
- protected boolean assertOnTransferProgress()
- {
- return false;
- }
-
- protected ProgressAnswer replaceMockForGet( Wagon wagon, int expectedSize )
- {
- Resource resource = new Resource( this.resource );
- mockTransferListener.transferInitiated(
- createTransferEvent( wagon, resource, TransferEvent.TRANSFER_INITIATED, TransferEvent.REQUEST_GET,
- destFile ) );
- resource = new Resource( this.resource );
- resource.setContentLength( getExpectedContentLengthOnGet( expectedSize ) );
- resource.setLastModified( getExpectedLastModifiedOnGet( testRepository, resource ) );
- TransferEvent te =
- createTransferEvent( wagon, resource, TransferEvent.TRANSFER_STARTED, TransferEvent.REQUEST_GET, null );
- mockTransferListener.transferStarted( te );
- mockTransferListener.transferProgress(
- eq( new TransferEvent( wagon, resource, TransferEvent.TRANSFER_PROGRESS, TransferEvent.REQUEST_GET ) ),
- anyObject( byte[].class ), anyInt() );
-
- ProgressAnswer progressAnswer = new ProgressAnswer();
-
- if ( assertOnTransferProgress() )
- {
- expectLastCall().andAnswer( progressAnswer );
- }
- else
- {
- expectLastCall().andAnswer( progressAnswer );
- expectLastCall().anyTimes();
- }
- mockTransferListener.debug( anyString() );
- expectLastCall().anyTimes();
-
- mockTransferListener.transferCompleted(
- createTransferEvent( wagon, resource, TransferEvent.TRANSFER_COMPLETED, TransferEvent.REQUEST_GET,
- destFile ) );
-
- replay( mockTransferListener );
- return progressAnswer;
- }
-
- protected int getExpectedContentLengthOnGet( int expectedSize )
- {
- return expectedSize;
- }
-
- protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
- {
- // default implementation - prone to failing if the time between test file creation and completion of putFile()
- // cross the "second" boundary, causing the "remote" and local files to have different times.
-
- return sourceFile.lastModified();
- }
-
- protected void fileRoundTripTesting()
- throws Exception
- {
- message( "File round trip testing ..." );
-
- int expectedSize = putFile();
-
- assertNotNull( "check checksum is not null", checksumObserver.getActualChecksum() );
-
- assertEquals( "compare checksums", "6b144b7285ffd6b0bc8300da162120b9", checksumObserver.getActualChecksum() );
-
- checksumObserver = new ChecksumObserver();
-
- getFile( expectedSize );
-
- assertNotNull( "check checksum is not null", checksumObserver.getActualChecksum() );
-
- assertEquals( "compare checksums", "6b144b7285ffd6b0bc8300da162120b9", checksumObserver.getActualChecksum() );
-
- // Now compare the conents of the artifact that was placed in
- // the repository with the contents of the artifact that was
- // retrieved from the repository.
-
- String sourceContent = FileUtils.fileRead( sourceFile );
-
- String destContent = FileUtils.fileRead( destFile );
-
- assertEquals( sourceContent, destContent );
- }
-
- // ----------------------------------------------------------------------
- //
- // ----------------------------------------------------------------------
-
- protected Repository createFileRepository( String url )
- {
- File path = new File( url.substring( 7 ) );
-
- path.mkdirs();
-
- Repository repository = new Repository();
-
- repository.setUrl( url );
-
- return repository;
- }
-
-}
+package org.apache.maven.wagon;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.events.TransferListener;
+import org.apache.maven.wagon.observers.ChecksumObserver;
+import org.apache.maven.wagon.observers.Debug;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.repository.RepositoryPermissions;
+import org.apache.maven.wagon.resource.Resource;
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.util.FileUtils;
+import org.easymock.IAnswer;
+
+// CHECKSTYLE_OFF: AvoidStarImport
+import static org.easymock.EasyMock.*;
+//CHECKSTYLE_ON: AvoidStarImport
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.security.NoSuchAlgorithmException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:jason at maven.org">Jason van Zyl</a>
+ */
+public abstract class WagonTestCase
+ extends PlexusTestCase
+{
+ protected static Logger logger = LoggerFactory.getLogger( WagonTestCase.class );
+
+
+ static final class ProgressAnswer implements IAnswer
+ {
+ private int size;
+
+ public Object answer() throws Throwable
+ {
+ int length = (Integer) getCurrentArguments()[2];
+ size += length;
+ return null;
+ }
+
+ public int getSize()
+ {
+ return size;
+ }
+ }
+
+ protected static final String POM = "pom.xml";
+
+ protected Repository localRepository;
+
+ protected Repository testRepository;
+
+ protected String localRepositoryPath;
+
+ protected File sourceFile;
+
+ protected File destFile;
+
+ protected String resource;
+
+ protected File artifactSourceFile;
+
+ protected File artifactDestFile;
+
+ protected ChecksumObserver checksumObserver;
+
+ protected TransferListener mockTransferListener;
+
+ // ----------------------------------------------------------------------
+ // Constructors
+ // ----------------------------------------------------------------------
+
+ protected void setUp()
+ throws Exception
+ {
+ checksumObserver = new ChecksumObserver();
+
+ mockTransferListener = createMock( TransferListener.class );
+
+ super.setUp();
+ }
+
+ // ----------------------------------------------------------------------
+ // Methods that should be provided by subclasses for proper testing
+ // ----------------------------------------------------------------------
+
+ /**
+ * URL of the repository. For a complete test it should point to a non existing folder so we also check for the
+ * creation of new folders in the remote site. <p/> return the URL of the repository as specified by Wagon syntax
+ */
+ protected abstract String getTestRepositoryUrl()
+ throws IOException;
+
+ /**
+ * Protocol id of the Wagon to use, eg. <code>scp</code>, <code>ftp</code>
+ *
+ * @return the protocol id
+ */
+ protected abstract String getProtocol();
+
+ /**
+ * The number of the port which should get used to start the test server
+ *
+ * @return the port number for the test server
+ */
+ protected abstract int getTestRepositoryPort();
+
+ // ----------------------------------------------------------------------
+ // 1. Create a local file repository which mimic a users local file
+ // Repository.
+ //
+ // 2. Create a test repository for the type of wagon we are testing. So,
+ // for example, for testing the file wagon we might have a test
+ // repository url of file://${basedir}/target/file-repository.
+ // ----------------------------------------------------------------------
+
+ protected void setupRepositories()
+ throws Exception
+ {
+ resource = "test-resource";
+
+ // ----------------------------------------------------------------------
+ // Create the test repository for the wagon we are testing.
+ // ----------------------------------------------------------------------
+
+ testRepository = new Repository();
+
+ testRepository.setUrl( getTestRepositoryUrl() );
+
+ testRepository.setPermissions( getPermissions() );
+
+ // ----------------------------------------------------------------------
+ // Create a test local repository.
+ // ----------------------------------------------------------------------
+
+ localRepositoryPath = FileTestUtils.createDir( "local-repository" ).getPath();
+
+ localRepository = createFileRepository( "file://" + localRepositoryPath );
+
+ message( "Local repository: " + localRepository );
+
+ File f = new File( localRepositoryPath );
+
+ if ( !f.exists() )
+ {
+ f.mkdirs();
+ }
+ }
+
+ protected void customizeContext()
+ throws Exception
+ {
+ getContainer().addContextValue( "test.repository", localRepositoryPath );
+ }
+
+ protected void setupWagonTestingFixtures()
+ throws Exception
+ {
+ }
+
+ protected void tearDownWagonTestingFixtures()
+ throws Exception
+ {
+ }
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ protected AuthenticationInfo getAuthInfo()
+ {
+ return new AuthenticationInfo();
+ }
+
+ protected RepositoryPermissions getPermissions()
+ {
+ return new RepositoryPermissions();
+ }
+
+ protected Wagon getWagon()
+ throws Exception
+ {
+ Wagon wagon = (Wagon) lookup( Wagon.ROLE, getProtocol() );
+
+ Debug debug = new Debug();
+
+ wagon.addSessionListener( debug );
+
+ wagon.addTransferListener( debug );
+
+ return wagon;
+ }
+
+ protected void message( String message )
+ {
+ logger.info( message );
+ }
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ public void testWagon()
+ throws Exception
+ {
+ if ( supportsGetIfNewer() )
+ {
+ setupRepositories();
+
+ setupWagonTestingFixtures();
+
+ fileRoundTripTesting();
+
+ tearDownWagonTestingFixtures();
+ }
+ }
+
+ public void testWagonGetIfNewerIsNewer()
+ throws Exception
+ {
+ if ( supportsGetIfNewer() )
+ {
+ setupRepositories();
+ setupWagonTestingFixtures();
+ int expectedSize = putFile();
+ // CHECKSTYLE_OFF: MagicNumber
+ getIfNewer( getExpectedLastModifiedOnGet( testRepository, new Resource( resource ) ) + 30000, false,
+ expectedSize );
+ // CHECKSTYLE_ON: MagicNumber
+ }
+ }
+
+ protected boolean supportsGetIfNewer()
+ {
+ return true;
+ }
+
+
+ public void testWagonGetIfNewerIsSame()
+ throws Exception
+ {
+ if ( supportsGetIfNewer() )
+ {
+ setupRepositories();
+ setupWagonTestingFixtures();
+ int expectedSize = putFile();
+ getIfNewer( getExpectedLastModifiedOnGet( testRepository, new Resource( resource ) ), false, expectedSize );
+ }
+ }
+
+ public void testWagonGetIfNewerIsOlder()
+ throws Exception
+ {
+ if ( supportsGetIfNewer() )
+ {
+ setupRepositories();
+ setupWagonTestingFixtures();
+ int expectedSize = putFile();
+ getIfNewer( new SimpleDateFormat( "yyyy-MM-dd" ).parse( "2006-01-01" ).getTime(), true, expectedSize );
+ }
+ }
+
+ private void getIfNewer( long timestamp, boolean expectedResult, int expectedSize )
+ throws Exception
+ {
+ Wagon wagon = getWagon();
+
+ ProgressAnswer progressAnswer = setupGetIfNewerTest( wagon, expectedResult, expectedSize );
+
+ connectWagon( wagon );
+
+ boolean result = wagon.getIfNewer( this.resource, destFile, timestamp );
+ assertEquals( expectedResult, result );
+
+ disconnectWagon( wagon );
+
+ assertGetIfNewerTest( progressAnswer, expectedResult, expectedSize );
+
+ tearDownWagonTestingFixtures();
+ }
+
+ protected ProgressAnswer setupGetIfNewerTest( Wagon wagon, boolean expectedResult, int expectedSize )
+ throws NoSuchAlgorithmException, IOException
+ {
+ checksumObserver = new ChecksumObserver();
+
+ destFile = FileTestUtils.createUniqueFile( getName(), getName() );
+ destFile.delete();
+ assertFalse( destFile.exists() );
+ destFile.deleteOnExit();
+
+ ProgressAnswer progressAnswer = null;
+ if ( expectedResult )
+ {
+ progressAnswer = replaceMockForGet( wagon, expectedSize );
+ }
+ else
+ {
+ replaceMockForSkippedGetIfNewer( wagon, expectedSize );
+ }
+ return progressAnswer;
+ }
+
+ protected void assertGetIfNewerTest( ProgressAnswer progressAnswer, boolean expectedResult,
+ int expectedSize )
+ throws IOException
+ {
+ if ( expectedResult )
+ {
+ verifyMock( progressAnswer, expectedSize );
+
+ assertNotNull( "check checksum is not null", checksumObserver.getActualChecksum() );
+
+ assertEquals( "compare checksums", "6b144b7285ffd6b0bc8300da162120b9",
+ checksumObserver.getActualChecksum() );
+
+ // Now compare the contents of the artifact that was placed in
+ // the repository with the contents of the artifact that was
+ // retrieved from the repository.
+
+ String sourceContent = FileUtils.fileRead( sourceFile );
+ String destContent = FileUtils.fileRead( destFile );
+ assertEquals( sourceContent, destContent );
+ }
+ else
+ {
+ verify( mockTransferListener );
+
+ reset( mockTransferListener );
+
+ assertNull( "check checksum is null", checksumObserver.getActualChecksum() );
+
+ assertFalse( destFile.exists() );
+ }
+ }
+
+
+ private void replaceMockForSkippedGetIfNewer( Wagon wagon, int expectedSize )
+ {
+ Resource resource = new Resource( this.resource );
+ mockTransferListener.transferInitiated(
+ createTransferEvent( wagon, resource, TransferEvent.TRANSFER_INITIATED, TransferEvent.REQUEST_GET,
+ destFile ) );
+ resource = new Resource( this.resource );
+ resource.setContentLength( getExpectedContentLengthOnGet( expectedSize ) );
+ resource.setLastModified( getExpectedLastModifiedOnGet( testRepository, resource ) );
+ // TODO: transfer skipped event?
+ // mockTransferListener.transferSkipped( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_STARTED,
+ // TransferEvent.REQUEST_GET, destFile ) );
+
+ mockTransferListener.debug( anyString() );
+ expectLastCall().anyTimes();
+
+ replay( mockTransferListener );
+ }
+
+ public void testWagonPutDirectory()
+ throws Exception
+ {
+ setupRepositories();
+
+ setupWagonTestingFixtures();
+
+ Wagon wagon = getWagon();
+
+ if ( wagon.supportsDirectoryCopy() )
+ {
+ sourceFile = new File( FileTestUtils.getTestOutputDir(), "directory-copy" );
+
+ FileUtils.deleteDirectory( sourceFile );
+
+ writeTestFile( "test-resource-1.txt" );
+ writeTestFile( "a/test-resource-2.txt" );
+ writeTestFile( "a/b/test-resource-3.txt" );
+ writeTestFile( "c/test-resource-4.txt" );
+ writeTestFile( "d/e/f/test-resource-5.txt" );
+
+ wagon.connect( testRepository, getAuthInfo() );
+
+ wagon.putDirectory( sourceFile, "directory-copy" );
+
+ destFile = FileTestUtils.createUniqueFile( getName(), getName() );
+
+ destFile.deleteOnExit();
+
+ wagon.get( "directory-copy/test-resource-1.txt", destFile );
+ wagon.get( "directory-copy/a/test-resource-2.txt", destFile );
+ wagon.get( "directory-copy/a/b/test-resource-3.txt", destFile );
+ wagon.get( "directory-copy/c/test-resource-4.txt", destFile );
+ wagon.get( "directory-copy/d/e/f/test-resource-5.txt", destFile );
+
+ wagon.disconnect();
+ }
+
+ tearDownWagonTestingFixtures();
+ }
+
+ /**
+ * Test for putting a directory with a destination that multiple directories deep, all of which haven't been
+ * created.
+ *
+ * @throws Exception
+ * @since 1.0-beta-2
+ */
+ public void testWagonPutDirectoryDeepDestination()
+ throws Exception
+ {
+ setupRepositories();
+
+ setupWagonTestingFixtures();
+
+ Wagon wagon = getWagon();
+
+ if ( wagon.supportsDirectoryCopy() )
+ {
+ sourceFile = new File( FileTestUtils.getTestOutputDir(), "deep0/deep1/deep2" );
+
+ FileUtils.deleteDirectory( sourceFile );
+
+ writeTestFile( "test-resource-1.txt" );
+ writeTestFile( "a/test-resource-2.txt" );
+ writeTestFile( "a/b/test-resource-3.txt" );
+ writeTestFile( "c/test-resource-4.txt" );
+ writeTestFile( "d/e/f/test-resource-5.txt" );
+
+ wagon.connect( testRepository, getAuthInfo() );
+
+ wagon.putDirectory( sourceFile, "deep0/deep1/deep2" );
+
+ destFile = FileTestUtils.createUniqueFile( getName(), getName() );
+
+ destFile.deleteOnExit();
+
+ wagon.get( "deep0/deep1/deep2/test-resource-1.txt", destFile );
+ wagon.get( "deep0/deep1/deep2/a/test-resource-2.txt", destFile );
+ wagon.get( "deep0/deep1/deep2/a/b/test-resource-3.txt", destFile );
+ wagon.get( "deep0/deep1/deep2/c/test-resource-4.txt", destFile );
+ wagon.get( "deep0/deep1/deep2/d/e/f/test-resource-5.txt", destFile );
+
+ wagon.disconnect();
+ }
+
+ tearDownWagonTestingFixtures();
+ }
+
+ /**
+ * Test that when putting a directory that already exists new files get also copied
+ *
+ * @throws Exception
+ * @since 1.0-beta-1
+ */
+ public void testWagonPutDirectoryWhenDirectoryAlreadyExists()
+ throws Exception
+ {
+
+ final String dirName = "directory-copy-existing";
+
+ final String resourceToCreate = "test-resource-1.txt";
+
+ final String[] resources = { "a/test-resource-2.txt", "a/b/test-resource-3.txt", "c/test-resource-4.txt" };
+
+ setupRepositories();
+
+ setupWagonTestingFixtures();
+
+ Wagon wagon = getWagon();
+
+ if ( wagon.supportsDirectoryCopy() )
+ {
+ sourceFile = new File( FileTestUtils.getTestOutputDir(), dirName );
+
+ FileUtils.deleteDirectory( sourceFile );
+
+ createDirectory( wagon, resourceToCreate, dirName );
+
+ for ( String resource : resources )
+ {
+ writeTestFile( resource );
+ }
+
+ wagon.connect( testRepository, getAuthInfo() );
+
+ wagon.putDirectory( sourceFile, dirName );
+
+ List<String> resourceNames = new ArrayList<String>( resources.length + 1 );
+
+ resourceNames.add( dirName + "/" + resourceToCreate );
+ for ( String resource : resources )
+ {
+ resourceNames.add( dirName + "/" + resource );
+ }
+
+ assertResourcesAreInRemoteSide( wagon, resourceNames );
+
+ wagon.disconnect();
+ }
+
+ tearDownWagonTestingFixtures();
+ }
+
+ /**
+ * Test that when putting a directory that already exists new files get also copied and destination is "."
+ *
+ * @throws Exception
+ * @since 1.0-beta-1
+ */
+ public void testWagonPutDirectoryForDot()
+ throws Exception
+ {
+ final String resourceToCreate = "test-resource-1.txt";
+
+ final String[] resources = { "a/test-resource-2.txt", "a/b/test-resource-3.txt", "c/test-resource-4.txt" };
+
+ setupRepositories();
+
+ setupWagonTestingFixtures();
+
+ Wagon wagon = getWagon();
+
+ if ( wagon.supportsDirectoryCopy() )
+ {
+ sourceFile = new File( FileTestUtils.getTestOutputDir(), "dot-repo" );
+
+ FileUtils.deleteDirectory( sourceFile );
+
+ createDirectory( wagon, resourceToCreate, "." );
+
+ for ( String resource : resources )
+ {
+ writeTestFile( resource );
+ }
+
+ wagon.connect( testRepository, getAuthInfo() );
+
+ wagon.putDirectory( sourceFile, "." );
+
+ List<String> resourceNames = new ArrayList<String>( resources.length + 1 );
+
+ resourceNames.add( resourceToCreate );
+ Collections.addAll( resourceNames, resources );
+
+ assertResourcesAreInRemoteSide( wagon, resourceNames );
+
+ wagon.disconnect();
+ }
+
+ tearDownWagonTestingFixtures();
+ }
+
+ /**
+ * Create a directory with a resource and check that the other ones don't exist
+ *
+ * @param wagon
+ * @param resourceToCreate name of the resource to be created
+ * @param dirName directory name to create
+ * @throws Exception
+ */
+ protected void createDirectory( Wagon wagon, String resourceToCreate, String dirName )
+ throws Exception
+ {
+ writeTestFile( resourceToCreate );
+ }
+
+ protected void assertResourcesAreInRemoteSide( Wagon wagon, List<String> resourceNames )
+ throws IOException, TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ for ( String resourceName : resourceNames )
+ {
+ File destFile = FileTestUtils.createUniqueFile( getName(), resourceName );
+
+ destFile.deleteOnExit();
+
+ wagon.get( resourceName, destFile );
+ }
+ }
+
+ /**
+ * Assert that a resource does not exist in the remote wagon system
+ *
+ * @param wagon wagon to get the resource from
+ * @param resourceName name of the resource
+ * @throws IOException if a temp file can't be created
+ * @throws AuthorizationException
+ * @throws TransferFailedException
+ * @since 1.0-beta-1
+ */
+ protected void assertNotExists( Wagon wagon, String resourceName )
+ throws IOException, TransferFailedException, AuthorizationException
+ {
+ File tmpFile = File.createTempFile( "wagon", null );
+ try
+ {
+ wagon.get( resourceName, tmpFile );
+ fail( "Resource exists: " + resourceName );
+ }
+ catch ( ResourceDoesNotExistException e )
+ {
+ // ok
+ }
+ finally
+ {
+ tmpFile.delete();
+ }
+ }
+
+ private void writeTestFile( String child )
+ throws IOException
+ {
+ File dir = new File( sourceFile, child );
+ dir.getParentFile().mkdirs();
+ FileUtils.fileWrite( dir.getAbsolutePath(), child );
+ }
+
+ public void testFailedGet()
+ throws Exception
+ {
+ setupRepositories();
+
+ setupWagonTestingFixtures();
+
+ message( "Getting test artifact from test repository " + testRepository );
+
+ Wagon wagon = getWagon();
+
+ wagon.addTransferListener( checksumObserver );
+
+ wagon.connect( testRepository, getAuthInfo() );
+
+ destFile = FileTestUtils.createUniqueFile( getName(), getName() );
+
+ destFile.deleteOnExit();
+
+ try
+ {
+ wagon.get( "fubar.txt", destFile );
+ fail( "File was found when it shouldn't have been" );
+ }
+ catch ( ResourceDoesNotExistException e )
+ {
+ // expected
+ assertTrue( true );
+ }
+ finally
+ {
+ wagon.removeTransferListener( checksumObserver );
+
+ wagon.disconnect();
+
+ tearDownWagonTestingFixtures();
+ }
+ }
+
+ public void testFailedGetIfNewer()
+ throws Exception
+ {
+ if ( supportsGetIfNewer() )
+ {
+ setupRepositories();
+ setupWagonTestingFixtures();
+ message( "Getting test artifact from test repository " + testRepository );
+ Wagon wagon = getWagon();
+ wagon.addTransferListener( checksumObserver );
+ wagon.connect( testRepository, getAuthInfo() );
+ destFile = FileTestUtils.createUniqueFile( getName(), getName() );
+ destFile.deleteOnExit();
+ try
+ {
+ wagon.getIfNewer( "fubar.txt", destFile, 0 );
+ fail( "File was found when it shouldn't have been" );
+ }
+ catch ( ResourceDoesNotExistException e )
+ {
+ // expected
+ assertTrue( true );
+ }
+ finally
+ {
+ wagon.removeTransferListener( checksumObserver );
+
+ wagon.disconnect();
+
+ tearDownWagonTestingFixtures();
+ }
+ }
+ }
+
+ /**
+ * Test {@link Wagon#getFileList(String)}.
+ *
+ * @throws Exception
+ * @since 1.0-beta-2
+ */
+ public void testWagonGetFileList()
+ throws Exception
+ {
+ setupRepositories();
+
+ setupWagonTestingFixtures();
+
+ String dirName = "file-list";
+
+ String filenames[] =
+ new String[]{ "test-resource.txt", "test-resource.pom", "test-resource b.txt", "more-resources.dat",
+ ".index.txt" };
+
+ for ( String filename : filenames )
+ {
+ putFile( dirName + "/" + filename, dirName + "/" + filename, filename + "\n" );
+ }
+
+ Wagon wagon = getWagon();
+
+ wagon.connect( testRepository, getAuthInfo() );
+
+ List<String> list = wagon.getFileList( dirName );
+ assertNotNull( "file list should not be null.", list );
+ assertTrue( "file list should contain more items (actually contains '" + list + "').",
+ list.size() >= filenames.length );
+
+ for ( String filename : filenames )
+ {
+ assertTrue( "Filename '" + filename + "' should be in list.", list.contains( filename ) );
+ }
+
+ // WAGON-250
+ list = wagon.getFileList( "" );
+ assertNotNull( "file list should not be null.", list );
+ assertTrue( "file list should contain items (actually contains '" + list + "').", !list.isEmpty() );
+ assertTrue( list.contains( "file-list/" ) );
+ assertFalse( list.contains( "file-list" ) );
+ assertFalse( list.contains( "." ) );
+ assertFalse( list.contains( ".." ) );
+ assertFalse( list.contains( "./" ) );
+ assertFalse( list.contains( "../" ) );
+
+ wagon.disconnect();
+
+ tearDownWagonTestingFixtures();
+ }
+
+ /**
+ * Test {@link Wagon#getFileList(String)} when the directory does not exist.
+ *
+ * @throws Exception
+ * @since 1.0-beta-2
+ */
+ public void testWagonGetFileListWhenDirectoryDoesNotExist()
+ throws Exception
+ {
+ setupRepositories();
+
+ setupWagonTestingFixtures();
+
+ String dirName = "file-list-unexisting";
+
+ Wagon wagon = getWagon();
+
+ wagon.connect( testRepository, getAuthInfo() );
+
+ try
+ {
+ wagon.getFileList( dirName );
+ fail( "getFileList on unexisting directory must throw ResourceDoesNotExistException" );
+ }
+ catch ( ResourceDoesNotExistException e )
+ {
+ // expected
+ }
+ finally
+ {
+ wagon.disconnect();
+
+ tearDownWagonTestingFixtures();
+ }
+ }
+
+ /**
+ * Test for an existing resource.
+ *
+ * @throws Exception
+ * @since 1.0-beta-2
+ */
+ public void testWagonResourceExists()
+ throws Exception
+ {
+ setupRepositories();
+
+ setupWagonTestingFixtures();
+
+ Wagon wagon = getWagon();
+
+ putFile();
+
+ wagon.connect( testRepository, getAuthInfo() );
+
+ assertTrue( sourceFile.getName() + " does not exist", wagon.resourceExists( sourceFile.getName() ) );
+
+ wagon.disconnect();
+
+ tearDownWagonTestingFixtures();
+ }
+
+ /**
+ * Test for an invalid resource.
+ *
+ * @throws Exception
+ * @since 1.0-beta-2
+ */
+ public void testWagonResourceNotExists()
+ throws Exception
+ {
+ setupRepositories();
+
+ setupWagonTestingFixtures();
+
+ Wagon wagon = getWagon();
+
+ wagon.connect( testRepository, getAuthInfo() );
+
+ assertFalse( wagon.resourceExists( "a/bad/resource/name/that/should/not/exist.txt" ) );
+
+ wagon.disconnect();
+
+ tearDownWagonTestingFixtures();
+ }
+
+ // ----------------------------------------------------------------------
+ // File <--> File round trip testing
+ // ----------------------------------------------------------------------
+ // We are testing taking a file, our sourcefile, and placing it into the
+ // test repository that we have setup.
+ // ----------------------------------------------------------------------
+
+ protected void putFile( String resourceName, String testFileName, String content )
+ throws Exception
+ {
+ sourceFile = new File( FileTestUtils.getTestOutputDir(), testFileName );
+ sourceFile.getParentFile().mkdirs();
+ FileUtils.fileWrite( sourceFile.getAbsolutePath(), content );
+
+ Wagon wagon = getWagon();
+
+ ProgressAnswer progressAnswer = replayMockForPut( resourceName, content, wagon );
+
+ message( "Putting test artifact: " + resourceName + " into test repository " + testRepository );
+
+ connectWagon( wagon );
+
+ wagon.put( sourceFile, resourceName );
+
+ disconnectWagon( wagon );
+
+ verifyMock( progressAnswer, content.length() );
+ }
+
+ protected ProgressAnswer replayMockForPut( String resourceName, String content, Wagon wagon )
+ {
+ Resource resource = new Resource( resourceName );
+ mockTransferListener.transferInitiated(
+ createTransferEvent( wagon, resource, TransferEvent.TRANSFER_INITIATED, TransferEvent.REQUEST_PUT,
+ sourceFile ) );
+ resource = new Resource( resourceName );
+ resource.setContentLength( content.length() );
+ resource.setLastModified( sourceFile.lastModified() );
+ mockTransferListener.transferStarted(
+ createTransferEvent( wagon, resource, TransferEvent.TRANSFER_STARTED, TransferEvent.REQUEST_PUT,
+ sourceFile ) );
+ mockTransferListener.transferProgress(
+ eq( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_PROGRESS, TransferEvent.REQUEST_PUT,
+ sourceFile ) ), anyObject( byte[].class ), anyInt() );
+ ProgressAnswer progressAnswer = new ProgressAnswer();
+ expectLastCall().andStubAnswer( progressAnswer );
+
+ mockTransferListener.debug( anyString() );
+ expectLastCall().anyTimes();
+
+ mockTransferListener.transferCompleted(
+ createTransferEvent( wagon, resource, TransferEvent.TRANSFER_COMPLETED, TransferEvent.REQUEST_PUT,
+ sourceFile ) );
+
+ replay( mockTransferListener );
+ return progressAnswer;
+ }
+
+ protected TransferEvent createTransferEvent( Wagon wagon, Resource resource, int eventType, int requestType,
+ File file )
+ {
+ TransferEvent transferEvent = new TransferEvent( wagon, resource, eventType, requestType );
+ transferEvent.setLocalFile( file );
+ return transferEvent;
+ }
+
+ protected int putFile()
+ throws Exception
+ {
+ String content = "test-resource.txt\n";
+ putFile( resource, "test-resource", content );
+ return content.length();
+ }
+
+ protected void getFile( int expectedSize )
+ throws Exception
+ {
+ destFile = FileTestUtils.createUniqueFile( getName(), getName() );
+ destFile.deleteOnExit();
+
+ Wagon wagon = getWagon();
+
+ ProgressAnswer progressAnswer = replaceMockForGet( wagon, expectedSize );
+
+ message( "Getting test artifact from test repository " + testRepository );
+
+ connectWagon( wagon );
+
+ wagon.get( this.resource, destFile );
+
+ disconnectWagon( wagon );
+
+ verifyMock( progressAnswer, expectedSize );
+ }
+
+
+ protected void verifyMock( ProgressAnswer progressAnswer, int length )
+ {
+ verify( mockTransferListener );
+
+ assertEquals( length, progressAnswer.getSize() );
+
+ reset( mockTransferListener );
+ }
+
+ protected void disconnectWagon( Wagon wagon )
+ throws ConnectionException
+ {
+ wagon.removeTransferListener( mockTransferListener );
+
+ wagon.removeTransferListener( checksumObserver );
+
+ wagon.disconnect();
+ }
+
+ protected void connectWagon( Wagon wagon )
+ throws ConnectionException, AuthenticationException
+ {
+ wagon.addTransferListener( checksumObserver );
+
+ wagon.addTransferListener( mockTransferListener );
+
+ wagon.connect( testRepository, getAuthInfo() );
+ }
+
+ /**
+ *
+ * some test (mock on transfertprogress call) relies on the fact that InputStream #read(byte[] b, int off, int len)
+ * read all bytes. But javadoc says: ""
+ */
+ protected boolean assertOnTransferProgress()
+ {
+ return false;
+ }
+
+ protected ProgressAnswer replaceMockForGet( Wagon wagon, int expectedSize )
+ {
+ Resource resource = new Resource( this.resource );
+ mockTransferListener.transferInitiated(
+ createTransferEvent( wagon, resource, TransferEvent.TRANSFER_INITIATED, TransferEvent.REQUEST_GET,
+ destFile ) );
+ resource = new Resource( this.resource );
+ resource.setContentLength( getExpectedContentLengthOnGet( expectedSize ) );
+ resource.setLastModified( getExpectedLastModifiedOnGet( testRepository, resource ) );
+ TransferEvent te =
+ createTransferEvent( wagon, resource, TransferEvent.TRANSFER_STARTED, TransferEvent.REQUEST_GET, null );
+ mockTransferListener.transferStarted( te );
+ mockTransferListener.transferProgress(
+ eq( new TransferEvent( wagon, resource, TransferEvent.TRANSFER_PROGRESS, TransferEvent.REQUEST_GET ) ),
+ anyObject( byte[].class ), anyInt() );
+
+ ProgressAnswer progressAnswer = new ProgressAnswer();
+
+ if ( assertOnTransferProgress() )
+ {
+ expectLastCall().andAnswer( progressAnswer );
+ }
+ else
+ {
+ expectLastCall().andAnswer( progressAnswer );
+ expectLastCall().anyTimes();
+ }
+ mockTransferListener.debug( anyString() );
+ expectLastCall().anyTimes();
+
+ mockTransferListener.transferCompleted(
+ createTransferEvent( wagon, resource, TransferEvent.TRANSFER_COMPLETED, TransferEvent.REQUEST_GET,
+ destFile ) );
+
+ replay( mockTransferListener );
+ return progressAnswer;
+ }
+
+ protected int getExpectedContentLengthOnGet( int expectedSize )
+ {
+ return expectedSize;
+ }
+
+ protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
+ {
+ // default implementation - prone to failing if the time between test file creation and completion of putFile()
+ // cross the "second" boundary, causing the "remote" and local files to have different times.
+
+ return sourceFile.lastModified();
+ }
+
+ protected void fileRoundTripTesting()
+ throws Exception
+ {
+ message( "File round trip testing ..." );
+
+ int expectedSize = putFile();
+
+ assertNotNull( "check checksum is not null", checksumObserver.getActualChecksum() );
+
+ assertEquals( "compare checksums", "6b144b7285ffd6b0bc8300da162120b9", checksumObserver.getActualChecksum() );
+
+ checksumObserver = new ChecksumObserver();
+
+ getFile( expectedSize );
+
+ assertNotNull( "check checksum is not null", checksumObserver.getActualChecksum() );
+
+ assertEquals( "compare checksums", "6b144b7285ffd6b0bc8300da162120b9", checksumObserver.getActualChecksum() );
+
+ // Now compare the conents of the artifact that was placed in
+ // the repository with the contents of the artifact that was
+ // retrieved from the repository.
+
+ String sourceContent = FileUtils.fileRead( sourceFile );
+
+ String destContent = FileUtils.fileRead( destFile );
+
+ assertEquals( sourceContent, destContent );
+ }
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ protected Repository createFileRepository( String url )
+ {
+ File path = new File( url.substring( 7 ) );
+
+ path.mkdirs();
+
+ Repository repository = new Repository();
+
+ repository.setUrl( url );
+
+ return repository;
+ }
+
+}
diff --git a/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java b/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java
index acdab16..0f3e0d9 100644
--- a/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java
+++ b/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java
@@ -1,2167 +1,2208 @@
-package org.apache.maven.wagon.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.FileTestUtils;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
-import org.apache.maven.wagon.StreamingWagon;
-import org.apache.maven.wagon.StreamingWagonTestCase;
-import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
-import org.apache.maven.wagon.authorization.AuthorizationException;
-import org.apache.maven.wagon.proxy.ProxyInfo;
-import org.apache.maven.wagon.proxy.ProxyInfoProvider;
-import org.apache.maven.wagon.repository.Repository;
-import org.apache.maven.wagon.resource.Resource;
-import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.StringUtils;
-import org.mortbay.jetty.Handler;
-import org.mortbay.jetty.HttpConnection;
-import org.mortbay.jetty.Request;
-import org.mortbay.jetty.Response;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.handler.AbstractHandler;
-import org.mortbay.jetty.handler.HandlerCollection;
-import org.mortbay.jetty.security.Constraint;
-import org.mortbay.jetty.security.ConstraintMapping;
-import org.mortbay.jetty.security.HashUserRealm;
-import org.mortbay.jetty.security.SecurityHandler;
-import org.mortbay.jetty.servlet.Context;
-import org.mortbay.jetty.servlet.DefaultServlet;
-import org.mortbay.jetty.servlet.ServletHolder;
-
-import javax.servlet.ServletException;
-import javax.servlet.ServletInputStream;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.lang.reflect.Method;
-import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.zip.GZIPOutputStream;
-
-/**
- *
- */
-public abstract class HttpWagonTestCase
- extends StreamingWagonTestCase
-{
- public static final int SC_TOO_MANY_REQUESTS = 429;
-
- private Server server;
-
- protected void setupWagonTestingFixtures()
- throws Exception
- {
- // File round trip testing
-
- File file = FileTestUtils.createUniqueFile( "local-repository", "test-resource" );
-
- file.delete();
-
- file.getParentFile().mkdirs();
-
- File repositoryDirectory = getRepositoryDirectory();
- FileUtils.deleteDirectory( repositoryDirectory );
- repositoryDirectory.mkdirs();
-
- server = new Server( 0 );
-
- PutHandler putHandler = new PutHandler( repositoryDirectory );
- server.addHandler( putHandler );
-
- createContext( server, repositoryDirectory );
-
- addConnectors( server );
-
- server.start();
-
- testRepository.setUrl( getTestRepositoryUrl() );
- }
-
- @Override
- protected final int getTestRepositoryPort()
- {
- if ( server == null )
- {
- return 0;
- }
- return server.getConnectors()[0].getLocalPort();
- }
-
- protected void createContext( Server server, File repositoryDirectory )
- throws IOException
- {
- Context root = new Context( server, "/", Context.SESSIONS );
- root.setResourceBase( repositoryDirectory.getAbsolutePath() );
- ServletHolder servletHolder = new ServletHolder( new DefaultServlet() );
- root.addServlet( servletHolder, "/*" );
- }
-
- protected void tearDownWagonTestingFixtures()
- throws Exception
- {
- server.stop();
- }
-
- public void testWagonGetFileList()
- throws Exception
- {
- File dir = getRepositoryDirectory();
- FileUtils.deleteDirectory( dir );
-
- File f = new File( dir, "file-list" );
- f.mkdirs();
-
- super.testWagonGetFileList();
- }
-
- public void testHttpHeaders()
- throws Exception
- {
- Properties properties = new Properties();
- properties.setProperty( "User-Agent", "Maven-Wagon/1.0" );
-
- StreamingWagon wagon = (StreamingWagon) getWagon();
-
- setHttpHeaders( wagon, properties );
-
- Server server = new Server( 0 );
- TestHeaderHandler handler = new TestHeaderHandler();
- server.setHandler( handler );
- addConnectors( server );
- server.start();
-
- wagon.connect(
- new Repository( "id", getProtocol() + "://localhost:" + server.getConnectors()[0].getLocalPort() ) );
-
- wagon.getToStream( "resource", new ByteArrayOutputStream() );
-
- wagon.disconnect();
-
- server.stop();
-
- assertEquals( "Maven-Wagon/1.0", handler.headers.get( "User-Agent" ) );
- }
-
- /**
- * test set of User-Agent as it's done by aether wagon connector with using setHttpHeaders
- */
- public void testHttpHeadersWithCommonMethods()
- throws Exception
- {
- Properties properties = new Properties();
- properties.setProperty( "User-Agent", "Maven-Wagon/1.0" );
-
- StreamingWagon wagon = (StreamingWagon) getWagon();
-
- Method setHttpHeaders = wagon.getClass().getMethod( "setHttpHeaders", Properties.class );
- setHttpHeaders.invoke( wagon, properties );
-
- Server server = new Server( 0 );
- TestHeaderHandler handler = new TestHeaderHandler();
- server.setHandler( handler );
- addConnectors( server );
- server.start();
-
- wagon.connect(
- new Repository( "id", getProtocol() + "://localhost:" + server.getConnectors()[0].getLocalPort() ) );
-
- wagon.getToStream( "resource", new ByteArrayOutputStream() );
-
- wagon.disconnect();
-
- server.stop();
-
- assertEquals( "Maven-Wagon/1.0", handler.headers.get( "User-Agent" ) );
- }
-
- public void testUserAgentHeaderIsPresentByDefault()
- throws Exception
- {
- StreamingWagon wagon = (StreamingWagon) getWagon();
- Server server = new Server( 0 );
- TestHeaderHandler handler = new TestHeaderHandler();
- server.setHandler( handler );
- addConnectors( server );
- server.start();
- wagon.connect( new Repository( "id", getProtocol() + "://localhost:"
- + server.getConnectors()[0].getLocalPort() ) );
- wagon.getToStream( "resource", new ByteArrayOutputStream() );
- wagon.disconnect();
- server.stop();
-
- assertNotNull( "default User-Agent header of wagon provider should be present",
- handler.headers.get( "User-Agent" ) );
- }
-
- public void testUserAgentHeaderIsPresentOnlyOnceIfSetMultipleTimes()
- throws Exception
- {
- StreamingWagon wagon = (StreamingWagon) getWagon();
-
- // 1. set User-Agent header via HttpConfiguration
- Properties headers1 = new Properties();
- headers1.setProperty( "User-Agent", "test-user-agent" );
- setHttpHeaders( wagon, headers1 );
-
- // 2. redundantly set User-Agent header via setHttpHeaders()
- Properties headers2 = new Properties();
- headers2.setProperty( "User-Agent", "test-user-agent" );
- Method setHttpHeaders = wagon.getClass().getMethod( "setHttpHeaders", Properties.class );
- setHttpHeaders.invoke( wagon, headers2 );
-
- Server server = new Server( 0 );
- TestHeaderHandler handler = new TestHeaderHandler();
- server.setHandler( handler );
- addConnectors( server );
- server.start();
- wagon.connect( new Repository( "id", getProtocol() + "://localhost:"
- + server.getConnectors()[0].getLocalPort() ) );
- wagon.getToStream( "resource", new ByteArrayOutputStream() );
- wagon.disconnect();
- server.stop();
-
- assertEquals( "test-user-agent", handler.headers.get( "User-Agent" ) );
-
- }
-
- protected abstract void setHttpHeaders( StreamingWagon wagon, Properties properties );
-
- protected void addConnectors( Server server )
- {
- }
-
- protected String getRepositoryUrl( Server server )
- {
- int localPort = server.getConnectors()[0].getLocalPort();
- return getProtocol() + "://localhost:" + localPort;
- }
-
- public void testGetForbidden()
- throws Exception
- {
- try
- {
- runTestGet( HttpServletResponse.SC_FORBIDDEN );
- fail();
- }
- catch ( AuthorizationException e )
- {
- assertTrue( true );
- }
- }
-
- public void testGet404()
- throws Exception
- {
- try
- {
- runTestGet( HttpServletResponse.SC_NOT_FOUND );
- fail();
- }
- catch ( ResourceDoesNotExistException e )
- {
- assertTrue( true );
- }
- }
-
- public void testList429()
- throws Exception
- {
- StreamingWagon wagon = (StreamingWagon) getWagon();
- try
- {
-
- Server server = new Server( 0 );
- final AtomicBoolean called = new AtomicBoolean();
-
- AbstractHandler handler = new AbstractHandler()
- {
- public void handle( String s, HttpServletRequest request, HttpServletResponse response, int i )
- throws IOException, ServletException
- {
- if ( called.get() )
- {
- response.setStatus( HttpServletResponse.SC_OK );
- ( (Request) request ).setHandled( true );
- }
- else
- {
- called.set( true );
- response.setStatus( SC_TOO_MANY_REQUESTS );
- ( (Request) request ).setHandled( true );
-
- }
- }
- };
-
- server.setHandler( handler );
- addConnectors( server );
- server.start();
-
- wagon.connect( new Repository( "id", getRepositoryUrl( server ) ) );
-
- try
- {
- wagon.getFileList( "resource" );
- }
- finally
- {
- wagon.disconnect();
-
- server.stop();
- }
-
- }
- catch ( ResourceDoesNotExistException e )
- {
- assertTrue( true );
- }
- catch ( TransferFailedException e )
- {
- if ( wagon.getClass().getName().contains( "Lightweight" ) )
- {
- //we don't care about lightweight
- assertTrue( true );
- }
- else
- {
- fail();
- }
-
- }
- }
-
- public void testGet500()
- throws Exception
- {
- try
- {
- runTestGet( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
- fail();
- }
- catch ( TransferFailedException e )
- {
- assertTrue( true );
- }
- }
-
- private void runTestGet( int status )
- throws Exception
- {
- StreamingWagon wagon = (StreamingWagon) getWagon();
-
- Server server = new Server( 0 );
- StatusHandler handler = new StatusHandler();
- handler.setStatusToReturn( status );
- server.setHandler( handler );
- addConnectors( server );
- server.start();
-
- wagon.connect( new Repository( "id", getRepositoryUrl( server ) ) );
-
- try
- {
- wagon.getToStream( "resource", new ByteArrayOutputStream() );
- fail();
- }
- finally
- {
- wagon.disconnect();
-
- server.stop();
- }
- }
-
- public void testResourceExistsForbidden()
- throws Exception
- {
- try
- {
- runTestResourceExists( HttpServletResponse.SC_FORBIDDEN );
- fail();
- }
- catch ( AuthorizationException e )
- {
- assertTrue( true );
- }
- }
-
- public void testResourceExists404()
- throws Exception
- {
- try
- {
- assertFalse( runTestResourceExists( HttpServletResponse.SC_NOT_FOUND ) );
- }
- catch ( ResourceDoesNotExistException e )
- {
- assertTrue( true );
- }
- }
-
- public void testResourceExists500()
- throws Exception
- {
- try
- {
- runTestResourceExists( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
- fail();
- }
- catch ( TransferFailedException e )
- {
- assertTrue( true );
- }
- }
-
- public void testResourceExists429()
- throws Exception
- {
- try
- {
-
- final AtomicBoolean called = new AtomicBoolean();
-
- AbstractHandler handler = new AbstractHandler()
- {
- public void handle( String s, HttpServletRequest request, HttpServletResponse response, int i )
- throws IOException, ServletException
- {
- if ( called.get() )
- {
- response.setStatus( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
- ( (Request) request ).setHandled( true );
- }
- else
- {
- called.set( true );
- response.setStatus( SC_TOO_MANY_REQUESTS );
- ( (Request) request ).setHandled( true );
- }
- }
- };
-
- StreamingWagon wagon = (StreamingWagon) getWagon();
- Server server = new Server( 0 );
- server.setHandler( handler );
- addConnectors( server );
- server.start();
- wagon.connect( new Repository( "id", getRepositoryUrl( server ) ) );
-
- try
- {
- wagon.resourceExists( "resource" );
- }
- finally
- {
- wagon.disconnect();
-
- server.stop();
- }
-
- fail();
- }
- catch ( TransferFailedException e )
- {
- assertTrue( true );
- }
- }
-
-
- private boolean runTestResourceExists( int status )
- throws Exception
- {
- StreamingWagon wagon = (StreamingWagon) getWagon();
-
- Server server = new Server( 0 );
- StatusHandler handler = new StatusHandler();
- handler.setStatusToReturn( status );
- server.setHandler( handler );
- addConnectors( server );
- server.start();
-
- wagon.connect( new Repository( "id", getRepositoryUrl( server ) ) );
-
- try
- {
- return wagon.resourceExists( "resource" );
- }
- finally
- {
- wagon.disconnect();
-
- server.stop();
- }
- }
-
- protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
- {
- File file = new File( getRepositoryDirectory(), resource.getName() );
- return ( file.lastModified() / 1000 ) * 1000;
- }
-
- protected File getRepositoryDirectory()
- {
- return getTestFile( "target/test-output/http-repository" );
- }
-
- public void testGzipGet()
- throws Exception
- {
- Server server = new Server( getTestRepositoryPort() );
-
- String localRepositoryPath = FileTestUtils.getTestOutputDir().toString();
- Context root = new Context( server, "/", Context.SESSIONS );
- root.setResourceBase( localRepositoryPath );
- ServletHolder servletHolder = new ServletHolder( new DefaultServlet() );
- servletHolder.setInitParameter( "gzip", "true" );
- root.addServlet( servletHolder, "/*" );
- addConnectors( server );
- server.start();
-
- try
- {
- Wagon wagon = getWagon();
-
- Repository testRepository = new Repository( "id", getRepositoryUrl( server ) );
-
- File sourceFile = new File( localRepositoryPath + "/gzip" );
-
- sourceFile.deleteOnExit();
-
- String resName = "gzip-res.txt";
- String sourceContent = writeTestFileGzip( sourceFile, resName );
-
- wagon.connect( testRepository );
-
- File destFile = FileTestUtils.createUniqueFile( getName(), getName() );
-
- destFile.deleteOnExit();
-
- wagon.get( "gzip/" + resName, destFile );
-
- wagon.disconnect();
-
- String destContent = FileUtils.fileRead( destFile );
-
- assertEquals( sourceContent, destContent );
- }
- finally
- {
- server.stop();
- }
- }
-
- public void testProxiedRequest()
- throws Exception
- {
- ProxyInfo proxyInfo = createProxyInfo();
- TestHeaderHandler handler = new TestHeaderHandler();
-
- runTestProxiedRequest( proxyInfo, handler );
- }
-
- public void testProxiedRequestWithAuthentication()
- throws Exception
- {
- ProxyInfo proxyInfo = createProxyInfo();
- proxyInfo.setUserName( "user" );
- proxyInfo.setPassword( "secret" );
- AuthorizingProxyHandler handler = new AuthorizingProxyHandler();
-
- runTestProxiedRequest( proxyInfo, handler );
-
- assertTrue( handler.headers.containsKey( "Proxy-Authorization" ) );
-
- if ( supportProxyPreemptiveAuthentication() )
- {
- assertEquals( HttpServletResponse.SC_OK, handler.handlerRequestResponses.get( 0 ).responseCode );
- }
- else
- {
- assertEquals( HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED,
- handler.handlerRequestResponses.get( 0 ).responseCode );
- assertEquals( HttpServletResponse.SC_OK, handler.handlerRequestResponses.get( 1 ).responseCode );
- }
-
- }
-
- public void testProxiedRequestWithAuthenticationWithProvider()
- throws Exception
- {
- final ProxyInfo proxyInfo = createProxyInfo();
- proxyInfo.setUserName( "user" );
- proxyInfo.setPassword( "secret" );
- AuthorizingProxyHandler handler = new AuthorizingProxyHandler();
-
- ProxyInfoProvider proxyInfoProvider = new ProxyInfoProvider()
- {
- public ProxyInfo getProxyInfo( String protocol )
- {
- return proxyInfo;
- }
- };
- runTestProxiedRequestWithProvider( proxyInfoProvider, handler );
-
- assertTrue( handler.headers.containsKey( "Proxy-Authorization" ) );
-
- if ( supportProxyPreemptiveAuthentication() )
- {
- assertEquals( HttpServletResponse.SC_OK, handler.handlerRequestResponses.get( 0 ).responseCode );
- }
- else
- {
- assertEquals( HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED,
- handler.handlerRequestResponses.get( 0 ).responseCode );
- assertEquals( HttpServletResponse.SC_OK, handler.handlerRequestResponses.get( 1 ).responseCode );
- }
-
- }
-
- public void testRedirectGetToStream()
- throws Exception
- {
- StreamingWagon wagon = (StreamingWagon) getWagon();
-
- Server server = new Server( 0 );
- TestHeaderHandler handler = new TestHeaderHandler();
-
- server.setHandler( handler );
- addConnectors( server );
- server.start();
-
- Server redirectServer = new Server( 0 );
-
- addConnectors( redirectServer );
-
- String protocol = getProtocol();
-
- // protocol is wagon protocol but in fact dav is http(s)
- if ( protocol.equals( "dav" ) )
- {
- protocol = "http";
- }
-
- if ( protocol.equals( "davs" ) )
- {
- protocol = "https";
- }
-
- String redirectUrl = protocol + "://localhost:" + server.getConnectors()[0].getLocalPort();
-
- RedirectHandler redirectHandler =
- new RedirectHandler( "Found", HttpServletResponse.SC_SEE_OTHER, redirectUrl, null );
-
- redirectServer.setHandler( redirectHandler );
-
- redirectServer.start();
-
- wagon.connect( new Repository( "id", getRepositoryUrl( redirectServer ) ) );
-
- File tmpResult = File.createTempFile( "foo", "get" );
-
- FileOutputStream fileOutputStream = new FileOutputStream( tmpResult );
-
- try
- {
- wagon.getToStream( "resource", fileOutputStream );
- fileOutputStream.flush();
- fileOutputStream.close();
- String found = FileUtils.fileRead( tmpResult );
- assertEquals( "found:'" + found + "'", "Hello, World!", found );
-
- checkHandlerResult( handler.handlerRequestResponses, HttpServletResponse.SC_OK );
- checkHandlerResult( redirectHandler.handlerRequestResponses, HttpServletResponse.SC_FOUND );
- }
- finally
- {
- wagon.disconnect();
-
- server.stop();
-
- tmpResult.delete();
- }
- }
-
- public void testRedirectGet()
- throws Exception
- {
- StreamingWagon wagon = (StreamingWagon) getWagon();
-
- Server server = new Server( 0 );
- TestHeaderHandler handler = new TestHeaderHandler();
-
- server.setHandler( handler );
- addConnectors( server );
- server.start();
-
- Server redirectServer = new Server( 0 );
-
- addConnectors( redirectServer );
-
- String protocol = getProtocol();
-
- // protocol is wagon protocol but in fact dav is http(s)
- if ( protocol.equals( "dav" ) )
- {
- protocol = "http";
- }
-
- if ( protocol.equals( "davs" ) )
- {
- protocol = "https";
- }
-
- String redirectUrl = protocol + "://localhost:" + server.getConnectors()[0].getLocalPort();
-
- RedirectHandler redirectHandler =
- new RedirectHandler( "Found", HttpServletResponse.SC_SEE_OTHER, redirectUrl, null );
-
- redirectServer.setHandler( redirectHandler );
-
- redirectServer.start();
-
- wagon.connect( new Repository( "id", getRepositoryUrl( redirectServer ) ) );
-
- File tmpResult = File.createTempFile( "foo", "get" );
-
- try
- {
- wagon.get( "resource", tmpResult );
- String found = FileUtils.fileRead( tmpResult );
- assertEquals( "found:'" + found + "'", "Hello, World!", found );
-
- checkHandlerResult( handler.handlerRequestResponses, HttpServletResponse.SC_OK );
- checkHandlerResult( redirectHandler.handlerRequestResponses, HttpServletResponse.SC_FOUND );
- }
- finally
- {
- wagon.disconnect();
-
- server.stop();
-
- tmpResult.delete();
- }
- }
-
-
- public void testRedirectPutFromStreamWithFullUrl()
- throws Exception
- {
- Server realServer = new Server( 0 );
-
- addConnectors( realServer );
-
- File repositoryDirectory = getRepositoryDirectory();
- FileUtils.deleteDirectory( repositoryDirectory );
- repositoryDirectory.mkdirs();
-
- PutHandler putHandler = new PutHandler( repositoryDirectory );
-
- realServer.setHandler( putHandler );
-
- realServer.start();
-
- Server redirectServer = new Server( 0 );
-
- addConnectors( redirectServer );
-
- String protocol = getProtocol();
-
- // protocol is wagon protocol but in fact dav is http(s)
- if ( protocol.equals( "dav" ) )
- {
- protocol = "http";
- }
-
- if ( protocol.equals( "davs" ) )
- {
- protocol = "https";
- }
-
- String redirectUrl = protocol + "://localhost:" + realServer.getConnectors()[0].getLocalPort();
-
- RedirectHandler redirectHandler =
- new RedirectHandler( "Found", HttpServletResponse.SC_SEE_OTHER, redirectUrl, repositoryDirectory );
-
- redirectServer.setHandler( redirectHandler );
-
- redirectServer.start();
-
- try
- {
- StreamingWagon wagon = (StreamingWagon) getWagon();
- Repository repository = new Repository( "foo", getRepositoryUrl( redirectServer ) );
- wagon.connect( repository );
-
- File sourceFile = new File( repositoryDirectory, "test-secured-put-resource" );
- sourceFile.delete();
- assertFalse( sourceFile.exists() );
-
- File tempFile = File.createTempFile( "wagon", "tmp" );
- tempFile.deleteOnExit();
- String content = "put top secret";
- FileUtils.fileWrite( tempFile.getAbsolutePath(), content );
-
- FileInputStream fileInputStream = new FileInputStream( tempFile );
- try
- {
- wagon.putFromStream( fileInputStream, "test-secured-put-resource", content.length(), -1 );
- }
- finally
- {
- fileInputStream.close();
- tempFile.delete();
-
- }
-
- assertEquals( content, FileUtils.fileRead( sourceFile.getAbsolutePath() ) );
-
- checkRequestResponseForRedirectPutFromStreamWithFullUrl( putHandler, redirectHandler );
- }
- finally
- {
- realServer.stop();
- redirectServer.stop();
- }
- }
-
- protected void checkRequestResponseForRedirectPutFromStreamWithFullUrl( PutHandler putHandler,
- RedirectHandler redirectHandler )
- {
- checkHandlerResult( putHandler.handlerRequestResponses, HttpServletResponse.SC_CREATED );
- checkHandlerResult( redirectHandler.handlerRequestResponses, HttpServletResponse.SC_FOUND );
- }
-
- public void testRedirectPutFromStreamRelativeUrl()
- throws Exception
- {
- Server realServer = new Server( 0 );
- addConnectors( realServer );
- File repositoryDirectory = getRepositoryDirectory();
- FileUtils.deleteDirectory( repositoryDirectory );
- repositoryDirectory.mkdirs();
-
- PutHandler putHandler = new PutHandler( repositoryDirectory );
-
- realServer.setHandler( putHandler );
-
- realServer.start();
-
- Server redirectServer = new Server( 0 );
-
- addConnectors( redirectServer );
-
- RedirectHandler redirectHandler =
- new RedirectHandler( "Found", HttpServletResponse.SC_SEE_OTHER, "/redirectRequest/foo",
- repositoryDirectory );
-
- redirectServer.setHandler( redirectHandler );
-
- redirectServer.start();
-
- try
- {
- StreamingWagon wagon = (StreamingWagon) getWagon();
- Repository repository = new Repository( "foo", getRepositoryUrl( redirectServer ) );
- wagon.connect( repository );
-
- File sourceFile = new File( repositoryDirectory, "/redirectRequest/foo/test-secured-put-resource" );
- sourceFile.delete();
- assertFalse( sourceFile.exists() );
-
- File tempFile = File.createTempFile( "wagon", "tmp" );
- tempFile.deleteOnExit();
- String content = "put top secret";
- FileUtils.fileWrite( tempFile.getAbsolutePath(), content );
-
- FileInputStream fileInputStream = new FileInputStream( tempFile );
- try
- {
- wagon.putFromStream( fileInputStream, "test-secured-put-resource", content.length(), -1 );
- }
- finally
- {
- fileInputStream.close();
- tempFile.delete();
-
- }
-
- assertEquals( content, FileUtils.fileRead( sourceFile.getAbsolutePath() ) );
-
- checkRequestResponseForRedirectPutFromStreamWithRelativeUrl( putHandler, redirectHandler );
-
- }
- finally
- {
- realServer.stop();
- redirectServer.stop();
- }
- }
-
- protected void checkRequestResponseForRedirectPutFromStreamWithRelativeUrl( PutHandler putHandler,
- RedirectHandler redirectHandler )
- {
- checkHandlerResult( putHandler.handlerRequestResponses );
- checkHandlerResult( redirectHandler.handlerRequestResponses, HttpServletResponse.SC_FOUND,
- HttpServletResponse.SC_CREATED );
- }
-
- protected void checkHandlerResult( List<HandlerRequestResponse> handlerRequestResponses,
- int... expectedResponseCodes )
- {
- boolean success = true;
- if ( handlerRequestResponses.size() == expectedResponseCodes.length )
- {
- for ( int i = 0; i < expectedResponseCodes.length; i++ )
- {
- success &= ( expectedResponseCodes[i] == handlerRequestResponses.get( i ).responseCode );
- }
- }
-
- if ( !success )
- {
- fail( "expected " + expectedResponseCodes + ", got " + handlerRequestResponses );
- }
- }
-
- public void testRedirectPutFileWithFullUrl()
- throws Exception
- {
- Server realServer = new Server( 0 );
-
- addConnectors( realServer );
-
- File repositoryDirectory = getRepositoryDirectory();
- FileUtils.deleteDirectory( repositoryDirectory );
- repositoryDirectory.mkdirs();
-
- PutHandler putHandler = new PutHandler( repositoryDirectory );
-
- realServer.setHandler( putHandler );
-
- realServer.start();
-
- Server redirectServer = new Server( 0 );
-
- addConnectors( redirectServer );
-
- String protocol = getProtocol();
-
- // protocol is wagon protocol but in fact dav is http(s)
- if ( protocol.equals( "dav" ) )
- {
- protocol = "http";
- }
-
- if ( protocol.equals( "davs" ) )
- {
- protocol = "https";
- }
-
- String redirectUrl = protocol + "://localhost:" + realServer.getConnectors()[0].getLocalPort();
-
- RedirectHandler redirectHandler =
- new RedirectHandler( "Found", HttpServletResponse.SC_SEE_OTHER, redirectUrl, repositoryDirectory );
-
- redirectServer.setHandler( redirectHandler );
-
- redirectServer.start();
-
- try
- {
- StreamingWagon wagon = (StreamingWagon) getWagon();
- Repository repository = new Repository( "foo", getRepositoryUrl( redirectServer ) );
- wagon.connect( repository );
-
- File sourceFile = new File( repositoryDirectory, "test-secured-put-resource" );
- sourceFile.delete();
- assertFalse( sourceFile.exists() );
-
- File tempFile = File.createTempFile( "wagon", "tmp" );
- tempFile.deleteOnExit();
- String content = "put top secret";
- FileUtils.fileWrite( tempFile.getAbsolutePath(), content );
-
- try
- {
- wagon.put( tempFile, "test-secured-put-resource" );
- }
- finally
- {
- tempFile.delete();
- }
-
- assertEquals( content, FileUtils.fileRead( sourceFile.getAbsolutePath() ) );
-
- }
- finally
- {
- realServer.stop();
- redirectServer.stop();
- }
- }
-
-
- public void testRedirectPutFileRelativeUrl()
- throws Exception
- {
- Server realServer = new Server( 0 );
- addConnectors( realServer );
- File repositoryDirectory = getRepositoryDirectory();
- FileUtils.deleteDirectory( repositoryDirectory );
- repositoryDirectory.mkdirs();
-
- PutHandler putHandler = new PutHandler( repositoryDirectory );
-
- realServer.setHandler( putHandler );
-
- realServer.start();
-
- Server redirectServer = new Server( 0 );
-
- addConnectors( redirectServer );
-
- RedirectHandler redirectHandler =
- new RedirectHandler( "Found", HttpServletResponse.SC_SEE_OTHER, "/redirectRequest/foo",
- repositoryDirectory );
-
- redirectServer.setHandler( redirectHandler );
-
- redirectServer.start();
-
- try
- {
- StreamingWagon wagon = (StreamingWagon) getWagon();
- Repository repository = new Repository( "foo", getRepositoryUrl( redirectServer ) );
- wagon.connect( repository );
-
- File sourceFile = new File( repositoryDirectory, "/redirectRequest/foo/test-secured-put-resource" );
- sourceFile.delete();
- assertFalse( sourceFile.exists() );
-
- File tempFile = File.createTempFile( "wagon", "tmp" );
- tempFile.deleteOnExit();
- String content = "put top secret";
- FileUtils.fileWrite( tempFile.getAbsolutePath(), content );
-
- try
- {
- wagon.put( tempFile, "test-secured-put-resource" );
- }
- finally
- {
- tempFile.delete();
- }
-
- assertEquals( content, FileUtils.fileRead( sourceFile.getAbsolutePath() ) );
-
- }
- finally
- {
- realServer.stop();
- redirectServer.stop();
- }
- }
-
-
- /**
- *
- */
- @SuppressWarnings( "checkstyle:visibilitymodifier" )
- public static class RedirectHandler
- extends AbstractHandler
- {
- String reason;
-
- int retCode;
-
- String redirectUrl;
-
- File repositoryDirectory;
-
- public List<HandlerRequestResponse> handlerRequestResponses = new ArrayList<HandlerRequestResponse>();
-
- RedirectHandler( String reason, int retCode, String redirectUrl, File repositoryDirectory )
- {
- this.reason = reason;
- this.retCode = retCode;
- this.redirectUrl = redirectUrl;
- this.repositoryDirectory = repositoryDirectory;
- }
-
- public void handle( String s, HttpServletRequest req, HttpServletResponse resp, int i )
- throws IOException, ServletException
- {
- if ( req.getRequestURI().contains( "redirectRequest" ) )
- {
- PutHandler putHandler = new PutHandler( this.repositoryDirectory );
- putHandler.handle( s, req, resp, i );
- handlerRequestResponses.add(
- new HandlerRequestResponse( req.getMethod(), ( (Response) resp ).getStatus(),
- req.getRequestURI() ) );
- return;
- }
- resp.setStatus( this.retCode );
- resp.sendRedirect( this.redirectUrl + "/" + req.getRequestURI() );
- handlerRequestResponses.add(
- new HandlerRequestResponse( req.getMethod(), ( (Response) resp ).getStatus(), req.getRequestURI() ) );
- }
- }
-
-
- private void runTestProxiedRequest( ProxyInfo proxyInfo, TestHeaderHandler handler )
- throws Exception
- {
- // what an UGLY hack!
- // but apparently jetty needs some time to free up resources
- // <5s: broken test :(
- // CHECKSTYLE_OFF: MagicNumber
- Thread.sleep( 5001L );
- // CHECKSTYLE_ON: MagicNumber
-
- Server proxyServer = new Server( 0 );
-
- proxyServer.setHandler( handler );
-
- proxyServer.start();
-
- proxyInfo.setPort( proxyServer.getConnectors()[0].getLocalPort() );
-
- System.out.println(
- "start proxy on host/port " + proxyInfo.getHost() + "/" + proxyInfo.getPort() + " with non proxyHosts "
- + proxyInfo.getNonProxyHosts() );
-
- while ( !proxyServer.isRunning() || !proxyServer.isStarted() )
- {
- Thread.sleep( 10 );
- }
-
- try
- {
- StreamingWagon wagon = (StreamingWagon) getWagon();
-
- Repository testRepository = new Repository( "id", "http://www.example.com/" );
-
- String localRepositoryPath = FileTestUtils.getTestOutputDir().toString();
- File sourceFile = new File( localRepositoryPath, "test-proxied-resource" );
- FileUtils.fileWrite( sourceFile.getAbsolutePath(), "content" );
-
- wagon.connect( testRepository, proxyInfo );
-
- try
- {
- wagon.getToStream( "test-proxied-resource", new ByteArrayOutputStream() );
-
- assertTrue( handler.headers.containsKey( "Proxy-Connection" ) );
- }
- finally
- {
- System.setProperty( "http.proxyHost", "" );
- System.setProperty( "http.proxyPort", "" );
- wagon.disconnect();
- }
- }
- finally
- {
- proxyServer.stop();
- }
- }
-
- private void runTestProxiedRequestWithProvider( ProxyInfoProvider proxyInfoProvider, TestHeaderHandler handler )
- throws Exception
- {
- // what an UGLY hack!
- // but apparently jetty needs some time to free up resources
- // <5s: broken test :(
- // CHECKSTYLE_OFF: MagicNumber
- Thread.sleep( 5001L );
- // CHECKSTYLE_ON: MagicNumber
-
- Server proxyServer = new Server( 0 );
-
- proxyServer.setHandler( handler );
-
- proxyServer.start();
-
- proxyInfoProvider.getProxyInfo( null ).setPort( proxyServer.getConnectors()[0].getLocalPort() );
-
- System.out.println( "start proxy on host/port " + proxyInfoProvider.getProxyInfo( null ).getHost() + "/"
- + proxyInfoProvider.getProxyInfo( null ).getPort() + " with non proxyHosts "
- + proxyInfoProvider.getProxyInfo( null ).getNonProxyHosts() );
-
- while ( !proxyServer.isRunning() || !proxyServer.isStarted() )
- {
- Thread.sleep( 10 );
- }
-
- try
- {
- StreamingWagon wagon = (StreamingWagon) getWagon();
-
- Repository testRepository = new Repository( "id", "http://www.example.com/" );
-
- String localRepositoryPath = FileTestUtils.getTestOutputDir().toString();
- File sourceFile = new File( localRepositoryPath, "test-proxied-resource" );
- FileUtils.fileWrite( sourceFile.getAbsolutePath(), "content" );
-
- wagon.connect( testRepository, proxyInfoProvider );
-
- try
- {
- wagon.getToStream( "test-proxied-resource", new ByteArrayOutputStream() );
-
- assertTrue( handler.headers.containsKey( "Proxy-Connection" ) );
- }
- finally
- {
- System.setProperty( "http.proxyHost", "" );
- System.setProperty( "http.proxyPort", "" );
- wagon.disconnect();
- }
- }
- finally
- {
- proxyServer.stop();
- }
- }
-
- private ProxyInfo createProxyInfo()
- {
- ProxyInfo proxyInfo = new ProxyInfo();
- proxyInfo.setHost( "localhost" );
- proxyInfo.setNonProxyHosts( null );
- proxyInfo.setType( "http" );
- return proxyInfo;
- }
-
- public void testSecuredGetUnauthorized()
- throws Exception
- {
- try
- {
- runTestSecuredGet( null );
- fail();
- }
- catch ( AuthorizationException e )
- {
- assertTrue( true );
- }
- }
-
- public void testSecuredGetWrongPassword()
- throws Exception
- {
- try
- {
- AuthenticationInfo authInfo = new AuthenticationInfo();
- authInfo.setUserName( "user" );
- authInfo.setPassword( "admin" );
- runTestSecuredGet( authInfo );
- fail();
- }
- catch ( AuthorizationException e )
- {
- assertTrue( true );
- }
- }
-
- public void testSecuredGet()
- throws Exception
- {
- AuthenticationInfo authInfo = new AuthenticationInfo();
- authInfo.setUserName( "user" );
- authInfo.setPassword( "secret" );
- runTestSecuredGet( authInfo );
- }
-
-
- public void runTestSecuredGet( AuthenticationInfo authInfo )
- throws Exception
- {
- String localRepositoryPath = FileTestUtils.getTestOutputDir().toString();
- Server server = createSecurityServer( localRepositoryPath );
-
- server.start();
-
- try
- {
- StreamingWagon wagon = (StreamingWagon) getWagon();
-
- Repository testRepository = new Repository( "id", getRepositoryUrl( server ) );
-
- File sourceFile = new File( localRepositoryPath, "test-secured-resource" );
- FileUtils.fileWrite( sourceFile.getAbsolutePath(), "top secret" );
-
- wagon.connect( testRepository, authInfo );
-
- File file = File.createTempFile( "wagon-test", "txt" );
-
- try
- {
- wagon.get( "test-secured-resource", file );
- }
- finally
- {
- wagon.disconnect();
- }
-
- FileInputStream in = new FileInputStream( file );
-
- assertEquals( "top secret", IOUtil.toString( in ) );
-
- TestSecurityHandler securityHandler = (TestSecurityHandler) ( (Context) server.getHandler() ).getHandler();
- testPreemptiveAuthenticationGet( securityHandler, supportPreemptiveAuthenticationGet() );
-
- }
- finally
- {
- server.stop();
- }
- }
-
-
- public void testSecuredGetToStream()
- throws Exception
- {
- AuthenticationInfo authInfo = new AuthenticationInfo();
- authInfo.setUserName( "user" );
- authInfo.setPassword( "secret" );
- runTestSecuredGetToStream( authInfo );
- }
-
- public void runTestSecuredGetToStream( AuthenticationInfo authInfo )
- throws Exception
- {
- String localRepositoryPath = FileTestUtils.getTestOutputDir().toString();
- Server server = createSecurityServer( localRepositoryPath );
-
- server.start();
-
- try
- {
- StreamingWagon wagon = (StreamingWagon) getWagon();
-
- Repository testRepository = new Repository( "id", getRepositoryUrl( server ) );
-
- File sourceFile = new File( localRepositoryPath, "test-secured-resource" );
- FileUtils.fileWrite( sourceFile.getAbsolutePath(), "top secret" );
-
- wagon.connect( testRepository, authInfo );
-
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- try
- {
- wagon.getToStream( "test-secured-resource", out );
- }
- finally
- {
- wagon.disconnect();
- }
-
- assertEquals( "top secret", out.toString( "US-ASCII" ) );
-
- TestSecurityHandler securityHandler = (TestSecurityHandler) ( (Context) server.getHandler() ).getHandler();
- testPreemptiveAuthenticationGet( securityHandler, supportPreemptiveAuthenticationGet() );
- }
- finally
- {
- server.stop();
- }
- }
-
- public void testSecuredResourceExistsUnauthorized()
- throws Exception
- {
- try
- {
- runTestSecuredResourceExists( null );
- fail();
- }
- catch ( AuthorizationException e )
- {
- assertTrue( true );
- }
- }
-
- public void testSecuredResourceExistsWrongPassword()
- throws Exception
- {
- try
- {
- AuthenticationInfo authInfo = new AuthenticationInfo();
- authInfo.setUserName( "user" );
- authInfo.setPassword( "admin" );
- runTestSecuredResourceExists( authInfo );
- }
- catch ( AuthorizationException e )
- {
- assertTrue( true );
- }
- }
-
- public void testSecuredResourceExists()
- throws Exception
- {
- AuthenticationInfo authInfo = new AuthenticationInfo();
- authInfo.setUserName( "user" );
- authInfo.setPassword( "secret" );
- runTestSecuredResourceExists( authInfo );
- }
-
- public void runTestSecuredResourceExists( AuthenticationInfo authInfo )
- throws Exception
- {
- String localRepositoryPath = FileTestUtils.getTestOutputDir().toString();
- Server server = createSecurityServer( localRepositoryPath );
-
- server.start();
-
- try
- {
- StreamingWagon wagon = (StreamingWagon) getWagon();
-
- Repository testRepository = new Repository( "id", getRepositoryUrl( server ) );
-
- File sourceFile = new File( localRepositoryPath, "test-secured-resource-exists" );
- FileUtils.fileWrite( sourceFile.getAbsolutePath(), "top secret" );
-
- wagon.connect( testRepository, authInfo );
-
- try
- {
- assertTrue( wagon.resourceExists( "test-secured-resource-exists" ) );
-
- assertFalse( wagon.resourceExists( "test-secured-resource-not-exists" ) );
- }
- finally
- {
- wagon.disconnect();
- }
- }
- finally
- {
- server.stop();
- }
- }
-
- private Server createSecurityServer( String localRepositoryPath )
- {
- Server server = new Server( 0 );
-
- SecurityHandler sh = createSecurityHandler();
-
- Context root = new Context( Context.SESSIONS );
- root.setContextPath( "/" );
- root.addHandler( sh );
- root.setResourceBase( localRepositoryPath );
- ServletHolder servletHolder = new ServletHolder( new DefaultServlet() );
- root.addServlet( servletHolder, "/*" );
-
- server.setHandler( root );
- addConnectors( server );
- return server;
- }
-
-
- private String writeTestFileGzip( File parent, String child )
- throws IOException
- {
- File file = new File( parent, child );
- file.getParentFile().mkdirs();
- file.deleteOnExit();
- OutputStream out = new FileOutputStream( file );
- try
- {
- out.write( child.getBytes() );
- }
- finally
- {
- out.close();
- }
-
- file = new File( parent, child + ".gz" );
- file.deleteOnExit();
- String content;
- out = new FileOutputStream( file );
- out = new GZIPOutputStream( out );
- try
- {
- // write out different data than non-gz file, so we can
- // assert the gz version was returned
- content = file.getAbsolutePath();
- out.write( content.getBytes() );
- }
- finally
- {
- out.close();
- }
-
- return content;
- }
-
- public void testPutForbidden()
- throws Exception
- {
- try
- {
- runTestPut( HttpServletResponse.SC_FORBIDDEN );
- fail();
- }
- catch ( AuthorizationException e )
- {
- assertTrue( true );
- }
- }
-
- public void testPut404()
- throws Exception
- {
- try
- {
- runTestPut( HttpServletResponse.SC_NOT_FOUND );
- fail();
- }
- catch ( ResourceDoesNotExistException e )
- {
- assertTrue( true );
- }
- }
-
- public void testPut500()
- throws Exception
- {
- try
- {
- runTestPut( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
- fail();
- }
- catch ( TransferFailedException e )
- {
- assertTrue( true );
- }
- }
-
- public void testPut429()
- throws Exception
- {
-
- try
- {
-
- StreamingWagon wagon = (StreamingWagon) getWagon();
- Server server = new Server( 0 );
- final AtomicBoolean called = new AtomicBoolean();
-
- AbstractHandler handler = new AbstractHandler()
- {
- public void handle( String s, HttpServletRequest request, HttpServletResponse response, int i )
- throws IOException, ServletException
- {
- if ( called.get() )
- {
- response.setStatus( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
- ( (Request) request ).setHandled( true );
- }
- else
- {
- called.set( true );
- response.setStatus( SC_TOO_MANY_REQUESTS );
- ( (Request) request ).setHandled( true );
- }
- }
- };
-
- server.setHandler( handler );
- addConnectors( server );
- server.start();
-
- wagon.connect( new Repository( "id", getRepositoryUrl( server ) ) );
-
- File tempFile = File.createTempFile( "wagon", "tmp" );
- tempFile.deleteOnExit();
- FileUtils.fileWrite( tempFile.getAbsolutePath(), "content" );
-
- try
- {
- wagon.put( tempFile, "resource" );
- fail();
- }
- finally
- {
- wagon.disconnect();
-
- server.stop();
-
- tempFile.delete();
- }
-
- }
- catch ( TransferFailedException e )
- {
- assertTrue( true );
- }
- }
-
-
- private void runTestPut( int status )
- throws Exception
- {
- StreamingWagon wagon = (StreamingWagon) getWagon();
-
- Server server = new Server( 0 );
- StatusHandler handler = new StatusHandler();
- handler.setStatusToReturn( status );
- server.setHandler( handler );
- addConnectors( server );
- server.start();
-
- wagon.connect( new Repository( "id", getRepositoryUrl( server ) ) );
-
- File tempFile = File.createTempFile( "wagon", "tmp" );
- tempFile.deleteOnExit();
- FileUtils.fileWrite( tempFile.getAbsolutePath(), "content" );
-
- try
- {
- wagon.put( tempFile, "resource" );
- fail();
- }
- finally
- {
- wagon.disconnect();
-
- server.stop();
-
- tempFile.delete();
- }
- }
-
- public void testSecuredPutUnauthorized()
- throws Exception
- {
- try
- {
- runTestSecuredPut( null );
- fail();
- }
- catch ( TransferFailedException e )
- {
- assertTrue( true );
- }
- }
-
- public void testSecuredPutWrongPassword()
- throws Exception
- {
- try
- {
- AuthenticationInfo authInfo = new AuthenticationInfo();
- authInfo.setUserName( "user" );
- authInfo.setPassword( "admin" );
- runTestSecuredPut( authInfo );
- fail();
- }
- catch ( TransferFailedException e )
- {
- assertTrue( true );
- }
- }
-
- public void testSecuredPut()
- throws Exception
- {
- AuthenticationInfo authInfo = new AuthenticationInfo();
- authInfo.setUserName( "user" );
- authInfo.setPassword( "secret" );
- runTestSecuredPut( authInfo );
- }
-
- public void runTestSecuredPut( AuthenticationInfo authInfo )
- throws Exception
- {
- runTestSecuredPut( authInfo, 1 );
- }
-
- public void runTestSecuredPut( AuthenticationInfo authInfo, int putNumber )
- throws Exception
- {
- String localRepositoryPath = FileTestUtils.getTestOutputDir().toString();
- Server server = new Server( 0 );
-
- TestSecurityHandler sh = createSecurityHandler();
-
- PutHandler putHandler = new PutHandler( new File( localRepositoryPath ) );
-
- HandlerCollection handlers = new HandlerCollection();
- handlers.setHandlers( new Handler[]{ sh, putHandler } );
-
- server.setHandler( handlers );
- addConnectors( server );
- server.start();
-
- StreamingWagon wagon = (StreamingWagon) getWagon();
- Repository testRepository = new Repository( "id", getRepositoryUrl( server ) );
- wagon.connect( testRepository, authInfo );
- try
- {
- for ( int i = 0; i < putNumber; i++ )
- {
- File sourceFile = new File( localRepositoryPath, "test-secured-put-resource" );
- sourceFile.delete();
- assertFalse( sourceFile.exists() );
-
- File tempFile = File.createTempFile( "wagon", "tmp" );
- tempFile.deleteOnExit();
- FileUtils.fileWrite( tempFile.getAbsolutePath(), "put top secret" );
-
- try
- {
- wagon.put( tempFile, "test-secured-put-resource" );
- }
- finally
- {
- tempFile.delete();
- }
-
- assertEquals( "put top secret", FileUtils.fileRead( sourceFile.getAbsolutePath() ) );
- }
- }
- finally
- {
- wagon.disconnect();
- server.stop();
- }
- assertEquals( putNumber, putHandler.putCallNumber );
- testPreemptiveAuthenticationPut( sh, supportPreemptiveAuthenticationPut() );
- }
-
- public void testNonSecuredPutFromStream()
- throws Exception
- {
- AuthenticationInfo authInfo = new AuthenticationInfo();
- authInfo.setUserName( "user" );
- authInfo.setPassword( "secret" );
- runTestSecuredPutFromStream( authInfo, 1, false );
- }
-
- public void testSecuredPutFromStream()
- throws Exception
- {
- AuthenticationInfo authInfo = new AuthenticationInfo();
- authInfo.setUserName( "user" );
- authInfo.setPassword( "secret" );
- runTestSecuredPutFromStream( authInfo, 1, true );
- }
-
- public void runTestSecuredPutFromStream( AuthenticationInfo authInfo, int putNumber, boolean addSecurityHandler )
- throws Exception
- {
- String localRepositoryPath = FileTestUtils.getTestOutputDir().toString();
- Server server = new Server( 0 );
-
- TestSecurityHandler sh = createSecurityHandler();
-
- PutHandler putHandler = new PutHandler( new File( localRepositoryPath ) );
-
- HandlerCollection handlers = new HandlerCollection();
- handlers.setHandlers( addSecurityHandler ? new Handler[]{ sh, putHandler } : new Handler[]{ putHandler } );
-
- server.setHandler( handlers );
- addConnectors( server );
- server.start();
-
- StreamingWagon wagon = (StreamingWagon) getWagon();
- Repository testRepository = new Repository( "id", getRepositoryUrl( server ) );
- if ( addSecurityHandler )
- {
- wagon.connect( testRepository, authInfo );
- }
- else
- {
- wagon.connect( testRepository );
- }
- try
- {
- for ( int i = 0; i < putNumber; i++ )
- {
- File sourceFile = new File( localRepositoryPath, "test-secured-put-resource" );
- sourceFile.delete();
- assertFalse( sourceFile.exists() );
-
- File tempFile = File.createTempFile( "wagon", "tmp" );
- tempFile.deleteOnExit();
- String content = "put top secret";
- FileUtils.fileWrite( tempFile.getAbsolutePath(), content );
-
- FileInputStream fileInputStream = new FileInputStream( tempFile );
- try
- {
- wagon.putFromStream( fileInputStream, "test-secured-put-resource", content.length(), -1 );
- }
- finally
- {
- fileInputStream.close();
- tempFile.delete();
-
- }
-
- assertEquals( content, FileUtils.fileRead( sourceFile.getAbsolutePath() ) );
- }
- }
- finally
- {
- wagon.disconnect();
- server.stop();
- }
- assertEquals( putNumber, putHandler.putCallNumber );
- if ( addSecurityHandler )
- {
- testPreemptiveAuthenticationPut( sh, supportPreemptiveAuthenticationPut() );
- }
-
- // ensure we didn't use chunked transfer which doesn't work on ngnix
- for ( DeployedResource deployedResource : putHandler.deployedResources )
- {
- if ( StringUtils.equalsIgnoreCase( "chunked", deployedResource.transferEncoding ) )
- {
- fail( "deployedResource use chunked: " + deployedResource );
- }
- }
- }
-
-
- protected abstract boolean supportPreemptiveAuthenticationPut();
-
- protected abstract boolean supportPreemptiveAuthenticationGet();
-
- protected abstract boolean supportProxyPreemptiveAuthentication();
-
- protected void testPreemptiveAuthenticationGet( TestSecurityHandler sh, boolean preemptive )
- {
- testPreemptiveAuthentication( sh, preemptive );
- }
-
- protected void testPreemptiveAuthenticationPut( TestSecurityHandler sh, boolean preemptive )
- {
- testPreemptiveAuthentication( sh, preemptive );
- }
-
- protected void testPreemptiveAuthentication( TestSecurityHandler sh, boolean preemptive )
- {
-
- if ( preemptive )
- {
- assertEquals( "not 1 security handler use " + sh.handlerRequestResponses, 1,
- sh.handlerRequestResponses.size() );
- assertEquals( HttpServletResponse.SC_OK, sh.handlerRequestResponses.get( 0 ).responseCode );
- }
- else
- {
- assertEquals( "not 2 security handler use " + sh.handlerRequestResponses, 2,
- sh.handlerRequestResponses.size() );
- assertEquals( HttpServletResponse.SC_UNAUTHORIZED, sh.handlerRequestResponses.get( 0 ).responseCode );
- assertEquals( HttpServletResponse.SC_OK, sh.handlerRequestResponses.get( 1 ).responseCode );
-
- }
- }
-
- static class StatusHandler
- extends AbstractHandler
- {
- private int status;
-
- public void setStatusToReturn( int status )
- {
- this.status = status;
- }
-
- public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
- throws IOException, ServletException
- {
- if ( status != 0 )
- {
- response.setStatus( status );
- ( (Request) request ).setHandled( true );
- }
- }
- }
-
- static class DeployedResource
- {
- String httpMethod;
-
- String requestUri;
-
- String contentLength;
-
- String transferEncoding;
-
- public DeployedResource()
- {
- // no op
- }
-
- @Override
- public String toString()
- {
- final StringBuilder sb = new StringBuilder();
- sb.append( "DeployedResource" );
- sb.append( "{httpMethod='" ).append( httpMethod ).append( '\'' );
- sb.append( ", requestUri='" ).append( requestUri ).append( '\'' );
- sb.append( ", contentLength='" ).append( contentLength ).append( '\'' );
- sb.append( ", transferEncoding='" ).append( transferEncoding ).append( '\'' );
- sb.append( '}' );
- return sb.toString();
- }
- }
-
- /**
- *
- */
- @SuppressWarnings( "checkstyle:visibilitymodifier" )
- public static class PutHandler
- extends AbstractHandler
- {
- private final File resourceBase;
-
- public List<DeployedResource> deployedResources = new ArrayList<DeployedResource>();
-
- public int putCallNumber = 0;
-
- public List<HandlerRequestResponse> handlerRequestResponses = new ArrayList<HandlerRequestResponse>();
-
- public PutHandler( File repositoryDirectory )
- {
- this.resourceBase = repositoryDirectory;
- }
-
- public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
- throws IOException, ServletException
- {
- Request baseRequest =
- request instanceof Request ? (Request) request : HttpConnection.getCurrentConnection().getRequest();
-
- if ( baseRequest.isHandled() || !"PUT".equals( baseRequest.getMethod() ) )
- {
- return;
- }
-
- baseRequest.setHandled( true );
-
- File file = new File( resourceBase, URLDecoder.decode( request.getPathInfo() ) );
- file.getParentFile().mkdirs();
- FileOutputStream out = new FileOutputStream( file );
- ServletInputStream in = request.getInputStream();
- try
- {
- IOUtil.copy( in, out );
- }
- finally
- {
- in.close();
- out.close();
- }
- putCallNumber++;
- DeployedResource deployedResource = new DeployedResource();
-
- deployedResource.httpMethod = request.getMethod();
- deployedResource.requestUri = request.getRequestURI();
- deployedResource.transferEncoding = request.getHeader( "Transfer-Encoding" );
- deployedResource.contentLength = request.getHeader( "Content-Length" );
- deployedResources.add( deployedResource );
-
- response.setStatus( HttpServletResponse.SC_CREATED );
-
- handlerRequestResponses.add(
- new HandlerRequestResponse( request.getMethod(), ( (Response) response ).getStatus(),
- request.getRequestURI() ) );
- }
- }
-
- private static class AuthorizingProxyHandler
- extends TestHeaderHandler
- {
-
- List<HandlerRequestResponse> handlerRequestResponses = new ArrayList<HandlerRequestResponse>();
-
- public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
- throws IOException, ServletException
- {
- System.out.println( " handle proxy request" );
- if ( request.getHeader( "Proxy-Authorization" ) == null )
- {
- handlerRequestResponses.add(
- new HandlerRequestResponse( request.getMethod(),
- HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED,
- request.getRequestURI() ) );
- response.setStatus( HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED );
- response.addHeader( "Proxy-Authenticate", "Basic realm=\"Squid proxy-caching web server\"" );
-
- ( (Request) request ).setHandled( true );
- return;
- }
- handlerRequestResponses.add(
- new HandlerRequestResponse( request.getMethod(), HttpServletResponse.SC_OK, request.getRequestURI() ) );
- super.handle( target, request, response, dispatch );
- }
- }
-
- /**
- *
- */
- @SuppressWarnings( "checkstyle:visibilitymodifier" )
- private static class TestHeaderHandler
- extends AbstractHandler
- {
- public Map<String, String> headers = Collections.emptyMap();
-
- public List<HandlerRequestResponse> handlerRequestResponses = new ArrayList<HandlerRequestResponse>();
-
- public TestHeaderHandler()
- {
- }
-
- public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
- throws IOException, ServletException
- {
- headers = new HashMap<String, String>();
- for ( Enumeration<String> e = request.getHeaderNames(); e.hasMoreElements(); )
- {
- String name = e.nextElement();
- Enumeration headerValues = request.getHeaders( name );
- // as per HTTP spec http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html
- // multiple values for the same header key are concatenated separated by comma
- // otherwise we wouldn't notice headers with same key added multiple times
- StringBuffer combinedHeaderValue = new StringBuffer();
- for ( int i = 0; headerValues.hasMoreElements(); i++ )
- {
- if ( i > 0 )
- {
- combinedHeaderValue.append( "," );
- }
- combinedHeaderValue.append( headerValues.nextElement() );
- }
- headers.put( name, combinedHeaderValue.toString() );
- }
-
- response.setContentType( "text/plain" );
- response.setStatus( HttpServletResponse.SC_OK );
- response.getWriter().print( "Hello, World!" );
-
- handlerRequestResponses.add(
- new HandlerRequestResponse( request.getMethod(), ( (Response) response ).getStatus(),
- request.getRequestURI() ) );
-
- ( (Request) request ).setHandled( true );
- }
-
- }
-
- protected TestSecurityHandler createSecurityHandler()
- {
- Constraint constraint = new Constraint();
- constraint.setName( Constraint.__BASIC_AUTH );
- constraint.setRoles( new String[]{ "admin" } );
- constraint.setAuthenticate( true );
-
- ConstraintMapping cm = new ConstraintMapping();
- cm.setConstraint( constraint );
- cm.setPathSpec( "/*" );
-
- TestSecurityHandler sh = new TestSecurityHandler();
- HashUserRealm hashUserRealm = new HashUserRealm( "MyRealm" );
- hashUserRealm.put( "user", "secret" );
- hashUserRealm.addUserToRole( "user", "admin" );
- sh.setUserRealm( hashUserRealm );
- sh.setConstraintMappings( new ConstraintMapping[]{ cm } );
- return sh;
- }
-
- /**
- *
- */
- @SuppressWarnings( "checkstyle:visibilitymodifier" )
- public static class TestSecurityHandler
- extends SecurityHandler
- {
-
- public List<HandlerRequestResponse> handlerRequestResponses = new ArrayList<HandlerRequestResponse>();
-
- @Override
- public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
- throws IOException, ServletException
- {
- String method = request.getMethod();
- super.handle( target, request, response, dispatch );
-
- handlerRequestResponses.add(
- new HandlerRequestResponse( method, ( (Response) response ).getStatus(), request.getRequestURI() ) );
- }
-
- }
-
- /**
- *
- */
- @SuppressWarnings( "checkstyle:visibilitymodifier" )
- public static class HandlerRequestResponse
- {
- public String method;
-
- public int responseCode;
-
- public String requestUri;
-
- private HandlerRequestResponse( String method, int responseCode, String requestUri )
- {
- this.method = method;
- this.responseCode = responseCode;
- this.requestUri = requestUri;
- }
-
- @Override
- public String toString()
- {
- final StringBuilder sb = new StringBuilder();
- sb.append( "HandlerRequestResponse" );
- sb.append( "{method='" ).append( method ).append( '\'' );
- sb.append( ", responseCode=" ).append( responseCode );
- sb.append( ", requestUri='" ).append( requestUri ).append( '\'' );
- sb.append( '}' );
- return sb.toString();
- }
- }
-}
+package org.apache.maven.wagon.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.FileTestUtils;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.StreamingWagon;
+import org.apache.maven.wagon.StreamingWagonTestCase;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.proxy.ProxyInfo;
+import org.apache.maven.wagon.proxy.ProxyInfoProvider;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.resource.Resource;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.StringUtils;
+import org.eclipse.jetty.security.ConstraintMapping;
+import org.eclipse.jetty.security.ConstraintSecurityHandler;
+import org.eclipse.jetty.security.HashLoginService;
+import org.eclipse.jetty.security.SecurityHandler;
+import org.eclipse.jetty.security.authentication.BasicAuthenticator;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.Response;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.handler.AbstractHandler;
+import org.eclipse.jetty.server.handler.HandlerCollection;
+import org.eclipse.jetty.util.security.Constraint;
+import org.eclipse.jetty.util.security.Password;
+import org.eclipse.jetty.servlet.DefaultServlet;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.reflect.Method;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.zip.GZIPOutputStream;
+
+/**
+ *
+ */
+public abstract class HttpWagonTestCase
+ extends StreamingWagonTestCase
+{
+ public static final int SC_TOO_MANY_REQUESTS = 429;
+
+ private Server server;
+
+ protected void setupWagonTestingFixtures()
+ throws Exception
+ {
+ // File round trip testing
+
+ File file = FileTestUtils.createUniqueFile( "local-repository", "test-resource" );
+
+ file.delete();
+
+ file.getParentFile().mkdirs();
+
+ File repositoryDirectory = getRepositoryDirectory();
+ FileUtils.deleteDirectory( repositoryDirectory );
+ repositoryDirectory.mkdirs();
+
+ server = new Server( 0 );
+
+ PutHandler putHandler = new PutHandler( repositoryDirectory );
+
+ ServletContextHandler context = createContext( server, repositoryDirectory );
+ HandlerCollection handlers = new HandlerCollection();
+ handlers.addHandler( putHandler );
+ handlers.addHandler( context );
+ server.setHandler( handlers );
+
+ addConnectors( server );
+
+ server.start();
+
+ testRepository.setUrl( getTestRepositoryUrl() );
+ }
+
+ @Override
+ protected final int getTestRepositoryPort()
+ {
+ if ( server == null )
+ {
+ return 0;
+ }
+ return server.getConnectors()[0].getLocalPort();
+ }
+
+ protected ServletContextHandler createContext( Server server, File repositoryDirectory )
+ throws IOException
+ {
+ ServletContextHandler root = new ServletContextHandler( ServletContextHandler.SESSIONS );
+ root.setResourceBase( repositoryDirectory.getAbsolutePath() );
+ ServletHolder servletHolder = new ServletHolder( new DefaultServlet() );
+ root.addServlet( servletHolder, "/*" );
+ return root;
+ }
+
+ protected void tearDownWagonTestingFixtures()
+ throws Exception
+ {
+ server.stop();
+ }
+
+ public void testWagonGetFileList()
+ throws Exception
+ {
+ File dir = getRepositoryDirectory();
+ FileUtils.deleteDirectory( dir );
+
+ File f = new File( dir, "file-list" );
+ f.mkdirs();
+
+ super.testWagonGetFileList();
+ }
+
+ public void testHttpHeaders()
+ throws Exception
+ {
+ Properties properties = new Properties();
+ properties.setProperty( "User-Agent", "Maven-Wagon/1.0" );
+
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+
+ setHttpHeaders( wagon, properties );
+
+ Server server = new Server( 0 );
+ TestHeaderHandler handler = new TestHeaderHandler();
+ server.setHandler( handler );
+ addConnectors( server );
+ server.start();
+
+ wagon.connect(
+ new Repository( "id", getProtocol() + "://localhost:" + server.getConnectors()[0].getLocalPort() ) );
+
+ wagon.getToStream( "resource", new ByteArrayOutputStream() );
+
+ wagon.disconnect();
+
+ server.stop();
+
+ assertEquals( "Maven-Wagon/1.0", handler.headers.get( "User-Agent" ) );
+ }
+
+ /**
+ * test set of User-Agent as it's done by aether wagon connector with using setHttpHeaders
+ */
+ public void testHttpHeadersWithCommonMethods()
+ throws Exception
+ {
+ Properties properties = new Properties();
+ properties.setProperty( "User-Agent", "Maven-Wagon/1.0" );
+
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+
+ Method setHttpHeaders = wagon.getClass().getMethod( "setHttpHeaders", Properties.class );
+ setHttpHeaders.invoke( wagon, properties );
+
+ Server server = new Server( 0 );
+ TestHeaderHandler handler = new TestHeaderHandler();
+ server.setHandler( handler );
+ addConnectors( server );
+ server.start();
+
+ wagon.connect(
+ new Repository( "id", getProtocol() + "://localhost:" + server.getConnectors()[0].getLocalPort() ) );
+
+ wagon.getToStream( "resource", new ByteArrayOutputStream() );
+
+ wagon.disconnect();
+
+ server.stop();
+
+ assertEquals( "Maven-Wagon/1.0", handler.headers.get( "User-Agent" ) );
+ }
+
+ public void testUserAgentHeaderIsPresentByDefault()
+ throws Exception
+ {
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+ Server server = new Server( 0 );
+ TestHeaderHandler handler = new TestHeaderHandler();
+ server.setHandler( handler );
+ addConnectors( server );
+ server.start();
+ wagon.connect( new Repository( "id", getProtocol() + "://localhost:"
+ + server.getConnectors()[0].getLocalPort() ) );
+ wagon.getToStream( "resource", new ByteArrayOutputStream() );
+ wagon.disconnect();
+ server.stop();
+
+ assertNotNull( "default User-Agent header of wagon provider should be present",
+ handler.headers.get( "User-Agent" ) );
+ }
+
+ public void testUserAgentHeaderIsPresentOnlyOnceIfSetMultipleTimes()
+ throws Exception
+ {
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+
+ // 1. set User-Agent header via HttpConfiguration
+ Properties headers1 = new Properties();
+ headers1.setProperty( "User-Agent", "test-user-agent" );
+ setHttpHeaders( wagon, headers1 );
+
+ // 2. redundantly set User-Agent header via setHttpHeaders()
+ Properties headers2 = new Properties();
+ headers2.setProperty( "User-Agent", "test-user-agent" );
+ Method setHttpHeaders = wagon.getClass().getMethod( "setHttpHeaders", Properties.class );
+ setHttpHeaders.invoke( wagon, headers2 );
+
+ Server server = new Server( 0 );
+ TestHeaderHandler handler = new TestHeaderHandler();
+ server.setHandler( handler );
+ addConnectors( server );
+ server.start();
+ wagon.connect( new Repository( "id", getProtocol() + "://localhost:"
+ + server.getConnectors()[0].getLocalPort() ) );
+ wagon.getToStream( "resource", new ByteArrayOutputStream() );
+ wagon.disconnect();
+ server.stop();
+
+ assertEquals( "test-user-agent", handler.headers.get( "User-Agent" ) );
+
+ }
+
+ protected abstract void setHttpHeaders( StreamingWagon wagon, Properties properties );
+
+ protected void addConnectors( Server server )
+ {
+ }
+
+ protected String getRepositoryUrl( Server server )
+ {
+ int localPort = server.getConnectors()[0].getLocalPort();
+ return getProtocol() + "://localhost:" + localPort;
+ }
+
+ public void testGetForbidden()
+ throws Exception
+ {
+ try
+ {
+ runTestGet( HttpServletResponse.SC_FORBIDDEN );
+ fail();
+ }
+ catch ( AuthorizationException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+ public void testGet404()
+ throws Exception
+ {
+ try
+ {
+ runTestGet( HttpServletResponse.SC_NOT_FOUND );
+ fail();
+ }
+ catch ( ResourceDoesNotExistException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+ public void testList429()
+ throws Exception
+ {
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+ try
+ {
+
+ Server server = new Server( 0 );
+ final AtomicBoolean called = new AtomicBoolean();
+
+ AbstractHandler handler = new AbstractHandler()
+ {
+ public void handle( String target, Request baseRequest, HttpServletRequest request,
+ HttpServletResponse response ) throws IOException, ServletException
+ {
+ if ( called.get() )
+ {
+ response.setStatus( HttpServletResponse.SC_OK );
+ baseRequest.setHandled( true );
+ }
+ else
+ {
+ called.set( true );
+ response.setStatus( SC_TOO_MANY_REQUESTS );
+ baseRequest.setHandled( true );
+
+ }
+ }
+ };
+
+ server.setHandler( handler );
+ addConnectors( server );
+ server.start();
+
+ wagon.connect( new Repository( "id", getRepositoryUrl( server ) ) );
+
+ try
+ {
+ wagon.getFileList( "resource" );
+ }
+ finally
+ {
+ wagon.disconnect();
+
+ server.stop();
+ }
+
+ }
+ catch ( ResourceDoesNotExistException e )
+ {
+ assertTrue( true );
+ }
+ catch ( TransferFailedException e )
+ {
+ if ( wagon.getClass().getName().contains( "Lightweight" ) )
+ {
+ //we don't care about lightweight
+ assertTrue( true );
+ }
+ else
+ {
+ fail();
+ }
+
+ }
+ }
+
+ public void testGet500()
+ throws Exception
+ {
+ try
+ {
+ runTestGet( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
+ fail();
+ }
+ catch ( TransferFailedException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+ private void runTestGet( int status )
+ throws Exception
+ {
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+
+ Server server = new Server( 0 );
+ StatusHandler handler = new StatusHandler();
+ handler.setStatusToReturn( status );
+ server.setHandler( handler );
+ addConnectors( server );
+ server.start();
+
+ wagon.connect( new Repository( "id", getRepositoryUrl( server ) ) );
+
+ try
+ {
+ wagon.getToStream( "resource", new ByteArrayOutputStream() );
+ fail();
+ }
+ finally
+ {
+ wagon.disconnect();
+
+ server.stop();
+ }
+ }
+
+ public void testResourceExistsForbidden()
+ throws Exception
+ {
+ try
+ {
+ runTestResourceExists( HttpServletResponse.SC_FORBIDDEN );
+ fail();
+ }
+ catch ( AuthorizationException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+ public void testResourceExists404()
+ throws Exception
+ {
+ try
+ {
+ assertFalse( runTestResourceExists( HttpServletResponse.SC_NOT_FOUND ) );
+ }
+ catch ( ResourceDoesNotExistException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+ public void testResourceExists500()
+ throws Exception
+ {
+ try
+ {
+ runTestResourceExists( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
+ fail();
+ }
+ catch ( TransferFailedException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+ public void testResourceExists429()
+ throws Exception
+ {
+ try
+ {
+
+ final AtomicBoolean called = new AtomicBoolean();
+
+ AbstractHandler handler = new AbstractHandler()
+ {
+ public void handle( String target, Request baseRequest, HttpServletRequest request,
+ HttpServletResponse response ) throws IOException, ServletException
+ {
+ if ( called.get() )
+ {
+ response.setStatus( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
+ baseRequest.setHandled( true );
+ }
+ else
+ {
+ called.set( true );
+ response.setStatus( SC_TOO_MANY_REQUESTS );
+ baseRequest.setHandled( true );
+ }
+ }
+ };
+
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+ Server server = new Server( 0 );
+ server.setHandler( handler );
+ addConnectors( server );
+ server.start();
+ wagon.connect( new Repository( "id", getRepositoryUrl( server ) ) );
+
+ try
+ {
+ wagon.resourceExists( "resource" );
+ }
+ finally
+ {
+ wagon.disconnect();
+
+ server.stop();
+ }
+
+ fail();
+ }
+ catch ( TransferFailedException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+
+ private boolean runTestResourceExists( int status )
+ throws Exception
+ {
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+
+ Server server = new Server( 0 );
+ StatusHandler handler = new StatusHandler();
+ handler.setStatusToReturn( status );
+ server.setHandler( handler );
+ addConnectors( server );
+ server.start();
+
+ wagon.connect( new Repository( "id", getRepositoryUrl( server ) ) );
+
+ try
+ {
+ return wagon.resourceExists( "resource" );
+ }
+ finally
+ {
+ wagon.disconnect();
+
+ server.stop();
+ }
+ }
+
+ protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
+ {
+ File file = new File( getRepositoryDirectory(), resource.getName() );
+ return ( file.lastModified() / 1000 ) * 1000;
+ }
+
+ protected File getRepositoryDirectory()
+ {
+ return getTestFile( "target/test-output/http-repository" );
+ }
+
+ public void testGzipGet()
+ throws Exception
+ {
+ Server server = new Server( getTestRepositoryPort() );
+
+ String localRepositoryPath = FileTestUtils.getTestOutputDir().toString();
+ ServletContextHandler root = new ServletContextHandler( ServletContextHandler.SESSIONS );
+ root.setResourceBase( localRepositoryPath );
+ ServletHolder servletHolder = new ServletHolder( new DefaultServlet() );
+ servletHolder.setInitParameter( "gzip", "true" );
+ root.addServlet( servletHolder, "/*" );
+ addConnectors( server );
+ server.setHandler( root );
+ server.start();
+
+ try
+ {
+ Wagon wagon = getWagon();
+
+ Repository testRepository = new Repository( "id", getRepositoryUrl( server ) );
+
+ File sourceFile = new File( localRepositoryPath + "/gzip" );
+
+ sourceFile.deleteOnExit();
+
+ String resName = "gzip-res.txt";
+ String sourceContent = writeTestFileGzip( sourceFile, resName );
+
+ wagon.connect( testRepository );
+
+ File destFile = FileTestUtils.createUniqueFile( getName(), getName() );
+
+ destFile.deleteOnExit();
+
+ wagon.get( "gzip/" + resName, destFile );
+
+ wagon.disconnect();
+
+ String destContent = FileUtils.fileRead( destFile );
+
+ assertEquals( sourceContent, destContent );
+ }
+ finally
+ {
+ server.stop();
+ }
+ }
+
+ public void testProxiedRequest()
+ throws Exception
+ {
+ ProxyInfo proxyInfo = createProxyInfo();
+ TestHeaderHandler handler = new TestHeaderHandler();
+
+ runTestProxiedRequest( proxyInfo, handler );
+ }
+
+ public void testProxiedRequestWithAuthentication()
+ throws Exception
+ {
+ ProxyInfo proxyInfo = createProxyInfo();
+ proxyInfo.setUserName( "user" );
+ proxyInfo.setPassword( "secret" );
+ AuthorizingProxyHandler handler = new AuthorizingProxyHandler();
+
+ runTestProxiedRequest( proxyInfo, handler );
+
+ assertTrue( handler.headers.containsKey( "Proxy-Authorization" ) );
+
+ if ( supportProxyPreemptiveAuthentication() )
+ {
+ assertEquals( HttpServletResponse.SC_OK, handler.handlerRequestResponses.get( 0 ).responseCode );
+ }
+ else
+ {
+ assertEquals( HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED,
+ handler.handlerRequestResponses.get( 0 ).responseCode );
+ assertEquals( HttpServletResponse.SC_OK, handler.handlerRequestResponses.get( 1 ).responseCode );
+ }
+
+ }
+
+ public void testProxiedRequestWithAuthenticationWithProvider()
+ throws Exception
+ {
+ final ProxyInfo proxyInfo = createProxyInfo();
+ proxyInfo.setUserName( "user" );
+ proxyInfo.setPassword( "secret" );
+ AuthorizingProxyHandler handler = new AuthorizingProxyHandler();
+
+ ProxyInfoProvider proxyInfoProvider = new ProxyInfoProvider()
+ {
+ public ProxyInfo getProxyInfo( String protocol )
+ {
+ return proxyInfo;
+ }
+ };
+ runTestProxiedRequestWithProvider( proxyInfoProvider, handler );
+
+ assertTrue( handler.headers.containsKey( "Proxy-Authorization" ) );
+
+ if ( supportProxyPreemptiveAuthentication() )
+ {
+ assertEquals( HttpServletResponse.SC_OK, handler.handlerRequestResponses.get( 0 ).responseCode );
+ }
+ else
+ {
+ assertEquals( HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED,
+ handler.handlerRequestResponses.get( 0 ).responseCode );
+ assertEquals( HttpServletResponse.SC_OK, handler.handlerRequestResponses.get( 1 ).responseCode );
+ }
+
+ }
+
+ public void testRedirectGetToStream()
+ throws Exception
+ {
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+
+ Server realServer = new Server( 0 );
+ TestHeaderHandler handler = new TestHeaderHandler();
+
+ realServer.setHandler( handler );
+ addConnectors( realServer );
+ realServer.start();
+
+ Server redirectServer = new Server( 0 );
+
+ addConnectors( redirectServer );
+
+ String protocol = getProtocol();
+
+ // protocol is wagon protocol but in fact dav is http(s)
+ if ( protocol.equals( "dav" ) )
+ {
+ protocol = "http";
+ }
+
+ if ( protocol.equals( "davs" ) )
+ {
+ protocol = "https";
+ }
+
+ String redirectUrl = protocol + "://localhost:" + realServer.getConnectors()[0].getLocalPort();
+
+ RedirectHandler redirectHandler =
+ new RedirectHandler( "See Other", HttpServletResponse.SC_SEE_OTHER, redirectUrl, null );
+
+ redirectServer.setHandler( redirectHandler );
+
+ redirectServer.start();
+
+ wagon.connect( new Repository( "id", getRepositoryUrl( redirectServer ) ) );
+
+ File tmpResult = File.createTempFile( "foo", "get" );
+
+ FileOutputStream fileOutputStream = new FileOutputStream( tmpResult );
+
+ try
+ {
+ wagon.getToStream( "resource", fileOutputStream );
+ fileOutputStream.flush();
+ fileOutputStream.close();
+ String found = FileUtils.fileRead( tmpResult );
+ assertEquals( "found:'" + found + "'", "Hello, World!", found );
+
+ checkHandlerResult( redirectHandler.handlerRequestResponses, HttpServletResponse.SC_SEE_OTHER );
+ checkHandlerResult( handler.handlerRequestResponses, HttpServletResponse.SC_OK );
+ }
+ finally
+ {
+ wagon.disconnect();
+
+ redirectServer.stop();
+ realServer.stop();
+
+ tmpResult.delete();
+ }
+ }
+
+ public void testRedirectGet()
+ throws Exception
+ {
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+
+ Server realServer = new Server( 0 );
+ TestHeaderHandler handler = new TestHeaderHandler();
+
+ realServer.setHandler( handler );
+ addConnectors( realServer );
+ realServer.start();
+
+ Server redirectServer = new Server( 0 );
+
+ addConnectors( redirectServer );
+
+ String protocol = getProtocol();
+
+ // protocol is wagon protocol but in fact dav is http(s)
+ if ( protocol.equals( "dav" ) )
+ {
+ protocol = "http";
+ }
+
+ if ( protocol.equals( "davs" ) )
+ {
+ protocol = "https";
+ }
+
+ String redirectUrl = protocol + "://localhost:" + realServer.getConnectors()[0].getLocalPort();
+
+ RedirectHandler redirectHandler =
+ new RedirectHandler( "See Other", HttpServletResponse.SC_SEE_OTHER, redirectUrl, null );
+
+ redirectServer.setHandler( redirectHandler );
+
+ redirectServer.start();
+
+ wagon.connect( new Repository( "id", getRepositoryUrl( redirectServer ) ) );
+
+ File tmpResult = File.createTempFile( "foo", "get" );
+
+ try
+ {
+ wagon.get( "resource", tmpResult );
+ String found = FileUtils.fileRead( tmpResult );
+ assertEquals( "found:'" + found + "'", "Hello, World!", found );
+
+ checkHandlerResult( redirectHandler.handlerRequestResponses, HttpServletResponse.SC_SEE_OTHER );
+ checkHandlerResult( handler.handlerRequestResponses, HttpServletResponse.SC_OK );
+ }
+ finally
+ {
+ wagon.disconnect();
+
+ redirectServer.stop();
+ realServer.stop();
+
+ tmpResult.delete();
+ }
+ }
+
+
+ public void testRedirectPutFromStreamWithFullUrl()
+ throws Exception
+ {
+ Server realServer = new Server( 0 );
+
+ addConnectors( realServer );
+
+ File repositoryDirectory = getRepositoryDirectory();
+ FileUtils.deleteDirectory( repositoryDirectory );
+ repositoryDirectory.mkdirs();
+
+ PutHandler putHandler = new PutHandler( repositoryDirectory );
+
+ realServer.setHandler( putHandler );
+
+ realServer.start();
+
+ Server redirectServer = new Server( 0 );
+
+ addConnectors( redirectServer );
+
+ String protocol = getProtocol();
+
+ // protocol is wagon protocol but in fact dav is http(s)
+ if ( protocol.equals( "dav" ) )
+ {
+ protocol = "http";
+ }
+
+ if ( protocol.equals( "davs" ) )
+ {
+ protocol = "https";
+ }
+
+ String redirectUrl = protocol + "://localhost:" + realServer.getConnectors()[0].getLocalPort();
+
+ RedirectHandler redirectHandler =
+ new RedirectHandler( "See Other", HttpServletResponse.SC_SEE_OTHER, redirectUrl, repositoryDirectory );
+
+ redirectServer.setHandler( redirectHandler );
+
+ redirectServer.start();
+
+ try
+ {
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+ Repository repository = new Repository( "foo", getRepositoryUrl( redirectServer ) );
+ wagon.connect( repository );
+
+ File sourceFile = new File( repositoryDirectory, "test-secured-put-resource" );
+ sourceFile.delete();
+ assertFalse( sourceFile.exists() );
+
+ File tempFile = File.createTempFile( "wagon", "tmp" );
+ tempFile.deleteOnExit();
+ String content = "put top secret";
+ FileUtils.fileWrite( tempFile.getAbsolutePath(), content );
+
+ FileInputStream fileInputStream = new FileInputStream( tempFile );
+ try
+ {
+ wagon.putFromStream( fileInputStream, "test-secured-put-resource", content.length(), -1 );
+ assertEquals( content, FileUtils.fileRead( sourceFile.getAbsolutePath() ) );
+
+ checkRequestResponseForRedirectPutWithFullUrl( redirectHandler, putHandler );
+ }
+ finally
+ {
+ wagon.disconnect();
+ fileInputStream.close();
+ tempFile.delete();
+ }
+
+ }
+ finally
+ {
+ realServer.stop();
+ redirectServer.stop();
+ }
+ }
+
+ protected void checkRequestResponseForRedirectPutWithFullUrl( RedirectHandler redirectHandler,
+ PutHandler putHandler )
+ {
+ checkHandlerResult( redirectHandler.handlerRequestResponses, HttpServletResponse.SC_SEE_OTHER );
+ checkHandlerResult( putHandler.handlerRequestResponses, HttpServletResponse.SC_CREATED );
+ }
+
+ public void testRedirectPutFromStreamRelativeUrl()
+ throws Exception
+ {
+ Server realServer = new Server( 0 );
+ addConnectors( realServer );
+ File repositoryDirectory = getRepositoryDirectory();
+ FileUtils.deleteDirectory( repositoryDirectory );
+ repositoryDirectory.mkdirs();
+
+ PutHandler putHandler = new PutHandler( repositoryDirectory );
+
+ realServer.setHandler( putHandler );
+
+ realServer.start();
+
+ Server redirectServer = new Server( 0 );
+
+ addConnectors( redirectServer );
+
+ RedirectHandler redirectHandler =
+ new RedirectHandler( "See Other", HttpServletResponse.SC_SEE_OTHER, "/redirectRequest/foo",
+ repositoryDirectory );
+
+ redirectServer.setHandler( redirectHandler );
+
+ redirectServer.start();
+
+ try
+ {
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+ Repository repository = new Repository( "foo", getRepositoryUrl( redirectServer ) );
+ wagon.connect( repository );
+
+ File sourceFile = new File( repositoryDirectory, "/redirectRequest/foo/test-secured-put-resource" );
+ sourceFile.delete();
+ assertFalse( sourceFile.exists() );
+
+ File tempFile = File.createTempFile( "wagon", "tmp" );
+ tempFile.deleteOnExit();
+ String content = "put top secret";
+ FileUtils.fileWrite( tempFile.getAbsolutePath(), content );
+
+ FileInputStream fileInputStream = new FileInputStream( tempFile );
+ try
+ {
+ wagon.putFromStream( fileInputStream, "test-secured-put-resource", content.length(), -1 );
+ assertEquals( content, FileUtils.fileRead( sourceFile.getAbsolutePath() ) );
+
+ checkRequestResponseForRedirectPutWithRelativeUrl( redirectHandler, putHandler );
+ }
+ finally
+ {
+ wagon.disconnect();
+ fileInputStream.close();
+ tempFile.delete();
+ }
+
+ }
+ finally
+ {
+ realServer.stop();
+ redirectServer.stop();
+ }
+ }
+
+ protected void checkRequestResponseForRedirectPutWithRelativeUrl( RedirectHandler redirectHandler,
+ PutHandler putHandler )
+ {
+ checkHandlerResult( redirectHandler.handlerRequestResponses, HttpServletResponse.SC_SEE_OTHER,
+ HttpServletResponse.SC_CREATED );
+ checkHandlerResult( putHandler.handlerRequestResponses );
+ }
+
+ protected void checkHandlerResult( List<HandlerRequestResponse> handlerRequestResponses,
+ int... expectedResponseCodes )
+ {
+ boolean success = true;
+ if ( handlerRequestResponses.size() == expectedResponseCodes.length )
+ {
+ for ( int i = 0; i < expectedResponseCodes.length; i++ )
+ {
+ success &= ( expectedResponseCodes[i] == handlerRequestResponses.get( i ).responseCode );
+ }
+ }
+
+ if ( !success )
+ {
+ fail( "expected " + expectedResponseCodes + ", got " + handlerRequestResponses );
+ }
+ }
+
+ public void testRedirectPutFileWithFullUrl()
+ throws Exception
+ {
+ Server realServer = new Server( 0 );
+
+ addConnectors( realServer );
+
+ File repositoryDirectory = getRepositoryDirectory();
+ FileUtils.deleteDirectory( repositoryDirectory );
+ repositoryDirectory.mkdirs();
+
+ PutHandler putHandler = new PutHandler( repositoryDirectory );
+
+ realServer.setHandler( putHandler );
+
+ realServer.start();
+
+ Server redirectServer = new Server( 0 );
+
+ addConnectors( redirectServer );
+
+ String protocol = getProtocol();
+
+ // protocol is wagon protocol but in fact dav is http(s)
+ if ( protocol.equals( "dav" ) )
+ {
+ protocol = "http";
+ }
+
+ if ( protocol.equals( "davs" ) )
+ {
+ protocol = "https";
+ }
+
+ String redirectUrl = protocol + "://localhost:" + realServer.getConnectors()[0].getLocalPort();
+
+ RedirectHandler redirectHandler =
+ new RedirectHandler( "See Other", HttpServletResponse.SC_SEE_OTHER, redirectUrl, repositoryDirectory );
+
+ redirectServer.setHandler( redirectHandler );
+
+ redirectServer.start();
+
+ try
+ {
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+ Repository repository = new Repository( "foo", getRepositoryUrl( redirectServer ) );
+ wagon.connect( repository );
+
+ File sourceFile = new File( repositoryDirectory, "test-secured-put-resource" );
+ sourceFile.delete();
+ assertFalse( sourceFile.exists() );
+
+ File tempFile = File.createTempFile( "wagon", "tmp" );
+ tempFile.deleteOnExit();
+ String content = "put top secret";
+ FileUtils.fileWrite( tempFile.getAbsolutePath(), content );
+
+ try
+ {
+ wagon.put( tempFile, "test-secured-put-resource" );
+ assertEquals( content, FileUtils.fileRead( sourceFile.getAbsolutePath() ) );
+
+ checkRequestResponseForRedirectPutWithFullUrl( redirectHandler, putHandler );
+ }
+ finally
+ {
+ wagon.disconnect();
+ tempFile.delete();
+ }
+
+ }
+ finally
+ {
+ realServer.stop();
+ redirectServer.stop();
+ }
+ }
+
+
+ public void testRedirectPutFileRelativeUrl()
+ throws Exception
+ {
+ Server realServer = new Server( 0 );
+ addConnectors( realServer );
+ File repositoryDirectory = getRepositoryDirectory();
+ FileUtils.deleteDirectory( repositoryDirectory );
+ repositoryDirectory.mkdirs();
+
+ PutHandler putHandler = new PutHandler( repositoryDirectory );
+
+ realServer.setHandler( putHandler );
+
+ realServer.start();
+
+ Server redirectServer = new Server( 0 );
+
+ addConnectors( redirectServer );
+
+ RedirectHandler redirectHandler =
+ new RedirectHandler( "See Other", HttpServletResponse.SC_SEE_OTHER, "/redirectRequest/foo",
+ repositoryDirectory );
+
+ redirectServer.setHandler( redirectHandler );
+
+ redirectServer.start();
+
+ try
+ {
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+ Repository repository = new Repository( "foo", getRepositoryUrl( redirectServer ) );
+ wagon.connect( repository );
+
+ File sourceFile = new File( repositoryDirectory, "/redirectRequest/foo/test-secured-put-resource" );
+ sourceFile.delete();
+ assertFalse( sourceFile.exists() );
+
+ File tempFile = File.createTempFile( "wagon", "tmp" );
+ tempFile.deleteOnExit();
+ String content = "put top secret";
+ FileUtils.fileWrite( tempFile.getAbsolutePath(), content );
+
+ try
+ {
+ wagon.put( tempFile, "test-secured-put-resource" );
+ assertEquals( content, FileUtils.fileRead( sourceFile.getAbsolutePath() ) );
+
+ checkRequestResponseForRedirectPutWithRelativeUrl( redirectHandler, putHandler );
+ }
+ finally
+ {
+ wagon.disconnect();
+ tempFile.delete();
+ }
+
+ }
+ finally
+ {
+ realServer.stop();
+ redirectServer.stop();
+ }
+ }
+
+
+ /**
+ *
+ */
+ @SuppressWarnings( "checkstyle:visibilitymodifier" )
+ public static class RedirectHandler
+ extends AbstractHandler
+ {
+ String reason;
+
+ int retCode;
+
+ String redirectUrl;
+
+ File repositoryDirectory;
+
+ public List<HandlerRequestResponse> handlerRequestResponses = new ArrayList<HandlerRequestResponse>();
+
+ RedirectHandler( String reason, int retCode, String redirectUrl, File repositoryDirectory )
+ {
+ this.reason = reason;
+ this.retCode = retCode;
+ this.redirectUrl = redirectUrl;
+ this.repositoryDirectory = repositoryDirectory;
+ }
+
+ public void handle( String target, Request baseRequest, HttpServletRequest request,
+ HttpServletResponse response ) throws IOException, ServletException
+ {
+ if ( request.getRequestURI().contains( "redirectRequest" ) )
+ {
+ PutHandler putHandler = new PutHandler( this.repositoryDirectory );
+ putHandler.handle( target, baseRequest, request, response );
+ handlerRequestResponses.add(
+ new HandlerRequestResponse( request.getMethod(), ( (Response) response ).getStatus(),
+ request.getRequestURI() ) );
+ return;
+ }
+ response.setStatus( this.retCode );
+ response.setHeader( "Location", this.redirectUrl + request.getRequestURI() );
+ baseRequest.setHandled( true );
+
+ handlerRequestResponses.add(
+ new HandlerRequestResponse( request.getMethod(), ( (Response) response ).getStatus(),
+ request.getRequestURI() ) );
+ }
+
+
+ }
+
+
+ private void runTestProxiedRequest( ProxyInfo proxyInfo, TestHeaderHandler handler )
+ throws Exception
+ {
+ // what an UGLY hack!
+ // but apparently jetty needs some time to free up resources
+ // <5s: broken test :(
+ // CHECKSTYLE_OFF: MagicNumber
+ Thread.sleep( 5001L );
+ // CHECKSTYLE_ON: MagicNumber
+
+ Server proxyServer = new Server( 0 );
+
+ proxyServer.setHandler( handler );
+
+ proxyServer.start();
+
+ proxyInfo.setPort( proxyServer.getConnectors()[0].getLocalPort() );
+
+ System.out.println(
+ "start proxy on host/port " + proxyInfo.getHost() + "/" + proxyInfo.getPort() + " with non proxyHosts "
+ + proxyInfo.getNonProxyHosts() );
+
+ while ( !proxyServer.isRunning() || !proxyServer.isStarted() )
+ {
+ Thread.sleep( 10 );
+ }
+
+ try
+ {
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+
+ Repository testRepository = new Repository( "id", "http://www.example.com/" );
+
+ String localRepositoryPath = FileTestUtils.getTestOutputDir().toString();
+ File sourceFile = new File( localRepositoryPath, "test-proxied-resource" );
+ FileUtils.fileWrite( sourceFile.getAbsolutePath(), "content" );
+
+ wagon.connect( testRepository, proxyInfo );
+
+ try
+ {
+ wagon.getToStream( "test-proxied-resource", new ByteArrayOutputStream() );
+
+ assertTrue( handler.headers.containsKey( "Proxy-Connection" ) );
+ }
+ finally
+ {
+ System.setProperty( "http.proxyHost", "" );
+ System.setProperty( "http.proxyPort", "" );
+ wagon.disconnect();
+ }
+ }
+ finally
+ {
+ proxyServer.stop();
+ }
+ }
+
+ private void runTestProxiedRequestWithProvider( ProxyInfoProvider proxyInfoProvider, TestHeaderHandler handler )
+ throws Exception
+ {
+ // what an UGLY hack!
+ // but apparently jetty needs some time to free up resources
+ // <5s: broken test :(
+ // CHECKSTYLE_OFF: MagicNumber
+ Thread.sleep( 5001L );
+ // CHECKSTYLE_ON: MagicNumber
+
+ Server proxyServer = new Server( 0 );
+
+ proxyServer.setHandler( handler );
+
+ proxyServer.start();
+
+ proxyInfoProvider.getProxyInfo( null ).setPort( proxyServer.getConnectors()[0].getLocalPort() );
+
+ System.out.println( "start proxy on host/port " + proxyInfoProvider.getProxyInfo( null ).getHost() + "/"
+ + proxyInfoProvider.getProxyInfo( null ).getPort() + " with non proxyHosts "
+ + proxyInfoProvider.getProxyInfo( null ).getNonProxyHosts() );
+
+ while ( !proxyServer.isRunning() || !proxyServer.isStarted() )
+ {
+ Thread.sleep( 10 );
+ }
+
+ try
+ {
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+
+ Repository testRepository = new Repository( "id", "http://www.example.com/" );
+
+ String localRepositoryPath = FileTestUtils.getTestOutputDir().toString();
+ File sourceFile = new File( localRepositoryPath, "test-proxied-resource" );
+ FileUtils.fileWrite( sourceFile.getAbsolutePath(), "content" );
+
+ wagon.connect( testRepository, proxyInfoProvider );
+
+ try
+ {
+ wagon.getToStream( "test-proxied-resource", new ByteArrayOutputStream() );
+
+ assertTrue( handler.headers.containsKey( "Proxy-Connection" ) );
+ }
+ finally
+ {
+ System.setProperty( "http.proxyHost", "" );
+ System.setProperty( "http.proxyPort", "" );
+ wagon.disconnect();
+ }
+ }
+ finally
+ {
+ proxyServer.stop();
+ }
+ }
+
+ private ProxyInfo createProxyInfo()
+ {
+ ProxyInfo proxyInfo = new ProxyInfo();
+ proxyInfo.setHost( "localhost" );
+ proxyInfo.setNonProxyHosts( null );
+ proxyInfo.setType( "http" );
+ return proxyInfo;
+ }
+
+ public void testSecuredGetUnauthorized()
+ throws Exception
+ {
+ try
+ {
+ runTestSecuredGet( null );
+ fail();
+ }
+ catch ( AuthorizationException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+ public void testSecuredGetWrongPassword()
+ throws Exception
+ {
+ try
+ {
+ AuthenticationInfo authInfo = new AuthenticationInfo();
+ authInfo.setUserName( "user" );
+ authInfo.setPassword( "admin" );
+ runTestSecuredGet( authInfo );
+ fail();
+ }
+ catch ( AuthorizationException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+ public void testSecuredGet()
+ throws Exception
+ {
+ AuthenticationInfo authInfo = new AuthenticationInfo();
+ authInfo.setUserName( "user" );
+ authInfo.setPassword( "secret" );
+ runTestSecuredGet( authInfo );
+ }
+
+
+ public void runTestSecuredGet( AuthenticationInfo authInfo )
+ throws Exception
+ {
+ String localRepositoryPath = FileTestUtils.getTestOutputDir().toString();
+ Server server = createSecurityServer( localRepositoryPath );
+
+ server.start();
+
+ try
+ {
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+
+ Repository testRepository = new Repository( "id", getRepositoryUrl( server ) );
+
+ File sourceFile = new File( localRepositoryPath, "test-secured-resource" );
+ FileUtils.fileWrite( sourceFile.getAbsolutePath(), "top secret" );
+
+ wagon.connect( testRepository, authInfo );
+
+ File file = File.createTempFile( "wagon-test", "txt" );
+
+ try
+ {
+ wagon.get( "test-secured-resource", file );
+ }
+ finally
+ {
+ wagon.disconnect();
+ }
+
+ FileInputStream in = new FileInputStream( file );
+
+ assertEquals( "top secret", IOUtil.toString( in ) );
+
+ /*
+ * We need to wait a bit for all Jetty workers/threads to complete their work. Otherwise
+ * we may suffer from race conditions where handlerRequestResponses list is not completely
+ * populated and its premature iteration in testPreemptiveAuthenticationGet will lead to
+ * a test failure.
+ */
+ // CHECKSTYLE_OFF: MagicNumber
+ Thread.sleep ( 2000L );
+ // CHECKSTYLE_ON: MagicNumber
+
+ TestSecurityHandler securityHandler = server.getChildHandlerByClass( TestSecurityHandler.class );
+ testPreemptiveAuthenticationGet( securityHandler, supportPreemptiveAuthenticationGet() );
+
+ }
+ finally
+ {
+ server.stop();
+ }
+ }
+
+
+ public void testSecuredGetToStream()
+ throws Exception
+ {
+ AuthenticationInfo authInfo = new AuthenticationInfo();
+ authInfo.setUserName( "user" );
+ authInfo.setPassword( "secret" );
+ runTestSecuredGetToStream( authInfo );
+ }
+
+ public void runTestSecuredGetToStream( AuthenticationInfo authInfo )
+ throws Exception
+ {
+ String localRepositoryPath = FileTestUtils.getTestOutputDir().toString();
+ Server server = createSecurityServer( localRepositoryPath );
+
+ server.start();
+
+ try
+ {
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+
+ Repository testRepository = new Repository( "id", getRepositoryUrl( server ) );
+
+ File sourceFile = new File( localRepositoryPath, "test-secured-resource" );
+ FileUtils.fileWrite( sourceFile.getAbsolutePath(), "top secret" );
+
+ wagon.connect( testRepository, authInfo );
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ try
+ {
+ wagon.getToStream( "test-secured-resource", out );
+ }
+ finally
+ {
+ wagon.disconnect();
+ }
+
+ assertEquals( "top secret", out.toString( "US-ASCII" ) );
+
+ /*
+ * We need to wait a bit for all Jetty workers/threads to complete their work. Otherwise
+ * we may suffer from race conditions where handlerRequestResponses list is not completely
+ * populated and its premature iteration in testPreemptiveAuthenticationGet will lead to
+ * a test failure.
+ */
+ // CHECKSTYLE_OFF: MagicNumber
+ Thread.sleep ( 2000L );
+ // CHECKSTYLE_ON: MagicNumber
+
+ TestSecurityHandler securityHandler = server.getChildHandlerByClass( TestSecurityHandler.class );
+ testPreemptiveAuthenticationGet( securityHandler, supportPreemptiveAuthenticationGet() );
+ }
+ finally
+ {
+ server.stop();
+ }
+ }
+
+ public void testSecuredResourceExistsUnauthorized()
+ throws Exception
+ {
+ try
+ {
+ runTestSecuredResourceExists( null );
+ fail();
+ }
+ catch ( AuthorizationException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+ public void testSecuredResourceExistsWrongPassword()
+ throws Exception
+ {
+ try
+ {
+ AuthenticationInfo authInfo = new AuthenticationInfo();
+ authInfo.setUserName( "user" );
+ authInfo.setPassword( "admin" );
+ runTestSecuredResourceExists( authInfo );
+ }
+ catch ( AuthorizationException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+ public void testSecuredResourceExists()
+ throws Exception
+ {
+ AuthenticationInfo authInfo = new AuthenticationInfo();
+ authInfo.setUserName( "user" );
+ authInfo.setPassword( "secret" );
+ runTestSecuredResourceExists( authInfo );
+ }
+
+ public void runTestSecuredResourceExists( AuthenticationInfo authInfo )
+ throws Exception
+ {
+ String localRepositoryPath = FileTestUtils.getTestOutputDir().toString();
+ Server server = createSecurityServer( localRepositoryPath );
+
+ server.start();
+
+ try
+ {
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+
+ Repository testRepository = new Repository( "id", getRepositoryUrl( server ) );
+
+ File sourceFile = new File( localRepositoryPath, "test-secured-resource-exists" );
+ FileUtils.fileWrite( sourceFile.getAbsolutePath(), "top secret" );
+
+ wagon.connect( testRepository, authInfo );
+
+ try
+ {
+ assertTrue( wagon.resourceExists( "test-secured-resource-exists" ) );
+
+ assertFalse( wagon.resourceExists( "test-secured-resource-not-exists" ) );
+ }
+ finally
+ {
+ wagon.disconnect();
+ }
+ }
+ finally
+ {
+ server.stop();
+ }
+ }
+
+ private Server createSecurityServer( String localRepositoryPath )
+ {
+ Server server = new Server( 0 );
+
+ SecurityHandler sh = createSecurityHandler();
+
+ ServletContextHandler root = new ServletContextHandler( ServletContextHandler.SESSIONS
+ | ServletContextHandler.SECURITY );
+ root.setResourceBase( localRepositoryPath );
+ root.setSecurityHandler( sh );
+ ServletHolder servletHolder = new ServletHolder( new DefaultServlet() );
+ root.addServlet( servletHolder, "/*" );
+
+ server.setHandler( root );
+ addConnectors( server );
+ return server;
+ }
+
+
+ private String writeTestFileGzip( File parent, String child )
+ throws IOException
+ {
+ File file = new File( parent, child );
+ file.getParentFile().mkdirs();
+ file.deleteOnExit();
+ OutputStream out = new FileOutputStream( file );
+ try
+ {
+ out.write( child.getBytes() );
+ }
+ finally
+ {
+ out.close();
+ }
+
+ file = new File( parent, child + ".gz" );
+ file.deleteOnExit();
+ String content;
+ out = new FileOutputStream( file );
+ out = new GZIPOutputStream( out );
+ try
+ {
+ // write out different data than non-gz file, so we can
+ // assert the gz version was returned
+ content = file.getAbsolutePath();
+ out.write( content.getBytes() );
+ }
+ finally
+ {
+ out.close();
+ }
+
+ return content;
+ }
+
+ public void testPutForbidden()
+ throws Exception
+ {
+ try
+ {
+ runTestPut( HttpServletResponse.SC_FORBIDDEN );
+ fail();
+ }
+ catch ( AuthorizationException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+ public void testPut404()
+ throws Exception
+ {
+ try
+ {
+ runTestPut( HttpServletResponse.SC_NOT_FOUND );
+ fail();
+ }
+ catch ( ResourceDoesNotExistException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+ public void testPut500()
+ throws Exception
+ {
+ try
+ {
+ runTestPut( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
+ fail();
+ }
+ catch ( TransferFailedException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+ public void testPut429()
+ throws Exception
+ {
+
+ try
+ {
+
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+ Server server = new Server( 0 );
+ final AtomicBoolean called = new AtomicBoolean();
+
+ AbstractHandler handler = new AbstractHandler()
+ {
+ public void handle( String target, Request baseRequest, HttpServletRequest request,
+ HttpServletResponse response ) throws IOException, ServletException
+ {
+ if ( called.get() )
+ {
+ response.setStatus( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
+ baseRequest.setHandled( true );
+ }
+ else
+ {
+ called.set( true );
+ response.setStatus( SC_TOO_MANY_REQUESTS );
+ baseRequest.setHandled( true );
+ }
+ }
+ };
+
+ server.setHandler( handler );
+ addConnectors( server );
+ server.start();
+
+ wagon.connect( new Repository( "id", getRepositoryUrl( server ) ) );
+
+ File tempFile = File.createTempFile( "wagon", "tmp" );
+ tempFile.deleteOnExit();
+ FileUtils.fileWrite( tempFile.getAbsolutePath(), "content" );
+
+ try
+ {
+ wagon.put( tempFile, "resource" );
+ fail();
+ }
+ finally
+ {
+ wagon.disconnect();
+
+ server.stop();
+
+ tempFile.delete();
+ }
+
+ }
+ catch ( TransferFailedException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+
+ private void runTestPut( int status )
+ throws Exception
+ {
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+
+ Server server = new Server( 0 );
+ StatusHandler handler = new StatusHandler();
+ handler.setStatusToReturn( status );
+ server.setHandler( handler );
+ addConnectors( server );
+ server.start();
+
+ wagon.connect( new Repository( "id", getRepositoryUrl( server ) ) );
+
+ File tempFile = File.createTempFile( "wagon", "tmp" );
+ tempFile.deleteOnExit();
+ FileUtils.fileWrite( tempFile.getAbsolutePath(), "content" );
+
+ try
+ {
+ wagon.put( tempFile, "resource" );
+ fail();
+ }
+ finally
+ {
+ wagon.disconnect();
+
+ server.stop();
+
+ tempFile.delete();
+ }
+ }
+
+ public void testSecuredPutUnauthorized()
+ throws Exception
+ {
+ try
+ {
+ runTestSecuredPut( null );
+ fail();
+ }
+ catch ( TransferFailedException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+ public void testSecuredPutWrongPassword()
+ throws Exception
+ {
+ try
+ {
+ AuthenticationInfo authInfo = new AuthenticationInfo();
+ authInfo.setUserName( "user" );
+ authInfo.setPassword( "admin" );
+ runTestSecuredPut( authInfo );
+ fail();
+ }
+ catch ( TransferFailedException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+ public void testSecuredPut()
+ throws Exception
+ {
+ AuthenticationInfo authInfo = new AuthenticationInfo();
+ authInfo.setUserName( "user" );
+ authInfo.setPassword( "secret" );
+ runTestSecuredPut( authInfo );
+ }
+
+ public void runTestSecuredPut( AuthenticationInfo authInfo )
+ throws Exception
+ {
+ runTestSecuredPut( authInfo, 1 );
+ }
+
+ public void runTestSecuredPut( AuthenticationInfo authInfo, int putNumber )
+ throws Exception
+ {
+ String localRepositoryPath = FileTestUtils.getTestOutputDir().toString();
+ Server server = new Server( 0 );
+
+ TestSecurityHandler sh = createSecurityHandler();
+
+ PutHandler putHandler = new PutHandler( new File( localRepositoryPath ) );
+
+ sh.setHandler( putHandler );
+ server.setHandler( sh );
+ addConnectors( server );
+ server.start();
+
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+ Repository testRepository = new Repository( "id", getRepositoryUrl( server ) );
+ wagon.connect( testRepository, authInfo );
+ try
+ {
+ for ( int i = 0; i < putNumber; i++ )
+ {
+ File sourceFile = new File( localRepositoryPath, "test-secured-put-resource" );
+ sourceFile.delete();
+ assertFalse( sourceFile.exists() );
+
+ File tempFile = File.createTempFile( "wagon", "tmp" );
+ tempFile.deleteOnExit();
+ FileUtils.fileWrite( tempFile.getAbsolutePath(), "put top secret" );
+
+ try
+ {
+ wagon.put( tempFile, "test-secured-put-resource" );
+ }
+ finally
+ {
+ tempFile.delete();
+ }
+
+ assertEquals( "put top secret", FileUtils.fileRead( sourceFile.getAbsolutePath() ) );
+ }
+ }
+ finally
+ {
+ wagon.disconnect();
+ server.stop();
+ }
+ assertEquals( putNumber, putHandler.putCallNumber );
+ testPreemptiveAuthenticationPut( sh, supportPreemptiveAuthenticationPut() );
+ }
+
+ public void testNonSecuredPutFromStream()
+ throws Exception
+ {
+ AuthenticationInfo authInfo = new AuthenticationInfo();
+ authInfo.setUserName( "user" );
+ authInfo.setPassword( "secret" );
+ runTestSecuredPutFromStream( authInfo, 1, false );
+ }
+
+ public void testSecuredPutFromStream()
+ throws Exception
+ {
+ AuthenticationInfo authInfo = new AuthenticationInfo();
+ authInfo.setUserName( "user" );
+ authInfo.setPassword( "secret" );
+ runTestSecuredPutFromStream( authInfo, 1, true );
+ }
+
+ public void runTestSecuredPutFromStream( AuthenticationInfo authInfo, int putNumber, boolean addSecurityHandler )
+ throws Exception
+ {
+ String localRepositoryPath = FileTestUtils.getTestOutputDir().toString();
+ Server server = new Server( 0 );
+
+ TestSecurityHandler sh = createSecurityHandler();
+
+ PutHandler putHandler = new PutHandler( new File( localRepositoryPath ) );
+
+ if ( addSecurityHandler )
+ {
+ sh.setHandler( putHandler );
+ server.setHandler( sh );
+ }
+ else
+ {
+ server.setHandler( putHandler );
+ }
+ addConnectors( server );
+ server.start();
+
+ StreamingWagon wagon = (StreamingWagon) getWagon();
+ Repository testRepository = new Repository( "id", getRepositoryUrl( server ) );
+ if ( addSecurityHandler )
+ {
+ wagon.connect( testRepository, authInfo );
+ }
+ else
+ {
+ wagon.connect( testRepository );
+ }
+ try
+ {
+ for ( int i = 0; i < putNumber; i++ )
+ {
+ File sourceFile = new File( localRepositoryPath, "test-secured-put-resource" );
+ sourceFile.delete();
+ assertFalse( sourceFile.exists() );
+
+ File tempFile = File.createTempFile( "wagon", "tmp" );
+ tempFile.deleteOnExit();
+ String content = "put top secret";
+ FileUtils.fileWrite( tempFile.getAbsolutePath(), content );
+
+ FileInputStream fileInputStream = new FileInputStream( tempFile );
+ try
+ {
+ wagon.putFromStream( fileInputStream, "test-secured-put-resource", content.length(), -1 );
+ }
+ finally
+ {
+ fileInputStream.close();
+ tempFile.delete();
+
+ }
+
+ assertEquals( content, FileUtils.fileRead( sourceFile.getAbsolutePath() ) );
+ }
+ }
+ finally
+ {
+ wagon.disconnect();
+ server.stop();
+ }
+ assertEquals( putNumber, putHandler.putCallNumber );
+ if ( addSecurityHandler )
+ {
+ testPreemptiveAuthenticationPut( sh, supportPreemptiveAuthenticationPut() );
+ }
+
+ // ensure we didn't use chunked transfer which doesn't work on ngnix
+ for ( DeployedResource deployedResource : putHandler.deployedResources )
+ {
+ if ( StringUtils.equalsIgnoreCase( "chunked", deployedResource.transferEncoding ) )
+ {
+ fail( "deployedResource use chunked: " + deployedResource );
+ }
+ }
+ }
+
+
+ protected abstract boolean supportPreemptiveAuthenticationPut();
+
+ protected abstract boolean supportPreemptiveAuthenticationGet();
+
+ protected abstract boolean supportProxyPreemptiveAuthentication();
+
+ protected void testPreemptiveAuthenticationGet( TestSecurityHandler sh, boolean preemptive )
+ {
+ testPreemptiveAuthentication( sh, preemptive, HttpServletResponse.SC_OK );
+ }
+
+ protected void testPreemptiveAuthenticationPut( TestSecurityHandler sh, boolean preemptive )
+ {
+ testPreemptiveAuthentication( sh, preemptive, HttpServletResponse.SC_CREATED );
+ }
+
+ protected void testPreemptiveAuthentication( TestSecurityHandler sh, boolean preemptive, int statusCode )
+ {
+
+ if ( preemptive )
+ {
+ assertEquals( "not 1 security handler use " + sh.handlerRequestResponses, 1,
+ sh.handlerRequestResponses.size() );
+ assertEquals( statusCode, sh.handlerRequestResponses.get( 0 ).responseCode );
+ }
+ else
+ {
+ assertEquals( "not 2 security handler use " + sh.handlerRequestResponses, 2,
+ sh.handlerRequestResponses.size() );
+ assertEquals( HttpServletResponse.SC_UNAUTHORIZED, sh.handlerRequestResponses.get( 0 ).responseCode );
+ assertEquals( statusCode, sh.handlerRequestResponses.get( 1 ).responseCode );
+
+ }
+ }
+
+ static class StatusHandler
+ extends AbstractHandler
+ {
+ private int status;
+
+ public void setStatusToReturn( int status )
+ {
+ this.status = status;
+ }
+
+ public void handle( String target, Request baseRequest, HttpServletRequest request,
+ HttpServletResponse response ) throws IOException, ServletException
+ {
+ if ( status != 0 )
+ {
+ response.setStatus( status );
+ baseRequest.setHandled( true );
+ }
+ }
+ }
+
+ static class DeployedResource
+ {
+ String httpMethod;
+
+ String requestUri;
+
+ String contentLength;
+
+ String transferEncoding;
+
+ public DeployedResource()
+ {
+ // no op
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "DeployedResource" );
+ sb.append( "{httpMethod='" ).append( httpMethod ).append( '\'' );
+ sb.append( ", requestUri='" ).append( requestUri ).append( '\'' );
+ sb.append( ", contentLength='" ).append( contentLength ).append( '\'' );
+ sb.append( ", transferEncoding='" ).append( transferEncoding ).append( '\'' );
+ sb.append( '}' );
+ return sb.toString();
+ }
+ }
+
+ /**
+ *
+ */
+ @SuppressWarnings( "checkstyle:visibilitymodifier" )
+ public static class PutHandler
+ extends AbstractHandler
+ {
+ private final File resourceBase;
+
+ public List<DeployedResource> deployedResources = new ArrayList<DeployedResource>();
+
+ public int putCallNumber = 0;
+
+ public List<HandlerRequestResponse> handlerRequestResponses = new ArrayList<HandlerRequestResponse>();
+
+ public PutHandler( File repositoryDirectory )
+ {
+ this.resourceBase = repositoryDirectory;
+ }
+
+ public void handle( String target, Request baseRequest, HttpServletRequest request,
+ HttpServletResponse response ) throws IOException, ServletException
+ {
+ if ( baseRequest.isHandled() || !"PUT".equals( baseRequest.getMethod() ) )
+ {
+ return;
+ }
+
+ baseRequest.setHandled( true );
+
+ File file = new File( resourceBase, URLDecoder.decode( request.getPathInfo() ) );
+ file.getParentFile().mkdirs();
+ OutputStream out = null;
+ InputStream in = null;
+ try
+ {
+ in = request.getInputStream();
+ out = new FileOutputStream( file );
+ IOUtil.copy( in, out );
+ out.close();
+ out = null;
+ in.close();
+ in = null;
+ }
+ finally
+ {
+ IOUtil.close( in );
+ IOUtil.close( out );
+ }
+ putCallNumber++;
+ DeployedResource deployedResource = new DeployedResource();
+
+ deployedResource.httpMethod = request.getMethod();
+ deployedResource.requestUri = request.getRequestURI();
+ deployedResource.transferEncoding = request.getHeader( "Transfer-Encoding" );
+ deployedResource.contentLength = request.getHeader( "Content-Length" );
+ deployedResources.add( deployedResource );
+
+ response.setStatus( HttpServletResponse.SC_CREATED );
+
+ handlerRequestResponses.add(
+ new HandlerRequestResponse( request.getMethod(), ( (Response) response ).getStatus(),
+ request.getRequestURI() ) );
+ }
+ }
+
+ private static class AuthorizingProxyHandler
+ extends TestHeaderHandler
+ {
+
+ List<HandlerRequestResponse> handlerRequestResponses = new ArrayList<HandlerRequestResponse>();
+
+ public void handle( String target, Request baseRequest, HttpServletRequest request,
+ HttpServletResponse response ) throws IOException, ServletException
+ {
+ System.out.println( " handle proxy request" );
+ if ( request.getHeader( "Proxy-Authorization" ) == null )
+ {
+ handlerRequestResponses.add(
+ new HandlerRequestResponse( request.getMethod(),
+ HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED,
+ request.getRequestURI() ) );
+ response.setStatus( HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED );
+ response.addHeader( "Proxy-Authenticate", "Basic realm=\"Squid proxy-caching web server\"" );
+
+ baseRequest.setHandled( true );
+ return;
+ }
+ handlerRequestResponses.add(
+ new HandlerRequestResponse( request.getMethod(), HttpServletResponse.SC_OK, request.getRequestURI() ) );
+ super.handle( target, baseRequest, request, response );
+ }
+ }
+
+ /**
+ *
+ */
+ @SuppressWarnings( "checkstyle:visibilitymodifier" )
+ private static class TestHeaderHandler
+ extends AbstractHandler
+ {
+ public Map<String, String> headers = Collections.emptyMap();
+
+ public List<HandlerRequestResponse> handlerRequestResponses = new ArrayList<HandlerRequestResponse>();
+
+ public TestHeaderHandler()
+ {
+ }
+
+ public void handle( String target, Request baseRrequest, HttpServletRequest request,
+ HttpServletResponse response ) throws IOException, ServletException
+ {
+ headers = new HashMap<String, String>();
+ for ( Enumeration<String> e = baseRrequest.getHeaderNames(); e.hasMoreElements(); )
+ {
+ String name = e.nextElement();
+ Enumeration headerValues = baseRrequest.getHeaders( name );
+ // as per HTTP spec http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html
+ // multiple values for the same header key are concatenated separated by comma
+ // otherwise we wouldn't notice headers with same key added multiple times
+ StringBuffer combinedHeaderValue = new StringBuffer();
+ for ( int i = 0; headerValues.hasMoreElements(); i++ )
+ {
+ if ( i > 0 )
+ {
+ combinedHeaderValue.append( "," );
+ }
+ combinedHeaderValue.append( headerValues.nextElement() );
+ }
+ headers.put( name, combinedHeaderValue.toString() );
+ }
+
+ response.setContentType( "text/plain" );
+ response.setStatus( HttpServletResponse.SC_OK );
+ response.getWriter().print( "Hello, World!" );
+
+ handlerRequestResponses.add(
+ new HandlerRequestResponse( baseRrequest.getMethod(), ( (Response) response ).getStatus(),
+ baseRrequest.getRequestURI() ) );
+
+ baseRrequest.setHandled( true );
+ }
+
+ }
+
+ protected TestSecurityHandler createSecurityHandler()
+ {
+ Constraint constraint = new Constraint();
+ constraint.setName( Constraint.__BASIC_AUTH );
+ constraint.setRoles( new String[]{ "admin" } );
+ constraint.setAuthenticate( true );
+
+ ConstraintMapping cm = new ConstraintMapping();
+ cm.setConstraint( constraint );
+ cm.setPathSpec( "/*" );
+
+ TestSecurityHandler sh = new TestSecurityHandler();
+ HashLoginService hashLoginService = new HashLoginService( "MyRealm" );
+ hashLoginService.putUser( "user", new Password( "secret" ), new String[] { "admin" } );
+ sh.setLoginService( hashLoginService );
+ sh.setConstraintMappings( new ConstraintMapping[]{ cm } );
+ sh.setAuthenticator ( new BasicAuthenticator() );
+ return sh;
+ }
+
+ /**
+ *
+ */
+ @SuppressWarnings( "checkstyle:visibilitymodifier" )
+ public static class TestSecurityHandler
+ extends ConstraintSecurityHandler
+ {
+
+ public List<HandlerRequestResponse> handlerRequestResponses = new ArrayList<HandlerRequestResponse>();
+
+ @Override
+ public void handle( String target, Request baseRequest, HttpServletRequest request,
+ HttpServletResponse response ) throws IOException, ServletException
+ {
+ String method = request.getMethod();
+ super.handle( target, baseRequest, request, response );
+
+ handlerRequestResponses.add(
+ new HandlerRequestResponse( method, ( (Response) response ).getStatus(), request.getRequestURI() ) );
+ }
+ }
+
+ /**
+ *
+ */
+ @SuppressWarnings( "checkstyle:visibilitymodifier" )
+ public static class HandlerRequestResponse
+ {
+ public String method;
+
+ public int responseCode;
+
+ public String requestUri;
+
+ private HandlerRequestResponse( String method, int responseCode, String requestUri )
+ {
+ this.method = method;
+ this.responseCode = responseCode;
+ this.requestUri = requestUri;
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "HandlerRequestResponse" );
+ sb.append( "{method='" ).append( method ).append( '\'' );
+ sb.append( ", responseCode=" ).append( responseCode );
+ sb.append( ", requestUri='" ).append( requestUri ).append( '\'' );
+ sb.append( '}' );
+ return sb.toString();
+ }
+ }
+}
diff --git a/wagon-provider-test/src/site/apt/index.apt b/wagon-provider-test/src/site/apt/index.apt
index 7e43777..71eb90b 100644
--- a/wagon-provider-test/src/site/apt/index.apt
+++ b/wagon-provider-test/src/site/apt/index.apt
@@ -1,31 +1,31 @@
- ------
- Maven Wagon Test
- ------
- Carlos Sanchez
- ------
- 2006-04-16
- ------
-
- ~~ Licensed to the Apache Software Foundation (ASF) under one
- ~~ or more contributor license agreements. See the NOTICE file
- ~~ distributed with this work for additional information
- ~~ regarding copyright ownership. The ASF licenses this file
- ~~ to you under the Apache License, Version 2.0 (the
- ~~ "License"); you may not use this file except in compliance
- ~~ with the License. You may obtain a copy of the License at
- ~~
- ~~ http://www.apache.org/licenses/LICENSE-2.0
- ~~
- ~~ Unless required by applicable law or agreed to in writing,
- ~~ software distributed under the License is distributed on an
- ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~~ KIND, either express or implied. See the License for the
- ~~ specific language governing permissions and limitations
- ~~ under the License.
-
- ~~ NOTE: For help with the syntax of this file, see:
- ~~ http://maven.apache.org/doxia/references/apt-format.html
-
-Maven Wagon Test
-
- Suite of tests for Wagon implementations
+ ------
+ Maven Wagon Test
+ ------
+ Carlos Sanchez
+ ------
+ 2006-04-16
+ ------
+
+ ~~ Licensed to the Apache Software Foundation (ASF) under one
+ ~~ or more contributor license agreements. See the NOTICE file
+ ~~ distributed with this work for additional information
+ ~~ regarding copyright ownership. The ASF licenses this file
+ ~~ to you under the Apache License, Version 2.0 (the
+ ~~ "License"); you may not use this file except in compliance
+ ~~ with the License. You may obtain a copy of the License at
+ ~~
+ ~~ http://www.apache.org/licenses/LICENSE-2.0
+ ~~
+ ~~ Unless required by applicable law or agreed to in writing,
+ ~~ software distributed under the License is distributed on an
+ ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~~ KIND, either express or implied. See the License for the
+ ~~ specific language governing permissions and limitations
+ ~~ under the License.
+
+ ~~ NOTE: For help with the syntax of this file, see:
+ ~~ http://maven.apache.org/doxia/references/apt-format.html
+
+Maven Wagon Test
+
+ Suite of tests for Wagon implementations
diff --git a/wagon-provider-test/src/site/site.xml b/wagon-provider-test/src/site/site.xml
index d204081..f92b9d1 100644
--- a/wagon-provider-test/src/site/site.xml
+++ b/wagon-provider-test/src/site/site.xml
@@ -1,33 +1,33 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
- <body>
- <breadcrumbs>
- <item name="Provider Test" href="http://maven.apache.org/wagon/wagon-provider-test/index.html" />
- </breadcrumbs>
-
- <menu ref="parent"/>
- <menu ref="reports"/>
- </body>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
+ <body>
+ <breadcrumbs>
+ <item name="Provider Test" href="http://maven.apache.org/wagon/wagon-provider-test/index.html" />
+ </breadcrumbs>
+
+ <menu ref="parent"/>
+ <menu ref="reports"/>
+ </body>
</project>
\ No newline at end of file
diff --git a/wagon-providers/pom.xml b/wagon-providers/pom.xml
index 1995fb7..9f63443 100644
--- a/wagon-providers/pom.xml
+++ b/wagon-providers/pom.xml
@@ -1,81 +1,81 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon</artifactId>
- <version>2.10</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>wagon-providers</artifactId>
- <packaging>pom</packaging>
- <name>Apache Maven Wagon :: Providers</name>
-
- <modules>
- <module>wagon-file</module>
- <module>wagon-ftp</module>
- <module>wagon-http</module>
- <module>wagon-http-shared</module>
- <module>wagon-http-lightweight</module>
- <module>wagon-scm</module>
- <module>wagon-ssh-external</module>
- <module>wagon-ssh-common</module>
- <module>wagon-ssh-common-test</module>
- <module>wagon-ssh</module>
- <module>wagon-webdav-jackrabbit</module>
- </modules>
-
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- <version>4.3.5</version>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpcore</artifactId>
- <version>4.3.2</version>
- </dependency>
- <dependency>
- <groupId>org.apache.sshd</groupId>
- <artifactId>sshd-core</artifactId>
- <version>0.8.0</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
-
- <dependencies>
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-provider-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-provider-test</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon</artifactId>
+ <version>2.12</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>wagon-providers</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Maven Wagon :: Providers</name>
+
+ <modules>
+ <module>wagon-file</module>
+ <module>wagon-ftp</module>
+ <module>wagon-http</module>
+ <module>wagon-http-shared</module>
+ <module>wagon-http-lightweight</module>
+ <module>wagon-scm</module>
+ <module>wagon-ssh-external</module>
+ <module>wagon-ssh-common</module>
+ <module>wagon-ssh-common-test</module>
+ <module>wagon-ssh</module>
+ <module>wagon-webdav-jackrabbit</module>
+ </modules>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.5.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ <version>4.4.4</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sshd</groupId>
+ <artifactId>sshd-core</artifactId>
+ <version>0.8.0</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-provider-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-provider-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/wagon-providers/src/site/site.xml b/wagon-providers/src/site/site.xml
index 0d323d2..825f059 100644
--- a/wagon-providers/src/site/site.xml
+++ b/wagon-providers/src/site/site.xml
@@ -1,34 +1,34 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
- <body>
- <breadcrumbs>
- <item name="Providers" href="http://maven.apache.org/wagon/wagon-providers/index.html" />
- </breadcrumbs>
-
- <menu ref="parent"/>
- <menu ref="modules"/>
- <menu ref="reports"/>
- </body>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
+ <body>
+ <breadcrumbs>
+ <item name="Providers" href="http://maven.apache.org/wagon/wagon-providers/index.html" />
+ </breadcrumbs>
+
+ <menu ref="parent"/>
+ <menu ref="modules"/>
+ <menu ref="reports"/>
+ </body>
</project>
\ No newline at end of file
diff --git a/wagon-providers/wagon-file/pom.xml b/wagon-providers/wagon-file/pom.xml
index 35aad8a..6c8d1cc 100644
--- a/wagon-providers/wagon-file/pom.xml
+++ b/wagon-providers/wagon-file/pom.xml
@@ -1,41 +1,46 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-providers</artifactId>
- <version>2.10</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>wagon-file</artifactId>
- <name>Apache Maven Wagon :: Providers :: File Provider</name>
- <description>
- Wagon provider that gets and puts artifacts using file system protocol
- </description>
- <dependencies>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- </dependency>
- </dependencies>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-providers</artifactId>
+ <version>2.12</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>wagon-file</artifactId>
+ <name>Apache Maven Wagon :: Providers :: File Provider</name>
+ <description>
+ Wagon provider that gets and puts artifacts using file system protocol
+ </description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/wagon-providers/wagon-file/src/main/java/org/apache/maven/wagon/providers/file/FileWagon.java b/wagon-providers/wagon-file/src/main/java/org/apache/maven/wagon/providers/file/FileWagon.java
index 2776657..b7ae084 100644
--- a/wagon-providers/wagon-file/src/main/java/org/apache/maven/wagon/providers/file/FileWagon.java
+++ b/wagon-providers/wagon-file/src/main/java/org/apache/maven/wagon/providers/file/FileWagon.java
@@ -1,274 +1,273 @@
-package org.apache.maven.wagon.providers.file;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.maven.wagon.ConnectionException;
-import org.apache.maven.wagon.InputData;
-import org.apache.maven.wagon.LazyFileOutputStream;
-import org.apache.maven.wagon.OutputData;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
-import org.apache.maven.wagon.StreamWagon;
-import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.authorization.AuthorizationException;
-import org.apache.maven.wagon.resource.Resource;
-import org.codehaus.plexus.util.FileUtils;
-
-/**
- * Wagon Provider for Local File System
- *
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- * @plexus.component role="org.apache.maven.wagon.Wagon" role-hint="file" instantiation-strategy="per-lookup"
- */
-public class FileWagon
- extends StreamWagon
-{
- public void fillInputData( InputData inputData )
- throws TransferFailedException, ResourceDoesNotExistException
- {
- if ( getRepository().getBasedir() == null )
- {
- throw new TransferFailedException( "Unable to operate with a null basedir." );
- }
-
- Resource resource = inputData.getResource();
-
- File file = new File( getRepository().getBasedir(), resource.getName() );
-
- if ( !file.exists() )
- {
- throw new ResourceDoesNotExistException( "File: " + file + " does not exist" );
- }
-
- try
- {
- InputStream in = new BufferedInputStream( new FileInputStream( file ) );
-
- inputData.setInputStream( in );
-
- resource.setContentLength( file.length() );
-
- resource.setLastModified( file.lastModified() );
- }
- catch ( FileNotFoundException e )
- {
- throw new TransferFailedException( "Could not read from file: " + file.getAbsolutePath(), e );
- }
- }
-
- public void fillOutputData( OutputData outputData )
- throws TransferFailedException
- {
- if ( getRepository().getBasedir() == null )
- {
- throw new TransferFailedException( "Unable to operate with a null basedir." );
- }
-
- Resource resource = outputData.getResource();
-
- File file = new File( getRepository().getBasedir(), resource.getName() );
-
- createParentDirectories( file );
-
- OutputStream outputStream = new BufferedOutputStream( new LazyFileOutputStream( file ) );
-
- outputData.setOutputStream( outputStream );
- }
-
- protected void openConnectionInternal()
- throws ConnectionException
- {
- if ( getRepository() == null )
- {
- throw new ConnectionException( "Unable to operate with a null repository." );
- }
-
- if ( getRepository().getBasedir() == null )
- {
- // This condition is possible when using wagon-file under integration testing conditions.
- fireSessionDebug( "Using a null basedir." );
- return;
- }
-
- // Check the File repository exists
- File basedir = new File( getRepository().getBasedir() );
- if ( !basedir.exists() )
- {
- if ( !basedir.mkdirs() )
- {
- throw new ConnectionException( "Repository path " + basedir + " does not exist,"
- + " and cannot be created." );
- }
- }
-
- if ( !basedir.canRead() )
- {
- throw new ConnectionException( "Repository path " + basedir + " cannot be read" );
- }
- }
-
- public void closeConnection()
- {
- }
-
- public boolean supportsDirectoryCopy()
- {
- // TODO: should we test for null basedir here?
- return true;
- }
-
- public void putDirectory( File sourceDirectory, String destinationDirectory )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- if ( getRepository().getBasedir() == null )
- {
- throw new TransferFailedException( "Unable to putDirectory() with a null basedir." );
- }
-
- File path = resolveDestinationPath( destinationDirectory );
-
- try
- {
- /*
- * Done to address issue found in HP-UX with regards to "." directory references. Details found in ..
- * WAGON-30 - wagon-file failed when used by maven-site-plugin WAGON-33 - FileWagon#putDirectory() fails in
- * HP-UX if destinationDirectory is "."
- * http://www.nabble.com/With-maven-2.0.2-site%3Adeploy-doesn%27t-work-t934716.html for details. Using
- * path.getCanonicalFile() ensures that the path is fully resolved before an attempt to create it. TODO:
- * consider moving this to FileUtils.mkdirs()
- */
- File realFile = path.getCanonicalFile();
- realFile.mkdirs();
- }
- catch ( IOException e )
- {
- // Fall back to standard way if getCanonicalFile() fails.
- path.mkdirs();
- }
-
- if ( !path.exists() || !path.isDirectory() )
- {
- String emsg = "Could not make directory '" + path.getAbsolutePath() + "'.";
-
- // Add assistive message in case of failure.
- File basedir = new File( getRepository().getBasedir() );
- if ( !basedir.canWrite() )
- {
- emsg += " The base directory " + basedir + " is read-only.";
- }
-
- throw new TransferFailedException( emsg );
- }
-
- try
- {
- FileUtils.copyDirectoryStructure( sourceDirectory, path );
- }
- catch ( IOException e )
- {
- throw new TransferFailedException( "Error copying directory structure", e );
- }
- }
-
- private File resolveDestinationPath( String destinationPath )
- {
- String basedir = getRepository().getBasedir();
-
- destinationPath = StringUtils.replace( destinationPath, "\\", "/" );
-
- File path;
-
- if ( destinationPath.equals( "." ) )
- {
- path = new File( basedir );
- }
- else
- {
- path = new File( basedir, destinationPath );
- }
-
- return path;
- }
-
- public List<String> getFileList( String destinationDirectory )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- if ( getRepository().getBasedir() == null )
- {
- throw new TransferFailedException( "Unable to getFileList() with a null basedir." );
- }
-
- File path = resolveDestinationPath( destinationDirectory );
-
- if ( !path.exists() )
- {
- throw new ResourceDoesNotExistException( "Directory does not exist: " + destinationDirectory );
- }
-
- if ( !path.isDirectory() )
- {
- throw new ResourceDoesNotExistException( "Path is not a directory: " + destinationDirectory );
- }
-
- File[] files = path.listFiles();
-
- List<String> list = new ArrayList<String>( files.length );
- for ( File file : files )
- {
- String name = file.getName();
- if ( file.isDirectory() && !name.endsWith( "/" ) )
- {
- name += "/";
- }
- list.add( name );
- }
- return list;
- }
-
- public boolean resourceExists( String resourceName )
- throws TransferFailedException, AuthorizationException
- {
- if ( getRepository().getBasedir() == null )
- {
- throw new TransferFailedException( "Unable to getFileList() with a null basedir." );
- }
-
- File file = resolveDestinationPath( resourceName );
-
- if ( resourceName.endsWith( "/" ) )
- {
- return file.isDirectory();
- }
-
- return file.exists();
- }
-}
+package org.apache.maven.wagon.providers.file;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.wagon.ConnectionException;
+import org.apache.maven.wagon.InputData;
+import org.apache.maven.wagon.LazyFileOutputStream;
+import org.apache.maven.wagon.OutputData;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.StreamWagon;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.resource.Resource;
+import org.codehaus.plexus.util.FileUtils;
+
+/**
+ * Wagon Provider for Local File System
+ *
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ * @plexus.component role="org.apache.maven.wagon.Wagon" role-hint="file" instantiation-strategy="per-lookup"
+ */
+public class FileWagon
+ extends StreamWagon
+{
+ public void fillInputData( InputData inputData )
+ throws TransferFailedException, ResourceDoesNotExistException
+ {
+ if ( getRepository().getBasedir() == null )
+ {
+ throw new TransferFailedException( "Unable to operate with a null basedir." );
+ }
+
+ Resource resource = inputData.getResource();
+
+ File file = new File( getRepository().getBasedir(), resource.getName() );
+
+ if ( !file.exists() )
+ {
+ throw new ResourceDoesNotExistException( "File: " + file + " does not exist" );
+ }
+
+ try
+ {
+ InputStream in = new BufferedInputStream( new FileInputStream( file ) );
+
+ inputData.setInputStream( in );
+
+ resource.setContentLength( file.length() );
+
+ resource.setLastModified( file.lastModified() );
+ }
+ catch ( FileNotFoundException e )
+ {
+ throw new TransferFailedException( "Could not read from file: " + file.getAbsolutePath(), e );
+ }
+ }
+
+ public void fillOutputData( OutputData outputData )
+ throws TransferFailedException
+ {
+ if ( getRepository().getBasedir() == null )
+ {
+ throw new TransferFailedException( "Unable to operate with a null basedir." );
+ }
+
+ Resource resource = outputData.getResource();
+
+ File file = new File( getRepository().getBasedir(), resource.getName() );
+
+ createParentDirectories( file );
+
+ OutputStream outputStream = new BufferedOutputStream( new LazyFileOutputStream( file ) );
+
+ outputData.setOutputStream( outputStream );
+ }
+
+ protected void openConnectionInternal()
+ throws ConnectionException
+ {
+ if ( getRepository() == null )
+ {
+ throw new ConnectionException( "Unable to operate with a null repository." );
+ }
+
+ if ( getRepository().getBasedir() == null )
+ {
+ // This condition is possible when using wagon-file under integration testing conditions.
+ fireSessionDebug( "Using a null basedir." );
+ return;
+ }
+
+ // Check the File repository exists
+ File basedir = new File( getRepository().getBasedir() );
+ if ( !basedir.exists() )
+ {
+ if ( !basedir.mkdirs() )
+ {
+ throw new ConnectionException( "Repository path " + basedir + " does not exist,"
+ + " and cannot be created." );
+ }
+ }
+
+ if ( !basedir.canRead() )
+ {
+ throw new ConnectionException( "Repository path " + basedir + " cannot be read" );
+ }
+ }
+
+ public void closeConnection()
+ {
+ }
+
+ public boolean supportsDirectoryCopy()
+ {
+ // TODO: should we test for null basedir here?
+ return true;
+ }
+
+ public void putDirectory( File sourceDirectory, String destinationDirectory )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ if ( getRepository().getBasedir() == null )
+ {
+ throw new TransferFailedException( "Unable to putDirectory() with a null basedir." );
+ }
+
+ File path = resolveDestinationPath( destinationDirectory );
+
+ try
+ {
+ /*
+ * Done to address issue found in HP-UX with regards to "." directory references. Details found in ..
+ * WAGON-30 - wagon-file failed when used by maven-site-plugin WAGON-33 - FileWagon#putDirectory() fails in
+ * HP-UX if destinationDirectory is "."
+ * http://www.nabble.com/With-maven-2.0.2-site%3Adeploy-doesn%27t-work-t934716.html for details. Using
+ * path.getCanonicalFile() ensures that the path is fully resolved before an attempt to create it. TODO:
+ * consider moving this to FileUtils.mkdirs()
+ */
+ File realFile = path.getCanonicalFile();
+ realFile.mkdirs();
+ }
+ catch ( IOException e )
+ {
+ // Fall back to standard way if getCanonicalFile() fails.
+ path.mkdirs();
+ }
+
+ if ( !path.exists() || !path.isDirectory() )
+ {
+ String emsg = "Could not make directory '" + path.getAbsolutePath() + "'.";
+
+ // Add assistive message in case of failure.
+ File basedir = new File( getRepository().getBasedir() );
+ if ( !basedir.canWrite() )
+ {
+ emsg += " The base directory " + basedir + " is read-only.";
+ }
+
+ throw new TransferFailedException( emsg );
+ }
+
+ try
+ {
+ FileUtils.copyDirectoryStructure( sourceDirectory, path );
+ }
+ catch ( IOException e )
+ {
+ throw new TransferFailedException( "Error copying directory structure", e );
+ }
+ }
+
+ private File resolveDestinationPath( String destinationPath )
+ {
+ String basedir = getRepository().getBasedir();
+
+ destinationPath = destinationPath.replace( "\\", "/" );
+
+ File path;
+
+ if ( destinationPath.equals( "." ) )
+ {
+ path = new File( basedir );
+ }
+ else
+ {
+ path = new File( basedir, destinationPath );
+ }
+
+ return path;
+ }
+
+ public List<String> getFileList( String destinationDirectory )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ if ( getRepository().getBasedir() == null )
+ {
+ throw new TransferFailedException( "Unable to getFileList() with a null basedir." );
+ }
+
+ File path = resolveDestinationPath( destinationDirectory );
+
+ if ( !path.exists() )
+ {
+ throw new ResourceDoesNotExistException( "Directory does not exist: " + destinationDirectory );
+ }
+
+ if ( !path.isDirectory() )
+ {
+ throw new ResourceDoesNotExistException( "Path is not a directory: " + destinationDirectory );
+ }
+
+ File[] files = path.listFiles();
+
+ List<String> list = new ArrayList<String>( files.length );
+ for ( File file : files )
+ {
+ String name = file.getName();
+ if ( file.isDirectory() && !name.endsWith( "/" ) )
+ {
+ name += "/";
+ }
+ list.add( name );
+ }
+ return list;
+ }
+
+ public boolean resourceExists( String resourceName )
+ throws TransferFailedException, AuthorizationException
+ {
+ if ( getRepository().getBasedir() == null )
+ {
+ throw new TransferFailedException( "Unable to getFileList() with a null basedir." );
+ }
+
+ File file = resolveDestinationPath( resourceName );
+
+ if ( resourceName.endsWith( "/" ) )
+ {
+ return file.isDirectory();
+ }
+
+ return file.exists();
+ }
+}
diff --git a/wagon-providers/wagon-file/src/site/apt/index.apt b/wagon-providers/wagon-file/src/site/apt/index.apt
index 1596451..1c832aa 100644
--- a/wagon-providers/wagon-file/src/site/apt/index.apt
+++ b/wagon-providers/wagon-file/src/site/apt/index.apt
@@ -1,40 +1,40 @@
- ------
- Maven Wagon File
- ------
- Carlos Sanchez
- ------
- 2006-04-16
- ------
-
- ~~ Licensed to the Apache Software Foundation (ASF) under one
- ~~ or more contributor license agreements. See the NOTICE file
- ~~ distributed with this work for additional information
- ~~ regarding copyright ownership. The ASF licenses this file
- ~~ to you under the Apache License, Version 2.0 (the
- ~~ "License"); you may not use this file except in compliance
- ~~ with the License. You may obtain a copy of the License at
- ~~
- ~~ http://www.apache.org/licenses/LICENSE-2.0
- ~~
- ~~ Unless required by applicable law or agreed to in writing,
- ~~ software distributed under the License is distributed on an
- ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~~ KIND, either express or implied. See the License for the
- ~~ specific language governing permissions and limitations
- ~~ under the License.
-
- ~~ NOTE: For help with the syntax of this file, see:
- ~~ http://maven.apache.org/doxia/references/apt-format.html
-
-Maven Wagon File
-
- This component is an implementation of Wagon provider for File system access.
-
- It enables Maven to use remote repositories stored in local file system and to store Maven sites there also.
-
-
-Features
-
- * Deploy files and directories to local file system
-
- * Get files from local file system
+ ------
+ Maven Wagon File
+ ------
+ Carlos Sanchez
+ ------
+ 2006-04-16
+ ------
+
+ ~~ Licensed to the Apache Software Foundation (ASF) under one
+ ~~ or more contributor license agreements. See the NOTICE file
+ ~~ distributed with this work for additional information
+ ~~ regarding copyright ownership. The ASF licenses this file
+ ~~ to you under the Apache License, Version 2.0 (the
+ ~~ "License"); you may not use this file except in compliance
+ ~~ with the License. You may obtain a copy of the License at
+ ~~
+ ~~ http://www.apache.org/licenses/LICENSE-2.0
+ ~~
+ ~~ Unless required by applicable law or agreed to in writing,
+ ~~ software distributed under the License is distributed on an
+ ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~~ KIND, either express or implied. See the License for the
+ ~~ specific language governing permissions and limitations
+ ~~ under the License.
+
+ ~~ NOTE: For help with the syntax of this file, see:
+ ~~ http://maven.apache.org/doxia/references/apt-format.html
+
+Maven Wagon File
+
+ This component is an implementation of Wagon provider for File system access.
+
+ It enables Maven to use remote repositories stored in local file system and to store Maven sites there also.
+
+
+Features
+
+ * Deploy files and directories to local file system
+
+ * Get files from local file system
diff --git a/wagon-providers/wagon-file/src/site/site.xml b/wagon-providers/wagon-file/src/site/site.xml
index f502be3..3b7d567 100644
--- a/wagon-providers/wagon-file/src/site/site.xml
+++ b/wagon-providers/wagon-file/src/site/site.xml
@@ -1,33 +1,33 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
- <body>
- <breadcrumbs>
- <item name="File" href="http://maven.apache.org/wagon/wagon-providers/wagon-file/index.html" />
- </breadcrumbs>
-
- <menu ref="parent"/>
- <menu ref="reports"/>
- </body>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
+ <body>
+ <breadcrumbs>
+ <item name="File" href="http://maven.apache.org/wagon/wagon-providers/wagon-file/index.html" />
+ </breadcrumbs>
+
+ <menu ref="parent"/>
+ <menu ref="reports"/>
+ </body>
</project>
\ No newline at end of file
diff --git a/wagon-providers/wagon-file/src/test/java/org/apache/maven/wagon/providers/file/FileWagonTest.java b/wagon-providers/wagon-file/src/test/java/org/apache/maven/wagon/providers/file/FileWagonTest.java
index 6692988..6fb4b1f 100644
--- a/wagon-providers/wagon-file/src/test/java/org/apache/maven/wagon/providers/file/FileWagonTest.java
+++ b/wagon-providers/wagon-file/src/test/java/org/apache/maven/wagon/providers/file/FileWagonTest.java
@@ -1,97 +1,98 @@
-package org.apache.maven.wagon.providers.file;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.ConnectionException;
-import org.apache.maven.wagon.FileTestUtils;
-import org.apache.maven.wagon.StreamingWagonTestCase;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.repository.Repository;
-import org.apache.maven.wagon.resource.Resource;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class FileWagonTest
- extends StreamingWagonTestCase
-{
- protected String getProtocol()
- {
- return "file";
- }
-
- protected String getTestRepositoryUrl()
- throws IOException
- {
- File file = FileTestUtils.createUniqueDir( getName() + ".file-repository." );
-
- return "file://" + file.getPath();
- }
-
- @Override
- protected int getTestRepositoryPort() {
- // file transfer dont needs a port
- return 0;
- }
-
- /**
- * This test is introduced to allow for null file wagons.
- * Which is used heavily in the maven component ITs.
- *
- * @throws ConnectionException
- * @throws AuthenticationException
- */
- public void testNullFileWagon() throws ConnectionException, AuthenticationException
- {
- Wagon wagon = new FileWagon();
- Resource resource = new Resource();
- resource.setContentLength( 100000 );
- Repository repository = new Repository();
- wagon.connect( repository );
- }
-
- protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
- {
- return new File( repository.getBasedir(), resource.getName() ).lastModified();
- }
-
- public void testResourceExists()
- throws Exception
- {
- String url = "file://" + getBasedir();
-
- Wagon wagon = new FileWagon();
- Repository repository = new Repository( "someID", url );
- wagon.connect( repository );
-
- assertTrue( wagon.resourceExists( "target" ) );
- assertTrue( wagon.resourceExists( "target/" ) );
- assertTrue( wagon.resourceExists( "pom.xml" ) );
-
- assertFalse( wagon.resourceExists( "pom.xml/" ) );
-
- wagon.disconnect();
- }
-}
+package org.apache.maven.wagon.providers.file;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.ConnectionException;
+import org.apache.maven.wagon.FileTestUtils;
+import org.apache.maven.wagon.StreamingWagonTestCase;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.resource.Resource;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class FileWagonTest
+ extends StreamingWagonTestCase
+{
+ protected String getProtocol()
+ {
+ return "file";
+ }
+
+ protected String getTestRepositoryUrl()
+ throws IOException
+ {
+ File file = FileTestUtils.createUniqueDir( getName() + ".file-repository." );
+
+ return "file://" + file.getPath();
+ }
+
+ @Override
+ protected int getTestRepositoryPort() {
+ // file transfer dont needs a port
+ return 0;
+ }
+
+ /**
+ * This test is introduced to allow for null file wagons.
+ * Which is used heavily in the maven component ITs.
+ *
+ * @throws ConnectionException
+ * @throws AuthenticationException
+ */
+ public void testNullFileWagon() throws ConnectionException, AuthenticationException
+ {
+ Wagon wagon = new FileWagon();
+ Resource resource = new Resource();
+ resource.setContentLength( 100000 );
+ Repository repository = new Repository();
+ wagon.connect( repository );
+ wagon.disconnect();
+ }
+
+ protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
+ {
+ return new File( repository.getBasedir(), resource.getName() ).lastModified();
+ }
+
+ public void testResourceExists()
+ throws Exception
+ {
+ String url = "file://" + getBasedir();
+
+ Wagon wagon = new FileWagon();
+ Repository repository = new Repository( "someID", url );
+ wagon.connect( repository );
+
+ assertTrue( wagon.resourceExists( "target" ) );
+ assertTrue( wagon.resourceExists( "target/" ) );
+ assertTrue( wagon.resourceExists( "pom.xml" ) );
+
+ assertFalse( wagon.resourceExists( "pom.xml/" ) );
+
+ wagon.disconnect();
+ }
+}
diff --git a/wagon-providers/wagon-ftp/pom.xml b/wagon-providers/wagon-ftp/pom.xml
index 3bf2055..c7ae2e9 100644
--- a/wagon-providers/wagon-ftp/pom.xml
+++ b/wagon-providers/wagon-ftp/pom.xml
@@ -1,63 +1,63 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-providers</artifactId>
- <version>2.10</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>wagon-ftp</artifactId>
- <name>Apache Maven Wagon :: Providers :: FTP Provider</name>
- <description>
- Wagon provider that gets and puts artifacts from and to remote server using FTP protocol
- </description>
-
- <dependencies>
- <dependency>
- <groupId>commons-net</groupId>
- <artifactId>commons-net</artifactId>
- <version>3.1</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.ftpserver</groupId>
- <artifactId>ftpserver-core</artifactId>
- <version>1.0.6</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-simple</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- </dependency>
- </dependencies>
-
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-providers</artifactId>
+ <version>2.12</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>wagon-ftp</artifactId>
+ <name>Apache Maven Wagon :: Providers :: FTP Provider</name>
+ <description>
+ Wagon provider that gets and puts artifacts from and to remote server using FTP protocol
+ </description>
+
+ <dependencies>
+ <dependency>
+ <groupId>commons-net</groupId>
+ <artifactId>commons-net</artifactId>
+ <version>3.5</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ftpserver</groupId>
+ <artifactId>ftpserver-core</artifactId>
+ <version>1.0.6</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/wagon-providers/wagon-ftp/src/main/java/org/apache/maven/wagon/providers/ftp/FtpWagon.java b/wagon-providers/wagon-ftp/src/main/java/org/apache/maven/wagon/providers/ftp/FtpWagon.java
index 65fb1da..e7d74b1 100644
--- a/wagon-providers/wagon-ftp/src/main/java/org/apache/maven/wagon/providers/ftp/FtpWagon.java
+++ b/wagon-providers/wagon-ftp/src/main/java/org/apache/maven/wagon/providers/ftp/FtpWagon.java
@@ -1,805 +1,813 @@
-package org.apache.maven.wagon.providers.ftp;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.net.ProtocolCommandEvent;
-import org.apache.commons.net.ProtocolCommandListener;
-import org.apache.commons.net.ftp.FTP;
-import org.apache.commons.net.ftp.FTPClient;
-import org.apache.commons.net.ftp.FTPFile;
-import org.apache.commons.net.ftp.FTPReply;
-import org.apache.maven.wagon.ConnectionException;
-import org.apache.maven.wagon.InputData;
-import org.apache.maven.wagon.OutputData;
-import org.apache.maven.wagon.PathUtils;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
-import org.apache.maven.wagon.StreamWagon;
-import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.WagonConstants;
-import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
-import org.apache.maven.wagon.authorization.AuthorizationException;
-import org.apache.maven.wagon.repository.RepositoryPermissions;
-import org.apache.maven.wagon.resource.Resource;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-
-/**
- * FtpWagon
- *
- *
- * @plexus.component role="org.apache.maven.wagon.Wagon"
- * role-hint="ftp"
- * instantiation-strategy="per-lookup"
- */
-public class FtpWagon
- extends StreamWagon
-{
- private FTPClient ftp;
-
- /**
- * @plexus.configuration default-value="true"
- */
- private boolean passiveMode = true;
-
- /**
- * @plexus.configuration default-value="ISO-8859-1"
- */
- private String controlEncoding = FTP.DEFAULT_CONTROL_ENCODING;
-
- public boolean isPassiveMode()
- {
- return passiveMode;
- }
-
- public void setPassiveMode( boolean passiveMode )
- {
- this.passiveMode = passiveMode;
- }
-
- protected void openConnectionInternal()
- throws ConnectionException, AuthenticationException
- {
- AuthenticationInfo authInfo = getAuthenticationInfo();
-
- if ( authInfo == null )
- {
- throw new IllegalArgumentException( "Authentication Credentials cannot be null for FTP protocol" );
- }
-
- if ( authInfo.getUserName() == null )
- {
- authInfo.setUserName( System.getProperty( "user.name" ) );
- }
-
- String username = authInfo.getUserName();
-
- String password = authInfo.getPassword();
-
- if ( username == null )
- {
- throw new AuthenticationException( "Username not specified for repository " + getRepository().getId() );
- }
- if ( password == null )
- {
- throw new AuthenticationException( "Password not specified for repository " + getRepository().getId() );
- }
-
- String host = getRepository().getHost();
-
- ftp = new FTPClient();
- ftp.setDefaultTimeout( getTimeout() );
- ftp.setDataTimeout( getTimeout() );
- ftp.setControlEncoding( getControlEncoding() );
-
- ftp.addProtocolCommandListener( new PrintCommandListener( this ) );
-
- try
- {
- if ( getRepository().getPort() != WagonConstants.UNKNOWN_PORT )
- {
- ftp.connect( host, getRepository().getPort() );
- }
- else
- {
- ftp.connect( host );
- }
-
- // After connection attempt, you should check the reply code to
- // verify
- // success.
- int reply = ftp.getReplyCode();
-
- if ( !FTPReply.isPositiveCompletion( reply ) )
- {
- ftp.disconnect();
-
- throw new AuthenticationException( "FTP server refused connection." );
- }
- }
- catch ( IOException e )
- {
- if ( ftp.isConnected() )
- {
- try
- {
- fireSessionError( e );
-
- ftp.disconnect();
- }
- catch ( IOException f )
- {
- // do nothing
- }
- }
-
- throw new AuthenticationException( "Could not connect to server.", e );
- }
-
- try
- {
- if ( !ftp.login( username, password ) )
- {
- throw new AuthenticationException( "Cannot login to remote system" );
- }
-
- fireSessionDebug( "Remote system is " + ftp.getSystemName() );
-
- // Set to binary mode.
- ftp.setFileType( FTP.BINARY_FILE_TYPE );
- ftp.setListHiddenFiles( true );
-
- // Use passive mode as default because most of us are
- // behind firewalls these days.
- if ( isPassiveMode() )
- {
- ftp.enterLocalPassiveMode();
- }
- }
- catch ( IOException e )
- {
- throw new ConnectionException( "Cannot login to remote system", e );
- }
- }
-
- protected void firePutCompleted( Resource resource, File file )
- {
- try
- {
- // TODO [BP]: verify the order is correct
- ftp.completePendingCommand();
-
- RepositoryPermissions permissions = repository.getPermissions();
-
- if ( permissions != null && permissions.getGroup() != null )
- {
- // ignore failures
- ftp.sendSiteCommand( "CHGRP " + permissions.getGroup() + " " + resource.getName() );
- }
-
- if ( permissions != null && permissions.getFileMode() != null )
- {
- // ignore failures
- ftp.sendSiteCommand( "CHMOD " + permissions.getFileMode() + " " + resource.getName() );
- }
- }
- catch ( IOException e )
- {
- // TODO: handle
- // michal I am not sure what error means in that context
- // I think that we will be able to recover or simply we will fail later on
- }
-
- super.firePutCompleted( resource, file );
- }
-
- protected void fireGetCompleted( Resource resource, File localFile )
- {
- try
- {
- ftp.completePendingCommand();
- }
- catch ( IOException e )
- {
- // TODO: handle
- // michal I am not sure what error means in that context
- // actually I am not even sure why we have to invoke that command
- // I think that we will be able to recover or simply we will fail later on
- }
- super.fireGetCompleted( resource, localFile );
- }
-
- public void closeConnection()
- throws ConnectionException
- {
- if ( ftp != null && ftp.isConnected() )
- {
- try
- {
- // This is a NPE rethink shutting down the streams
- ftp.disconnect();
- }
- catch ( IOException e )
- {
- throw new ConnectionException( "Failed to close connection to FTP repository", e );
- }
- }
- }
-
- public void fillOutputData( OutputData outputData )
- throws TransferFailedException
- {
- OutputStream os;
-
- Resource resource = outputData.getResource();
-
- RepositoryPermissions permissions = repository.getPermissions();
-
- try
- {
- if ( !ftp.changeWorkingDirectory( getRepository().getBasedir() ) )
- {
- throw new TransferFailedException(
- "Required directory: '" + getRepository().getBasedir() + "' " + "is missing" );
- }
-
- String[] dirs = PathUtils.dirnames( resource.getName() );
-
- for ( String dir : dirs )
- {
- boolean dirChanged = ftp.changeWorkingDirectory( dir );
-
- if ( !dirChanged )
- {
- // first, try to create it
- boolean success = ftp.makeDirectory( dir );
-
- if ( success )
- {
- if ( permissions != null && permissions.getGroup() != null )
- {
- // ignore failures
- ftp.sendSiteCommand( "CHGRP " + permissions.getGroup() + " " + dir );
- }
-
- if ( permissions != null && permissions.getDirectoryMode() != null )
- {
- // ignore failures
- ftp.sendSiteCommand( "CHMOD " + permissions.getDirectoryMode() + " " + dir );
- }
-
- dirChanged = ftp.changeWorkingDirectory( dir );
- }
- }
-
- if ( !dirChanged )
- {
- throw new TransferFailedException( "Unable to create directory " + dir );
- }
- }
-
- // we come back to original basedir so
- // FTP wagon is ready for next requests
- if ( !ftp.changeWorkingDirectory( getRepository().getBasedir() ) )
- {
- throw new TransferFailedException( "Unable to return to the base directory" );
- }
-
- os = ftp.storeFileStream( resource.getName() );
-
- if ( os == null )
- {
- String msg =
- "Cannot transfer resource: '" + resource + "'. Output stream is null. FTP Server response: "
- + ftp.getReplyString();
-
- throw new TransferFailedException( msg );
-
- }
-
- fireTransferDebug( "resource = " + resource );
-
- }
- catch ( IOException e )
- {
- throw new TransferFailedException( "Error transferring over FTP", e );
- }
-
- outputData.setOutputStream( os );
-
- }
-
- // ----------------------------------------------------------------------
- //
- // ----------------------------------------------------------------------
-
- public void fillInputData( InputData inputData )
- throws TransferFailedException, ResourceDoesNotExistException
- {
- InputStream is;
-
- Resource resource = inputData.getResource();
-
- try
- {
- ftpChangeDirectory( resource );
-
- String filename = PathUtils.filename( resource.getName() );
- FTPFile[] ftpFiles = ftp.listFiles( filename );
-
- if ( ftpFiles == null || ftpFiles.length <= 0 )
- {
- throw new ResourceDoesNotExistException( "Could not find file: '" + resource + "'" );
- }
-
- long contentLength = ftpFiles[0].getSize();
-
- //@todo check how it works! javadoc of common login says:
- // Returns the file timestamp. This usually the last modification time.
- //
- Calendar timestamp = ftpFiles[0].getTimestamp();
- long lastModified = timestamp != null ? timestamp.getTimeInMillis() : 0;
-
- resource.setContentLength( contentLength );
-
- resource.setLastModified( lastModified );
-
- is = ftp.retrieveFileStream( filename );
- }
- catch ( IOException e )
- {
- throw new TransferFailedException( "Error transferring file via FTP", e );
- }
-
- inputData.setInputStream( is );
- }
-
- private void ftpChangeDirectory( Resource resource )
- throws IOException, TransferFailedException, ResourceDoesNotExistException
- {
- if ( !ftp.changeWorkingDirectory( getRepository().getBasedir() ) )
- {
- throw new ResourceDoesNotExistException(
- "Required directory: '" + getRepository().getBasedir() + "' " + "is missing" );
- }
-
- String[] dirs = PathUtils.dirnames( resource.getName() );
-
- for ( String dir : dirs )
- {
- boolean dirChanged = ftp.changeWorkingDirectory( dir );
-
- if ( !dirChanged )
- {
- String msg = "Resource " + resource + " not found. Directory " + dir + " does not exist";
-
- throw new ResourceDoesNotExistException( msg );
- }
- }
- }
-
- /**
- *
- */
- public class PrintCommandListener
- implements ProtocolCommandListener
- {
- private FtpWagon wagon;
-
- public PrintCommandListener( FtpWagon wagon )
- {
- this.wagon = wagon;
- }
-
- public void protocolCommandSent( ProtocolCommandEvent event )
- {
- wagon.fireSessionDebug( "Command sent: " + event.getMessage() );
-
- }
-
- public void protocolReplyReceived( ProtocolCommandEvent event )
- {
- wagon.fireSessionDebug( "Reply received: " + event.getMessage() );
- }
- }
-
- protected void fireSessionDebug( String msg )
- {
- super.fireSessionDebug( msg );
- }
-
- public List<String> getFileList( String destinationDirectory )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- Resource resource = new Resource( destinationDirectory );
-
- try
- {
- ftpChangeDirectory( resource );
-
- String filename = PathUtils.filename( resource.getName() );
- FTPFile[] ftpFiles = ftp.listFiles( filename );
-
- if ( ftpFiles == null || ftpFiles.length <= 0 )
- {
- throw new ResourceDoesNotExistException( "Could not find file: '" + resource + "'" );
- }
-
- List<String> ret = new ArrayList<String>();
- for ( FTPFile file : ftpFiles )
- {
- String name = file.getName();
-
- if ( file.isDirectory() && !name.endsWith( "/" ) )
- {
- name += "/";
- }
-
- ret.add( name );
- }
-
- return ret;
- }
- catch ( IOException e )
- {
- throw new TransferFailedException( "Error transferring file via FTP", e );
- }
- }
-
- public boolean resourceExists( String resourceName )
- throws TransferFailedException, AuthorizationException
- {
- Resource resource = new Resource( resourceName );
-
- try
- {
- ftpChangeDirectory( resource );
-
- String filename = PathUtils.filename( resource.getName() );
- int status = ftp.stat( filename );
-
- return ( ( status == FTPReply.FILE_STATUS ) || ( status == FTPReply.DIRECTORY_STATUS ) || ( status
- == FTPReply.FILE_STATUS_OK ) // not in the RFC but used by some FTP servers
- || ( status == FTPReply.COMMAND_OK ) // not in the RFC but used by some FTP servers
- || ( status == FTPReply.SYSTEM_STATUS ) );
- }
- catch ( IOException e )
- {
- throw new TransferFailedException( "Error transferring file via FTP", e );
- }
- catch ( ResourceDoesNotExistException e )
- {
- return false;
- }
- }
-
- public boolean supportsDirectoryCopy()
- {
- return true;
- }
-
- public void putDirectory( File sourceDirectory, String destinationDirectory )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
-
- // Change to root.
- try
- {
- if ( !ftp.changeWorkingDirectory( getRepository().getBasedir() ) )
- {
- RepositoryPermissions permissions = getRepository().getPermissions();
- if ( !makeFtpDirectoryRecursive( getRepository().getBasedir(), permissions ) )
- {
- throw new TransferFailedException(
- "Required directory: '" + getRepository().getBasedir() + "' " + "could not get created" );
- }
-
- // try it again sam ...
- if ( !ftp.changeWorkingDirectory( getRepository().getBasedir() ) )
- {
- throw new TransferFailedException( "Required directory: '" + getRepository().getBasedir() + "' "
- + "is missing and could not get created" );
- }
- }
- }
- catch ( IOException e )
- {
- throw new TransferFailedException( "Cannot change to root path " + getRepository().getBasedir(), e );
- }
-
- fireTransferDebug(
- "Recursively uploading directory " + sourceDirectory.getAbsolutePath() + " as " + destinationDirectory );
- ftpRecursivePut( sourceDirectory, destinationDirectory );
- }
-
- private void ftpRecursivePut( File sourceFile, String fileName )
- throws TransferFailedException
- {
- final RepositoryPermissions permissions = repository.getPermissions();
-
- fireTransferDebug( "processing = " + sourceFile.getAbsolutePath() + " as " + fileName );
-
- if ( sourceFile.isDirectory() )
- {
- if ( !fileName.equals( "." ) )
- {
- try
- {
- // change directory if it already exists.
- if ( !ftp.changeWorkingDirectory( fileName ) )
- {
- // first, try to create it
- if ( makeFtpDirectoryRecursive( fileName, permissions ) )
- {
- if ( !ftp.changeWorkingDirectory( fileName ) )
- {
- throw new TransferFailedException(
- "Unable to change cwd on ftp server to " + fileName + " when processing "
- + sourceFile.getAbsolutePath() );
- }
- }
- else
- {
- throw new TransferFailedException(
- "Unable to create directory " + fileName + " when processing "
- + sourceFile.getAbsolutePath() );
- }
- }
- }
- catch ( IOException e )
- {
- throw new TransferFailedException(
- "IOException caught while processing path at " + sourceFile.getAbsolutePath(), e );
- }
- }
-
- File[] files = sourceFile.listFiles();
- if ( files != null && files.length > 0 )
- {
- fireTransferDebug( "listing children of = " + sourceFile.getAbsolutePath() + " found " + files.length );
-
- // Directories first, then files. Let's go deep early.
- for ( File file : files )
- {
- if ( file.isDirectory() )
- {
- ftpRecursivePut( file, file.getName() );
- }
- }
- for ( File file : files )
- {
- if ( !file.isDirectory() )
- {
- ftpRecursivePut( file, file.getName() );
- }
- }
- }
-
- // Step back up a directory once we're done with the contents of this one.
- try
- {
- ftp.changeToParentDirectory();
- }
- catch ( IOException e )
- {
- throw new TransferFailedException( "IOException caught while attempting to step up to parent directory"
- + " after successfully processing "
- + sourceFile.getAbsolutePath(), e );
- }
- }
- else
- {
- // Oh how I hope and pray, in denial, but today I am still just a file.
-
- FileInputStream sourceFileStream = null;
- try
- {
- sourceFileStream = new FileInputStream( sourceFile );
-
- // It's a file. Upload it in the current directory.
- if ( ftp.storeFile( fileName, sourceFileStream ) )
- {
- if ( permissions != null )
- {
- // Process permissions; note that if we get errors or exceptions here, they are ignored.
- // This appears to be a conscious decision, based on other parts of this code.
- String group = permissions.getGroup();
- if ( group != null )
- {
- try
- {
- ftp.sendSiteCommand( "CHGRP " + permissions.getGroup() );
- }
- catch ( IOException e )
- {
- // ignore
- }
- }
- String mode = permissions.getFileMode();
- if ( mode != null )
- {
- try
- {
- ftp.sendSiteCommand( "CHMOD " + permissions.getDirectoryMode() );
- }
- catch ( IOException e )
- {
- // ignore
- }
- }
- }
- }
- else
- {
- String msg =
- "Cannot transfer resource: '" + sourceFile.getAbsolutePath() + "' FTP Server response: "
- + ftp.getReplyString();
- throw new TransferFailedException( msg );
- }
- }
- catch ( IOException e )
- {
- throw new TransferFailedException(
- "IOException caught while attempting to upload " + sourceFile.getAbsolutePath(), e );
- }
- finally
- {
- IOUtils.closeQuietly( sourceFileStream );
- }
-
- }
-
- fireTransferDebug( "completed = " + sourceFile.getAbsolutePath() );
- }
-
- /**
- * Set the permissions (if given) for the underlying folder.
- * Note: Since the FTP SITE command might be server dependent, we cannot
- * rely on the functionality available on each FTP server!
- * So we can only try and hope it works (and catch away all Exceptions).
- *
- * @param permissions group and directory permissions
- */
- private void setPermissions( RepositoryPermissions permissions )
- {
- if ( permissions != null )
- {
- // Process permissions; note that if we get errors or exceptions here, they are ignored.
- // This appears to be a conscious decision, based on other parts of this code.
- String group = permissions.getGroup();
- if ( group != null )
- {
- try
- {
- ftp.sendSiteCommand( "CHGRP " + permissions.getGroup() );
- }
- catch ( IOException e )
- {
- // ignore
- }
- }
- String mode = permissions.getDirectoryMode();
- if ( mode != null )
- {
- try
- {
- ftp.sendSiteCommand( "CHMOD " + permissions.getDirectoryMode() );
- }
- catch ( IOException e )
- {
- // ignore
- }
- }
- }
- }
-
- /**
- * Recursively create directories.
- *
- * @param fileName the path to create (might be nested)
- * @param permissions
- * @return ok
- * @throws IOException
- */
- private boolean makeFtpDirectoryRecursive( String fileName, RepositoryPermissions permissions )
- throws IOException
- {
- if ( fileName == null || fileName.length() == 0
- || fileName.replace( '/', '_' ).trim().length() == 0 ) // if a string is '/', '//' or similar
- {
- return false;
- }
-
- int slashPos = fileName.indexOf( "/" );
- String oldPwd = null;
- boolean ok = true;
-
- if ( slashPos == 0 )
- {
- // this is an absolute directory
- oldPwd = ftp.printWorkingDirectory();
-
- // start with the root
- ftp.changeWorkingDirectory( "/" );
- fileName = fileName.substring( 1 );
-
- // look up the next path separator
- slashPos = fileName.indexOf( "/" );
- }
-
- if ( slashPos >= 0 && slashPos < ( fileName.length() - 1 ) ) // not only a slash at the end, like in 'newDir/'
- {
- if ( oldPwd == null )
- {
- oldPwd = ftp.printWorkingDirectory();
- }
-
- String nextDir = fileName.substring( 0, slashPos );
-
- // we only create the nextDir if it doesn't yet exist
- if ( !ftp.changeWorkingDirectory( nextDir ) )
- {
- ok &= ftp.makeDirectory( nextDir );
- }
-
- if ( ok )
- {
- // set the permissions for the freshly created directory
- setPermissions( permissions );
-
- ftp.changeWorkingDirectory( nextDir );
-
- // now create the deeper directories
- String remainingDirs = fileName.substring( slashPos + 1 );
- ok &= makeFtpDirectoryRecursive( remainingDirs, permissions );
- }
- }
- else
- {
- ok = ftp.makeDirectory( fileName );
- }
-
- if ( oldPwd != null )
- {
- // change back to the old working directory
- ftp.changeWorkingDirectory( oldPwd );
- }
-
- return ok;
- }
-
- public String getControlEncoding()
- {
- return controlEncoding;
- }
-
- public void setControlEncoding( String controlEncoding )
- {
- this.controlEncoding = controlEncoding;
- }
-}
+package org.apache.maven.wagon.providers.ftp;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.net.ProtocolCommandEvent;
+import org.apache.commons.net.ProtocolCommandListener;
+import org.apache.commons.net.ftp.FTP;
+import org.apache.commons.net.ftp.FTPClient;
+import org.apache.commons.net.ftp.FTPFile;
+import org.apache.commons.net.ftp.FTPReply;
+import org.apache.maven.wagon.ConnectionException;
+import org.apache.maven.wagon.InputData;
+import org.apache.maven.wagon.OutputData;
+import org.apache.maven.wagon.PathUtils;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.StreamWagon;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.WagonConstants;
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.repository.RepositoryPermissions;
+import org.apache.maven.wagon.resource.Resource;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.List;
+
+/**
+ * FtpWagon
+ *
+ *
+ * @plexus.component role="org.apache.maven.wagon.Wagon"
+ * role-hint="ftp"
+ * instantiation-strategy="per-lookup"
+ */
+public class FtpWagon
+ extends StreamWagon
+{
+ private FTPClient ftp;
+
+ /**
+ * @plexus.configuration default-value="true"
+ */
+ private boolean passiveMode = true;
+
+ /**
+ * @plexus.configuration default-value="ISO-8859-1"
+ */
+ private String controlEncoding = FTP.DEFAULT_CONTROL_ENCODING;
+
+ public boolean isPassiveMode()
+ {
+ return passiveMode;
+ }
+
+ public void setPassiveMode( boolean passiveMode )
+ {
+ this.passiveMode = passiveMode;
+ }
+
+ protected void openConnectionInternal()
+ throws ConnectionException, AuthenticationException
+ {
+ AuthenticationInfo authInfo = getAuthenticationInfo();
+
+ if ( authInfo == null )
+ {
+ throw new NullPointerException( "authenticationInfo cannot be null" );
+ }
+
+ if ( authInfo.getUserName() == null )
+ {
+ authInfo.setUserName( System.getProperty( "user.name" ) );
+ }
+
+ String username = authInfo.getUserName();
+
+ String password = authInfo.getPassword();
+
+ if ( username == null )
+ {
+ throw new AuthenticationException( "Username not specified for repository " + getRepository().getId() );
+ }
+ if ( password == null )
+ {
+ throw new AuthenticationException( "Password not specified for repository " + getRepository().getId() );
+ }
+
+ String host = getRepository().getHost();
+
+ ftp = createClient();
+ ftp.setDefaultTimeout( getTimeout() );
+ ftp.setDataTimeout( getTimeout() );
+ ftp.setControlEncoding( getControlEncoding() );
+
+ ftp.addProtocolCommandListener( new PrintCommandListener( this ) );
+
+ try
+ {
+ if ( getRepository().getPort() != WagonConstants.UNKNOWN_PORT )
+ {
+ ftp.connect( host, getRepository().getPort() );
+ }
+ else
+ {
+ ftp.connect( host );
+ }
+
+ // After connection attempt, you should check the reply code to
+ // verify
+ // success.
+ int reply = ftp.getReplyCode();
+
+ if ( !FTPReply.isPositiveCompletion( reply ) )
+ {
+ ftp.disconnect();
+
+ throw new AuthenticationException( "FTP server refused connection." );
+ }
+ }
+ catch ( IOException e )
+ {
+ if ( ftp.isConnected() )
+ {
+ try
+ {
+ fireSessionError( e );
+
+ ftp.disconnect();
+ }
+ catch ( IOException f )
+ {
+ // do nothing
+ }
+ }
+
+ throw new AuthenticationException( "Could not connect to server.", e );
+ }
+
+ try
+ {
+ if ( !ftp.login( username, password ) )
+ {
+ throw new AuthenticationException( "Cannot login to remote system" );
+ }
+
+ fireSessionDebug( "Remote system is " + ftp.getSystemName() );
+
+ // Set to binary mode.
+ ftp.setFileType( FTP.BINARY_FILE_TYPE );
+ ftp.setListHiddenFiles( true );
+
+ // Use passive mode as default because most of us are
+ // behind firewalls these days.
+ if ( isPassiveMode() )
+ {
+ ftp.enterLocalPassiveMode();
+ }
+ }
+ catch ( IOException e )
+ {
+ throw new ConnectionException( "Cannot login to remote system", e );
+ }
+ }
+
+ protected FTPClient createClient()
+ {
+ return new FTPClient();
+ }
+
+ protected void firePutCompleted( Resource resource, File file )
+ {
+ try
+ {
+ // TODO [BP]: verify the order is correct
+ ftp.completePendingCommand();
+
+ RepositoryPermissions permissions = repository.getPermissions();
+
+ if ( permissions != null && permissions.getGroup() != null )
+ {
+ // ignore failures
+ ftp.sendSiteCommand( "CHGRP " + permissions.getGroup() + " " + resource.getName() );
+ }
+
+ if ( permissions != null && permissions.getFileMode() != null )
+ {
+ // ignore failures
+ ftp.sendSiteCommand( "CHMOD " + permissions.getFileMode() + " " + resource.getName() );
+ }
+ }
+ catch ( IOException e )
+ {
+ // TODO: handle
+ // michal I am not sure what error means in that context
+ // I think that we will be able to recover or simply we will fail later on
+ }
+
+ super.firePutCompleted( resource, file );
+ }
+
+ protected void fireGetCompleted( Resource resource, File localFile )
+ {
+ try
+ {
+ ftp.completePendingCommand();
+ }
+ catch ( IOException e )
+ {
+ // TODO: handle
+ // michal I am not sure what error means in that context
+ // actually I am not even sure why we have to invoke that command
+ // I think that we will be able to recover or simply we will fail later on
+ }
+ super.fireGetCompleted( resource, localFile );
+ }
+
+ public void closeConnection()
+ throws ConnectionException
+ {
+ if ( ftp != null && ftp.isConnected() )
+ {
+ try
+ {
+ // This is a NPE rethink shutting down the streams
+ ftp.disconnect();
+ }
+ catch ( IOException e )
+ {
+ throw new ConnectionException( "Failed to close connection to FTP repository", e );
+ }
+ }
+ }
+
+ public void fillOutputData( OutputData outputData )
+ throws TransferFailedException
+ {
+ OutputStream os;
+
+ Resource resource = outputData.getResource();
+
+ RepositoryPermissions permissions = repository.getPermissions();
+
+ try
+ {
+ if ( !ftp.changeWorkingDirectory( getRepository().getBasedir() ) )
+ {
+ throw new TransferFailedException(
+ "Required directory: '" + getRepository().getBasedir() + "' " + "is missing" );
+ }
+
+ String[] dirs = PathUtils.dirnames( resource.getName() );
+
+ for ( String dir : dirs )
+ {
+ boolean dirChanged = ftp.changeWorkingDirectory( dir );
+
+ if ( !dirChanged )
+ {
+ // first, try to create it
+ boolean success = ftp.makeDirectory( dir );
+
+ if ( success )
+ {
+ if ( permissions != null && permissions.getGroup() != null )
+ {
+ // ignore failures
+ ftp.sendSiteCommand( "CHGRP " + permissions.getGroup() + " " + dir );
+ }
+
+ if ( permissions != null && permissions.getDirectoryMode() != null )
+ {
+ // ignore failures
+ ftp.sendSiteCommand( "CHMOD " + permissions.getDirectoryMode() + " " + dir );
+ }
+
+ dirChanged = ftp.changeWorkingDirectory( dir );
+ }
+ }
+
+ if ( !dirChanged )
+ {
+ throw new TransferFailedException( "Unable to create directory " + dir );
+ }
+ }
+
+ // we come back to original basedir so
+ // FTP wagon is ready for next requests
+ if ( !ftp.changeWorkingDirectory( getRepository().getBasedir() ) )
+ {
+ throw new TransferFailedException( "Unable to return to the base directory" );
+ }
+
+ os = ftp.storeFileStream( resource.getName() );
+
+ if ( os == null )
+ {
+ String msg =
+ "Cannot transfer resource: '" + resource + "'. Output stream is null. FTP Server response: "
+ + ftp.getReplyString();
+
+ throw new TransferFailedException( msg );
+
+ }
+
+ fireTransferDebug( "resource = " + resource );
+
+ }
+ catch ( IOException e )
+ {
+ throw new TransferFailedException( "Error transferring over FTP", e );
+ }
+
+ outputData.setOutputStream( os );
+
+ }
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ public void fillInputData( InputData inputData )
+ throws TransferFailedException, ResourceDoesNotExistException
+ {
+ InputStream is;
+
+ Resource resource = inputData.getResource();
+
+ try
+ {
+ ftpChangeDirectory( resource );
+
+ String filename = PathUtils.filename( resource.getName() );
+ FTPFile[] ftpFiles = ftp.listFiles( filename );
+
+ if ( ftpFiles == null || ftpFiles.length <= 0 )
+ {
+ throw new ResourceDoesNotExistException( "Could not find file: '" + resource + "'" );
+ }
+
+ long contentLength = ftpFiles[0].getSize();
+
+ //@todo check how it works! javadoc of common login says:
+ // Returns the file timestamp. This usually the last modification time.
+ //
+ Calendar timestamp = ftpFiles[0].getTimestamp();
+ long lastModified = timestamp != null ? timestamp.getTimeInMillis() : 0;
+
+ resource.setContentLength( contentLength );
+
+ resource.setLastModified( lastModified );
+
+ is = ftp.retrieveFileStream( filename );
+ }
+ catch ( IOException e )
+ {
+ throw new TransferFailedException( "Error transferring file via FTP", e );
+ }
+
+ inputData.setInputStream( is );
+ }
+
+ private void ftpChangeDirectory( Resource resource )
+ throws IOException, TransferFailedException, ResourceDoesNotExistException
+ {
+ if ( !ftp.changeWorkingDirectory( getRepository().getBasedir() ) )
+ {
+ throw new ResourceDoesNotExistException(
+ "Required directory: '" + getRepository().getBasedir() + "' " + "is missing" );
+ }
+
+ String[] dirs = PathUtils.dirnames( resource.getName() );
+
+ for ( String dir : dirs )
+ {
+ boolean dirChanged = ftp.changeWorkingDirectory( dir );
+
+ if ( !dirChanged )
+ {
+ String msg = "Resource " + resource + " not found. Directory " + dir + " does not exist";
+
+ throw new ResourceDoesNotExistException( msg );
+ }
+ }
+ }
+
+ /**
+ *
+ */
+ public class PrintCommandListener
+ implements ProtocolCommandListener
+ {
+ private FtpWagon wagon;
+
+ public PrintCommandListener( FtpWagon wagon )
+ {
+ this.wagon = wagon;
+ }
+
+ public void protocolCommandSent( ProtocolCommandEvent event )
+ {
+ wagon.fireSessionDebug( "Command sent: " + event.getMessage() );
+
+ }
+
+ public void protocolReplyReceived( ProtocolCommandEvent event )
+ {
+ wagon.fireSessionDebug( "Reply received: " + event.getMessage() );
+ }
+ }
+
+ protected void fireSessionDebug( String msg )
+ {
+ super.fireSessionDebug( msg );
+ }
+
+ public List<String> getFileList( String destinationDirectory )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ Resource resource = new Resource( destinationDirectory );
+
+ try
+ {
+ ftpChangeDirectory( resource );
+
+ String filename = PathUtils.filename( resource.getName() );
+ FTPFile[] ftpFiles = ftp.listFiles( filename );
+
+ if ( ftpFiles == null || ftpFiles.length <= 0 )
+ {
+ throw new ResourceDoesNotExistException( "Could not find file: '" + resource + "'" );
+ }
+
+ List<String> ret = new ArrayList<String>();
+ for ( FTPFile file : ftpFiles )
+ {
+ String name = file.getName();
+
+ if ( file.isDirectory() && !name.endsWith( "/" ) )
+ {
+ name += "/";
+ }
+
+ ret.add( name );
+ }
+
+ return ret;
+ }
+ catch ( IOException e )
+ {
+ throw new TransferFailedException( "Error transferring file via FTP", e );
+ }
+ }
+
+ public boolean resourceExists( String resourceName )
+ throws TransferFailedException, AuthorizationException
+ {
+ Resource resource = new Resource( resourceName );
+
+ try
+ {
+ ftpChangeDirectory( resource );
+
+ String filename = PathUtils.filename( resource.getName() );
+ int status = ftp.stat( filename );
+
+ return ( ( status == FTPReply.FILE_STATUS ) || ( status == FTPReply.DIRECTORY_STATUS ) || ( status
+ == FTPReply.FILE_STATUS_OK ) // not in the RFC but used by some FTP servers
+ || ( status == FTPReply.COMMAND_OK ) // not in the RFC but used by some FTP servers
+ || ( status == FTPReply.SYSTEM_STATUS ) );
+ }
+ catch ( IOException e )
+ {
+ throw new TransferFailedException( "Error transferring file via FTP", e );
+ }
+ catch ( ResourceDoesNotExistException e )
+ {
+ return false;
+ }
+ }
+
+ public boolean supportsDirectoryCopy()
+ {
+ return true;
+ }
+
+ public void putDirectory( File sourceDirectory, String destinationDirectory )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+
+ // Change to root.
+ try
+ {
+ if ( !ftp.changeWorkingDirectory( getRepository().getBasedir() ) )
+ {
+ RepositoryPermissions permissions = getRepository().getPermissions();
+ if ( !makeFtpDirectoryRecursive( getRepository().getBasedir(), permissions ) )
+ {
+ throw new TransferFailedException(
+ "Required directory: '" + getRepository().getBasedir() + "' " + "could not get created" );
+ }
+
+ // try it again sam ...
+ if ( !ftp.changeWorkingDirectory( getRepository().getBasedir() ) )
+ {
+ throw new TransferFailedException( "Required directory: '" + getRepository().getBasedir() + "' "
+ + "is missing and could not get created" );
+ }
+ }
+ }
+ catch ( IOException e )
+ {
+ throw new TransferFailedException( "Cannot change to root path " + getRepository().getBasedir(), e );
+ }
+
+ fireTransferDebug(
+ "Recursively uploading directory " + sourceDirectory.getAbsolutePath() + " as " + destinationDirectory );
+ ftpRecursivePut( sourceDirectory, destinationDirectory );
+ }
+
+ private void ftpRecursivePut( File sourceFile, String fileName )
+ throws TransferFailedException
+ {
+ final RepositoryPermissions permissions = repository.getPermissions();
+
+ fireTransferDebug( "processing = " + sourceFile.getAbsolutePath() + " as " + fileName );
+
+ if ( sourceFile.isDirectory() )
+ {
+ if ( !fileName.equals( "." ) )
+ {
+ try
+ {
+ // change directory if it already exists.
+ if ( !ftp.changeWorkingDirectory( fileName ) )
+ {
+ // first, try to create it
+ if ( makeFtpDirectoryRecursive( fileName, permissions ) )
+ {
+ if ( !ftp.changeWorkingDirectory( fileName ) )
+ {
+ throw new TransferFailedException(
+ "Unable to change cwd on ftp server to " + fileName + " when processing "
+ + sourceFile.getAbsolutePath() );
+ }
+ }
+ else
+ {
+ throw new TransferFailedException(
+ "Unable to create directory " + fileName + " when processing "
+ + sourceFile.getAbsolutePath() );
+ }
+ }
+ }
+ catch ( IOException e )
+ {
+ throw new TransferFailedException(
+ "IOException caught while processing path at " + sourceFile.getAbsolutePath(), e );
+ }
+ }
+
+ File[] files = sourceFile.listFiles();
+ if ( files != null && files.length > 0 )
+ {
+ fireTransferDebug( "listing children of = " + sourceFile.getAbsolutePath() + " found " + files.length );
+
+ // Directories first, then files. Let's go deep early.
+ for ( File file : files )
+ {
+ if ( file.isDirectory() )
+ {
+ ftpRecursivePut( file, file.getName() );
+ }
+ }
+ for ( File file : files )
+ {
+ if ( !file.isDirectory() )
+ {
+ ftpRecursivePut( file, file.getName() );
+ }
+ }
+ }
+
+ // Step back up a directory once we're done with the contents of this one.
+ try
+ {
+ ftp.changeToParentDirectory();
+ }
+ catch ( IOException e )
+ {
+ throw new TransferFailedException( "IOException caught while attempting to step up to parent directory"
+ + " after successfully processing "
+ + sourceFile.getAbsolutePath(), e );
+ }
+ }
+ else
+ {
+ // Oh how I hope and pray, in denial, but today I am still just a file.
+
+ FileInputStream sourceFileStream = null;
+ try
+ {
+ sourceFileStream = new FileInputStream( sourceFile );
+
+ // It's a file. Upload it in the current directory.
+ if ( ftp.storeFile( fileName, sourceFileStream ) )
+ {
+ if ( permissions != null )
+ {
+ // Process permissions; note that if we get errors or exceptions here, they are ignored.
+ // This appears to be a conscious decision, based on other parts of this code.
+ String group = permissions.getGroup();
+ if ( group != null )
+ {
+ try
+ {
+ ftp.sendSiteCommand( "CHGRP " + permissions.getGroup() );
+ }
+ catch ( IOException e )
+ {
+ // ignore
+ }
+ }
+ String mode = permissions.getFileMode();
+ if ( mode != null )
+ {
+ try
+ {
+ ftp.sendSiteCommand( "CHMOD " + permissions.getDirectoryMode() );
+ }
+ catch ( IOException e )
+ {
+ // ignore
+ }
+ }
+ }
+ }
+ else
+ {
+ String msg =
+ "Cannot transfer resource: '" + sourceFile.getAbsolutePath() + "' FTP Server response: "
+ + ftp.getReplyString();
+ throw new TransferFailedException( msg );
+ }
+
+ sourceFileStream.close();
+ sourceFileStream = null;
+ }
+ catch ( IOException e )
+ {
+ throw new TransferFailedException(
+ "IOException caught while attempting to upload " + sourceFile.getAbsolutePath(), e );
+ }
+ finally
+ {
+ IOUtils.closeQuietly( sourceFileStream );
+ }
+
+ }
+
+ fireTransferDebug( "completed = " + sourceFile.getAbsolutePath() );
+ }
+
+ /**
+ * Set the permissions (if given) for the underlying folder.
+ * Note: Since the FTP SITE command might be server dependent, we cannot
+ * rely on the functionality available on each FTP server!
+ * So we can only try and hope it works (and catch away all Exceptions).
+ *
+ * @param permissions group and directory permissions
+ */
+ private void setPermissions( RepositoryPermissions permissions )
+ {
+ if ( permissions != null )
+ {
+ // Process permissions; note that if we get errors or exceptions here, they are ignored.
+ // This appears to be a conscious decision, based on other parts of this code.
+ String group = permissions.getGroup();
+ if ( group != null )
+ {
+ try
+ {
+ ftp.sendSiteCommand( "CHGRP " + permissions.getGroup() );
+ }
+ catch ( IOException e )
+ {
+ // ignore
+ }
+ }
+ String mode = permissions.getDirectoryMode();
+ if ( mode != null )
+ {
+ try
+ {
+ ftp.sendSiteCommand( "CHMOD " + permissions.getDirectoryMode() );
+ }
+ catch ( IOException e )
+ {
+ // ignore
+ }
+ }
+ }
+ }
+
+ /**
+ * Recursively create directories.
+ *
+ * @param fileName the path to create (might be nested)
+ * @param permissions
+ * @return ok
+ * @throws IOException
+ */
+ private boolean makeFtpDirectoryRecursive( String fileName, RepositoryPermissions permissions )
+ throws IOException
+ {
+ if ( fileName == null || fileName.length() == 0
+ || fileName.replace( '/', '_' ).trim().length() == 0 ) // if a string is '/', '//' or similar
+ {
+ return false;
+ }
+
+ int slashPos = fileName.indexOf( "/" );
+ String oldPwd = null;
+ boolean ok = true;
+
+ if ( slashPos == 0 )
+ {
+ // this is an absolute directory
+ oldPwd = ftp.printWorkingDirectory();
+
+ // start with the root
+ ftp.changeWorkingDirectory( "/" );
+ fileName = fileName.substring( 1 );
+
+ // look up the next path separator
+ slashPos = fileName.indexOf( "/" );
+ }
+
+ if ( slashPos >= 0 && slashPos < ( fileName.length() - 1 ) ) // not only a slash at the end, like in 'newDir/'
+ {
+ if ( oldPwd == null )
+ {
+ oldPwd = ftp.printWorkingDirectory();
+ }
+
+ String nextDir = fileName.substring( 0, slashPos );
+
+ // we only create the nextDir if it doesn't yet exist
+ if ( !ftp.changeWorkingDirectory( nextDir ) )
+ {
+ ok &= ftp.makeDirectory( nextDir );
+ }
+
+ if ( ok )
+ {
+ // set the permissions for the freshly created directory
+ setPermissions( permissions );
+
+ ftp.changeWorkingDirectory( nextDir );
+
+ // now create the deeper directories
+ String remainingDirs = fileName.substring( slashPos + 1 );
+ ok &= makeFtpDirectoryRecursive( remainingDirs, permissions );
+ }
+ }
+ else
+ {
+ ok = ftp.makeDirectory( fileName );
+ }
+
+ if ( oldPwd != null )
+ {
+ // change back to the old working directory
+ ftp.changeWorkingDirectory( oldPwd );
+ }
+
+ return ok;
+ }
+
+ public String getControlEncoding()
+ {
+ return controlEncoding;
+ }
+
+ public void setControlEncoding( String controlEncoding )
+ {
+ this.controlEncoding = controlEncoding;
+ }
+}
diff --git a/wagon-providers/wagon-ftp/src/main/java/org/apache/maven/wagon/providers/ftp/FtpsWagon.java b/wagon-providers/wagon-ftp/src/main/java/org/apache/maven/wagon/providers/ftp/FtpsWagon.java
new file mode 100644
index 0000000..00f7b14
--- /dev/null
+++ b/wagon-providers/wagon-ftp/src/main/java/org/apache/maven/wagon/providers/ftp/FtpsWagon.java
@@ -0,0 +1,64 @@
+package org.apache.maven.wagon.providers.ftp;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.net.ftp.FTPClient;
+import org.apache.commons.net.ftp.FTPSClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * FtpsWagon
+ *
+ *
+ * @plexus.component role="org.apache.maven.wagon.Wagon"
+ * role-hint="ftps"
+ * instantiation-strategy="per-lookup"
+ */
+public class FtpsWagon
+ extends FtpWagon
+{
+ private static final Logger LOG = LoggerFactory.getLogger( FtpsWagon.class );
+
+ /**
+ * @plexus.configuration default-value="TLS"
+ */
+ private String securityProtocol = "TLS";
+
+ /**
+ * @plexus.configuration default-value="false"
+ */
+ private boolean implicit = false;
+
+ /**
+ * @plexus.configuration default-value="true"
+ */
+ private boolean endpointChecking = true;
+
+ @Override
+ protected FTPClient createClient()
+ {
+ LOG.debug( "Creating secure FTP client. Protocol: [{}], implicit mode: [{}], endpoint checking: [{}].",
+ securityProtocol, implicit, endpointChecking );
+ FTPSClient client = new FTPSClient( securityProtocol, implicit );
+ client.setEndpointCheckingEnabled( endpointChecking );
+ return client;
+ }
+}
diff --git a/wagon-providers/wagon-ftp/src/site/apt/index.apt b/wagon-providers/wagon-ftp/src/site/apt/index.apt
index 0f7f47e..98deee0 100644
--- a/wagon-providers/wagon-ftp/src/site/apt/index.apt
+++ b/wagon-providers/wagon-ftp/src/site/apt/index.apt
@@ -1,41 +1,102 @@
- ------
- Maven Wagon FTP
- ------
- Carlos Sanchez
- ------
- 2006-06-04
- ------
-
- ~~ Licensed to the Apache Software Foundation (ASF) under one
- ~~ or more contributor license agreements. See the NOTICE file
- ~~ distributed with this work for additional information
- ~~ regarding copyright ownership. The ASF licenses this file
- ~~ to you under the Apache License, Version 2.0 (the
- ~~ "License"); you may not use this file except in compliance
- ~~ with the License. You may obtain a copy of the License at
- ~~
- ~~ http://www.apache.org/licenses/LICENSE-2.0
- ~~
- ~~ Unless required by applicable law or agreed to in writing,
- ~~ software distributed under the License is distributed on an
- ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~~ KIND, either express or implied. See the License for the
- ~~ specific language governing permissions and limitations
- ~~ under the License.
-
- ~~ NOTE: For help with the syntax of this file, see:
- ~~ http://maven.apache.org/doxia/references/apt-format.html
-
-Maven Wagon FTP
-
- This component is an implementation of Wagon provider for FTP access.
- It uses {{{http://jakarta.apache.org/commons/net/}commons-net}} as lower level layer.
-
- It enables Maven to use remote repositories stored in FTP servers. It doesn't allow deployment of directories.
-
-
-Features
-
- * Get files from FTP Server
-
- * Deploy files to FTP server
\ No newline at end of file
+ ------
+ Maven Wagon FTP
+ ------
+ Carlos Sanchez
+ ------
+ 2006-06-04
+ ------
+
+ ~~ Licensed to the Apache Software Foundation (ASF) under one
+ ~~ or more contributor license agreements. See the NOTICE file
+ ~~ distributed with this work for additional information
+ ~~ regarding copyright ownership. The ASF licenses this file
+ ~~ to you under the Apache License, Version 2.0 (the
+ ~~ "License"); you may not use this file except in compliance
+ ~~ with the License. You may obtain a copy of the License at
+ ~~
+ ~~ http://www.apache.org/licenses/LICENSE-2.0
+ ~~
+ ~~ Unless required by applicable law or agreed to in writing,
+ ~~ software distributed under the License is distributed on an
+ ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~~ KIND, either express or implied. See the License for the
+ ~~ specific language governing permissions and limitations
+ ~~ under the License.
+
+ ~~ NOTE: For help with the syntax of this file, see:
+ ~~ http://maven.apache.org/doxia/references/apt-format.html
+
+Maven Wagon FTP
+
+ This component is an implementation of Wagon provider for FTP access.
+ It uses {{{http://jakarta.apache.org/commons/net/}commons-net}} as lower level layer.
+
+ It enables Maven to use remote repositories stored in FTP servers. It doesn't allow deployment of directories.
+
+
+Features
+
+ * Get files from FTP Server
+
+ * Deploy files to FTP server
+
+Configuration
+
+ * <<<passiveMode>>> default: <<true>>
+
+ * <<<controlEncoding>>> default: <<"ISO-8859-1">>,
+ set from <<<org.apache.commons.net.ftp.FTP.DEFAULT_CONTROL_ENCODING>>>
+
+ * <<<securityProtocol>>> default: <<TLS>>, FTPS security protocol, TLS or SSL
+
+ * <<<implicit>>> default: <<false>>
+
+ * <<<endpointChecking>>> default: <<true>>
+
+Sample Configuration
+
+* pom.xml
+
+---------------------------------------------
+<project>
+ ...
+ <distributionManagement>
+ ...
+ <site>
+ <id>ftp.server.id</id>
+ <!--<url>ftp://ftp.example.com</url>-->
+ <url>ftps://secure.example.com</url>
+ </site>
+ </distributionManagement>
+ ...
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-ftp</artifactId>
+ </extension>
+ </extensions>
+ ...
+ </build>
+ ...
+</project>
+---------------------------------------------
+
+* settings.xml
+
+---------------------------------------------
+<settings>
+ ...
+ <servers>
+ ...
+ <server>
+ <id>ftp.server.id</id>
+ <username>username</username>
+ <password>password</password>
+ <configuration>
+ <endpointChecking>false</endpointChecking>
+ </configuration>
+ </server>
+ </servers>
+<settings>
+---------------------------------------------
diff --git a/wagon-providers/wagon-ftp/src/site/site.xml b/wagon-providers/wagon-ftp/src/site/site.xml
index f5d0ccb..12b9669 100644
--- a/wagon-providers/wagon-ftp/src/site/site.xml
+++ b/wagon-providers/wagon-ftp/src/site/site.xml
@@ -1,33 +1,33 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
- <body>
- <breadcrumbs>
- <item name="FTP" href="http://maven.apache.org/wagon/wagon-providers/wagon-ftp/index.html" />
- </breadcrumbs>
-
- <menu ref="parent"/>
- <menu ref="reports"/>
- </body>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
+ <body>
+ <breadcrumbs>
+ <item name="FTP" href="http://maven.apache.org/wagon/wagon-providers/wagon-ftp/index.html" />
+ </breadcrumbs>
+
+ <menu ref="parent"/>
+ <menu ref="reports"/>
+ </body>
</project>
\ No newline at end of file
diff --git a/wagon-providers/wagon-ftp/src/test/java/org/apache/maven/wagon/providers/ftp/FtpWagonTest.java b/wagon-providers/wagon-ftp/src/test/java/org/apache/maven/wagon/providers/ftp/FtpWagonTest.java
index 6c8f401..d1e3fa6 100644
--- a/wagon-providers/wagon-ftp/src/test/java/org/apache/maven/wagon/providers/ftp/FtpWagonTest.java
+++ b/wagon-providers/wagon-ftp/src/test/java/org/apache/maven/wagon/providers/ftp/FtpWagonTest.java
@@ -1,237 +1,237 @@
-package org.apache.maven.wagon.providers.ftp;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.io.FileUtils;
-import org.apache.ftpserver.FtpServer;
-import org.apache.ftpserver.FtpServerFactory;
-import org.apache.ftpserver.ftplet.Authority;
-import org.apache.ftpserver.ftplet.UserManager;
-import org.apache.ftpserver.listener.ListenerFactory;
-import org.apache.ftpserver.usermanager.PropertiesUserManagerFactory;
-import org.apache.ftpserver.usermanager.impl.BaseUser;
-import org.apache.ftpserver.usermanager.impl.WritePermission;
-import org.apache.maven.wagon.FileTestUtils;
-import org.apache.maven.wagon.StreamingWagonTestCase;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
-import org.apache.maven.wagon.repository.Repository;
-import org.apache.maven.wagon.resource.Resource;
-
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class FtpWagonTest
- extends StreamingWagonTestCase
-{
- static private FtpServer server;
-
- protected String getProtocol()
- {
- return "ftp";
- }
-
- @Override
- protected int getTestRepositoryPort() {
- return 10023;
- }
-
- protected void setupWagonTestingFixtures()
- throws Exception
- {
- File ftpHomeDir = getRepositoryDirectory();
- if ( !ftpHomeDir.exists() )
- {
- ftpHomeDir.mkdirs();
- }
-
- if (server == null)
- {
- FtpServerFactory serverFactory = new FtpServerFactory();
-
- ListenerFactory factory = new ListenerFactory();
-
- // set the port of the listener
- factory.setPort(getTestRepositoryPort());
-
- // replace the default listener
- serverFactory.addListener("default", factory.createListener());
-
- PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
- UserManager um = userManagerFactory.createUserManager();
-
- BaseUser user = new BaseUser();
- user.setName("admin");
- user.setPassword("admin");
-
- List<Authority> authorities = new ArrayList<Authority>();
- authorities.add( new WritePermission() );
-
- user.setAuthorities( authorities );
-
- user.setHomeDirectory( ftpHomeDir.getAbsolutePath() );
-
-
- um.save(user);
-
- serverFactory.setUserManager( um );
-
- server = serverFactory.createServer();
-
- // start the server
- server.start();
-
- }
- }
-
- protected void createDirectory( Wagon wagon, String resourceToCreate, String dirName )
- throws Exception
- {
- super.createDirectory( wagon, resourceToCreate, dirName );
-
- getRepositoryDirectory().mkdirs();
- }
-
- protected void tearDownWagonTestingFixtures()
- throws Exception
- {
- server.stop();
- server = null;
- }
-
- protected String getTestRepositoryUrl()
- {
- return "ftp://localhost:" + getTestRepositoryPort();
- }
-
- public AuthenticationInfo getAuthInfo()
- {
- AuthenticationInfo authInfo = new AuthenticationInfo();
-
- authInfo.setUserName( "admin" );
-
- authInfo.setPassword( "admin" );
-
- return authInfo;
- }
-
- protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
- {
- File file = new File( getRepositoryDirectory(), resource.getName() );
-
- // granularity for FTP is minutes
- return ( file.lastModified() / 60000 ) * 60000;
- }
-
- private File getRepositoryDirectory()
- {
- return getTestFile( "target/test-output/local-repository" );
- }
-
- public void testNoPassword()
- throws Exception
- {
- AuthenticationInfo authenticationInfo = new AuthenticationInfo();
- authenticationInfo.setUserName( "me" );
- try
- {
- getWagon().connect( new Repository( "id", getTestRepositoryUrl() ), authenticationInfo );
- fail();
- }
- catch ( AuthenticationException e )
- {
- assertTrue( true );
- }
- }
-
- public void testDefaultUserName()
- throws Exception
- {
- AuthenticationInfo authenticationInfo = new AuthenticationInfo();
- authenticationInfo.setPassword( "secret" );
- try
- {
- getWagon().connect( new Repository( "id", getTestRepositoryUrl() ), authenticationInfo );
- fail();
- }
- catch ( AuthenticationException e )
- {
- assertEquals( System.getProperty( "user.name" ), authenticationInfo.getUserName() );
- }
- }
-
- /**
- * This is a unit test to show WAGON-265
- */
- public void testPutDirectoryCreation()
- throws Exception
- {
- setupRepositories();
-
- setupWagonTestingFixtures();
-
- Wagon wagon = getWagon();
-
- if ( wagon.supportsDirectoryCopy() )
- {
- // do the cleanup first
- File destDir = new File( getRepositoryDirectory(), "dirExists" );
- FileUtils.deleteDirectory( destDir );
- destDir.mkdirs();
- destDir = new File( destDir, "not_yet_existing/also_not" );
-
- File sourceDir = new File( getRepositoryDirectory(), "testDirectory" );
-
- FileUtils.deleteDirectory(sourceDir);
- sourceDir.mkdir();
-
- File testRes = new File( sourceDir, "test-resource-1.txt" );
- testRes.createNewFile();
-
- // This is the difference to our normal use case:
- // the directory specified in the repo string doesn't yet exist!
-
- testRepository.setUrl( testRepository.getUrl() + "/dirExists/not_yet_existing/also_not" );
-
- wagon.connect( testRepository, getAuthInfo() );
-
- wagon.putDirectory( sourceDir, "testDirectory" );
-
- destFile = FileTestUtils.createUniqueFile(getName(), getName());
-
- destFile.deleteOnExit();
-
- wagon.get( "testDirectory/test-resource-1.txt", destFile );
-
- wagon.disconnect();
- }
-
- tearDownWagonTestingFixtures();
-
-
- }
-}
+package org.apache.maven.wagon.providers.ftp;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.io.FileUtils;
+import org.apache.ftpserver.FtpServer;
+import org.apache.ftpserver.FtpServerFactory;
+import org.apache.ftpserver.ftplet.Authority;
+import org.apache.ftpserver.ftplet.UserManager;
+import org.apache.ftpserver.listener.ListenerFactory;
+import org.apache.ftpserver.usermanager.PropertiesUserManagerFactory;
+import org.apache.ftpserver.usermanager.impl.BaseUser;
+import org.apache.ftpserver.usermanager.impl.WritePermission;
+import org.apache.maven.wagon.FileTestUtils;
+import org.apache.maven.wagon.StreamingWagonTestCase;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.resource.Resource;
+
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class FtpWagonTest
+ extends StreamingWagonTestCase
+{
+ static private FtpServer server;
+
+ protected String getProtocol()
+ {
+ return "ftp";
+ }
+
+ @Override
+ protected int getTestRepositoryPort() {
+ return 10023;
+ }
+
+ protected void setupWagonTestingFixtures()
+ throws Exception
+ {
+ File ftpHomeDir = getRepositoryDirectory();
+ if ( !ftpHomeDir.exists() )
+ {
+ ftpHomeDir.mkdirs();
+ }
+
+ if (server == null)
+ {
+ FtpServerFactory serverFactory = new FtpServerFactory();
+
+ ListenerFactory factory = new ListenerFactory();
+
+ // set the port of the listener
+ factory.setPort(getTestRepositoryPort());
+
+ // replace the default listener
+ serverFactory.addListener("default", factory.createListener());
+
+ PropertiesUserManagerFactory userManagerFactory = new PropertiesUserManagerFactory();
+ UserManager um = userManagerFactory.createUserManager();
+
+ BaseUser user = new BaseUser();
+ user.setName("admin");
+ user.setPassword("admin");
+
+ List<Authority> authorities = new ArrayList<Authority>();
+ authorities.add( new WritePermission() );
+
+ user.setAuthorities( authorities );
+
+ user.setHomeDirectory( ftpHomeDir.getAbsolutePath() );
+
+
+ um.save(user);
+
+ serverFactory.setUserManager( um );
+
+ server = serverFactory.createServer();
+
+ // start the server
+ server.start();
+
+ }
+ }
+
+ protected void createDirectory( Wagon wagon, String resourceToCreate, String dirName )
+ throws Exception
+ {
+ super.createDirectory( wagon, resourceToCreate, dirName );
+
+ getRepositoryDirectory().mkdirs();
+ }
+
+ protected void tearDownWagonTestingFixtures()
+ throws Exception
+ {
+ server.stop();
+ server = null;
+ }
+
+ protected String getTestRepositoryUrl()
+ {
+ return "ftp://localhost:" + getTestRepositoryPort();
+ }
+
+ public AuthenticationInfo getAuthInfo()
+ {
+ AuthenticationInfo authInfo = new AuthenticationInfo();
+
+ authInfo.setUserName( "admin" );
+
+ authInfo.setPassword( "admin" );
+
+ return authInfo;
+ }
+
+ protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
+ {
+ File file = new File( getRepositoryDirectory(), resource.getName() );
+
+ // granularity for FTP is minutes
+ return ( file.lastModified() / 60000 ) * 60000;
+ }
+
+ private File getRepositoryDirectory()
+ {
+ return getTestFile( "target/test-output/local-repository" );
+ }
+
+ public void testNoPassword()
+ throws Exception
+ {
+ AuthenticationInfo authenticationInfo = new AuthenticationInfo();
+ authenticationInfo.setUserName( "me" );
+ try
+ {
+ getWagon().connect( new Repository( "id", getTestRepositoryUrl() ), authenticationInfo );
+ fail();
+ }
+ catch ( AuthenticationException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+ public void testDefaultUserName()
+ throws Exception
+ {
+ AuthenticationInfo authenticationInfo = new AuthenticationInfo();
+ authenticationInfo.setPassword( "secret" );
+ try
+ {
+ getWagon().connect( new Repository( "id", getTestRepositoryUrl() ), authenticationInfo );
+ fail();
+ }
+ catch ( AuthenticationException e )
+ {
+ assertEquals( System.getProperty( "user.name" ), authenticationInfo.getUserName() );
+ }
+ }
+
+ /**
+ * This is a unit test to show WAGON-265
+ */
+ public void testPutDirectoryCreation()
+ throws Exception
+ {
+ setupRepositories();
+
+ setupWagonTestingFixtures();
+
+ Wagon wagon = getWagon();
+
+ if ( wagon.supportsDirectoryCopy() )
+ {
+ // do the cleanup first
+ File destDir = new File( getRepositoryDirectory(), "dirExists" );
+ FileUtils.deleteDirectory( destDir );
+ destDir.mkdirs();
+ destDir = new File( destDir, "not_yet_existing/also_not" );
+
+ File sourceDir = new File( getRepositoryDirectory(), "testDirectory" );
+
+ FileUtils.deleteDirectory(sourceDir);
+ sourceDir.mkdir();
+
+ File testRes = new File( sourceDir, "test-resource-1.txt" );
+ testRes.createNewFile();
+
+ // This is the difference to our normal use case:
+ // the directory specified in the repo string doesn't yet exist!
+
+ testRepository.setUrl( testRepository.getUrl() + "/dirExists/not_yet_existing/also_not" );
+
+ wagon.connect( testRepository, getAuthInfo() );
+
+ wagon.putDirectory( sourceDir, "testDirectory" );
+
+ destFile = FileTestUtils.createUniqueFile(getName(), getName());
+
+ destFile.deleteOnExit();
+
+ wagon.get( "testDirectory/test-resource-1.txt", destFile );
+
+ wagon.disconnect();
+ }
+
+ tearDownWagonTestingFixtures();
+
+
+ }
+}
diff --git a/wagon-providers/wagon-ftp/src/test/resources/org/apache/maven/wagon/providers/ftp/FtpWagonTest.xml b/wagon-providers/wagon-ftp/src/test/resources/org/apache/maven/wagon/providers/ftp/FtpWagonTest.xml
index 8a47664..3b19f5a 100644
--- a/wagon-providers/wagon-ftp/src/test/resources/org/apache/maven/wagon/providers/ftp/FtpWagonTest.xml
+++ b/wagon-providers/wagon-ftp/src/test/resources/org/apache/maven/wagon/providers/ftp/FtpWagonTest.xml
@@ -1,21 +1,21 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<plexus>
-</plexus>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<plexus>
+</plexus>
diff --git a/wagon-providers/wagon-http-lightweight/pom.xml b/wagon-providers/wagon-http-lightweight/pom.xml
index 6fadf8b..4d9edae 100644
--- a/wagon-providers/wagon-http-lightweight/pom.xml
+++ b/wagon-providers/wagon-http-lightweight/pom.xml
@@ -1,51 +1,73 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-providers</artifactId>
- <version>2.10</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>wagon-http-lightweight</artifactId>
- <name>Apache Maven Wagon :: Providers :: Lightweight HTTP Provider</name>
- <description>
- Wagon provider that gets and puts artifacts through http using standard Java library
- </description>
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>wagon-http-shared</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <!-- used fo the TCK -->
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-tck-http</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-providers</artifactId>
+ <version>2.12</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>wagon-http-lightweight</artifactId>
+ <name>Apache Maven Wagon :: Providers :: Lightweight HTTP Provider</name>
+ <description>
+ Wagon provider that gets and puts artifacts through http using standard Java library
+ </description>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>wagon-http-shared</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <!-- used fo the TCK -->
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-tck-http</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty.aggregate</groupId>
+ <artifactId>jetty-all</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java b/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java
index 6ad5583..5037e7f 100644
--- a/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java
+++ b/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.java
@@ -1,464 +1,471 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.io.IOUtils;
-import org.apache.maven.wagon.ConnectionException;
-import org.apache.maven.wagon.InputData;
-import org.apache.maven.wagon.OutputData;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
-import org.apache.maven.wagon.StreamWagon;
-import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.authorization.AuthorizationException;
-import org.apache.maven.wagon.events.TransferEvent;
-import org.apache.maven.wagon.proxy.ProxyInfo;
-import org.apache.maven.wagon.resource.Resource;
-import org.apache.maven.wagon.shared.http.EncodingUtil;
-import org.apache.maven.wagon.shared.http.HtmlFileListParser;
-import org.codehaus.plexus.util.Base64;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.HttpURLConnection;
-import java.net.InetSocketAddress;
-import java.net.MalformedURLException;
-import java.net.PasswordAuthentication;
-import java.net.Proxy;
-import java.net.Proxy.Type;
-import java.net.SocketAddress;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-import java.util.zip.GZIPInputStream;
-
-/**
- * LightweightHttpWagon, using JDK's HttpURLConnection.
- *
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- * @plexus.component role="org.apache.maven.wagon.Wagon" role-hint="http" instantiation-strategy="per-lookup"
- * @see HttpURLConnection
- */
-public class LightweightHttpWagon
- extends StreamWagon
-{
- private boolean preemptiveAuthentication;
-
- private HttpURLConnection putConnection;
-
- private Proxy proxy = Proxy.NO_PROXY;
-
- public static final int MAX_REDIRECTS = 10;
-
- /**
- * Whether to use any proxy cache or not.
- *
- * @plexus.configuration default="false"
- */
- private boolean useCache;
-
- /**
- * @plexus.configuration
- */
- private Properties httpHeaders;
-
- /**
- * @plexus.requirement
- */
- private volatile LightweightHttpWagonAuthenticator authenticator;
-
- /**
- * Builds a complete URL string from the repository URL and the relative path of the resource passed.
- *
- * @param resource the resource to extract the relative path from.
- * @return the complete URL
- */
- private String buildUrl( Resource resource )
- {
- return EncodingUtil.encodeURLToString( getRepository().getUrl(), resource.getName() );
- }
-
- public void fillInputData( InputData inputData )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- Resource resource = inputData.getResource();
-
- String visitingUrl = buildUrl( resource );
- try
- {
- List<String> visitedUrls = new ArrayList<String>();
-
- for ( int redirectCount = 0; redirectCount < MAX_REDIRECTS; redirectCount++ )
- {
- if ( visitedUrls.contains( visitingUrl ) )
- {
- throw new TransferFailedException( "Cyclic http redirect detected. Aborting! " + visitingUrl );
- }
- visitedUrls.add( visitingUrl );
-
- URL url = new URL( visitingUrl );
- HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection( this.proxy );
-
- urlConnection.setRequestProperty( "Accept-Encoding", "gzip" );
- if ( !useCache )
- {
- urlConnection.setRequestProperty( "Pragma", "no-cache" );
- }
-
- addHeaders( urlConnection );
-
- // TODO: handle all response codes
- int responseCode = urlConnection.getResponseCode();
- if ( responseCode == HttpURLConnection.HTTP_FORBIDDEN
- || responseCode == HttpURLConnection.HTTP_UNAUTHORIZED )
- {
- throw new AuthorizationException( "Access denied to: " + buildUrl( resource ) );
- }
- if ( responseCode == HttpURLConnection.HTTP_MOVED_PERM
- || responseCode == HttpURLConnection.HTTP_MOVED_TEMP )
- {
- visitingUrl = urlConnection.getHeaderField( "Location" );
- continue;
- }
-
- InputStream is = urlConnection.getInputStream();
- String contentEncoding = urlConnection.getHeaderField( "Content-Encoding" );
- boolean isGZipped = contentEncoding != null && "gzip".equalsIgnoreCase( contentEncoding );
- if ( isGZipped )
- {
- is = new GZIPInputStream( is );
- }
- inputData.setInputStream( is );
- resource.setLastModified( urlConnection.getLastModified() );
- resource.setContentLength( urlConnection.getContentLength() );
- break;
- }
- }
- catch ( MalformedURLException e )
- {
- throw new ResourceDoesNotExistException( "Invalid repository URL: " + e.getMessage(), e );
- }
- catch ( FileNotFoundException e )
- {
- throw new ResourceDoesNotExistException( "Unable to locate resource in repository", e );
- }
- catch ( IOException e )
- {
- StringBuilder message = new StringBuilder( "Error transferring file: " );
- message.append( e.getMessage() );
- message.append( " from " + visitingUrl );
- if ( getProxyInfo() != null && getProxyInfo().getHost() != null )
- {
- message.append( " with proxyInfo " ).append( getProxyInfo().toString() );
- }
- throw new TransferFailedException( message.toString(), e );
- }
- }
-
- private void addHeaders( HttpURLConnection urlConnection )
- {
- if ( httpHeaders != null )
- {
- for ( Object header : httpHeaders.keySet() )
- {
- urlConnection.setRequestProperty( (String) header, httpHeaders.getProperty( (String) header ) );
- }
- }
- setAuthorization( urlConnection );
- }
-
- private void setAuthorization( HttpURLConnection urlConnection )
- {
- if ( preemptiveAuthentication && authenticationInfo != null && authenticationInfo.getUserName() != null )
- {
- String credentials = authenticationInfo.getUserName() + ":" + authenticationInfo.getPassword();
- String encoded = new String( Base64.encodeBase64( credentials.getBytes() ) );
- urlConnection.setRequestProperty( "Authorization", "Basic " + encoded );
- }
- }
-
- public void fillOutputData( OutputData outputData )
- throws TransferFailedException
- {
- Resource resource = outputData.getResource();
- try
- {
- URL url = new URL( buildUrl( resource ) );
- putConnection = (HttpURLConnection) url.openConnection( this.proxy );
-
- addHeaders( putConnection );
-
- putConnection.setRequestMethod( "PUT" );
- putConnection.setDoOutput( true );
- outputData.setOutputStream( putConnection.getOutputStream() );
- }
- catch ( IOException e )
- {
- throw new TransferFailedException( "Error transferring file: " + e.getMessage(), e );
- }
- }
-
- protected void finishPutTransfer( Resource resource, InputStream input, OutputStream output )
- throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
- {
- try
- {
- int statusCode = putConnection.getResponseCode();
-
- switch ( statusCode )
- {
- // Success Codes
- case HttpURLConnection.HTTP_OK: // 200
- case HttpURLConnection.HTTP_CREATED: // 201
- case HttpURLConnection.HTTP_ACCEPTED: // 202
- case HttpURLConnection.HTTP_NO_CONTENT: // 204
- break;
-
- case HttpURLConnection.HTTP_FORBIDDEN:
- throw new AuthorizationException( "Access denied to: " + buildUrl( resource ) );
-
- case HttpURLConnection.HTTP_NOT_FOUND:
- throw new ResourceDoesNotExistException( "File: " + buildUrl( resource ) + " does not exist" );
-
- // add more entries here
- default:
- throw new TransferFailedException(
- "Failed to transfer file: " + buildUrl( resource ) + ". Return code is: " + statusCode );
- }
- }
- catch ( IOException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
-
- throw new TransferFailedException( "Error transferring file: " + e.getMessage(), e );
- }
- }
-
- protected void openConnectionInternal()
- throws ConnectionException, AuthenticationException
- {
- final ProxyInfo proxyInfo = getProxyInfo( "http", getRepository().getHost() );
- if ( proxyInfo != null )
- {
- this.proxy = getProxy( proxyInfo );
- this.proxyInfo = proxyInfo;
- }
- authenticator.setWagon( this );
-
- boolean usePreemptiveAuthentication =
- Boolean.getBoolean( "maven.wagon.http.preemptiveAuthentication" ) || Boolean.parseBoolean(
- repository.getParameter( "preemptiveAuthentication" ) ) || this.preemptiveAuthentication;
-
- setPreemptiveAuthentication( usePreemptiveAuthentication );
- }
-
- @SuppressWarnings( "deprecation" )
- public PasswordAuthentication requestProxyAuthentication()
- {
- if ( proxyInfo != null && proxyInfo.getUserName() != null )
- {
- String password = "";
- if ( proxyInfo.getPassword() != null )
- {
- password = proxyInfo.getPassword();
- }
- return new PasswordAuthentication( proxyInfo.getUserName(), password.toCharArray() );
- }
- return null;
- }
-
- public PasswordAuthentication requestServerAuthentication()
- {
- if ( authenticationInfo != null && authenticationInfo.getUserName() != null )
- {
- String password = "";
- if ( authenticationInfo.getPassword() != null )
- {
- password = authenticationInfo.getPassword();
- }
- return new PasswordAuthentication( authenticationInfo.getUserName(), password.toCharArray() );
- }
- return null;
- }
-
- private Proxy getProxy( ProxyInfo proxyInfo )
- {
- return new Proxy( getProxyType( proxyInfo ), getSocketAddress( proxyInfo ) );
- }
-
- private Type getProxyType( ProxyInfo proxyInfo )
- {
- if ( ProxyInfo.PROXY_SOCKS4.equals( proxyInfo.getType() ) || ProxyInfo.PROXY_SOCKS5.equals(
- proxyInfo.getType() ) )
- {
- return Type.SOCKS;
- }
- else
- {
- return Type.HTTP;
- }
- }
-
- public SocketAddress getSocketAddress( ProxyInfo proxyInfo )
- {
- return InetSocketAddress.createUnresolved( proxyInfo.getHost(), proxyInfo.getPort() );
- }
-
- public void closeConnection()
- throws ConnectionException
- {
- //FIXME WAGON-375 use persistent connection feature provided by the jdk
- if ( putConnection != null )
- {
- putConnection.disconnect();
- }
- authenticator.resetWagon();
- }
-
- public List<String> getFileList( String destinationDirectory )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- InputData inputData = new InputData();
-
- if ( destinationDirectory.length() > 0 && !destinationDirectory.endsWith( "/" ) )
- {
- destinationDirectory += "/";
- }
-
- String url = buildUrl( new Resource( destinationDirectory ) );
-
- Resource resource = new Resource( destinationDirectory );
-
- inputData.setResource( resource );
-
- fillInputData( inputData );
-
- InputStream is = inputData.getInputStream();
-
- try
- {
-
- if ( is == null )
- {
- throw new TransferFailedException(
- url + " - Could not open input stream for resource: '" + resource + "'" );
- }
-
- return HtmlFileListParser.parseFileList( url, is );
- }
- finally
- {
- IOUtils.closeQuietly( is );
- }
- }
-
- public boolean resourceExists( String resourceName )
- throws TransferFailedException, AuthorizationException
- {
- HttpURLConnection headConnection;
-
- try
- {
- Resource resource = new Resource( resourceName );
- URL url = new URL( buildUrl( resource ) );
- headConnection = (HttpURLConnection) url.openConnection( this.proxy );
-
- addHeaders( headConnection );
-
- headConnection.setRequestMethod( "HEAD" );
- headConnection.setDoOutput( true );
-
- int statusCode = headConnection.getResponseCode();
-
- switch ( statusCode )
- {
- case HttpURLConnection.HTTP_OK:
- return true;
-
- case HttpURLConnection.HTTP_FORBIDDEN:
- throw new AuthorizationException( "Access denied to: " + url );
-
- case HttpURLConnection.HTTP_NOT_FOUND:
- return false;
-
- case HttpURLConnection.HTTP_UNAUTHORIZED:
- throw new AuthorizationException( "Access denied to: " + url );
-
- default:
- throw new TransferFailedException(
- "Failed to look for file: " + buildUrl( resource ) + ". Return code is: " + statusCode );
- }
- }
- catch ( IOException e )
- {
- throw new TransferFailedException( "Error transferring file: " + e.getMessage(), e );
- }
- }
-
- public boolean isUseCache()
- {
- return useCache;
- }
-
- public void setUseCache( boolean useCache )
- {
- this.useCache = useCache;
- }
-
- public Properties getHttpHeaders()
- {
- return httpHeaders;
- }
-
- public void setHttpHeaders( Properties httpHeaders )
- {
- this.httpHeaders = httpHeaders;
- }
-
- void setSystemProperty( String key, String value )
- {
- if ( value != null )
- {
- System.setProperty( key, value );
- }
- else
- {
- System.getProperties().remove( key );
- }
- }
-
- public void setPreemptiveAuthentication( boolean preemptiveAuthentication )
- {
- this.preemptiveAuthentication = preemptiveAuthentication;
- }
-
- public LightweightHttpWagonAuthenticator getAuthenticator()
- {
- return authenticator;
- }
-
- public void setAuthenticator( LightweightHttpWagonAuthenticator authenticator )
- {
- this.authenticator = authenticator;
- }
-}
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.io.IOUtils;
+import org.apache.maven.wagon.ConnectionException;
+import org.apache.maven.wagon.InputData;
+import org.apache.maven.wagon.OutputData;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.StreamWagon;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.proxy.ProxyInfo;
+import org.apache.maven.wagon.resource.Resource;
+import org.apache.maven.wagon.shared.http.EncodingUtil;
+import org.apache.maven.wagon.shared.http.HtmlFileListParser;
+import org.codehaus.plexus.util.Base64;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.InetSocketAddress;
+import java.net.MalformedURLException;
+import java.net.PasswordAuthentication;
+import java.net.Proxy;
+import java.net.Proxy.Type;
+import java.net.SocketAddress;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+import java.util.zip.GZIPInputStream;
+
+/**
+ * LightweightHttpWagon, using JDK's HttpURLConnection.
+ *
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ * @plexus.component role="org.apache.maven.wagon.Wagon" role-hint="http" instantiation-strategy="per-lookup"
+ * @see HttpURLConnection
+ */
+public class LightweightHttpWagon
+ extends StreamWagon
+{
+ private boolean preemptiveAuthentication;
+
+ private HttpURLConnection putConnection;
+
+ private Proxy proxy = Proxy.NO_PROXY;
+
+ public static final int MAX_REDIRECTS = 10;
+
+ /**
+ * Whether to use any proxy cache or not.
+ *
+ * @plexus.configuration default="false"
+ */
+ private boolean useCache;
+
+ /**
+ * @plexus.configuration
+ */
+ private Properties httpHeaders;
+
+ /**
+ * @plexus.requirement
+ */
+ private volatile LightweightHttpWagonAuthenticator authenticator;
+
+ /**
+ * Builds a complete URL string from the repository URL and the relative path of the resource passed.
+ *
+ * @param resource the resource to extract the relative path from.
+ * @return the complete URL
+ */
+ private String buildUrl( Resource resource )
+ {
+ return EncodingUtil.encodeURLToString( getRepository().getUrl(), resource.getName() );
+ }
+
+ public void fillInputData( InputData inputData )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ Resource resource = inputData.getResource();
+
+ String visitingUrl = buildUrl( resource );
+ try
+ {
+ List<String> visitedUrls = new ArrayList<String>();
+
+ for ( int redirectCount = 0; redirectCount < MAX_REDIRECTS; redirectCount++ )
+ {
+ if ( visitedUrls.contains( visitingUrl ) )
+ {
+ throw new TransferFailedException( "Cyclic http redirect detected. Aborting! " + visitingUrl );
+ }
+ visitedUrls.add( visitingUrl );
+
+ URL url = new URL( visitingUrl );
+ HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection( this.proxy );
+
+ urlConnection.setRequestProperty( "Accept-Encoding", "gzip" );
+ if ( !useCache )
+ {
+ urlConnection.setRequestProperty( "Pragma", "no-cache" );
+ }
+
+ addHeaders( urlConnection );
+
+ // TODO: handle all response codes
+ int responseCode = urlConnection.getResponseCode();
+ if ( responseCode == HttpURLConnection.HTTP_FORBIDDEN
+ || responseCode == HttpURLConnection.HTTP_UNAUTHORIZED )
+ {
+ throw new AuthorizationException( "Access denied to: " + buildUrl( resource ) );
+ }
+ if ( responseCode == HttpURLConnection.HTTP_MOVED_PERM
+ || responseCode == HttpURLConnection.HTTP_MOVED_TEMP )
+ {
+ visitingUrl = urlConnection.getHeaderField( "Location" );
+ continue;
+ }
+
+ InputStream is = urlConnection.getInputStream();
+ String contentEncoding = urlConnection.getHeaderField( "Content-Encoding" );
+ boolean isGZipped = contentEncoding != null && "gzip".equalsIgnoreCase( contentEncoding );
+ if ( isGZipped )
+ {
+ is = new GZIPInputStream( is );
+ }
+ inputData.setInputStream( is );
+ resource.setLastModified( urlConnection.getLastModified() );
+ resource.setContentLength( urlConnection.getContentLength() );
+ break;
+ }
+ }
+ catch ( MalformedURLException e )
+ {
+ throw new ResourceDoesNotExistException( "Invalid repository URL: " + e.getMessage(), e );
+ }
+ catch ( FileNotFoundException e )
+ {
+ throw new ResourceDoesNotExistException( "Unable to locate resource in repository", e );
+ }
+ catch ( IOException e )
+ {
+ StringBuilder message = new StringBuilder( "Error transferring file: " );
+ message.append( e.getMessage() );
+ message.append( " from " + visitingUrl );
+ if ( getProxyInfo() != null && getProxyInfo().getHost() != null )
+ {
+ message.append( " with proxyInfo " ).append( getProxyInfo().toString() );
+ }
+ throw new TransferFailedException( message.toString(), e );
+ }
+ }
+
+ private void addHeaders( HttpURLConnection urlConnection )
+ {
+ if ( httpHeaders != null )
+ {
+ for ( Object header : httpHeaders.keySet() )
+ {
+ urlConnection.setRequestProperty( (String) header, httpHeaders.getProperty( (String) header ) );
+ }
+ }
+ setAuthorization( urlConnection );
+ }
+
+ private void setAuthorization( HttpURLConnection urlConnection )
+ {
+ if ( preemptiveAuthentication && authenticationInfo != null && authenticationInfo.getUserName() != null )
+ {
+ String credentials = authenticationInfo.getUserName() + ":" + authenticationInfo.getPassword();
+ String encoded = new String( Base64.encodeBase64( credentials.getBytes() ) );
+ urlConnection.setRequestProperty( "Authorization", "Basic " + encoded );
+ }
+ }
+
+ public void fillOutputData( OutputData outputData )
+ throws TransferFailedException
+ {
+ Resource resource = outputData.getResource();
+ try
+ {
+ URL url = new URL( buildUrl( resource ) );
+ putConnection = (HttpURLConnection) url.openConnection( this.proxy );
+
+ addHeaders( putConnection );
+
+ putConnection.setRequestMethod( "PUT" );
+ putConnection.setDoOutput( true );
+ outputData.setOutputStream( putConnection.getOutputStream() );
+ }
+ catch ( IOException e )
+ {
+ throw new TransferFailedException( "Error transferring file: " + e.getMessage(), e );
+ }
+ }
+
+ protected void finishPutTransfer( Resource resource, InputStream input, OutputStream output )
+ throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
+ {
+ try
+ {
+ int statusCode = putConnection.getResponseCode();
+
+ switch ( statusCode )
+ {
+ // Success Codes
+ case HttpURLConnection.HTTP_OK: // 200
+ case HttpURLConnection.HTTP_CREATED: // 201
+ case HttpURLConnection.HTTP_ACCEPTED: // 202
+ case HttpURLConnection.HTTP_NO_CONTENT: // 204
+ break;
+
+ case HttpURLConnection.HTTP_FORBIDDEN:
+ throw new AuthorizationException( "Access denied to: " + buildUrl( resource ) );
+
+ case HttpURLConnection.HTTP_NOT_FOUND:
+ throw new ResourceDoesNotExistException( "File: " + buildUrl( resource ) + " does not exist" );
+
+ // add more entries here
+ default:
+ throw new TransferFailedException(
+ "Failed to transfer file: " + buildUrl( resource ) + ". Return code is: " + statusCode );
+ }
+ }
+ catch ( IOException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
+ throw new TransferFailedException( "Error transferring file: " + e.getMessage(), e );
+ }
+ }
+
+ protected void openConnectionInternal()
+ throws ConnectionException, AuthenticationException
+ {
+ final ProxyInfo proxyInfo = getProxyInfo( "http", getRepository().getHost() );
+ if ( proxyInfo != null )
+ {
+ this.proxy = getProxy( proxyInfo );
+ this.proxyInfo = proxyInfo;
+ }
+ authenticator.setWagon( this );
+
+ boolean usePreemptiveAuthentication =
+ Boolean.getBoolean( "maven.wagon.http.preemptiveAuthentication" ) || Boolean.parseBoolean(
+ repository.getParameter( "preemptiveAuthentication" ) ) || this.preemptiveAuthentication;
+
+ setPreemptiveAuthentication( usePreemptiveAuthentication );
+ }
+
+ @SuppressWarnings( "deprecation" )
+ public PasswordAuthentication requestProxyAuthentication()
+ {
+ if ( proxyInfo != null && proxyInfo.getUserName() != null )
+ {
+ String password = "";
+ if ( proxyInfo.getPassword() != null )
+ {
+ password = proxyInfo.getPassword();
+ }
+ return new PasswordAuthentication( proxyInfo.getUserName(), password.toCharArray() );
+ }
+ return null;
+ }
+
+ public PasswordAuthentication requestServerAuthentication()
+ {
+ if ( authenticationInfo != null && authenticationInfo.getUserName() != null )
+ {
+ String password = "";
+ if ( authenticationInfo.getPassword() != null )
+ {
+ password = authenticationInfo.getPassword();
+ }
+ return new PasswordAuthentication( authenticationInfo.getUserName(), password.toCharArray() );
+ }
+ return null;
+ }
+
+ private Proxy getProxy( ProxyInfo proxyInfo )
+ {
+ return new Proxy( getProxyType( proxyInfo ), getSocketAddress( proxyInfo ) );
+ }
+
+ private Type getProxyType( ProxyInfo proxyInfo )
+ {
+ if ( ProxyInfo.PROXY_SOCKS4.equals( proxyInfo.getType() ) || ProxyInfo.PROXY_SOCKS5.equals(
+ proxyInfo.getType() ) )
+ {
+ return Type.SOCKS;
+ }
+ else
+ {
+ return Type.HTTP;
+ }
+ }
+
+ public SocketAddress getSocketAddress( ProxyInfo proxyInfo )
+ {
+ return InetSocketAddress.createUnresolved( proxyInfo.getHost(), proxyInfo.getPort() );
+ }
+
+ public void closeConnection()
+ throws ConnectionException
+ {
+ //FIXME WAGON-375 use persistent connection feature provided by the jdk
+ if ( putConnection != null )
+ {
+ putConnection.disconnect();
+ }
+ authenticator.resetWagon();
+ }
+
+ public List<String> getFileList( String destinationDirectory )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ InputData inputData = new InputData();
+
+ if ( destinationDirectory.length() > 0 && !destinationDirectory.endsWith( "/" ) )
+ {
+ destinationDirectory += "/";
+ }
+
+ String url = buildUrl( new Resource( destinationDirectory ) );
+
+ Resource resource = new Resource( destinationDirectory );
+
+ inputData.setResource( resource );
+
+ fillInputData( inputData );
+
+ InputStream is = inputData.getInputStream();
+
+ try
+ {
+
+ if ( is == null )
+ {
+ throw new TransferFailedException(
+ url + " - Could not open input stream for resource: '" + resource + "'" );
+ }
+
+ final List<String> htmlFileList = HtmlFileListParser.parseFileList( url, is );
+ is.close();
+ is = null;
+ return htmlFileList;
+ }
+ catch ( final IOException e )
+ {
+ throw new TransferFailedException( "Failure transferring " + resource.getName(), e );
+ }
+ finally
+ {
+ IOUtils.closeQuietly( is );
+ }
+ }
+
+ public boolean resourceExists( String resourceName )
+ throws TransferFailedException, AuthorizationException
+ {
+ HttpURLConnection headConnection;
+
+ try
+ {
+ Resource resource = new Resource( resourceName );
+ URL url = new URL( buildUrl( resource ) );
+ headConnection = (HttpURLConnection) url.openConnection( this.proxy );
+
+ addHeaders( headConnection );
+
+ headConnection.setRequestMethod( "HEAD" );
+ headConnection.setDoOutput( true );
+
+ int statusCode = headConnection.getResponseCode();
+
+ switch ( statusCode )
+ {
+ case HttpURLConnection.HTTP_OK:
+ return true;
+
+ case HttpURLConnection.HTTP_FORBIDDEN:
+ throw new AuthorizationException( "Access denied to: " + url );
+
+ case HttpURLConnection.HTTP_NOT_FOUND:
+ return false;
+
+ case HttpURLConnection.HTTP_UNAUTHORIZED:
+ throw new AuthorizationException( "Access denied to: " + url );
+
+ default:
+ throw new TransferFailedException(
+ "Failed to look for file: " + buildUrl( resource ) + ". Return code is: " + statusCode );
+ }
+ }
+ catch ( IOException e )
+ {
+ throw new TransferFailedException( "Error transferring file: " + e.getMessage(), e );
+ }
+ }
+
+ public boolean isUseCache()
+ {
+ return useCache;
+ }
+
+ public void setUseCache( boolean useCache )
+ {
+ this.useCache = useCache;
+ }
+
+ public Properties getHttpHeaders()
+ {
+ return httpHeaders;
+ }
+
+ public void setHttpHeaders( Properties httpHeaders )
+ {
+ this.httpHeaders = httpHeaders;
+ }
+
+ void setSystemProperty( String key, String value )
+ {
+ if ( value != null )
+ {
+ System.setProperty( key, value );
+ }
+ else
+ {
+ System.getProperties().remove( key );
+ }
+ }
+
+ public void setPreemptiveAuthentication( boolean preemptiveAuthentication )
+ {
+ this.preemptiveAuthentication = preemptiveAuthentication;
+ }
+
+ public LightweightHttpWagonAuthenticator getAuthenticator()
+ {
+ return authenticator;
+ }
+
+ public void setAuthenticator( LightweightHttpWagonAuthenticator authenticator )
+ {
+ this.authenticator = authenticator;
+ }
+}
diff --git a/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonAuthenticator.java b/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonAuthenticator.java
index d5d02bf..3f2b86c 100644
--- a/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonAuthenticator.java
+++ b/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonAuthenticator.java
@@ -1,61 +1,61 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.net.Authenticator;
-import java.net.PasswordAuthentication;
-
-/**
- * @author <a href="mailto:nicolas.deloof at cloudbees.com">Nicolas De loof</a>
- * @plexus.component role="org.apache.maven.wagon.providers.http.LightweightHttpWagonAuthenticator"
- */
-public class LightweightHttpWagonAuthenticator
- extends Authenticator
-{
- ThreadLocal<LightweightHttpWagon> localWagon = new ThreadLocal<LightweightHttpWagon>();
-
- protected PasswordAuthentication getPasswordAuthentication()
- {
- LightweightHttpWagon wagon = localWagon.get();
- if ( wagon != null )
- {
- if ( getRequestorType() == RequestorType.PROXY )
- {
- return wagon.requestProxyAuthentication();
- }
- else
- {
- return wagon.requestServerAuthentication();
- }
- }
- return null;
- }
-
- public void setWagon( LightweightHttpWagon wagon )
- {
- localWagon.set( wagon );
- Authenticator.setDefault( this );
- }
-
- public void resetWagon()
- {
- localWagon.remove();
- }
-}
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.net.Authenticator;
+import java.net.PasswordAuthentication;
+
+/**
+ * @author <a href="mailto:nicolas.deloof at cloudbees.com">Nicolas De loof</a>
+ * @plexus.component role="org.apache.maven.wagon.providers.http.LightweightHttpWagonAuthenticator"
+ */
+public class LightweightHttpWagonAuthenticator
+ extends Authenticator
+{
+ ThreadLocal<LightweightHttpWagon> localWagon = new ThreadLocal<LightweightHttpWagon>();
+
+ protected PasswordAuthentication getPasswordAuthentication()
+ {
+ LightweightHttpWagon wagon = localWagon.get();
+ if ( wagon != null )
+ {
+ if ( getRequestorType() == RequestorType.PROXY )
+ {
+ return wagon.requestProxyAuthentication();
+ }
+ else
+ {
+ return wagon.requestServerAuthentication();
+ }
+ }
+ return null;
+ }
+
+ public void setWagon( LightweightHttpWagon wagon )
+ {
+ localWagon.set( wagon );
+ Authenticator.setDefault( this );
+ }
+
+ public void resetWagon()
+ {
+ localWagon.remove();
+ }
+}
diff --git a/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpsWagon.java b/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpsWagon.java
index 686b8b8..c524403 100644
--- a/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpsWagon.java
+++ b/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpsWagon.java
@@ -1,82 +1,82 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.ConnectionException;
-import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.proxy.ProxyInfo;
-
-/**
- * LightweightHttpsWagon, using JDK's HttpURLConnection.
- *
- * @author <a href="mailto:joakim at erdfelt.com">Joakim Erdfelt</a>
- *
- *
- * @plexus.component role="org.apache.maven.wagon.Wagon"
- * role-hint="https"
- * instantiation-strategy="per-lookup"
- */
-public class LightweightHttpsWagon
- extends LightweightHttpWagon
-{
- private String previousHttpsProxyHost;
-
- private String previousHttpsProxyPort;
-
- private String previousHttpsProxyExclusions;
-
- public LightweightHttpsWagon()
- {
- super();
- }
-
- public void openConnection()
- throws ConnectionException, AuthenticationException
- {
- previousHttpsProxyHost = System.getProperty( "https.proxyHost" );
- previousHttpsProxyPort = System.getProperty( "https.proxyPort" );
- previousHttpsProxyExclusions = System.getProperty( "https.nonProxyHosts" );
-
- final ProxyInfo proxyInfo = getProxyInfo( "https", getRepository().getHost() );
- if ( proxyInfo != null )
- {
- setSystemProperty( "https.proxyHost", proxyInfo.getHost() );
- setSystemProperty( "https.proxyPort", String.valueOf( proxyInfo.getPort() ) );
- setSystemProperty( "https.nonProxyHosts", proxyInfo.getNonProxyHosts() );
- }
- else
- {
- setSystemProperty( "https.proxyHost", null );
- setSystemProperty( "https.proxyPort", null );
- }
-
- super.openConnection();
- }
-
- public void closeConnection()
- throws ConnectionException
- {
- super.closeConnection();
-
- setSystemProperty( "https.proxyHost", previousHttpsProxyHost );
- setSystemProperty( "https.proxyPort", previousHttpsProxyPort );
- setSystemProperty( "https.nonProxyHosts", previousHttpsProxyExclusions );
- }
-}
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.ConnectionException;
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.proxy.ProxyInfo;
+
+/**
+ * LightweightHttpsWagon, using JDK's HttpURLConnection.
+ *
+ * @author <a href="mailto:joakim at erdfelt.com">Joakim Erdfelt</a>
+ *
+ *
+ * @plexus.component role="org.apache.maven.wagon.Wagon"
+ * role-hint="https"
+ * instantiation-strategy="per-lookup"
+ */
+public class LightweightHttpsWagon
+ extends LightweightHttpWagon
+{
+ private String previousHttpsProxyHost;
+
+ private String previousHttpsProxyPort;
+
+ private String previousHttpsProxyExclusions;
+
+ public LightweightHttpsWagon()
+ {
+ super();
+ }
+
+ public void openConnection()
+ throws ConnectionException, AuthenticationException
+ {
+ previousHttpsProxyHost = System.getProperty( "https.proxyHost" );
+ previousHttpsProxyPort = System.getProperty( "https.proxyPort" );
+ previousHttpsProxyExclusions = System.getProperty( "https.nonProxyHosts" );
+
+ final ProxyInfo proxyInfo = getProxyInfo( "https", getRepository().getHost() );
+ if ( proxyInfo != null )
+ {
+ setSystemProperty( "https.proxyHost", proxyInfo.getHost() );
+ setSystemProperty( "https.proxyPort", String.valueOf( proxyInfo.getPort() ) );
+ setSystemProperty( "https.nonProxyHosts", proxyInfo.getNonProxyHosts() );
+ }
+ else
+ {
+ setSystemProperty( "https.proxyHost", null );
+ setSystemProperty( "https.proxyPort", null );
+ }
+
+ super.openConnection();
+ }
+
+ public void closeConnection()
+ throws ConnectionException
+ {
+ super.closeConnection();
+
+ setSystemProperty( "https.proxyHost", previousHttpsProxyHost );
+ setSystemProperty( "https.proxyPort", previousHttpsProxyPort );
+ setSystemProperty( "https.nonProxyHosts", previousHttpsProxyExclusions );
+ }
+}
diff --git a/wagon-providers/wagon-http-lightweight/src/site/apt/index.apt b/wagon-providers/wagon-http-lightweight/src/site/apt/index.apt
index 3a123b3..39963c3 100644
--- a/wagon-providers/wagon-http-lightweight/src/site/apt/index.apt
+++ b/wagon-providers/wagon-http-lightweight/src/site/apt/index.apt
@@ -1,45 +1,45 @@
- ------
- Maven Wagon HTTP lightweight
- ------
- Carlos Sanchez
- ------
- 2011-09-20
- ------
-
- ~~ Licensed to the Apache Software Foundation (ASF) under one
- ~~ or more contributor license agreements. See the NOTICE file
- ~~ distributed with this work for additional information
- ~~ regarding copyright ownership. The ASF licenses this file
- ~~ to you under the Apache License, Version 2.0 (the
- ~~ "License"); you may not use this file except in compliance
- ~~ with the License. You may obtain a copy of the License at
- ~~
- ~~ http://www.apache.org/licenses/LICENSE-2.0
- ~~
- ~~ Unless required by applicable law or agreed to in writing,
- ~~ software distributed under the License is distributed on an
- ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~~ KIND, either express or implied. See the License for the
- ~~ specific language governing permissions and limitations
- ~~ under the License.
-
- ~~ NOTE: For help with the syntax of this file, see:
- ~~ http://maven.apache.org/doxia/references/apt-format.html
-
-Maven Wagon HTTP lightweight
-
- This component is an implementation of Wagon provider for HTTP access.
- It uses standard JDK classes as lower lever layer.
-
- It enables Maven to use remote repositories stored in HTTP servers.
-
-
-Features
-
- * Get files from HTTP/HTTPS Server
-
- * Put files to HTTP/HTTPS Server
-
-Known Limitation
-
- The main limitation is that you can't download data that doesn't fit entirely into memory.
+ ------
+ Maven Wagon HTTP lightweight
+ ------
+ Carlos Sanchez
+ ------
+ 2011-09-20
+ ------
+
+ ~~ Licensed to the Apache Software Foundation (ASF) under one
+ ~~ or more contributor license agreements. See the NOTICE file
+ ~~ distributed with this work for additional information
+ ~~ regarding copyright ownership. The ASF licenses this file
+ ~~ to you under the Apache License, Version 2.0 (the
+ ~~ "License"); you may not use this file except in compliance
+ ~~ with the License. You may obtain a copy of the License at
+ ~~
+ ~~ http://www.apache.org/licenses/LICENSE-2.0
+ ~~
+ ~~ Unless required by applicable law or agreed to in writing,
+ ~~ software distributed under the License is distributed on an
+ ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~~ KIND, either express or implied. See the License for the
+ ~~ specific language governing permissions and limitations
+ ~~ under the License.
+
+ ~~ NOTE: For help with the syntax of this file, see:
+ ~~ http://maven.apache.org/doxia/references/apt-format.html
+
+Maven Wagon HTTP lightweight
+
+ This component is an implementation of Wagon provider for HTTP access.
+ It uses standard JDK classes as lower lever layer.
+
+ It enables Maven to use remote repositories stored in HTTP servers.
+
+
+Features
+
+ * Get files from HTTP/HTTPS Server
+
+ * Put files to HTTP/HTTPS Server
+
+Known Limitation
+
+ The main limitation is that you can't download data that doesn't fit entirely into memory.
diff --git a/wagon-providers/wagon-http-lightweight/src/site/site.xml b/wagon-providers/wagon-http-lightweight/src/site/site.xml
index cefad33..58dec3e 100644
--- a/wagon-providers/wagon-http-lightweight/src/site/site.xml
+++ b/wagon-providers/wagon-http-lightweight/src/site/site.xml
@@ -1,33 +1,33 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
- <body>
- <breadcrumbs>
- <item name="Lightweight HTTP" href="http://maven.apache.org/wagon/wagon-providers/wagon-http-lightweight/index.html" />
- </breadcrumbs>
-
- <menu ref="parent"/>
- <menu ref="reports"/>
- </body>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
+ <body>
+ <breadcrumbs>
+ <item name="Lightweight HTTP" href="http://maven.apache.org/wagon/wagon-providers/wagon-http-lightweight/index.html" />
+ </breadcrumbs>
+
+ <menu ref="parent"/>
+ <menu ref="reports"/>
+ </body>
</project>
\ No newline at end of file
diff --git a/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java b/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java
index 06929c4..20f688b 100644
--- a/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java
+++ b/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.java
@@ -1,66 +1,66 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.StreamingWagon;
-import org.apache.maven.wagon.http.HttpWagonTestCase;
-
-import java.util.Properties;
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class LightweightHttpWagonTest
- extends HttpWagonTestCase
-{
- protected String getProtocol()
- {
- return "http";
- }
-
- protected String getTestRepositoryUrl()
- {
- return getProtocol() + "://localhost:" + getTestRepositoryPort() + "/";
- }
-
- protected void setHttpHeaders( StreamingWagon wagon, Properties properties )
- {
- ( (LightweightHttpWagon) wagon ).setHttpHeaders( properties );
- }
-
- @Override
- protected boolean supportPreemptiveAuthenticationGet()
- {
- return false;
- }
-
- @Override
- protected boolean supportPreemptiveAuthenticationPut()
- {
- return false;
- }
-
- @Override
- protected boolean supportProxyPreemptiveAuthentication()
- {
- return false;
- }
-}
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.StreamingWagon;
+import org.apache.maven.wagon.http.HttpWagonTestCase;
+
+import java.util.Properties;
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class LightweightHttpWagonTest
+ extends HttpWagonTestCase
+{
+ protected String getProtocol()
+ {
+ return "http";
+ }
+
+ protected String getTestRepositoryUrl()
+ {
+ return getProtocol() + "://localhost:" + getTestRepositoryPort() + "/";
+ }
+
+ protected void setHttpHeaders( StreamingWagon wagon, Properties properties )
+ {
+ ( (LightweightHttpWagon) wagon ).setHttpHeaders( properties );
+ }
+
+ @Override
+ protected boolean supportPreemptiveAuthenticationGet()
+ {
+ return false;
+ }
+
+ @Override
+ protected boolean supportPreemptiveAuthenticationPut()
+ {
+ return false;
+ }
+
+ @Override
+ protected boolean supportProxyPreemptiveAuthentication()
+ {
+ return false;
+ }
+}
diff --git a/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonWithPreemptiveAuthenticationTest.java b/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonWithPreemptiveAuthenticationTest.java
index 1c86648..3694ad0 100644
--- a/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonWithPreemptiveAuthenticationTest.java
+++ b/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonWithPreemptiveAuthenticationTest.java
@@ -1,51 +1,51 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.Wagon;
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class LightweightHttpWagonWithPreemptiveAuthenticationTest
- extends LightweightHttpWagonTest
-{
- @Override
- protected Wagon getWagon()
- throws Exception
- {
- LightweightHttpWagon wagon = (LightweightHttpWagon) super.getWagon();
- wagon.setPreemptiveAuthentication( true );
- return wagon;
- }
-
- @Override
- protected boolean supportPreemptiveAuthenticationGet()
- {
- return true;
- }
-
- @Override
- protected boolean supportPreemptiveAuthenticationPut()
- {
- return true;
- }
-}
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.Wagon;
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class LightweightHttpWagonWithPreemptiveAuthenticationTest
+ extends LightweightHttpWagonTest
+{
+ @Override
+ protected Wagon getWagon()
+ throws Exception
+ {
+ LightweightHttpWagon wagon = (LightweightHttpWagon) super.getWagon();
+ wagon.setPreemptiveAuthentication( true );
+ return wagon;
+ }
+
+ @Override
+ protected boolean supportPreemptiveAuthenticationGet()
+ {
+ return true;
+ }
+
+ @Override
+ protected boolean supportPreemptiveAuthenticationPut()
+ {
+ return true;
+ }
+}
diff --git a/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpsWagonTest.java b/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpsWagonTest.java
index 3b532eb..e31f85c 100644
--- a/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpsWagonTest.java
+++ b/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpsWagonTest.java
@@ -1,54 +1,54 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.mortbay.jetty.Connector;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.security.SslSocketConnector;
-
-public class LightweightHttpsWagonTest
- extends LightweightHttpWagonTest
-{
- protected String getProtocol()
- {
- return "https";
- }
-
- protected void addConnectors( Server server )
- {
- System.setProperty( "javax.net.ssl.trustStore",
- getTestFile( "src/test/resources/ssl/keystore" ).getAbsolutePath() );
-
- SslSocketConnector connector = new SslSocketConnector();
- connector.setPort( server.getConnectors()[0].getPort() );
- connector.setKeystore( getTestPath( "src/test/resources/ssl/keystore" ) );
- connector.setPassword( "wagonhttp" );
- connector.setKeyPassword( "wagonhttp" );
- connector.setTruststore( getTestPath( "src/test/resources/ssl/keystore" ) );
- connector.setTrustPassword( "wagonhttp" );
- server.setConnectors( new Connector[] { connector } );
- }
-
- @Override
- protected boolean assertOnTransferProgress()
- {
- return false;
- }
-}
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.ssl.SslSocketConnector;
+
+public class LightweightHttpsWagonTest
+ extends LightweightHttpWagonTest
+{
+ protected String getProtocol()
+ {
+ return "https";
+ }
+
+ protected void addConnectors( Server server )
+ {
+ System.setProperty( "javax.net.ssl.trustStore",
+ getTestFile( "src/test/resources/ssl/keystore" ).getAbsolutePath() );
+
+ SslSocketConnector connector = new SslSocketConnector();
+ connector.setPort( server.getConnectors()[0].getPort() );
+ connector.setKeystore( getTestPath( "src/test/resources/ssl/keystore" ) );
+ connector.setPassword( "wagonhttp" );
+ connector.setKeyPassword( "wagonhttp" );
+ connector.setTruststore( getTestPath( "src/test/resources/ssl/keystore" ) );
+ connector.setTrustPassword( "wagonhttp" );
+ server.setConnectors( new Connector[] { connector } );
+ }
+
+ @Override
+ protected boolean assertOnTransferProgress()
+ {
+ return false;
+ }
+}
diff --git a/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/TckTest.java b/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/TckTest.java
index 8342f40..b3f6b6c 100644
--- a/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/TckTest.java
+++ b/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/TckTest.java
@@ -1,35 +1,35 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.tck.http.GetWagonTests;
-import org.apache.maven.wagon.tck.http.HttpsGetWagonTests;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * This test will runn the TCK suite on wagon-http-lightweight
- */
- at RunWith( Suite.class )
- at Suite.SuiteClasses( { GetWagonTests.class, HttpsGetWagonTests.class } )
-public class TckTest
-{
- // no op
-}
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.tck.http.GetWagonTests;
+import org.apache.maven.wagon.tck.http.HttpsGetWagonTests;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * This test will runn the TCK suite on wagon-http-lightweight
+ */
+ at RunWith( Suite.class )
+ at Suite.SuiteClasses( { GetWagonTests.class, HttpsGetWagonTests.class } )
+public class TckTest
+{
+ // no op
+}
diff --git a/wagon-providers/wagon-http-lightweight/src/test/resources/META-INF/plexus/components.xml b/wagon-providers/wagon-http-lightweight/src/test/resources/META-INF/plexus/components.xml
index 8c4cc2f..fdc761b 100644
--- a/wagon-providers/wagon-http-lightweight/src/test/resources/META-INF/plexus/components.xml
+++ b/wagon-providers/wagon-http-lightweight/src/test/resources/META-INF/plexus/components.xml
@@ -1,38 +1,38 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<component-set>
- <components>
- <component>
- <role>org.apache.maven.wagon.tck.http.WagonTestCaseConfigurator</role>
- <implementation>org.apache.maven.wagon.tck.http.WagonTestCaseConfigurator</implementation>
- <configuration>
- <wagonHint>http</wagonHint>
- <useCaseConfigs>
- <highLatencyLowTimeout>
- <unsupported/>
- </highLatencyLowTimeout>
- <inifiniteLatencyTimeout>
- <unsupported/>
- </inifiniteLatencyTimeout>
- </useCaseConfigs>
- </configuration>
- </component>
- </components>
-</component-set>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<component-set>
+ <components>
+ <component>
+ <role>org.apache.maven.wagon.tck.http.WagonTestCaseConfigurator</role>
+ <implementation>org.apache.maven.wagon.tck.http.WagonTestCaseConfigurator</implementation>
+ <configuration>
+ <wagonHint>http</wagonHint>
+ <useCaseConfigs>
+ <highLatencyLowTimeout>
+ <unsupported/>
+ </highLatencyLowTimeout>
+ <inifiniteLatencyTimeout>
+ <unsupported/>
+ </inifiniteLatencyTimeout>
+ </useCaseConfigs>
+ </configuration>
+ </component>
+ </components>
+</component-set>
diff --git a/wagon-providers/wagon-http-shared/pom.xml b/wagon-providers/wagon-http-shared/pom.xml
index 840afdf..af626a5 100644
--- a/wagon-providers/wagon-http-shared/pom.xml
+++ b/wagon-providers/wagon-http-shared/pom.xml
@@ -1,51 +1,60 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-providers</artifactId>
- <version>2.10</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>wagon-http-shared</artifactId>
- <name>Apache Maven Wagon :: Providers :: HTTP Shared Library</name>
- <description>
- Shared Library for wagon providers supporting HTTP.
- </description>
-
- <dependencies>
- <dependency>
- <groupId>org.jsoup</groupId>
- <artifactId>jsoup</artifactId>
- <version>1.7.2</version>
- </dependency>
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- </dependency>
- </dependencies>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-providers</artifactId>
+ <version>2.12</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>wagon-http-shared</artifactId>
+ <name>Apache Maven Wagon :: Providers :: HTTP Shared Library</name>
+ <description>
+ Shared Library for wagon providers supporting HTTP.
+ </description>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jsoup</groupId>
+ <artifactId>jsoup</artifactId>
+ <version>1.7.2</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/EncodingUtil.java b/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/EncodingUtil.java
index 9136553..8f25470 100644
--- a/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/EncodingUtil.java
+++ b/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/EncodingUtil.java
@@ -1,107 +1,105 @@
-package org.apache.maven.wagon.shared.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.lang.StringUtils;
-
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-/**
- * Encoding utility.
- *
- * @since 2.7
- */
-public class EncodingUtil
-{
- /**
- * Parses and returns an encoded version of the given URL string.
- *
- * @param url Raw/decoded string form of a URL to parse/encode.
- * @return Parsed/encoded {@link URI} that represents the string form URL passed in.
- * @throws MalformedURLException
- * @throws URISyntaxException
- */
- public static URI encodeURL( String url )
- throws MalformedURLException, URISyntaxException
- {
- URL urlObject = new URL( url );
-
- URI uriEncoded =
- new URI( urlObject.getProtocol(), //
- urlObject.getAuthority(), //
- urlObject.getPath(), //
- urlObject.getQuery(), //
- urlObject.getRef() );
-
- return uriEncoded;
- }
-
- /**
- * Parses and returns an encoded version of the given URL string.
- * Wraps the {@link MalformedURLException} and {@link URISyntaxException} in case the passed URL is invalid.
- *
- * @param url Raw/decoded string form of a URL to parse/encode.
- * @return Parsed/encoded URI (as string) that represents the
- * @throws IllegalArgumentException in case the URL string is invalid.
- */
- public static String encodeURLToString( String url )
- {
- try
- {
- return encodeURL( url ).toString();
- }
- catch ( Exception e )
- {
- throw new IllegalArgumentException( String.format( "Error parsing url: %s", url ), e );
- }
- }
-
- /**
- * Parses and returns an encoded version of the given URL string alongside the given paths.
- *
- * @param baseUrl Base URL to use when constructing the final URL, ie: scheme://authority/initial.path.
- * @param paths Additional path(s) to append at the end of the base path.
- * @return Composed URL (base + paths) already encoded, separating the individual path components by "/".
- * @since TODO
- */
- public static String encodeURLToString( String baseUrl, String... paths )
- {
- StringBuilder url = new StringBuilder( baseUrl );
-
- String[] parts = paths == null ? //
- new String[0] : //
- paths.length == 1 ? StringUtils.split( paths[0], "/" ) : paths;
-
- for ( String part : parts )
- {
- if ( !url.toString().endsWith( "/" ) )
- {
- url.append( '/' );
- }
-
- url.append( part );
- }
-
- return encodeURLToString( url.toString() );
- }
-}
+package org.apache.maven.wagon.shared.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+
+/**
+ * Encoding utility.
+ *
+ * @since 2.7
+ */
+public class EncodingUtil
+{
+ /**
+ * Parses and returns an encoded version of the given URL string.
+ *
+ * @param url Raw/decoded string form of a URL to parse/encode.
+ * @return Parsed/encoded {@link URI} that represents the string form URL passed in.
+ * @throws MalformedURLException
+ * @throws URISyntaxException
+ */
+ public static URI encodeURL( String url )
+ throws MalformedURLException, URISyntaxException
+ {
+ URL urlObject = new URL( url );
+
+ URI uriEncoded =
+ new URI( urlObject.getProtocol(), //
+ urlObject.getAuthority(), //
+ urlObject.getPath(), //
+ urlObject.getQuery(), //
+ urlObject.getRef() );
+
+ return uriEncoded;
+ }
+
+ /**
+ * Parses and returns an encoded version of the given URL string.
+ * Wraps the {@link MalformedURLException} and {@link URISyntaxException} in case the passed URL is invalid.
+ *
+ * @param url Raw/decoded string form of a URL to parse/encode.
+ * @return Parsed/encoded URI (as string) that represents the
+ * @throws IllegalArgumentException in case the URL string is invalid.
+ */
+ public static String encodeURLToString( String url )
+ {
+ try
+ {
+ return encodeURL( url ).toString();
+ }
+ catch ( Exception e )
+ {
+ throw new IllegalArgumentException( String.format( "Error parsing url: %s", url ), e );
+ }
+ }
+
+ /**
+ * Parses and returns an encoded version of the given URL string alongside the given paths.
+ *
+ * @param baseUrl Base URL to use when constructing the final URL, ie: scheme://authority/initial.path.
+ * @param paths Additional path(s) to append at the end of the base path.
+ * @return Composed URL (base + paths) already encoded, separating the individual path components by "/".
+ * @since TODO
+ */
+ public static String encodeURLToString( String baseUrl, String... paths )
+ {
+ StringBuilder url = new StringBuilder( baseUrl );
+
+ String[] parts = paths == null ? //
+ new String[0] : //
+ paths.length == 1 ? paths[0].split( "/" ) : paths;
+
+ for ( String part : parts )
+ {
+ if ( !url.toString().endsWith( "/" ) )
+ {
+ url.append( '/' );
+ }
+
+ url.append( part );
+ }
+
+ return encodeURLToString( url.toString() );
+ }
+}
diff --git a/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/HtmlFileListParser.java b/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/HtmlFileListParser.java
index 5ff34d9..71807fd 100644
--- a/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/HtmlFileListParser.java
+++ b/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/HtmlFileListParser.java
@@ -1,165 +1,164 @@
-package org.apache.maven.wagon.shared.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.maven.wagon.TransferFailedException;
-import org.jsoup.Jsoup;
-import org.jsoup.nodes.Document;
-import org.jsoup.nodes.Element;
-import org.jsoup.select.Elements;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.regex.Pattern;
-
-/**
- * Html File List Parser.
- */
-public class HtmlFileListParser
-{
- // Apache Fancy Index Sort Headers
- private static final Pattern APACHE_INDEX_SKIP = Pattern.compile( "\\?[CDMNS]=.*" );
-
- // URLs with excessive paths.
- private static final Pattern URLS_WITH_PATHS = Pattern.compile( "/[^/]*/" );
-
- // URLs that to a parent directory.
- private static final Pattern URLS_TO_PARENT = Pattern.compile( "\\.\\./" );
-
- // mailto urls
- private static final Pattern MAILTO_URLS = Pattern.compile( "mailto:.*" );
-
- private static final Pattern[] SKIPS =
- new Pattern[]{ APACHE_INDEX_SKIP, URLS_WITH_PATHS, URLS_TO_PARENT, MAILTO_URLS };
-
- /**
- * Fetches a raw HTML from a provided InputStream, parses it, and returns the file list.
- *
- * @param stream the input stream.
- * @return the file list.
- * @throws TransferFailedException if there was a problem fetching the raw html.
- */
- public static List<String> parseFileList( String baseurl, InputStream stream )
- throws TransferFailedException
- {
- try
- {
- URI baseURI = new URI( baseurl );
- // to make debugging easier, start with a string. This is assuming UTF-8, which might not be a safe
- // assumption.
- String content = IOUtils.toString( stream, "utf-8" );
- Document doc = Jsoup.parse( content, baseurl );
- Elements links = doc.select( "a[href]" );
- Set<String> results = new HashSet<String>();
- for ( Element link : links )
- {
- /*
- * The abs:href loses directories, so we deal with absolute paths ourselves below in cleanLink
- */
- String target = link.attr( "href" );
- if ( target != null )
- {
- String clean = cleanLink( baseURI, target );
- if ( isAcceptableLink( clean ) )
- {
- results.add( clean );
- }
- }
-
- }
-
- return new ArrayList<String>( results );
- }
- catch ( URISyntaxException e )
- {
- throw new TransferFailedException( "Unable to parse as base URI: " + baseurl, e );
- }
- catch ( IOException e )
- {
- throw new TransferFailedException( "I/O error reading HTML listing of artifacts: " + e.getMessage(), e );
- }
- }
-
- private static String cleanLink( URI baseURI, String link )
- {
- if ( StringUtils.isEmpty( link ) )
- {
- return "";
- }
-
- String ret = link;
-
- try
- {
- URI linkuri = new URI( ret );
- if ( link.startsWith( "/" ) )
- {
- linkuri = baseURI.resolve( linkuri );
- }
- URI relativeURI = baseURI.relativize( linkuri ).normalize();
- ret = relativeURI.toASCIIString();
- if ( ret.startsWith( baseURI.getPath() ) )
- {
- ret = ret.substring( baseURI.getPath().length() );
- }
-
- ret = URLDecoder.decode( ret, "UTF-8" );
- }
- catch ( URISyntaxException e )
- {
- // ignore
- }
- catch ( UnsupportedEncodingException e )
- {
- // ignore
- }
-
- return ret;
- }
-
- private static boolean isAcceptableLink( String link )
- {
- if ( StringUtils.isEmpty( link ) )
- {
- return false;
- }
-
- for ( Pattern pattern : SKIPS )
- {
- if ( pattern.matcher( link ).find() )
- {
- return false;
- }
- }
-
- return true;
- }
-
+package org.apache.maven.wagon.shared.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.io.IOUtils;
+import org.apache.maven.wagon.TransferFailedException;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+import org.jsoup.select.Elements;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.regex.Pattern;
+
+/**
+ * Html File List Parser.
+ */
+public class HtmlFileListParser
+{
+ // Apache Fancy Index Sort Headers
+ private static final Pattern APACHE_INDEX_SKIP = Pattern.compile( "\\?[CDMNS]=.*" );
+
+ // URLs with excessive paths.
+ private static final Pattern URLS_WITH_PATHS = Pattern.compile( "/[^/]*/" );
+
+ // URLs that to a parent directory.
+ private static final Pattern URLS_TO_PARENT = Pattern.compile( "\\.\\./" );
+
+ // mailto urls
+ private static final Pattern MAILTO_URLS = Pattern.compile( "mailto:.*" );
+
+ private static final Pattern[] SKIPS =
+ new Pattern[]{ APACHE_INDEX_SKIP, URLS_WITH_PATHS, URLS_TO_PARENT, MAILTO_URLS };
+
+ /**
+ * Fetches a raw HTML from a provided InputStream, parses it, and returns the file list.
+ *
+ * @param stream the input stream.
+ * @return the file list.
+ * @throws TransferFailedException if there was a problem fetching the raw html.
+ */
+ public static List<String> parseFileList( String baseurl, InputStream stream )
+ throws TransferFailedException
+ {
+ try
+ {
+ URI baseURI = new URI( baseurl );
+ // to make debugging easier, start with a string. This is assuming UTF-8, which might not be a safe
+ // assumption.
+ String content = IOUtils.toString( stream, "utf-8" );
+ Document doc = Jsoup.parse( content, baseurl );
+ Elements links = doc.select( "a[href]" );
+ Set<String> results = new HashSet<String>();
+ for ( Element link : links )
+ {
+ /*
+ * The abs:href loses directories, so we deal with absolute paths ourselves below in cleanLink
+ */
+ String target = link.attr( "href" );
+ if ( target != null )
+ {
+ String clean = cleanLink( baseURI, target );
+ if ( isAcceptableLink( clean ) )
+ {
+ results.add( clean );
+ }
+ }
+
+ }
+
+ return new ArrayList<String>( results );
+ }
+ catch ( URISyntaxException e )
+ {
+ throw new TransferFailedException( "Unable to parse as base URI: " + baseurl, e );
+ }
+ catch ( IOException e )
+ {
+ throw new TransferFailedException( "I/O error reading HTML listing of artifacts: " + e.getMessage(), e );
+ }
+ }
+
+ private static String cleanLink( URI baseURI, String link )
+ {
+ if ( link == null || link.length() == 0 )
+ {
+ return "";
+ }
+
+ String ret = link;
+
+ try
+ {
+ URI linkuri = new URI( ret );
+ if ( link.startsWith( "/" ) )
+ {
+ linkuri = baseURI.resolve( linkuri );
+ }
+ URI relativeURI = baseURI.relativize( linkuri ).normalize();
+ ret = relativeURI.toASCIIString();
+ if ( ret.startsWith( baseURI.getPath() ) )
+ {
+ ret = ret.substring( baseURI.getPath().length() );
+ }
+
+ ret = URLDecoder.decode( ret, "UTF-8" );
+ }
+ catch ( URISyntaxException e )
+ {
+ // ignore
+ }
+ catch ( UnsupportedEncodingException e )
+ {
+ // ignore
+ }
+
+ return ret;
+ }
+
+ private static boolean isAcceptableLink( String link )
+ {
+ if ( link == null || link.length() == 0 )
+ {
+ return false;
+ }
+
+ for ( Pattern pattern : SKIPS )
+ {
+ if ( pattern.matcher( link ).find() )
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
}
\ No newline at end of file
diff --git a/wagon-providers/wagon-http-shared/src/site/site.xml b/wagon-providers/wagon-http-shared/src/site/site.xml
index 0ede383..631613c 100644
--- a/wagon-providers/wagon-http-shared/src/site/site.xml
+++ b/wagon-providers/wagon-http-shared/src/site/site.xml
@@ -1,33 +1,33 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
- <body>
- <breadcrumbs>
- <item name="HTTP Shared" href="http://maven.apache.org/wagon/wagon-providers/wagon-http-shared/index.html" />
- </breadcrumbs>
-
- <menu ref="parent"/>
- <menu ref="reports"/>
- </body>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
+ <body>
+ <breadcrumbs>
+ <item name="HTTP Shared" href="http://maven.apache.org/wagon/wagon-providers/wagon-http-shared/index.html" />
+ </breadcrumbs>
+
+ <menu ref="parent"/>
+ <menu ref="reports"/>
+ </body>
</project>
\ No newline at end of file
diff --git a/wagon-providers/wagon-http-shared/src/test/java/org/apache/maven/wagon/shared/http/EncodingUtilTest.java b/wagon-providers/wagon-http-shared/src/test/java/org/apache/maven/wagon/shared/http/EncodingUtilTest.java
index f20f35f..0207788 100644
--- a/wagon-providers/wagon-http-shared/src/test/java/org/apache/maven/wagon/shared/http/EncodingUtilTest.java
+++ b/wagon-providers/wagon-http-shared/src/test/java/org/apache/maven/wagon/shared/http/EncodingUtilTest.java
@@ -1,53 +1,53 @@
-package org.apache.maven.wagon.shared.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
-
-public class EncodingUtilTest
- extends TestCase
-{
- public void testEncodeURLWithSpaces()
- throws URISyntaxException, MalformedURLException
- {
- String encodedURL = EncodingUtil.encodeURLToString( "file://host:1/path with spaces" );
-
- assertEquals( "file://host:1/path%20with%20spaces", encodedURL );
- }
-
- public void testEncodeURLWithSpacesInPath()
- throws URISyntaxException, MalformedURLException
- {
- String encodedURL = EncodingUtil.encodeURLToString( "file://host:1", "path with spaces" );
-
- assertEquals( "file://host:1/path%20with%20spaces", encodedURL );
- }
-
- public void testEncodeURLWithSpacesInBothBaseAndPath()
- throws URISyntaxException, MalformedURLException
- {
- String encodedURL = EncodingUtil.encodeURLToString( "file://host:1/with a", "path with spaces" );
-
- assertEquals( "file://host:1/with%20a/path%20with%20spaces", encodedURL );
- }
-}
+package org.apache.maven.wagon.shared.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+
+import java.net.MalformedURLException;
+import java.net.URISyntaxException;
+
+public class EncodingUtilTest
+ extends TestCase
+{
+ public void testEncodeURLWithSpaces()
+ throws URISyntaxException, MalformedURLException
+ {
+ String encodedURL = EncodingUtil.encodeURLToString( "file://host:1/path with spaces" );
+
+ assertEquals( "file://host:1/path%20with%20spaces", encodedURL );
+ }
+
+ public void testEncodeURLWithSpacesInPath()
+ throws URISyntaxException, MalformedURLException
+ {
+ String encodedURL = EncodingUtil.encodeURLToString( "file://host:1", "path with spaces" );
+
+ assertEquals( "file://host:1/path%20with%20spaces", encodedURL );
+ }
+
+ public void testEncodeURLWithSpacesInBothBaseAndPath()
+ throws URISyntaxException, MalformedURLException
+ {
+ String encodedURL = EncodingUtil.encodeURLToString( "file://host:1/with a", "path with spaces" );
+
+ assertEquals( "file://host:1/with%20a/path%20with%20spaces", encodedURL );
+ }
+}
diff --git a/wagon-providers/wagon-http-shared/src/test/java/org/apache/maven/wagon/shared/http/HtmlFileListParserTest.java b/wagon-providers/wagon-http-shared/src/test/java/org/apache/maven/wagon/shared/http/HtmlFileListParserTest.java
index 7e93d12..e5c907c 100644
--- a/wagon-providers/wagon-http-shared/src/test/java/org/apache/maven/wagon/shared/http/HtmlFileListParserTest.java
+++ b/wagon-providers/wagon-http-shared/src/test/java/org/apache/maven/wagon/shared/http/HtmlFileListParserTest.java
@@ -1,726 +1,728 @@
-package org.apache.maven.wagon.shared.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.Logger;
-import org.apache.maven.wagon.TransferFailedException;
-
-/**
- * Unit Tests for the HtmlFileListParser
- */
-public class HtmlFileListParserTest
- extends TestCase
-{
- private static Logger logger = Logger.getLogger( HtmlFileListParserTest.class );
-
- private void assertContainsExpected( List<String> links, String[] expected )
- {
- if ( expected.length != links.size() )
- {
- Collections.sort( links );
- for ( String link : links )
- {
- logger.info(" \"" + link + "\", ");
- }
- assertEquals( "Links to Expected size", expected.length, links.size() );
- }
-
- for ( String exp : expected )
- {
- assertTrue( "Should find [" + exp + "] in link list", links.contains( exp ) );
- }
- }
-
- private void assertNotContainingAvoided( List<String> links, String[] avoided )
- {
- for ( String a : avoided )
- {
- assertFalse( "Should not find [" + a + "] in link list", links.contains( a ) );
- }
- }
-
- private List<String> parseLinks( String url, String filename )
- throws TransferFailedException
- {
- InputStream is = this.getClass().getResourceAsStream( "/filelistings/" + filename );
- List<String> files = HtmlFileListParser.parseFileList( url, is );
-
- assertNotNull( "file list should not be null.", files );
- assertFalse( "file list should not be empty.", files.isEmpty() );
-
- /* Debug */
- if ( false )
- {
- for ( String file : files )
- {
- logger.info( "File: '" + file + "'" );
- }
- }
-
- return files;
- }
-
- /**
- * Example showing jetty directory browsing of commons-lang
- *
- * @throws TransferFailedException
- */
- public void testParseCommonsLang()
- throws TransferFailedException
- {
- List<String> links = parseLinks( "http://localhost/repository/commons-lang/commons-lang/2.3",
- "commons-lang.html" );
-
- String[] expected = new String[] {
- "commons-lang-2.3-javadoc.jar",
- "commons-lang-2.3-javadoc.jar.asc",
- "commons-lang-2.3-javadoc.jar.md5",
- "commons-lang-2.3-javadoc.jar.sha1",
- "commons-lang-2.3-sources.jar",
- "commons-lang-2.3-sources.jar.asc",
- "commons-lang-2.3-sources.jar.md5",
- "commons-lang-2.3-sources.jar.sha1",
- "commons-lang-2.3.jar",
- "commons-lang-2.3.jar.asc",
- "commons-lang-2.3.jar.md5",
- "commons-lang-2.3.jar.sha1",
- "commons-lang-2.3.pom",
- "commons-lang-2.3.pom.md5",
- "commons-lang-2.3.pom.sha1",
- "maven-metadata.xml",
- "maven-metadata.xml.md5",
- "maven-metadata.xml.sha1" };
-
- assertContainsExpected( links, expected );
-
- String[] avoided = new String[] { "../" };
-
- assertNotContainingAvoided( links, avoided );
- }
-
- public void testParseIbiblio()
- throws Exception
- {
- List<String> links = parseLinks( "http://www.ibiblio.org/maven2/org/apache/maven/wagon/",
- "ibiblio-wagon.html" );
-
- String[] expected = new String[] {
- "wagon-1.0-alpha-2.pom",
- "wagon-1.0-alpha-2.pom.asc",
- "wagon-1.0-alpha-2.pom.md5",
- "wagon-1.0-alpha-2.pom.sha1",
- "wagon-1.0-alpha-3-20050413.021234-4.pom",
- "wagon-1.0-alpha-3-20050413.021234-4.pom.md5",
- "wagon-1.0-alpha-3-20050413.021234-4.pom.sha1",
- "wagon-1.0-alpha-3-20050419.043745-5.pom",
- "wagon-1.0-alpha-3-20050419.043745-5.pom.md5",
- "wagon-1.0-alpha-3-20050419.043745-5.pom.sha1",
- "wagon-1.0-alpha-3-20050419.044035-6.pom",
- "wagon-1.0-alpha-3-20050419.044035-6.pom.md5",
- "wagon-1.0-alpha-3-20050419.044035-6.pom.sha1",
- "wagon-1.0-alpha-3-20050421.162738-7.pom",
- "wagon-1.0-alpha-3-20050421.162738-7.pom.md5",
- "wagon-1.0-alpha-3-20050421.162738-7.pom.sha1",
- "wagon-1.0-alpha-3-20050422.075233-8.pom",
- "wagon-1.0-alpha-3-20050422.075233-8.pom.md5",
- "wagon-1.0-alpha-3-20050422.075233-8.pom.sha1",
- "wagon-1.0-alpha-3-20050429.051847-9.pom",
- "wagon-1.0-alpha-3-20050429.051847-9.pom.md5",
- "wagon-1.0-alpha-3-20050429.051847-9.pom.sha1",
- "wagon-file/",
- "wagon-ftp/",
- "wagon-http-lightweight/",
- "wagon-http/",
- "wagon-lightweight-http/",
- "wagon-provider-api/",
- "wagon-provider-test/",
- "wagon-provider/",
- "wagon-providers-1.0-alpha-2.pom",
- "wagon-providers-1.0-alpha-2.pom.asc",
- "wagon-providers-1.0-alpha-2.pom.md5",
- "wagon-providers-1.0-alpha-2.pom.sha1",
- "wagon-providers-1.0-alpha-3-20050407.202848-1.pom",
- "wagon-providers-1.0-alpha-3-20050407.202848-1.pom.md5",
- "wagon-providers-1.0-alpha-3-20050407.202848-1.pom.sha1",
- "wagon-providers-1.0-alpha-3-20050419.044035-2.pom",
- "wagon-providers-1.0-alpha-3-20050419.044035-2.pom.md5",
- "wagon-providers-1.0-alpha-3-20050419.044035-2.pom.sha1",
- "wagon-providers-1.0-alpha-3-20050421.162738-3.pom",
- "wagon-providers-1.0-alpha-3-20050421.162738-3.pom.md5",
- "wagon-providers-1.0-alpha-3-20050421.162738-3.pom.sha1",
- "wagon-providers-1.0-alpha-3-20050422.075233-4.pom",
- "wagon-providers-1.0-alpha-3-20050422.075233-4.pom.md5",
- "wagon-providers-1.0-alpha-3-20050422.075233-4.pom.sha1",
- "wagon-providers-1.0-alpha-3-20050429.051847-5.pom",
- "wagon-providers-1.0-alpha-3-20050429.051847-5.pom.md5",
- "wagon-providers-1.0-alpha-3-20050429.051847-5.pom.sha1",
- "wagon-providers/",
- "wagon-scm/",
- "wagon-ssh-external/",
- "wagon-ssh/",
- "wagon-webdav/",
- "wagon/" };
-
- assertContainsExpected( links, expected );
-
- String[] avoided = new String[] { "/org/", "?C=S;O=A", "?C=D;O=A", "?C=M;O=A", "?D=A", "?M=A", "?N=D", "?S=A" };
-
- assertNotContainingAvoided( links, avoided );
- }
-
- /**
- * Test of an html which is improperly formatted, and contains full host-specific paths to the resources.
- * @throws Exception
- */
- public void testParseJetty()
- throws Exception
- {
- List<String> links = parseLinks( "http://www.ibiblio.org/maven2/org/apache/maven/wagon/",
- "jetty-wagon.html" );
-
- String[] expected = new String[] {
- "wagon-1.0-alpha-2.pom",
- "wagon-1.0-alpha-2.pom.asc",
- "wagon-1.0-alpha-2.pom.md5",
- "wagon-1.0-alpha-2.pom.sha1",
- "wagon-1.0-alpha-3-20050413.021234-4.pom",
- "wagon-1.0-alpha-3-20050413.021234-4.pom.md5",
- "wagon-1.0-alpha-3-20050413.021234-4.pom.sha1",
- "wagon-1.0-alpha-3-20050419.043745-5.pom",
- "wagon-1.0-alpha-3-20050419.043745-5.pom.md5",
- "wagon-1.0-alpha-3-20050419.043745-5.pom.sha1",
- "wagon-1.0-alpha-3-20050419.044035-6.pom",
- "wagon-1.0-alpha-3-20050419.044035-6.pom.md5",
- "wagon-1.0-alpha-3-20050419.044035-6.pom.sha1",
- "wagon-1.0-alpha-3-20050421.162738-7.pom",
- "wagon-1.0-alpha-3-20050421.162738-7.pom.md5",
- "wagon-1.0-alpha-3-20050421.162738-7.pom.sha1",
- "wagon-1.0-alpha-3-20050422.075233-8.pom",
- "wagon-1.0-alpha-3-20050422.075233-8.pom.md5",
- "wagon-1.0-alpha-3-20050422.075233-8.pom.sha1",
- "wagon-1.0-alpha-3-20050429.051847-9.pom",
- "wagon-1.0-alpha-3-20050429.051847-9.pom.md5",
- "wagon-1.0-alpha-3-20050429.051847-9.pom.sha1",
- "wagon-file/",
- "wagon-ftp/",
- "wagon-http-lightweight/",
- "wagon-http/",
- "wagon-lightweight-http/",
- "wagon-provider-api/",
- "wagon-provider-test/",
- "wagon-provider/",
- "wagon-providers-1.0-alpha-2.pom",
- "wagon-providers-1.0-alpha-2.pom.asc",
- "wagon-providers-1.0-alpha-2.pom.md5",
- "wagon-providers-1.0-alpha-2.pom.sha1",
- "wagon-providers-1.0-alpha-3-20050407.202848-1.pom",
- "wagon-providers-1.0-alpha-3-20050407.202848-1.pom.md5",
- "wagon-providers-1.0-alpha-3-20050407.202848-1.pom.sha1",
- "wagon-providers-1.0-alpha-3-20050419.044035-2.pom",
- "wagon-providers-1.0-alpha-3-20050419.044035-2.pom.md5",
- "wagon-providers-1.0-alpha-3-20050419.044035-2.pom.sha1",
- "wagon-providers-1.0-alpha-3-20050421.162738-3.pom",
- "wagon-providers-1.0-alpha-3-20050421.162738-3.pom.md5",
- "wagon-providers-1.0-alpha-3-20050421.162738-3.pom.sha1",
- "wagon-providers-1.0-alpha-3-20050422.075233-4.pom",
- "wagon-providers-1.0-alpha-3-20050422.075233-4.pom.md5",
- "wagon-providers-1.0-alpha-3-20050422.075233-4.pom.sha1",
- "wagon-providers-1.0-alpha-3-20050429.051847-5.pom",
- "wagon-providers-1.0-alpha-3-20050429.051847-5.pom.md5",
- "wagon-providers-1.0-alpha-3-20050429.051847-5.pom.sha1",
- "wagon-providers/",
- "wagon-scm/",
- "wagon-ssh-external/",
- "wagon-ssh/",
- "wagon-webdav/",
- "wagon/" };
-
- assertContainsExpected( links, expected );
-
- String[] avoided = new String[] { "/org/", "?C=S;O=A", "?C=D;O=A", "?C=M;O=A" };
-
- assertNotContainingAvoided( links, avoided );
- }
-
- /**
- * Test of an html which is improperly formatted, contains full host-specific paths to the resources and uses non-normalized base URI
- * @throws Exception
- */
- public void testParseJettyWithNonNormalizedBaseURI()
- throws Exception
- {
- List<String> links = parseLinks( "http://www.ibiblio.org/maven2/org/apache/maven/wagon//",
- "jetty-wagon.html" );
-
- String[] expected = new String[] {
- "wagon-1.0-alpha-2.pom",
- "wagon-1.0-alpha-2.pom.asc",
- "wagon-1.0-alpha-2.pom.md5",
- "wagon-1.0-alpha-2.pom.sha1",
- "wagon-1.0-alpha-3-20050413.021234-4.pom",
- "wagon-1.0-alpha-3-20050413.021234-4.pom.md5",
- "wagon-1.0-alpha-3-20050413.021234-4.pom.sha1",
- "wagon-1.0-alpha-3-20050419.043745-5.pom",
- "wagon-1.0-alpha-3-20050419.043745-5.pom.md5",
- "wagon-1.0-alpha-3-20050419.043745-5.pom.sha1",
- "wagon-1.0-alpha-3-20050419.044035-6.pom",
- "wagon-1.0-alpha-3-20050419.044035-6.pom.md5",
- "wagon-1.0-alpha-3-20050419.044035-6.pom.sha1",
- "wagon-1.0-alpha-3-20050421.162738-7.pom",
- "wagon-1.0-alpha-3-20050421.162738-7.pom.md5",
- "wagon-1.0-alpha-3-20050421.162738-7.pom.sha1",
- "wagon-1.0-alpha-3-20050422.075233-8.pom",
- "wagon-1.0-alpha-3-20050422.075233-8.pom.md5",
- "wagon-1.0-alpha-3-20050422.075233-8.pom.sha1",
- "wagon-1.0-alpha-3-20050429.051847-9.pom",
- "wagon-1.0-alpha-3-20050429.051847-9.pom.md5",
- "wagon-1.0-alpha-3-20050429.051847-9.pom.sha1",
- "wagon-file/",
- "wagon-ftp/",
- "wagon-http-lightweight/",
- "wagon-http/",
- "wagon-lightweight-http/",
- "wagon-provider-api/",
- "wagon-provider-test/",
- "wagon-provider/",
- "wagon-providers-1.0-alpha-2.pom",
- "wagon-providers-1.0-alpha-2.pom.asc",
- "wagon-providers-1.0-alpha-2.pom.md5",
- "wagon-providers-1.0-alpha-2.pom.sha1",
- "wagon-providers-1.0-alpha-3-20050407.202848-1.pom",
- "wagon-providers-1.0-alpha-3-20050407.202848-1.pom.md5",
- "wagon-providers-1.0-alpha-3-20050407.202848-1.pom.sha1",
- "wagon-providers-1.0-alpha-3-20050419.044035-2.pom",
- "wagon-providers-1.0-alpha-3-20050419.044035-2.pom.md5",
- "wagon-providers-1.0-alpha-3-20050419.044035-2.pom.sha1",
- "wagon-providers-1.0-alpha-3-20050421.162738-3.pom",
- "wagon-providers-1.0-alpha-3-20050421.162738-3.pom.md5",
- "wagon-providers-1.0-alpha-3-20050421.162738-3.pom.sha1",
- "wagon-providers-1.0-alpha-3-20050422.075233-4.pom",
- "wagon-providers-1.0-alpha-3-20050422.075233-4.pom.md5",
- "wagon-providers-1.0-alpha-3-20050422.075233-4.pom.sha1",
- "wagon-providers-1.0-alpha-3-20050429.051847-5.pom",
- "wagon-providers-1.0-alpha-3-20050429.051847-5.pom.md5",
- "wagon-providers-1.0-alpha-3-20050429.051847-5.pom.sha1",
- "wagon-providers/",
- "wagon-scm/",
- "wagon-ssh-external/",
- "wagon-ssh/",
- "wagon-webdav/",
- "wagon/" };
-
- assertContainsExpected( links, expected );
-
- String[] avoided = new String[] { "/org/", "?C=S;O=A", "?C=D;O=A", "?C=M;O=A" };
-
- assertNotContainingAvoided( links, avoided );
- }
-
- /**
- * Using repository.codehaus.org output as an example.
- * This is an example of an older RHEL installation of apache httpd with old fancy indexing output
- * This example tests how to detect directories properly.
- *
- * @throws TransferFailedException
- */
- public void testParseMevenIde()
- throws TransferFailedException
- {
- List<String> links = parseLinks( "http://repository.codehaus.org/org/codehaus/mevenide/", "mevenide.html" );
-
- String[] expected = new String[] {
- "apisupport/",
- "autoupdate/",
- "continuum-rpc/",
- "continuum/",
- "debugger-bridge/",
- "deployment-bridge/",
- "feature/",
- "grammar/",
- "ide-mojos/",
- "indexer/",
- "j2ee/",
- "junit/",
- "maven-metadata.xml",
- "maven-metadata.xml.md5",
- "maven-metadata.xml.sha1",
- "mevenide2-parent/",
- "nb-mvn-embedder/",
- "nb-project/",
- "nb-repo-browser/",
- "netbeans-debugger-plugin/",
- "netbeans-deploy-plugin/",
- "netbeans-libs/",
- "netbeans-nbmreload-plugin/",
- "netbeans-repository/",
- "netbeans-run-plugin/",
- "netbeans/",
- "persistence/",
- "plugin-bridges/",
- "plugins/",
- "reload-nbm-bridge/",
- "run-jar-bridge/" };
-
- assertContainsExpected( links, expected );
-
- String[] avoided = new String[] { "/org/codehaus/", "?C=S;O=A", "?C=D;O=A", "?C=M;O=A" };
-
- assertNotContainingAvoided( links, avoided );
- }
-
- public void testParseMirror()
- throws Exception
- {
- List<String> links = parseLinks( "http://www.ibiblio.org/maven2/org/apache/maven/wagon/",
- "mirror-wagon.html" );
-
- String[] expected = new String[] {
- "wagon-1.0-alpha-2.pom",
- "wagon-1.0-alpha-2.pom.asc",
- "wagon-1.0-alpha-2.pom.md5",
- "wagon-1.0-alpha-2.pom.sha1",
- "wagon-1.0-alpha-3-20050413.021234-4.pom",
- "wagon-1.0-alpha-3-20050413.021234-4.pom.md5",
- "wagon-1.0-alpha-3-20050413.021234-4.pom.sha1",
- "wagon-1.0-alpha-3-20050419.043745-5.pom",
- "wagon-1.0-alpha-3-20050419.043745-5.pom.md5",
- "wagon-1.0-alpha-3-20050419.043745-5.pom.sha1",
- "wagon-1.0-alpha-3-20050419.044035-6.pom",
- "wagon-1.0-alpha-3-20050419.044035-6.pom.md5",
- "wagon-1.0-alpha-3-20050419.044035-6.pom.sha1",
- "wagon-1.0-alpha-3-20050421.162738-7.pom",
- "wagon-1.0-alpha-3-20050421.162738-7.pom.md5",
- "wagon-1.0-alpha-3-20050421.162738-7.pom.sha1",
- "wagon-1.0-alpha-3-20050422.075233-8.pom",
- "wagon-1.0-alpha-3-20050422.075233-8.pom.md5",
- "wagon-1.0-alpha-3-20050422.075233-8.pom.sha1",
- "wagon-1.0-alpha-3-20050429.051847-9.pom",
- "wagon-1.0-alpha-3-20050429.051847-9.pom.md5",
- "wagon-1.0-alpha-3-20050429.051847-9.pom.sha1",
- "wagon-file/",
- "wagon-ftp/",
- "wagon-http-lightweight/",
- "wagon-http/",
- "wagon-lightweight-http/",
- "wagon-provider-api/",
- "wagon-provider-test/",
- "wagon-provider/",
- "wagon-providers-1.0-alpha-2.pom",
- "wagon-providers-1.0-alpha-2.pom.asc",
- "wagon-providers-1.0-alpha-2.pom.md5",
- "wagon-providers-1.0-alpha-2.pom.sha1",
- "wagon-providers-1.0-alpha-3-20050407.202848-1.pom",
- "wagon-providers-1.0-alpha-3-20050407.202848-1.pom.md5",
- "wagon-providers-1.0-alpha-3-20050407.202848-1.pom.sha1",
- "wagon-providers-1.0-alpha-3-20050419.044035-2.pom",
- "wagon-providers-1.0-alpha-3-20050419.044035-2.pom.md5",
- "wagon-providers-1.0-alpha-3-20050419.044035-2.pom.sha1",
- "wagon-providers-1.0-alpha-3-20050421.162738-3.pom",
- "wagon-providers-1.0-alpha-3-20050421.162738-3.pom.md5",
- "wagon-providers-1.0-alpha-3-20050421.162738-3.pom.sha1",
- "wagon-providers-1.0-alpha-3-20050422.075233-4.pom",
- "wagon-providers-1.0-alpha-3-20050422.075233-4.pom.md5",
- "wagon-providers-1.0-alpha-3-20050422.075233-4.pom.sha1",
- "wagon-providers-1.0-alpha-3-20050429.051847-5.pom",
- "wagon-providers-1.0-alpha-3-20050429.051847-5.pom.md5",
- "wagon-providers-1.0-alpha-3-20050429.051847-5.pom.sha1",
- "wagon-providers/",
- "wagon-scm/",
- "wagon-ssh-external/",
- "wagon-ssh/",
- "wagon-webdav/",
- "wagon/" };
-
- assertContainsExpected( links, expected );
-
- String[] avoided = new String[] {
- "/org/codehaus/",
- "?C=S;O=A",
- "?C=D;O=A",
- "?C=M;O=A",
- "mailto:mirror.admin at mirror.com" };
-
- assertNotContainingAvoided( links, avoided );
- }
-
- /**
- * Example of output from repo1.maven.org
- * This example is of nekohtml specifically.
- *
- * @throws TransferFailedException
- */
- public void testParseNekoHtml()
- throws TransferFailedException
- {
- List<String> links = parseLinks( "http://repo1.maven.org//maven2/nekohtml/nekohtml/1.9.6/", "nekohtml.html" );
-
- String[] expected = new String[] {
- "nekohtml-1.9.6-javadoc.jar",
- "nekohtml-1.9.6-javadoc.jar.md5",
- "nekohtml-1.9.6-javadoc.jar.sha1",
- "nekohtml-1.9.6-sources.jar",
- "nekohtml-1.9.6-sources.jar.md5",
- "nekohtml-1.9.6-sources.jar.sha1",
- "nekohtml-1.9.6.jar",
- "nekohtml-1.9.6.jar.md5",
- "nekohtml-1.9.6.jar.sha1",
- "nekohtml-1.9.6.pom",
- "nekohtml-1.9.6.pom.md5",
- "nekohtml-1.9.6.pom.sha1" };
-
- assertContainsExpected( links, expected );
-
- String[] avoided = new String[] { "/maven2/nekohtml/nekohtml/", "?C=S;O=A", "?C=D;O=A", "?C=M;O=A" };
-
- assertNotContainingAvoided( links, avoided );
- }
-
- /**
- * Example of detecting directories on repo1.maven.org
- *
- * @throws TransferFailedException
- */
- public void testParseNetSourceforge()
- throws TransferFailedException
- {
- List<String> links = parseLinks( "http://repo1.maven.org/maven2/net/sf/", "net_sf.html" );
-
- String[] expected = new String[] {
- "a2j/",
- "aislib/",
- "alchim/",
- "antenna/",
- "apt-jelly/",
- "beanlib/",
- "bluecove/",
- "buildbox/",
- "click/",
- "clirr/",
- "datavision/",
- "dozer/",
- "dtddoc/",
- "dynpageplus/",
- "ehcache/",
- "ezmorph/",
- "falcon/",
- "grester/",
- "gwt-widget/",
- "hermesftp/",
- "hibernate/",
- "jcharts/",
- "jdatabaseimport/",
- "jeceira/",
- "jfcunit/",
- "jfig/",
- "jguard/",
- "jipcam/",
- "jlynx/",
- "jour/",
- "jpf/",
- "json-lib/",
- "jsptest/",
- "jsr107cache/",
- "jt400/",
- "jxls/",
- "kxml/",
- "ldaptemplate/",
- "locale4j/",
- "mapasuta/",
- "maven-har/",
- "maven-sar/",
- "opencsv/",
- "oval/",
- "proguard/",
- "qdwizard/",
- "resultsetmapper/",
- "retrotranslator/",
- "saxon/",
- "shadesdb/",
- "smc/",
- "speculoos/",
- "springlayout/",
- "stat-scm/",
- "statsvn/",
- "stax/",
- "struts/",
- "tacos/",
- "testextensions/",
- "webdav-servlet/" };
-
- assertContainsExpected( links, expected );
-
- String[] avoided = new String[] { "/maven2/net/", "?C=S;O=A", "?C=D;O=A", "?C=M;O=A" };
-
- assertNotContainingAvoided( links, avoided );
- }
-
- /**
- * Another larger example of the directory link detection on repository.codehaus.org
- *
- * @throws TransferFailedException
- */
- public void testParseOrgCodehaus()
- throws TransferFailedException
- {
- List<String> links = parseLinks( "http://repository.codehaus.org/org/codehaus", "org.codehaus.html" );
-
- String[] expected = new String[] {
- "agilifier/",
- "benji/",
- "bruce/",
- "btm/",
- "cargo/",
- "castor-spring/",
- "castor/",
- "cozmos/",
- "dataforge/",
- "dimple/",
- "droolsdotnet/",
- "enunciate/",
- "fabric3/",
- "gant/",
- "grails-plugins/",
- "groovy/",
- "gsoc/",
- "guessencoding/",
- "gumtree/",
- "gwt-openlayers/",
- "haus/",
- "izpack/",
- "javasim/",
- "jedi/",
- "jequel/",
- "jet/",
- "jettison/",
- "jfdi/",
- "jikesrvm/",
- "jra/",
- "jremoting/",
- "jtestme/",
- "jtestr/",
- "labs-ng/",
- "logicabyss/",
- "marionette/",
- "mevenide/",
- "modello/",
- "mojo/",
- "mvel/",
- "mvflex/",
- "native-mojo/",
- "openim/",
- "plexus/",
- "polymap/",
- "prometheus/",
- "prophit/",
- "quaere/",
- "redback/",
- "rulessandpit/",
- "rvm/",
- "savana/",
- "scala-ide/",
- "senro/",
- "sonar/",
- "staxmate/",
- "stomp/",
- "svn4j/",
- "swiby/",
- "swizzle/",
- "sxc/",
- "testdox/",
- "wadi/",
- "waffle/",
- "woodstox/",
- "xdoclet/",
- "xfire/",
- "xharness/",
- "xsite/",
- "xstream/",
- "xwire/" };
-
- assertContainsExpected( links, expected );
-
- String[] avoided = new String[] { "/org/", "?C=S;O=A", "?C=D;O=A", "?C=M;O=A" };
-
- assertNotContainingAvoided( links, avoided );
- }
-
- /**
- * Test the output found from apache httpd with fancy indexing and dav module.
- * Using people.apache.org output as source material.
- *
- * @throws TransferFailedException
- */
- public void testParsePeopleApacheOrg()
- throws TransferFailedException
- {
- List<String> links = parseLinks(
- "http://people.apache.org/repo/m2-ibiblio-rsync-repository/org/apache/maven/archiva/archiva-plexus-runtime/1.0.1/",
- "org.apache.maven.html" );
-
- String[] expected = new String[] {
- "archiva-plexus-runtime-1.0.1-bin.tar.gz",
- "archiva-plexus-runtime-1.0.1-bin.tar.gz.asc",
- "archiva-plexus-runtime-1.0.1-bin.tar.gz.asc.md5",
- "archiva-plexus-runtime-1.0.1-bin.tar.gz.asc.sha1",
- "archiva-plexus-runtime-1.0.1-bin.tar.gz.md5",
- "archiva-plexus-runtime-1.0.1-bin.tar.gz.sha1",
- "archiva-plexus-runtime-1.0.1-bin.zip",
- "archiva-plexus-runtime-1.0.1-bin.zip.asc",
- "archiva-plexus-runtime-1.0.1-bin.zip.asc.md5",
- "archiva-plexus-runtime-1.0.1-bin.zip.asc.sha1",
- "archiva-plexus-runtime-1.0.1-bin.zip.md5",
- "archiva-plexus-runtime-1.0.1-bin.zip.sha1",
- "archiva-plexus-runtime-1.0.1-sources.jar",
- "archiva-plexus-runtime-1.0.1-sources.jar.asc",
- "archiva-plexus-runtime-1.0.1-sources.jar.asc.md5",
- "archiva-plexus-runtime-1.0.1-sources.jar.asc.sha1",
- "archiva-plexus-runtime-1.0.1-sources.jar.md5",
- "archiva-plexus-runtime-1.0.1-sources.jar.sha1",
- "archiva-plexus-runtime-1.0.1.jar",
- "archiva-plexus-runtime-1.0.1.jar.asc",
- "archiva-plexus-runtime-1.0.1.jar.asc.md5",
- "archiva-plexus-runtime-1.0.1.jar.asc.sha1",
- "archiva-plexus-runtime-1.0.1.jar.md5",
- "archiva-plexus-runtime-1.0.1.jar.sha1",
- "archiva-plexus-runtime-1.0.1.pom",
- "archiva-plexus-runtime-1.0.1.pom.asc",
- "archiva-plexus-runtime-1.0.1.pom.asc.md5",
- "archiva-plexus-runtime-1.0.1.pom.asc.sha1",
- "archiva-plexus-runtime-1.0.1.pom.md5",
- "archiva-plexus-runtime-1.0.1.pom.sha1",
- "readme artifacts.txt"};
-
- assertContainsExpected( links, expected );
-
- String[] avoided = new String[] {
- "/repo/m2-ibiblio-rsync-repository/org/apache/maven/archiva/archiva-plexus-runtime/",
- "?C=S;O=A",
- "?C=D;O=A",
- "?C=M;O=A" };
-
- assertNotContainingAvoided( links, avoided );
- }
-}
+package org.apache.maven.wagon.shared.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.maven.wagon.TransferFailedException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Unit Tests for the HtmlFileListParser
+ */
+public class HtmlFileListParserTest
+ extends TestCase
+{
+ private static Logger logger = LoggerFactory.getLogger( HtmlFileListParserTest.class );
+
+ private void assertContainsExpected( List<String> links, String[] expected )
+ {
+ if ( expected.length != links.size() )
+ {
+ Collections.sort( links );
+ for ( String link : links )
+ {
+ logger.info(" \"" + link + "\", ");
+ }
+ assertEquals( "Links to Expected size", expected.length, links.size() );
+ }
+
+ for ( String exp : expected )
+ {
+ assertTrue( "Should find [" + exp + "] in link list", links.contains( exp ) );
+ }
+ }
+
+ private void assertNotContainingAvoided( List<String> links, String[] avoided )
+ {
+ for ( String a : avoided )
+ {
+ assertFalse( "Should not find [" + a + "] in link list", links.contains( a ) );
+ }
+ }
+
+ private List<String> parseLinks( String url, String filename )
+ throws TransferFailedException
+ {
+ InputStream is = this.getClass().getResourceAsStream( "/filelistings/" + filename );
+ List<String> files = HtmlFileListParser.parseFileList( url, is );
+
+ assertNotNull( "file list should not be null.", files );
+ assertFalse( "file list should not be empty.", files.isEmpty() );
+
+ /* Debug */
+ if ( false )
+ {
+ for ( String file : files )
+ {
+ logger.info( "File: '" + file + "'" );
+ }
+ }
+
+ return files;
+ }
+
+ /**
+ * Example showing jetty directory browsing of commons-lang
+ *
+ * @throws TransferFailedException
+ */
+ public void testParseCommonsLang()
+ throws TransferFailedException
+ {
+ List<String> links = parseLinks( "http://localhost/repository/commons-lang/commons-lang/2.3",
+ "commons-lang.html" );
+
+ String[] expected = new String[] {
+ "commons-lang-2.3-javadoc.jar",
+ "commons-lang-2.3-javadoc.jar.asc",
+ "commons-lang-2.3-javadoc.jar.md5",
+ "commons-lang-2.3-javadoc.jar.sha1",
+ "commons-lang-2.3-sources.jar",
+ "commons-lang-2.3-sources.jar.asc",
+ "commons-lang-2.3-sources.jar.md5",
+ "commons-lang-2.3-sources.jar.sha1",
+ "commons-lang-2.3.jar",
+ "commons-lang-2.3.jar.asc",
+ "commons-lang-2.3.jar.md5",
+ "commons-lang-2.3.jar.sha1",
+ "commons-lang-2.3.pom",
+ "commons-lang-2.3.pom.md5",
+ "commons-lang-2.3.pom.sha1",
+ "maven-metadata.xml",
+ "maven-metadata.xml.md5",
+ "maven-metadata.xml.sha1" };
+
+ assertContainsExpected( links, expected );
+
+ String[] avoided = new String[] { "../" };
+
+ assertNotContainingAvoided( links, avoided );
+ }
+
+ public void testParseIbiblio()
+ throws Exception
+ {
+ List<String> links = parseLinks( "http://www.ibiblio.org/maven2/org/apache/maven/wagon/",
+ "ibiblio-wagon.html" );
+
+ String[] expected = new String[] {
+ "wagon-1.0-alpha-2.pom",
+ "wagon-1.0-alpha-2.pom.asc",
+ "wagon-1.0-alpha-2.pom.md5",
+ "wagon-1.0-alpha-2.pom.sha1",
+ "wagon-1.0-alpha-3-20050413.021234-4.pom",
+ "wagon-1.0-alpha-3-20050413.021234-4.pom.md5",
+ "wagon-1.0-alpha-3-20050413.021234-4.pom.sha1",
+ "wagon-1.0-alpha-3-20050419.043745-5.pom",
+ "wagon-1.0-alpha-3-20050419.043745-5.pom.md5",
+ "wagon-1.0-alpha-3-20050419.043745-5.pom.sha1",
+ "wagon-1.0-alpha-3-20050419.044035-6.pom",
+ "wagon-1.0-alpha-3-20050419.044035-6.pom.md5",
+ "wagon-1.0-alpha-3-20050419.044035-6.pom.sha1",
+ "wagon-1.0-alpha-3-20050421.162738-7.pom",
+ "wagon-1.0-alpha-3-20050421.162738-7.pom.md5",
+ "wagon-1.0-alpha-3-20050421.162738-7.pom.sha1",
+ "wagon-1.0-alpha-3-20050422.075233-8.pom",
+ "wagon-1.0-alpha-3-20050422.075233-8.pom.md5",
+ "wagon-1.0-alpha-3-20050422.075233-8.pom.sha1",
+ "wagon-1.0-alpha-3-20050429.051847-9.pom",
+ "wagon-1.0-alpha-3-20050429.051847-9.pom.md5",
+ "wagon-1.0-alpha-3-20050429.051847-9.pom.sha1",
+ "wagon-file/",
+ "wagon-ftp/",
+ "wagon-http-lightweight/",
+ "wagon-http/",
+ "wagon-lightweight-http/",
+ "wagon-provider-api/",
+ "wagon-provider-test/",
+ "wagon-provider/",
+ "wagon-providers-1.0-alpha-2.pom",
+ "wagon-providers-1.0-alpha-2.pom.asc",
+ "wagon-providers-1.0-alpha-2.pom.md5",
+ "wagon-providers-1.0-alpha-2.pom.sha1",
+ "wagon-providers-1.0-alpha-3-20050407.202848-1.pom",
+ "wagon-providers-1.0-alpha-3-20050407.202848-1.pom.md5",
+ "wagon-providers-1.0-alpha-3-20050407.202848-1.pom.sha1",
+ "wagon-providers-1.0-alpha-3-20050419.044035-2.pom",
+ "wagon-providers-1.0-alpha-3-20050419.044035-2.pom.md5",
+ "wagon-providers-1.0-alpha-3-20050419.044035-2.pom.sha1",
+ "wagon-providers-1.0-alpha-3-20050421.162738-3.pom",
+ "wagon-providers-1.0-alpha-3-20050421.162738-3.pom.md5",
+ "wagon-providers-1.0-alpha-3-20050421.162738-3.pom.sha1",
+ "wagon-providers-1.0-alpha-3-20050422.075233-4.pom",
+ "wagon-providers-1.0-alpha-3-20050422.075233-4.pom.md5",
+ "wagon-providers-1.0-alpha-3-20050422.075233-4.pom.sha1",
+ "wagon-providers-1.0-alpha-3-20050429.051847-5.pom",
+ "wagon-providers-1.0-alpha-3-20050429.051847-5.pom.md5",
+ "wagon-providers-1.0-alpha-3-20050429.051847-5.pom.sha1",
+ "wagon-providers/",
+ "wagon-scm/",
+ "wagon-ssh-external/",
+ "wagon-ssh/",
+ "wagon-webdav/",
+ "wagon/" };
+
+ assertContainsExpected( links, expected );
+
+ String[] avoided = new String[] { "/org/", "?C=S;O=A", "?C=D;O=A", "?C=M;O=A", "?D=A", "?M=A", "?N=D", "?S=A" };
+
+ assertNotContainingAvoided( links, avoided );
+ }
+
+ /**
+ * Test of an html which is improperly formatted, and contains full host-specific paths to the resources.
+ * @throws Exception
+ */
+ public void testParseJetty()
+ throws Exception
+ {
+ List<String> links = parseLinks( "http://www.ibiblio.org/maven2/org/apache/maven/wagon/",
+ "jetty-wagon.html" );
+
+ String[] expected = new String[] {
+ "wagon-1.0-alpha-2.pom",
+ "wagon-1.0-alpha-2.pom.asc",
+ "wagon-1.0-alpha-2.pom.md5",
+ "wagon-1.0-alpha-2.pom.sha1",
+ "wagon-1.0-alpha-3-20050413.021234-4.pom",
+ "wagon-1.0-alpha-3-20050413.021234-4.pom.md5",
+ "wagon-1.0-alpha-3-20050413.021234-4.pom.sha1",
+ "wagon-1.0-alpha-3-20050419.043745-5.pom",
+ "wagon-1.0-alpha-3-20050419.043745-5.pom.md5",
+ "wagon-1.0-alpha-3-20050419.043745-5.pom.sha1",
+ "wagon-1.0-alpha-3-20050419.044035-6.pom",
+ "wagon-1.0-alpha-3-20050419.044035-6.pom.md5",
+ "wagon-1.0-alpha-3-20050419.044035-6.pom.sha1",
+ "wagon-1.0-alpha-3-20050421.162738-7.pom",
+ "wagon-1.0-alpha-3-20050421.162738-7.pom.md5",
+ "wagon-1.0-alpha-3-20050421.162738-7.pom.sha1",
+ "wagon-1.0-alpha-3-20050422.075233-8.pom",
+ "wagon-1.0-alpha-3-20050422.075233-8.pom.md5",
+ "wagon-1.0-alpha-3-20050422.075233-8.pom.sha1",
+ "wagon-1.0-alpha-3-20050429.051847-9.pom",
+ "wagon-1.0-alpha-3-20050429.051847-9.pom.md5",
+ "wagon-1.0-alpha-3-20050429.051847-9.pom.sha1",
+ "wagon-file/",
+ "wagon-ftp/",
+ "wagon-http-lightweight/",
+ "wagon-http/",
+ "wagon-lightweight-http/",
+ "wagon-provider-api/",
+ "wagon-provider-test/",
+ "wagon-provider/",
+ "wagon-providers-1.0-alpha-2.pom",
+ "wagon-providers-1.0-alpha-2.pom.asc",
+ "wagon-providers-1.0-alpha-2.pom.md5",
+ "wagon-providers-1.0-alpha-2.pom.sha1",
+ "wagon-providers-1.0-alpha-3-20050407.202848-1.pom",
+ "wagon-providers-1.0-alpha-3-20050407.202848-1.pom.md5",
+ "wagon-providers-1.0-alpha-3-20050407.202848-1.pom.sha1",
+ "wagon-providers-1.0-alpha-3-20050419.044035-2.pom",
+ "wagon-providers-1.0-alpha-3-20050419.044035-2.pom.md5",
+ "wagon-providers-1.0-alpha-3-20050419.044035-2.pom.sha1",
+ "wagon-providers-1.0-alpha-3-20050421.162738-3.pom",
+ "wagon-providers-1.0-alpha-3-20050421.162738-3.pom.md5",
+ "wagon-providers-1.0-alpha-3-20050421.162738-3.pom.sha1",
+ "wagon-providers-1.0-alpha-3-20050422.075233-4.pom",
+ "wagon-providers-1.0-alpha-3-20050422.075233-4.pom.md5",
+ "wagon-providers-1.0-alpha-3-20050422.075233-4.pom.sha1",
+ "wagon-providers-1.0-alpha-3-20050429.051847-5.pom",
+ "wagon-providers-1.0-alpha-3-20050429.051847-5.pom.md5",
+ "wagon-providers-1.0-alpha-3-20050429.051847-5.pom.sha1",
+ "wagon-providers/",
+ "wagon-scm/",
+ "wagon-ssh-external/",
+ "wagon-ssh/",
+ "wagon-webdav/",
+ "wagon/" };
+
+ assertContainsExpected( links, expected );
+
+ String[] avoided = new String[] { "/org/", "?C=S;O=A", "?C=D;O=A", "?C=M;O=A" };
+
+ assertNotContainingAvoided( links, avoided );
+ }
+
+ /**
+ * Test of an html which is improperly formatted, contains full host-specific paths to the resources and uses non-normalized base URI
+ * @throws Exception
+ */
+ public void testParseJettyWithNonNormalizedBaseURI()
+ throws Exception
+ {
+ List<String> links = parseLinks( "http://www.ibiblio.org/maven2/org/apache/maven/wagon//",
+ "jetty-wagon.html" );
+
+ String[] expected = new String[] {
+ "wagon-1.0-alpha-2.pom",
+ "wagon-1.0-alpha-2.pom.asc",
+ "wagon-1.0-alpha-2.pom.md5",
+ "wagon-1.0-alpha-2.pom.sha1",
+ "wagon-1.0-alpha-3-20050413.021234-4.pom",
+ "wagon-1.0-alpha-3-20050413.021234-4.pom.md5",
+ "wagon-1.0-alpha-3-20050413.021234-4.pom.sha1",
+ "wagon-1.0-alpha-3-20050419.043745-5.pom",
+ "wagon-1.0-alpha-3-20050419.043745-5.pom.md5",
+ "wagon-1.0-alpha-3-20050419.043745-5.pom.sha1",
+ "wagon-1.0-alpha-3-20050419.044035-6.pom",
+ "wagon-1.0-alpha-3-20050419.044035-6.pom.md5",
+ "wagon-1.0-alpha-3-20050419.044035-6.pom.sha1",
+ "wagon-1.0-alpha-3-20050421.162738-7.pom",
+ "wagon-1.0-alpha-3-20050421.162738-7.pom.md5",
+ "wagon-1.0-alpha-3-20050421.162738-7.pom.sha1",
+ "wagon-1.0-alpha-3-20050422.075233-8.pom",
+ "wagon-1.0-alpha-3-20050422.075233-8.pom.md5",
+ "wagon-1.0-alpha-3-20050422.075233-8.pom.sha1",
+ "wagon-1.0-alpha-3-20050429.051847-9.pom",
+ "wagon-1.0-alpha-3-20050429.051847-9.pom.md5",
+ "wagon-1.0-alpha-3-20050429.051847-9.pom.sha1",
+ "wagon-file/",
+ "wagon-ftp/",
+ "wagon-http-lightweight/",
+ "wagon-http/",
+ "wagon-lightweight-http/",
+ "wagon-provider-api/",
+ "wagon-provider-test/",
+ "wagon-provider/",
+ "wagon-providers-1.0-alpha-2.pom",
+ "wagon-providers-1.0-alpha-2.pom.asc",
+ "wagon-providers-1.0-alpha-2.pom.md5",
+ "wagon-providers-1.0-alpha-2.pom.sha1",
+ "wagon-providers-1.0-alpha-3-20050407.202848-1.pom",
+ "wagon-providers-1.0-alpha-3-20050407.202848-1.pom.md5",
+ "wagon-providers-1.0-alpha-3-20050407.202848-1.pom.sha1",
+ "wagon-providers-1.0-alpha-3-20050419.044035-2.pom",
+ "wagon-providers-1.0-alpha-3-20050419.044035-2.pom.md5",
+ "wagon-providers-1.0-alpha-3-20050419.044035-2.pom.sha1",
+ "wagon-providers-1.0-alpha-3-20050421.162738-3.pom",
+ "wagon-providers-1.0-alpha-3-20050421.162738-3.pom.md5",
+ "wagon-providers-1.0-alpha-3-20050421.162738-3.pom.sha1",
+ "wagon-providers-1.0-alpha-3-20050422.075233-4.pom",
+ "wagon-providers-1.0-alpha-3-20050422.075233-4.pom.md5",
+ "wagon-providers-1.0-alpha-3-20050422.075233-4.pom.sha1",
+ "wagon-providers-1.0-alpha-3-20050429.051847-5.pom",
+ "wagon-providers-1.0-alpha-3-20050429.051847-5.pom.md5",
+ "wagon-providers-1.0-alpha-3-20050429.051847-5.pom.sha1",
+ "wagon-providers/",
+ "wagon-scm/",
+ "wagon-ssh-external/",
+ "wagon-ssh/",
+ "wagon-webdav/",
+ "wagon/" };
+
+ assertContainsExpected( links, expected );
+
+ String[] avoided = new String[] { "/org/", "?C=S;O=A", "?C=D;O=A", "?C=M;O=A" };
+
+ assertNotContainingAvoided( links, avoided );
+ }
+
+ /**
+ * Using repository.codehaus.org output as an example.
+ * This is an example of an older RHEL installation of apache httpd with old fancy indexing output
+ * This example tests how to detect directories properly.
+ *
+ * @throws TransferFailedException
+ */
+ public void testParseMevenIde()
+ throws TransferFailedException
+ {
+ List<String> links = parseLinks( "http://repository.codehaus.org/org/codehaus/mevenide/", "mevenide.html" );
+
+ String[] expected = new String[] {
+ "apisupport/",
+ "autoupdate/",
+ "continuum-rpc/",
+ "continuum/",
+ "debugger-bridge/",
+ "deployment-bridge/",
+ "feature/",
+ "grammar/",
+ "ide-mojos/",
+ "indexer/",
+ "j2ee/",
+ "junit/",
+ "maven-metadata.xml",
+ "maven-metadata.xml.md5",
+ "maven-metadata.xml.sha1",
+ "mevenide2-parent/",
+ "nb-mvn-embedder/",
+ "nb-project/",
+ "nb-repo-browser/",
+ "netbeans-debugger-plugin/",
+ "netbeans-deploy-plugin/",
+ "netbeans-libs/",
+ "netbeans-nbmreload-plugin/",
+ "netbeans-repository/",
+ "netbeans-run-plugin/",
+ "netbeans/",
+ "persistence/",
+ "plugin-bridges/",
+ "plugins/",
+ "reload-nbm-bridge/",
+ "run-jar-bridge/" };
+
+ assertContainsExpected( links, expected );
+
+ String[] avoided = new String[] { "/org/codehaus/", "?C=S;O=A", "?C=D;O=A", "?C=M;O=A" };
+
+ assertNotContainingAvoided( links, avoided );
+ }
+
+ public void testParseMirror()
+ throws Exception
+ {
+ List<String> links = parseLinks( "http://www.ibiblio.org/maven2/org/apache/maven/wagon/",
+ "mirror-wagon.html" );
+
+ String[] expected = new String[] {
+ "wagon-1.0-alpha-2.pom",
+ "wagon-1.0-alpha-2.pom.asc",
+ "wagon-1.0-alpha-2.pom.md5",
+ "wagon-1.0-alpha-2.pom.sha1",
+ "wagon-1.0-alpha-3-20050413.021234-4.pom",
+ "wagon-1.0-alpha-3-20050413.021234-4.pom.md5",
+ "wagon-1.0-alpha-3-20050413.021234-4.pom.sha1",
+ "wagon-1.0-alpha-3-20050419.043745-5.pom",
+ "wagon-1.0-alpha-3-20050419.043745-5.pom.md5",
+ "wagon-1.0-alpha-3-20050419.043745-5.pom.sha1",
+ "wagon-1.0-alpha-3-20050419.044035-6.pom",
+ "wagon-1.0-alpha-3-20050419.044035-6.pom.md5",
+ "wagon-1.0-alpha-3-20050419.044035-6.pom.sha1",
+ "wagon-1.0-alpha-3-20050421.162738-7.pom",
+ "wagon-1.0-alpha-3-20050421.162738-7.pom.md5",
+ "wagon-1.0-alpha-3-20050421.162738-7.pom.sha1",
+ "wagon-1.0-alpha-3-20050422.075233-8.pom",
+ "wagon-1.0-alpha-3-20050422.075233-8.pom.md5",
+ "wagon-1.0-alpha-3-20050422.075233-8.pom.sha1",
+ "wagon-1.0-alpha-3-20050429.051847-9.pom",
+ "wagon-1.0-alpha-3-20050429.051847-9.pom.md5",
+ "wagon-1.0-alpha-3-20050429.051847-9.pom.sha1",
+ "wagon-file/",
+ "wagon-ftp/",
+ "wagon-http-lightweight/",
+ "wagon-http/",
+ "wagon-lightweight-http/",
+ "wagon-provider-api/",
+ "wagon-provider-test/",
+ "wagon-provider/",
+ "wagon-providers-1.0-alpha-2.pom",
+ "wagon-providers-1.0-alpha-2.pom.asc",
+ "wagon-providers-1.0-alpha-2.pom.md5",
+ "wagon-providers-1.0-alpha-2.pom.sha1",
+ "wagon-providers-1.0-alpha-3-20050407.202848-1.pom",
+ "wagon-providers-1.0-alpha-3-20050407.202848-1.pom.md5",
+ "wagon-providers-1.0-alpha-3-20050407.202848-1.pom.sha1",
+ "wagon-providers-1.0-alpha-3-20050419.044035-2.pom",
+ "wagon-providers-1.0-alpha-3-20050419.044035-2.pom.md5",
+ "wagon-providers-1.0-alpha-3-20050419.044035-2.pom.sha1",
+ "wagon-providers-1.0-alpha-3-20050421.162738-3.pom",
+ "wagon-providers-1.0-alpha-3-20050421.162738-3.pom.md5",
+ "wagon-providers-1.0-alpha-3-20050421.162738-3.pom.sha1",
+ "wagon-providers-1.0-alpha-3-20050422.075233-4.pom",
+ "wagon-providers-1.0-alpha-3-20050422.075233-4.pom.md5",
+ "wagon-providers-1.0-alpha-3-20050422.075233-4.pom.sha1",
+ "wagon-providers-1.0-alpha-3-20050429.051847-5.pom",
+ "wagon-providers-1.0-alpha-3-20050429.051847-5.pom.md5",
+ "wagon-providers-1.0-alpha-3-20050429.051847-5.pom.sha1",
+ "wagon-providers/",
+ "wagon-scm/",
+ "wagon-ssh-external/",
+ "wagon-ssh/",
+ "wagon-webdav/",
+ "wagon/" };
+
+ assertContainsExpected( links, expected );
+
+ String[] avoided = new String[] {
+ "/org/codehaus/",
+ "?C=S;O=A",
+ "?C=D;O=A",
+ "?C=M;O=A",
+ "mailto:mirror.admin at mirror.com" };
+
+ assertNotContainingAvoided( links, avoided );
+ }
+
+ /**
+ * Example of output from repo1.maven.org
+ * This example is of nekohtml specifically.
+ *
+ * @throws TransferFailedException
+ */
+ public void testParseNekoHtml()
+ throws TransferFailedException
+ {
+ List<String> links = parseLinks( "http://repo1.maven.org//maven2/nekohtml/nekohtml/1.9.6/", "nekohtml.html" );
+
+ String[] expected = new String[] {
+ "nekohtml-1.9.6-javadoc.jar",
+ "nekohtml-1.9.6-javadoc.jar.md5",
+ "nekohtml-1.9.6-javadoc.jar.sha1",
+ "nekohtml-1.9.6-sources.jar",
+ "nekohtml-1.9.6-sources.jar.md5",
+ "nekohtml-1.9.6-sources.jar.sha1",
+ "nekohtml-1.9.6.jar",
+ "nekohtml-1.9.6.jar.md5",
+ "nekohtml-1.9.6.jar.sha1",
+ "nekohtml-1.9.6.pom",
+ "nekohtml-1.9.6.pom.md5",
+ "nekohtml-1.9.6.pom.sha1" };
+
+ assertContainsExpected( links, expected );
+
+ String[] avoided = new String[] { "/maven2/nekohtml/nekohtml/", "?C=S;O=A", "?C=D;O=A", "?C=M;O=A" };
+
+ assertNotContainingAvoided( links, avoided );
+ }
+
+ /**
+ * Example of detecting directories on repo1.maven.org
+ *
+ * @throws TransferFailedException
+ */
+ public void testParseNetSourceforge()
+ throws TransferFailedException
+ {
+ List<String> links = parseLinks( "http://repo1.maven.org/maven2/net/sf/", "net_sf.html" );
+
+ String[] expected = new String[] {
+ "a2j/",
+ "aislib/",
+ "alchim/",
+ "antenna/",
+ "apt-jelly/",
+ "beanlib/",
+ "bluecove/",
+ "buildbox/",
+ "click/",
+ "clirr/",
+ "datavision/",
+ "dozer/",
+ "dtddoc/",
+ "dynpageplus/",
+ "ehcache/",
+ "ezmorph/",
+ "falcon/",
+ "grester/",
+ "gwt-widget/",
+ "hermesftp/",
+ "hibernate/",
+ "jcharts/",
+ "jdatabaseimport/",
+ "jeceira/",
+ "jfcunit/",
+ "jfig/",
+ "jguard/",
+ "jipcam/",
+ "jlynx/",
+ "jour/",
+ "jpf/",
+ "json-lib/",
+ "jsptest/",
+ "jsr107cache/",
+ "jt400/",
+ "jxls/",
+ "kxml/",
+ "ldaptemplate/",
+ "locale4j/",
+ "mapasuta/",
+ "maven-har/",
+ "maven-sar/",
+ "opencsv/",
+ "oval/",
+ "proguard/",
+ "qdwizard/",
+ "resultsetmapper/",
+ "retrotranslator/",
+ "saxon/",
+ "shadesdb/",
+ "smc/",
+ "speculoos/",
+ "springlayout/",
+ "stat-scm/",
+ "statsvn/",
+ "stax/",
+ "struts/",
+ "tacos/",
+ "testextensions/",
+ "webdav-servlet/" };
+
+ assertContainsExpected( links, expected );
+
+ String[] avoided = new String[] { "/maven2/net/", "?C=S;O=A", "?C=D;O=A", "?C=M;O=A" };
+
+ assertNotContainingAvoided( links, avoided );
+ }
+
+ /**
+ * Another larger example of the directory link detection on repository.codehaus.org
+ *
+ * @throws TransferFailedException
+ */
+ public void testParseOrgCodehaus()
+ throws TransferFailedException
+ {
+ List<String> links = parseLinks( "http://repository.codehaus.org/org/codehaus", "org.codehaus.html" );
+
+ String[] expected = new String[] {
+ "agilifier/",
+ "benji/",
+ "bruce/",
+ "btm/",
+ "cargo/",
+ "castor-spring/",
+ "castor/",
+ "cozmos/",
+ "dataforge/",
+ "dimple/",
+ "droolsdotnet/",
+ "enunciate/",
+ "fabric3/",
+ "gant/",
+ "grails-plugins/",
+ "groovy/",
+ "gsoc/",
+ "guessencoding/",
+ "gumtree/",
+ "gwt-openlayers/",
+ "haus/",
+ "izpack/",
+ "javasim/",
+ "jedi/",
+ "jequel/",
+ "jet/",
+ "jettison/",
+ "jfdi/",
+ "jikesrvm/",
+ "jra/",
+ "jremoting/",
+ "jtestme/",
+ "jtestr/",
+ "labs-ng/",
+ "logicabyss/",
+ "marionette/",
+ "mevenide/",
+ "modello/",
+ "mojo/",
+ "mvel/",
+ "mvflex/",
+ "native-mojo/",
+ "openim/",
+ "plexus/",
+ "polymap/",
+ "prometheus/",
+ "prophit/",
+ "quaere/",
+ "redback/",
+ "rulessandpit/",
+ "rvm/",
+ "savana/",
+ "scala-ide/",
+ "senro/",
+ "sonar/",
+ "staxmate/",
+ "stomp/",
+ "svn4j/",
+ "swiby/",
+ "swizzle/",
+ "sxc/",
+ "testdox/",
+ "wadi/",
+ "waffle/",
+ "woodstox/",
+ "xdoclet/",
+ "xfire/",
+ "xharness/",
+ "xsite/",
+ "xstream/",
+ "xwire/" };
+
+ assertContainsExpected( links, expected );
+
+ String[] avoided = new String[] { "/org/", "?C=S;O=A", "?C=D;O=A", "?C=M;O=A" };
+
+ assertNotContainingAvoided( links, avoided );
+ }
+
+ /**
+ * Test the output found from apache httpd with fancy indexing and dav module.
+ * Using people.apache.org output as source material.
+ *
+ * @throws TransferFailedException
+ */
+ public void testParsePeopleApacheOrg()
+ throws TransferFailedException
+ {
+ List<String> links = parseLinks(
+ "http://people.apache.org/repo/m2-ibiblio-rsync-repository/org/apache/maven/archiva/archiva-plexus-runtime/1.0.1/",
+ "org.apache.maven.html" );
+
+ String[] expected = new String[] {
+ "archiva-plexus-runtime-1.0.1-bin.tar.gz",
+ "archiva-plexus-runtime-1.0.1-bin.tar.gz.asc",
+ "archiva-plexus-runtime-1.0.1-bin.tar.gz.asc.md5",
+ "archiva-plexus-runtime-1.0.1-bin.tar.gz.asc.sha1",
+ "archiva-plexus-runtime-1.0.1-bin.tar.gz.md5",
+ "archiva-plexus-runtime-1.0.1-bin.tar.gz.sha1",
+ "archiva-plexus-runtime-1.0.1-bin.zip",
+ "archiva-plexus-runtime-1.0.1-bin.zip.asc",
+ "archiva-plexus-runtime-1.0.1-bin.zip.asc.md5",
+ "archiva-plexus-runtime-1.0.1-bin.zip.asc.sha1",
+ "archiva-plexus-runtime-1.0.1-bin.zip.md5",
+ "archiva-plexus-runtime-1.0.1-bin.zip.sha1",
+ "archiva-plexus-runtime-1.0.1-sources.jar",
+ "archiva-plexus-runtime-1.0.1-sources.jar.asc",
+ "archiva-plexus-runtime-1.0.1-sources.jar.asc.md5",
+ "archiva-plexus-runtime-1.0.1-sources.jar.asc.sha1",
+ "archiva-plexus-runtime-1.0.1-sources.jar.md5",
+ "archiva-plexus-runtime-1.0.1-sources.jar.sha1",
+ "archiva-plexus-runtime-1.0.1.jar",
+ "archiva-plexus-runtime-1.0.1.jar.asc",
+ "archiva-plexus-runtime-1.0.1.jar.asc.md5",
+ "archiva-plexus-runtime-1.0.1.jar.asc.sha1",
+ "archiva-plexus-runtime-1.0.1.jar.md5",
+ "archiva-plexus-runtime-1.0.1.jar.sha1",
+ "archiva-plexus-runtime-1.0.1.pom",
+ "archiva-plexus-runtime-1.0.1.pom.asc",
+ "archiva-plexus-runtime-1.0.1.pom.asc.md5",
+ "archiva-plexus-runtime-1.0.1.pom.asc.sha1",
+ "archiva-plexus-runtime-1.0.1.pom.md5",
+ "archiva-plexus-runtime-1.0.1.pom.sha1",
+ "readme artifacts.txt"};
+
+ assertContainsExpected( links, expected );
+
+ String[] avoided = new String[] {
+ "/repo/m2-ibiblio-rsync-repository/org/apache/maven/archiva/archiva-plexus-runtime/",
+ "?C=S;O=A",
+ "?C=D;O=A",
+ "?C=M;O=A" };
+
+ assertNotContainingAvoided( links, avoided );
+ }
+}
diff --git a/wagon-providers/wagon-http-shared/src/test/resources/filelistings/commons-lang.html b/wagon-providers/wagon-http-shared/src/test/resources/filelistings/commons-lang.html
index 66659ef..4bc5080 100644
--- a/wagon-providers/wagon-http-shared/src/test/resources/filelistings/commons-lang.html
+++ b/wagon-providers/wagon-http-shared/src/test/resources/filelistings/commons-lang.html
@@ -1,31 +1,31 @@
-<html>
-<head>
-<title>Collection: /commons-lang/commons-lang/2.3/</title>
-</head>
-<body>
-<h2>Collection: /commons-lang/commons-lang/2.3/</h2>
-<ul>
-<li><a href="../">commons-lang/</a> <i><small>(Parent)</small></i></li>
-</ul>
-<ul>
-<li><a href="./commons-lang-2.3-javadoc.jar">commons-lang-2.3-javadoc.jar</li>
-<li><a href="./commons-lang-2.3-javadoc.jar.asc">commons-lang-2.3-javadoc.jar.asc</li>
-<li><a href="./commons-lang-2.3-javadoc.jar.md5">commons-lang-2.3-javadoc.jar.md5</li>
-<li><a href="./commons-lang-2.3-javadoc.jar.sha1">commons-lang-2.3-javadoc.jar.sha1</li>
-<li><a href="./commons-lang-2.3-sources.jar">commons-lang-2.3-sources.jar</li>
-<li><a href="./commons-lang-2.3-sources.jar.asc">commons-lang-2.3-sources.jar.asc</li>
-<li><a href="./commons-lang-2.3-sources.jar.md5">commons-lang-2.3-sources.jar.md5</li>
-<li><a href="./commons-lang-2.3-sources.jar.sha1">commons-lang-2.3-sources.jar.sha1</li>
-<li><a href="./commons-lang-2.3.jar">commons-lang-2.3.jar</li>
-<li><a href="./commons-lang-2.3.jar.asc">commons-lang-2.3.jar.asc</li>
-<li><a href="./commons-lang-2.3.jar.md5">commons-lang-2.3.jar.md5</li>
-<li><a href="./commons-lang-2.3.jar.sha1">commons-lang-2.3.jar.sha1</li>
-<li><a href="./commons-lang-2.3.pom">commons-lang-2.3.pom</li>
-<li><a href="./commons-lang-2.3.pom.md5">commons-lang-2.3.pom.md5</li>
-<li><a href="./commons-lang-2.3.pom.sha1">commons-lang-2.3.pom.sha1</li>
-<li><a href="./maven-metadata.xml">maven-metadata.xml</li>
-<li><a href="./maven-metadata.xml.md5">maven-metadata.xml.md5</li>
-<li><a href="./maven-metadata.xml.sha1">maven-metadata.xml.sha1</li>
-</ul>
-</body>
-</html>
+<html>
+<head>
+<title>Collection: /commons-lang/commons-lang/2.3/</title>
+</head>
+<body>
+<h2>Collection: /commons-lang/commons-lang/2.3/</h2>
+<ul>
+<li><a href="../">commons-lang/</a> <i><small>(Parent)</small></i></li>
+</ul>
+<ul>
+<li><a href="./commons-lang-2.3-javadoc.jar">commons-lang-2.3-javadoc.jar</li>
+<li><a href="./commons-lang-2.3-javadoc.jar.asc">commons-lang-2.3-javadoc.jar.asc</li>
+<li><a href="./commons-lang-2.3-javadoc.jar.md5">commons-lang-2.3-javadoc.jar.md5</li>
+<li><a href="./commons-lang-2.3-javadoc.jar.sha1">commons-lang-2.3-javadoc.jar.sha1</li>
+<li><a href="./commons-lang-2.3-sources.jar">commons-lang-2.3-sources.jar</li>
+<li><a href="./commons-lang-2.3-sources.jar.asc">commons-lang-2.3-sources.jar.asc</li>
+<li><a href="./commons-lang-2.3-sources.jar.md5">commons-lang-2.3-sources.jar.md5</li>
+<li><a href="./commons-lang-2.3-sources.jar.sha1">commons-lang-2.3-sources.jar.sha1</li>
+<li><a href="./commons-lang-2.3.jar">commons-lang-2.3.jar</li>
+<li><a href="./commons-lang-2.3.jar.asc">commons-lang-2.3.jar.asc</li>
+<li><a href="./commons-lang-2.3.jar.md5">commons-lang-2.3.jar.md5</li>
+<li><a href="./commons-lang-2.3.jar.sha1">commons-lang-2.3.jar.sha1</li>
+<li><a href="./commons-lang-2.3.pom">commons-lang-2.3.pom</li>
+<li><a href="./commons-lang-2.3.pom.md5">commons-lang-2.3.pom.md5</li>
+<li><a href="./commons-lang-2.3.pom.sha1">commons-lang-2.3.pom.sha1</li>
+<li><a href="./maven-metadata.xml">maven-metadata.xml</li>
+<li><a href="./maven-metadata.xml.md5">maven-metadata.xml.md5</li>
+<li><a href="./maven-metadata.xml.sha1">maven-metadata.xml.sha1</li>
+</ul>
+</body>
+</html>
diff --git a/wagon-providers/wagon-http-shared/src/test/resources/filelistings/ibiblio-wagon.html b/wagon-providers/wagon-http-shared/src/test/resources/filelistings/ibiblio-wagon.html
index 618bfa1..5aa410e 100644
--- a/wagon-providers/wagon-http-shared/src/test/resources/filelistings/ibiblio-wagon.html
+++ b/wagon-providers/wagon-http-shared/src/test/resources/filelistings/ibiblio-wagon.html
@@ -1,99 +1,99 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<HTML>
- <HEAD>
- <TITLE>Index of /maven2/org/apache/maven/wagon</TITLE>
- </HEAD>
- <BODY>
-<H1>Index of /maven2/org/apache/maven/wagon</H1>
-<PRE><IMG SRC="/icons/blank.gif" ALT=" "> <A HREF="?N=D">Name</A> <A HREF="?M=A">Last modified</A> <A HREF="?S=A">Size</A> <A HREF="?D=A">Description</A>
-
-<HR>
-<IMG SRC="/icons/back.gif" ALT="[DIR]"> <A HREF="/maven2/org/apache/maven/">Parent Directory</A> 09-May-2006 10:57 -
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-2.pom">wagon-1.0-alpha-2.pom</A> 07-May-2006 18:31 3k
-<IMG SRC="/icons/text.gif" ALT="[TXT]"> <A HREF="wagon-1.0-alpha-2.pom.asc">wagon-1.0-alpha-2.pom.asc</A> 07-May-2006 18:31 1k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-2.pom.md5">wagon-1.0-alpha-2.pom.md5</A> 07-May-2006 18:31 1k
-
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-2.pom.sha1">wagon-1.0-alpha-2.pom.sha1</A> 07-May-2006 18:31 1k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050413.021234-4.pom">wagon-1.0-alpha-3-20050413.021234-4.pom</A> 08-Nov-2005 17:25 3k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050413.021234-4.pom.md5">wagon-1.0-alpha-3-20050413.021234-4.pom.md5</A> 10-May-2006 00:11 1k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050413.021234-4.pom.sha1">wagon-1.0-alpha-3-20050413.021234-4.pom.sha1</A> 10-May-2006 00:11 1k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050419.043745-5.pom">wagon-1.0-alpha-3-20050419.043745-5.pom</A> 08-Nov-2005 17:25 3k
-
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050419.043745-5.pom.md5">wagon-1.0-alpha-3-20050419.043745-5.pom.md5</A> 10-May-2006 00:11 1k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050419.043745-5.pom.sha1">wagon-1.0-alpha-3-20050419.043745-5.pom.sha1</A> 10-May-2006 00:11 1k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050419.044035-6.pom">wagon-1.0-alpha-3-20050419.044035-6.pom</A> 08-Nov-2005 17:25 3k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050419.044035-6.pom.md5">wagon-1.0-alpha-3-20050419.044035-6.pom.md5</A> 10-May-2006 00:11 1k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050419.044035-6.pom.sha1">wagon-1.0-alpha-3-20050419.044035-6.pom.sha1</A> 10-May-2006 00:11 1k
-
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050421.162738-7.pom">wagon-1.0-alpha-3-20050421.162738-7.pom</A> 08-Nov-2005 17:25 3k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050421.162738-7.pom.md5">wagon-1.0-alpha-3-20050421.162738-7.pom.md5</A> 10-May-2006 00:11 1k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050421.162738-7.pom.sha1">wagon-1.0-alpha-3-20050421.162738-7.pom.sha1</A> 10-May-2006 00:11 1k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050422.075233-8.pom">wagon-1.0-alpha-3-20050422.075233-8.pom</A> 08-Nov-2005 17:25 3k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050422.075233-8.pom.md5">wagon-1.0-alpha-3-20050422.075233-8.pom.md5</A> 10-May-2006 00:11 1k
-
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050422.075233-8.pom.sha1">wagon-1.0-alpha-3-20050422.075233-8.pom.sha1</A> 10-May-2006 00:11 1k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050429.051847-9.pom">wagon-1.0-alpha-3-20050429.051847-9.pom</A> 08-Nov-2005 17:25 3k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050429.051847-9.pom.md5">wagon-1.0-alpha-3-20050429.051847-9.pom.md5</A> 10-May-2006 00:11 1k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050429.051847-9.pom.sha1">wagon-1.0-alpha-3-20050429.051847-9.pom.sha1</A> 10-May-2006 00:11 1k
-<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon-file/">wagon-file/</A> 19-Jun-2006 08:27 -
-
-<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon-ftp/">wagon-ftp/</A> 19-Jun-2006 08:28 -
-<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon-http-lightweight/">wagon-http-lightweight/</A> 19-Jun-2006 08:30 -
-<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon-http/">wagon-http/</A> 19-Jun-2006 08:32 -
-<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon-lightweight-http/">wagon-lightweight-http/</A> 07-May-2006 18:31 -
-<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon-provider-api/">wagon-provider-api/</A> 19-Jun-2006 08:20 -
-
-<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon-provider-test/">wagon-provider-test/</A> 19-Jun-2006 08:25 -
-<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon-provider/">wagon-provider/</A> 13-May-2006 04:11 -
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-2.pom">wagon-providers-1.0-alpha-2.pom</A> 07-May-2006 18:31 1k
-<IMG SRC="/icons/text.gif" ALT="[TXT]"> <A HREF="wagon-providers-1.0-alpha-2.pom.asc">wagon-providers-1.0-alpha-2.pom.asc</A> 07-May-2006 18:31 1k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-2.pom.md5">wagon-providers-1.0-alpha-2.pom.md5</A> 07-May-2006 18:31 1k
-
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-2.pom.sha1">wagon-providers-1.0-alpha-2.pom.sha1</A> 07-May-2006 18:31 1k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050407.202848-1.pom">wagon-providers-1.0-alpha-3-20050407.202848-1.pom</A> 08-Nov-2005 17:25 1k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050407.202848-1.pom.md5">wagon-providers-1.0-alpha-3-20050407.202848-1.pom.md5</A> 10-May-2006 00:11 1k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050407.202848-1.pom.sha1">wagon-providers-1.0-alpha-3-20050407.202848-1.pom.sha1</A> 10-May-2006 00:11 1k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050419.044035-2.pom">wagon-providers-1.0-alpha-3-20050419.044035-2.pom</A> 08-Nov-2005 17:25 1k
-
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050419.044035-2.pom.md5">wagon-providers-1.0-alpha-3-20050419.044035-2.pom.md5</A> 10-May-2006 00:11 1k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050419.044035-2.pom.sha1">wagon-providers-1.0-alpha-3-20050419.044035-2.pom.sha1</A> 10-May-2006 00:11 1k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050421.162738-3.pom">wagon-providers-1.0-alpha-3-20050421.162738-3.pom</A> 08-Nov-2005 17:25 1k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050421.162738-3.pom.md5">wagon-providers-1.0-alpha-3-20050421.162738-3.pom.md5</A> 10-May-2006 00:11 1k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050421.162738-3.pom.sha1">wagon-providers-1.0-alpha-3-20050421.162738-3.pom.sha1</A> 10-May-2006 00:11 1k
-
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050422.075233-4.pom">wagon-providers-1.0-alpha-3-20050422.075233-4.pom</A> 08-Nov-2005 17:25 1k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050422.075233-4.pom.md5">wagon-providers-1.0-alpha-3-20050422.075233-4.pom.md5</A> 10-May-2006 00:11 1k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050422.075233-4.pom.sha1">wagon-providers-1.0-alpha-3-20050422.075233-4.pom.sha1</A> 10-May-2006 00:11 1k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050429.051847-5.pom">wagon-providers-1.0-alpha-3-20050429.051847-5.pom</A> 08-Nov-2005 17:25 1k
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050429.051847-5.pom.md5">wagon-providers-1.0-alpha-3-20050429.051847-5.pom.md5</A> 10-May-2006 00:11 1k
-
-<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050429.051847-5.pom.sha1">wagon-providers-1.0-alpha-3-20050429.051847-5.pom.sha1</A> 10-May-2006 00:11 1k
-<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon-providers/">wagon-providers/</A> 19-Jun-2006 08:26 -
-<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon-scm/">wagon-scm/</A> 07-May-2006 19:40 -
-<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon-ssh-external/">wagon-ssh-external/</A> 19-Jun-2006 08:34 -
-<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon-ssh/">wagon-ssh/</A> 19-Jun-2006 08:35 -
-
-<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon-webdav/">wagon-webdav/</A> 19-Jun-2006 08:38 -
-<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon/">wagon/</A> 19-Jun-2006 08:17 -
-</PRE><HR>
-<ADDRESS>Apache/1.3.33 Server at www.ibiblio.org Port 80</ADDRESS>
-</BODY></HTML>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<HTML>
+ <HEAD>
+ <TITLE>Index of /maven2/org/apache/maven/wagon</TITLE>
+ </HEAD>
+ <BODY>
+<H1>Index of /maven2/org/apache/maven/wagon</H1>
+<PRE><IMG SRC="/icons/blank.gif" ALT=" "> <A HREF="?N=D">Name</A> <A HREF="?M=A">Last modified</A> <A HREF="?S=A">Size</A> <A HREF="?D=A">Description</A>
+
+<HR>
+<IMG SRC="/icons/back.gif" ALT="[DIR]"> <A HREF="/maven2/org/apache/maven/">Parent Directory</A> 09-May-2006 10:57 -
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-2.pom">wagon-1.0-alpha-2.pom</A> 07-May-2006 18:31 3k
+<IMG SRC="/icons/text.gif" ALT="[TXT]"> <A HREF="wagon-1.0-alpha-2.pom.asc">wagon-1.0-alpha-2.pom.asc</A> 07-May-2006 18:31 1k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-2.pom.md5">wagon-1.0-alpha-2.pom.md5</A> 07-May-2006 18:31 1k
+
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-2.pom.sha1">wagon-1.0-alpha-2.pom.sha1</A> 07-May-2006 18:31 1k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050413.021234-4.pom">wagon-1.0-alpha-3-20050413.021234-4.pom</A> 08-Nov-2005 17:25 3k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050413.021234-4.pom.md5">wagon-1.0-alpha-3-20050413.021234-4.pom.md5</A> 10-May-2006 00:11 1k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050413.021234-4.pom.sha1">wagon-1.0-alpha-3-20050413.021234-4.pom.sha1</A> 10-May-2006 00:11 1k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050419.043745-5.pom">wagon-1.0-alpha-3-20050419.043745-5.pom</A> 08-Nov-2005 17:25 3k
+
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050419.043745-5.pom.md5">wagon-1.0-alpha-3-20050419.043745-5.pom.md5</A> 10-May-2006 00:11 1k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050419.043745-5.pom.sha1">wagon-1.0-alpha-3-20050419.043745-5.pom.sha1</A> 10-May-2006 00:11 1k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050419.044035-6.pom">wagon-1.0-alpha-3-20050419.044035-6.pom</A> 08-Nov-2005 17:25 3k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050419.044035-6.pom.md5">wagon-1.0-alpha-3-20050419.044035-6.pom.md5</A> 10-May-2006 00:11 1k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050419.044035-6.pom.sha1">wagon-1.0-alpha-3-20050419.044035-6.pom.sha1</A> 10-May-2006 00:11 1k
+
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050421.162738-7.pom">wagon-1.0-alpha-3-20050421.162738-7.pom</A> 08-Nov-2005 17:25 3k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050421.162738-7.pom.md5">wagon-1.0-alpha-3-20050421.162738-7.pom.md5</A> 10-May-2006 00:11 1k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050421.162738-7.pom.sha1">wagon-1.0-alpha-3-20050421.162738-7.pom.sha1</A> 10-May-2006 00:11 1k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050422.075233-8.pom">wagon-1.0-alpha-3-20050422.075233-8.pom</A> 08-Nov-2005 17:25 3k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050422.075233-8.pom.md5">wagon-1.0-alpha-3-20050422.075233-8.pom.md5</A> 10-May-2006 00:11 1k
+
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050422.075233-8.pom.sha1">wagon-1.0-alpha-3-20050422.075233-8.pom.sha1</A> 10-May-2006 00:11 1k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050429.051847-9.pom">wagon-1.0-alpha-3-20050429.051847-9.pom</A> 08-Nov-2005 17:25 3k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050429.051847-9.pom.md5">wagon-1.0-alpha-3-20050429.051847-9.pom.md5</A> 10-May-2006 00:11 1k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-1.0-alpha-3-20050429.051847-9.pom.sha1">wagon-1.0-alpha-3-20050429.051847-9.pom.sha1</A> 10-May-2006 00:11 1k
+<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon-file/">wagon-file/</A> 19-Jun-2006 08:27 -
+
+<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon-ftp/">wagon-ftp/</A> 19-Jun-2006 08:28 -
+<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon-http-lightweight/">wagon-http-lightweight/</A> 19-Jun-2006 08:30 -
+<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon-http/">wagon-http/</A> 19-Jun-2006 08:32 -
+<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon-lightweight-http/">wagon-lightweight-http/</A> 07-May-2006 18:31 -
+<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon-provider-api/">wagon-provider-api/</A> 19-Jun-2006 08:20 -
+
+<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon-provider-test/">wagon-provider-test/</A> 19-Jun-2006 08:25 -
+<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon-provider/">wagon-provider/</A> 13-May-2006 04:11 -
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-2.pom">wagon-providers-1.0-alpha-2.pom</A> 07-May-2006 18:31 1k
+<IMG SRC="/icons/text.gif" ALT="[TXT]"> <A HREF="wagon-providers-1.0-alpha-2.pom.asc">wagon-providers-1.0-alpha-2.pom.asc</A> 07-May-2006 18:31 1k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-2.pom.md5">wagon-providers-1.0-alpha-2.pom.md5</A> 07-May-2006 18:31 1k
+
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-2.pom.sha1">wagon-providers-1.0-alpha-2.pom.sha1</A> 07-May-2006 18:31 1k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050407.202848-1.pom">wagon-providers-1.0-alpha-3-20050407.202848-1.pom</A> 08-Nov-2005 17:25 1k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050407.202848-1.pom.md5">wagon-providers-1.0-alpha-3-20050407.202848-1.pom.md5</A> 10-May-2006 00:11 1k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050407.202848-1.pom.sha1">wagon-providers-1.0-alpha-3-20050407.202848-1.pom.sha1</A> 10-May-2006 00:11 1k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050419.044035-2.pom">wagon-providers-1.0-alpha-3-20050419.044035-2.pom</A> 08-Nov-2005 17:25 1k
+
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050419.044035-2.pom.md5">wagon-providers-1.0-alpha-3-20050419.044035-2.pom.md5</A> 10-May-2006 00:11 1k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050419.044035-2.pom.sha1">wagon-providers-1.0-alpha-3-20050419.044035-2.pom.sha1</A> 10-May-2006 00:11 1k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050421.162738-3.pom">wagon-providers-1.0-alpha-3-20050421.162738-3.pom</A> 08-Nov-2005 17:25 1k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050421.162738-3.pom.md5">wagon-providers-1.0-alpha-3-20050421.162738-3.pom.md5</A> 10-May-2006 00:11 1k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050421.162738-3.pom.sha1">wagon-providers-1.0-alpha-3-20050421.162738-3.pom.sha1</A> 10-May-2006 00:11 1k
+
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050422.075233-4.pom">wagon-providers-1.0-alpha-3-20050422.075233-4.pom</A> 08-Nov-2005 17:25 1k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050422.075233-4.pom.md5">wagon-providers-1.0-alpha-3-20050422.075233-4.pom.md5</A> 10-May-2006 00:11 1k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050422.075233-4.pom.sha1">wagon-providers-1.0-alpha-3-20050422.075233-4.pom.sha1</A> 10-May-2006 00:11 1k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050429.051847-5.pom">wagon-providers-1.0-alpha-3-20050429.051847-5.pom</A> 08-Nov-2005 17:25 1k
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050429.051847-5.pom.md5">wagon-providers-1.0-alpha-3-20050429.051847-5.pom.md5</A> 10-May-2006 00:11 1k
+
+<IMG SRC="/icons/unknown.gif" ALT="[ ]"> <A HREF="wagon-providers-1.0-alpha-3-20050429.051847-5.pom.sha1">wagon-providers-1.0-alpha-3-20050429.051847-5.pom.sha1</A> 10-May-2006 00:11 1k
+<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon-providers/">wagon-providers/</A> 19-Jun-2006 08:26 -
+<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon-scm/">wagon-scm/</A> 07-May-2006 19:40 -
+<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon-ssh-external/">wagon-ssh-external/</A> 19-Jun-2006 08:34 -
+<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon-ssh/">wagon-ssh/</A> 19-Jun-2006 08:35 -
+
+<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon-webdav/">wagon-webdav/</A> 19-Jun-2006 08:38 -
+<IMG SRC="/icons/folder.gif" ALT="[DIR]"> <A HREF="wagon/">wagon/</A> 19-Jun-2006 08:17 -
+</PRE><HR>
+<ADDRESS>Apache/1.3.33 Server at www.ibiblio.org Port 80</ADDRESS>
+</BODY></HTML>
diff --git a/wagon-providers/wagon-http-shared/src/test/resources/filelistings/jetty-wagon.html b/wagon-providers/wagon-http-shared/src/test/resources/filelistings/jetty-wagon.html
index 45187e4..e0cba6b 100644
--- a/wagon-providers/wagon-http-shared/src/test/resources/filelistings/jetty-wagon.html
+++ b/wagon-providers/wagon-http-shared/src/test/resources/filelistings/jetty-wagon.html
@@ -1,90 +1,90 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<HTML><HEAD><TITLE>Directory: /maven2/</TITLE></HEAD><BODY>
-<H1>Directory: /maven2/</H1><TABLE BORDER=0><TR><TD><A HREF=/maven2/org/apache/maven/wagon/../>Parent Directory</A></TD><TD></TD><TD></TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-2.pom">wagon-1.0-alpha-2.pom </TD><TD ALIGN=right>3k </TD><TD>07-May-2006 18:31</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-2.pom.asc">wagon-1.0-alpha-2.pom.asc </TD><TD ALIGN=right>1k </TD><TD>07-May-2006 18:31</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-2.pom.md5">wagon-1.0-alpha-2.pom.md5 </TD><TD ALIGN=right>1k </TD><TD>07-May-2006 18:31</TD></TR>
-
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-2.pom.sha1">wagon-1.0-alpha-2.pom.sha1 </TD><TD ALIGN=right>1k </TD><TD>07-May-2006 18:31</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050413.021234-4.pom">wagon-1.0-alpha-3-20050413.021234-4.pom </TD><TD ALIGN=right>3k </TD><TD>08-Nov-2005 17:25</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050413.021234-4.pom.md5">wagon-1.0-alpha-3-20050413.021234-4.pom.md5 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050413.021234-4.pom.sha1">wagon-1.0-alpha-3-20050413.021234-4.pom.sha1 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050419.043745-5.pom">wagon-1.0-alpha-3-20050419.043745-5.pom </TD><TD ALIGN=right>3k </TD><TD>08-Nov-2005 17:25</TD></TR>
-
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050419.043745-5.pom.md5">wagon-1.0-alpha-3-20050419.043745-5.pom.md5 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050419.043745-5.pom.sha1">wagon-1.0-alpha-3-20050419.043745-5.pom.sha1 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050419.044035-6.pom">wagon-1.0-alpha-3-20050419.044035-6.pom </TD><TD ALIGN=right>3k </TD><TD>08-Nov-2005 17:25</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050419.044035-6.pom.md5">wagon-1.0-alpha-3-20050419.044035-6.pom.md5 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050419.044035-6.pom.sha1">wagon-1.0-alpha-3-20050419.044035-6.pom.sha1 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
-
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050421.162738-7.pom">wagon-1.0-alpha-3-20050421.162738-7.pom </TD><TD ALIGN=right>3k </TD><TD>08-Nov-2005 17:25</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050421.162738-7.pom.md5">wagon-1.0-alpha-3-20050421.162738-7.pom.md5 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050421.162738-7.pom.sha1">wagon-1.0-alpha-3-20050421.162738-7.pom.sha1 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050422.075233-8.pom">wagon-1.0-alpha-3-20050422.075233-8.pom </TD><TD ALIGN=right>3k </TD><TD>08-Nov-2005 17:25</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050422.075233-8.pom.md5">wagon-1.0-alpha-3-20050422.075233-8.pom.md5 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
-
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050422.075233-8.pom.sha1">wagon-1.0-alpha-3-20050422.075233-8.pom.sha1 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050429.051847-9.pom">wagon-1.0-alpha-3-20050429.051847-9.pom </TD><TD ALIGN=right>3k </TD><TD>08-Nov-2005 17:25</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050429.051847-9.pom.md5">wagon-1.0-alpha-3-20050429.051847-9.pom.md5 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050429.051847-9.pom.sha1">wagon-1.0-alpha-3-20050429.051847-9.pom.sha1 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-file/">wagon-file/ </TD><TD ALIGN=right>- </TD><TD>19-Jun-2006 08:27</TD></TR>
-
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-ftp/">wagon-ftp/ </TD><TD ALIGN=right>- </TD><TD>19-Jun-2006 08:28</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-http-lightweight/">wagon-http-lightweight/ </TD><TD ALIGN=right>- </TD><TD>19-Jun-2006 08:30</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-http/">wagon-http/ </TD><TD ALIGN=right>- </TD><TD>19-Jun-2006 08:32</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-lightweight-http/">wagon-lightweight-http/ </TD><TD ALIGN=right>- </TD><TD>07-May-2006 18:31</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-provider-api/">wagon-provider-api/ </TD><TD ALIGN=right>- </TD><TD>19-Jun-2006 08:20</TD></TR>
-
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-provider-test/">wagon-provider-test/ </TD><TD ALIGN=right>- </TD><TD>19-Jun-2006 08:25</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-provider/">wagon-provider/ </TD><TD ALIGN=right>- </TD><TD>13-May-2006 04:11</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-2.pom">wagon-providers-1.0-alpha-2.pom </TD><TD ALIGN=right>1k </TD><TD>07-May-2006 18:31</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-2.pom.asc">wagon-providers-1.0-alpha-2.pom.asc </TD><TD ALIGN=right>1k </TD><TD>07-May-2006 18:31</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-2.pom.md5">wagon-providers-1.0-alpha-2.pom.md5 </TD><TD ALIGN=right>1k </TD><TD>07-May-2006 18:31</TD></TR>
-
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-2.pom.sha1">wagon-providers-1.0-alpha-2.pom.sha1 </TD><TD ALIGN=right>1k </TD><TD>07-May-2006 18:31</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050407.202848-1.pom">wagon-providers-1.0-alpha-3-20050407.202848-1.pom </TD><TD ALIGN=right>1k </TD><TD>08-Nov-2005 17:25</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050407.202848-1.pom.md5">wagon-providers-1.0-alpha-3-20050407.202848-1.pom.md5 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050407.202848-1.pom.sha1">wagon-providers-1.0-alpha-3-20050407.202848-1.pom.sha1 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050419.044035-2.pom">wagon-providers-1.0-alpha-3-20050419.044035-2.pom </TD><TD ALIGN=right>1k </TD><TD>08-Nov-2005 17:25</TD></TR>
-
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050419.044035-2.pom.md5">wagon-providers-1.0-alpha-3-20050419.044035-2.pom.md5 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050419.044035-2.pom.sha1">wagon-providers-1.0-alpha-3-20050419.044035-2.pom.sha1 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050421.162738-3.pom">wagon-providers-1.0-alpha-3-20050421.162738-3.pom </TD><TD ALIGN=right>1k </TD><TD>08-Nov-2005 17:25</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050421.162738-3.pom.md5">wagon-providers-1.0-alpha-3-20050421.162738-3.pom.md5 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050421.162738-3.pom.sha1">wagon-providers-1.0-alpha-3-20050421.162738-3.pom.sha1 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
-
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050422.075233-4.pom">wagon-providers-1.0-alpha-3-20050422.075233-4.pom </TD><TD ALIGN=right>1k </TD><TD>08-Nov-2005 17:25</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050422.075233-4.pom.md5">wagon-providers-1.0-alpha-3-20050422.075233-4.pom.md5 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050422.075233-4.pom.sha1">wagon-providers-1.0-alpha-3-20050422.075233-4.pom.sha1 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050429.051847-5.pom">wagon-providers-1.0-alpha-3-20050429.051847-5.pom </TD><TD ALIGN=right>1k </TD><TD>08-Nov-2005 17:25</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050429.051847-5.pom.md5">wagon-providers-1.0-alpha-3-20050429.051847-5.pom.md5 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
-
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050429.051847-5.pom.sha1">wagon-providers-1.0-alpha-3-20050429.051847-5.pom.sha1 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers/">wagon-providers/ </TD><TD ALIGN=right>- </TD><TD>19-Jun-2006 08:26</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-scm/">wagon-scm/ </TD><TD ALIGN=right>- </TD><TD>07-May-2006 19:40</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-ssh-external/">wagon-ssh-external/ </TD><TD ALIGN=right>- </TD><TD>19-Jun-2006 08:34</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-ssh/">wagon-ssh/ </TD><TD ALIGN=right>- </TD><TD>19-Jun-2006 08:35</TD></TR>
-
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-webdav/">wagon-webdav/ </TD><TD ALIGN=right>- </TD><TD>19-Jun-2006 08:38</TD></TR>
-<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon/">wagon/ </TD><TD ALIGN=right>- </TD><TD>19-Jun-2006 08:17</TD></TR>
-
-
-</TABLE>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<HTML><HEAD><TITLE>Directory: /maven2/</TITLE></HEAD><BODY>
+<H1>Directory: /maven2/</H1><TABLE BORDER=0><TR><TD><A HREF=/maven2/org/apache/maven/wagon/../>Parent Directory</A></TD><TD></TD><TD></TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-2.pom">wagon-1.0-alpha-2.pom </TD><TD ALIGN=right>3k </TD><TD>07-May-2006 18:31</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-2.pom.asc">wagon-1.0-alpha-2.pom.asc </TD><TD ALIGN=right>1k </TD><TD>07-May-2006 18:31</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-2.pom.md5">wagon-1.0-alpha-2.pom.md5 </TD><TD ALIGN=right>1k </TD><TD>07-May-2006 18:31</TD></TR>
+
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-2.pom.sha1">wagon-1.0-alpha-2.pom.sha1 </TD><TD ALIGN=right>1k </TD><TD>07-May-2006 18:31</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050413.021234-4.pom">wagon-1.0-alpha-3-20050413.021234-4.pom </TD><TD ALIGN=right>3k </TD><TD>08-Nov-2005 17:25</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050413.021234-4.pom.md5">wagon-1.0-alpha-3-20050413.021234-4.pom.md5 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050413.021234-4.pom.sha1">wagon-1.0-alpha-3-20050413.021234-4.pom.sha1 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050419.043745-5.pom">wagon-1.0-alpha-3-20050419.043745-5.pom </TD><TD ALIGN=right>3k </TD><TD>08-Nov-2005 17:25</TD></TR>
+
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050419.043745-5.pom.md5">wagon-1.0-alpha-3-20050419.043745-5.pom.md5 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050419.043745-5.pom.sha1">wagon-1.0-alpha-3-20050419.043745-5.pom.sha1 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050419.044035-6.pom">wagon-1.0-alpha-3-20050419.044035-6.pom </TD><TD ALIGN=right>3k </TD><TD>08-Nov-2005 17:25</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050419.044035-6.pom.md5">wagon-1.0-alpha-3-20050419.044035-6.pom.md5 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050419.044035-6.pom.sha1">wagon-1.0-alpha-3-20050419.044035-6.pom.sha1 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
+
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050421.162738-7.pom">wagon-1.0-alpha-3-20050421.162738-7.pom </TD><TD ALIGN=right>3k </TD><TD>08-Nov-2005 17:25</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050421.162738-7.pom.md5">wagon-1.0-alpha-3-20050421.162738-7.pom.md5 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050421.162738-7.pom.sha1">wagon-1.0-alpha-3-20050421.162738-7.pom.sha1 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050422.075233-8.pom">wagon-1.0-alpha-3-20050422.075233-8.pom </TD><TD ALIGN=right>3k </TD><TD>08-Nov-2005 17:25</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050422.075233-8.pom.md5">wagon-1.0-alpha-3-20050422.075233-8.pom.md5 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
+
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050422.075233-8.pom.sha1">wagon-1.0-alpha-3-20050422.075233-8.pom.sha1 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050429.051847-9.pom">wagon-1.0-alpha-3-20050429.051847-9.pom </TD><TD ALIGN=right>3k </TD><TD>08-Nov-2005 17:25</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050429.051847-9.pom.md5">wagon-1.0-alpha-3-20050429.051847-9.pom.md5 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-1.0-alpha-3-20050429.051847-9.pom.sha1">wagon-1.0-alpha-3-20050429.051847-9.pom.sha1 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-file/">wagon-file/ </TD><TD ALIGN=right>- </TD><TD>19-Jun-2006 08:27</TD></TR>
+
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-ftp/">wagon-ftp/ </TD><TD ALIGN=right>- </TD><TD>19-Jun-2006 08:28</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-http-lightweight/">wagon-http-lightweight/ </TD><TD ALIGN=right>- </TD><TD>19-Jun-2006 08:30</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-http/">wagon-http/ </TD><TD ALIGN=right>- </TD><TD>19-Jun-2006 08:32</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-lightweight-http/">wagon-lightweight-http/ </TD><TD ALIGN=right>- </TD><TD>07-May-2006 18:31</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-provider-api/">wagon-provider-api/ </TD><TD ALIGN=right>- </TD><TD>19-Jun-2006 08:20</TD></TR>
+
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-provider-test/">wagon-provider-test/ </TD><TD ALIGN=right>- </TD><TD>19-Jun-2006 08:25</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-provider/">wagon-provider/ </TD><TD ALIGN=right>- </TD><TD>13-May-2006 04:11</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-2.pom">wagon-providers-1.0-alpha-2.pom </TD><TD ALIGN=right>1k </TD><TD>07-May-2006 18:31</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-2.pom.asc">wagon-providers-1.0-alpha-2.pom.asc </TD><TD ALIGN=right>1k </TD><TD>07-May-2006 18:31</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-2.pom.md5">wagon-providers-1.0-alpha-2.pom.md5 </TD><TD ALIGN=right>1k </TD><TD>07-May-2006 18:31</TD></TR>
+
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-2.pom.sha1">wagon-providers-1.0-alpha-2.pom.sha1 </TD><TD ALIGN=right>1k </TD><TD>07-May-2006 18:31</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050407.202848-1.pom">wagon-providers-1.0-alpha-3-20050407.202848-1.pom </TD><TD ALIGN=right>1k </TD><TD>08-Nov-2005 17:25</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050407.202848-1.pom.md5">wagon-providers-1.0-alpha-3-20050407.202848-1.pom.md5 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050407.202848-1.pom.sha1">wagon-providers-1.0-alpha-3-20050407.202848-1.pom.sha1 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050419.044035-2.pom">wagon-providers-1.0-alpha-3-20050419.044035-2.pom </TD><TD ALIGN=right>1k </TD><TD>08-Nov-2005 17:25</TD></TR>
+
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050419.044035-2.pom.md5">wagon-providers-1.0-alpha-3-20050419.044035-2.pom.md5 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050419.044035-2.pom.sha1">wagon-providers-1.0-alpha-3-20050419.044035-2.pom.sha1 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050421.162738-3.pom">wagon-providers-1.0-alpha-3-20050421.162738-3.pom </TD><TD ALIGN=right>1k </TD><TD>08-Nov-2005 17:25</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050421.162738-3.pom.md5">wagon-providers-1.0-alpha-3-20050421.162738-3.pom.md5 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050421.162738-3.pom.sha1">wagon-providers-1.0-alpha-3-20050421.162738-3.pom.sha1 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
+
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050422.075233-4.pom">wagon-providers-1.0-alpha-3-20050422.075233-4.pom </TD><TD ALIGN=right>1k </TD><TD>08-Nov-2005 17:25</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050422.075233-4.pom.md5">wagon-providers-1.0-alpha-3-20050422.075233-4.pom.md5 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050422.075233-4.pom.sha1">wagon-providers-1.0-alpha-3-20050422.075233-4.pom.sha1 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050429.051847-5.pom">wagon-providers-1.0-alpha-3-20050429.051847-5.pom </TD><TD ALIGN=right>1k </TD><TD>08-Nov-2005 17:25</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050429.051847-5.pom.md5">wagon-providers-1.0-alpha-3-20050429.051847-5.pom.md5 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
+
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers-1.0-alpha-3-20050429.051847-5.pom.sha1">wagon-providers-1.0-alpha-3-20050429.051847-5.pom.sha1 </TD><TD ALIGN=right>1k </TD><TD>10-May-2006 00:11</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-providers/">wagon-providers/ </TD><TD ALIGN=right>- </TD><TD>19-Jun-2006 08:26</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-scm/">wagon-scm/ </TD><TD ALIGN=right>- </TD><TD>07-May-2006 19:40</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-ssh-external/">wagon-ssh-external/ </TD><TD ALIGN=right>- </TD><TD>19-Jun-2006 08:34</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-ssh/">wagon-ssh/ </TD><TD ALIGN=right>- </TD><TD>19-Jun-2006 08:35</TD></TR>
+
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon-webdav/">wagon-webdav/ </TD><TD ALIGN=right>- </TD><TD>19-Jun-2006 08:38</TD></TR>
+<TR><TD><A HREF="/maven2/org/apache/maven/wagon/wagon/">wagon/ </TD><TD ALIGN=right>- </TD><TD>19-Jun-2006 08:17</TD></TR>
+
+
+</TABLE>
diff --git a/wagon-providers/wagon-http-shared/src/test/resources/filelistings/mevenide.html b/wagon-providers/wagon-http-shared/src/test/resources/filelistings/mevenide.html
index 9d09cfb..808e744 100644
--- a/wagon-providers/wagon-http-shared/src/test/resources/filelistings/mevenide.html
+++ b/wagon-providers/wagon-http-shared/src/test/resources/filelistings/mevenide.html
@@ -1,42 +1,42 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
- <head>
- <title>Index of /org/codehaus/mevenide</title>
- </head>
- <body>
-<h1>Index of /org/codehaus/mevenide</h1>
-<pre><img src="/icons/blank.gif" alt="Icon "> <a href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr><img src="/icons/back.gif" alt="[DIR]"> <a href="/org/codehaus/">Parent Directory</a> -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="apisupport/">apisupport/</a> 22-Jan-2008 03:01 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="autoupdate/">autoupdate/</a> 22-Jan-2008 02:57 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="continuum-rpc/">continuum-rpc/</a> 09-Aug-2006 12:41 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="continuum/">continuum/</a> 09-Aug-2006 12:41 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="debugger-bridge/">debugger-bridge/</a> 22-Jan-2008 02:53 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="deployment-bridge/">deployment-bridge/</a> 22-Jan-2008 02:55 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="feature/">feature/</a> 22-Jan-2008 03:01 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="grammar/">grammar/</a> 22-Jan-2008 02:55 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="ide-mojos/">ide-mojos/</a> 31-Aug-2007 06:04 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="indexer/">indexer/</a> 22-Jan-2008 02:54 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="j2ee/">j2ee/</a> 22-Jan-2008 02:56 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="junit/">junit/</a> 22-Jan-2008 03:02 -
-<img src="/icons/text.gif" alt="[TXT]"> <a href="maven-metadata.xml">maven-metadata.xml</a> 22-Jan-2008 02:59 780
-<img src="/icons/text.gif" alt="[TXT]"> <a href="maven-metadata.xml.md5">maven-metadata.xml.md5</a> 22-Jan-2008 02:59 32
-<img src="/icons/text.gif" alt="[TXT]"> <a href="maven-metadata.xml.sha1">maven-metadata.xml.sha1</a> 22-Jan-2008 02:59 40
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="mevenide2-parent/">mevenide2-parent/</a> 18-Dec-2007 11:47 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="nb-mvn-embedder/">nb-mvn-embedder/</a> 22-Jan-2008 02:52 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="nb-project/">nb-project/</a> 22-Jan-2008 02:54 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="nb-repo-browser/">nb-repo-browser/</a> 24-Oct-2006 13:06 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="netbeans-debugger-plugin/">netbeans-debugger-plugin/</a> 31-Aug-2007 06:35 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="netbeans-deploy-plugin/">netbeans-deploy-plugin/</a> 31-Aug-2007 06:36 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="netbeans-libs/">netbeans-libs/</a> 22-Jan-2008 02:52 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="netbeans-nbmreload-plugin/">netbeans-nbmreload-plugin/</a> 31-Aug-2007 06:37 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="netbeans-repository/">netbeans-repository/</a> 22-Jan-2008 03:00 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="netbeans-run-plugin/">netbeans-run-plugin/</a> 31-Aug-2007 06:36 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="netbeans/">netbeans/</a> 22-Jan-2008 02:52 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="persistence/">persistence/</a> 22-Jan-2008 02:57 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="plugin-bridges/">plugin-bridges/</a> 22-Jan-2008 02:53 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="plugins/">plugins/</a> 17-May-2006 17:24 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="reload-nbm-bridge/">reload-nbm-bridge/</a> 22-Jan-2008 02:59 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="run-jar-bridge/">run-jar-bridge/</a> 22-Jan-2008 02:53 -
-<hr></pre>
-<address>Apache/2.0.52 (Red Hat) Server at repository.codehaus.org Port 80</address>
-</body></html>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /org/codehaus/mevenide</title>
+ </head>
+ <body>
+<h1>Index of /org/codehaus/mevenide</h1>
+<pre><img src="/icons/blank.gif" alt="Icon "> <a href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr><img src="/icons/back.gif" alt="[DIR]"> <a href="/org/codehaus/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="apisupport/">apisupport/</a> 22-Jan-2008 03:01 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="autoupdate/">autoupdate/</a> 22-Jan-2008 02:57 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="continuum-rpc/">continuum-rpc/</a> 09-Aug-2006 12:41 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="continuum/">continuum/</a> 09-Aug-2006 12:41 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="debugger-bridge/">debugger-bridge/</a> 22-Jan-2008 02:53 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="deployment-bridge/">deployment-bridge/</a> 22-Jan-2008 02:55 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="feature/">feature/</a> 22-Jan-2008 03:01 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="grammar/">grammar/</a> 22-Jan-2008 02:55 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="ide-mojos/">ide-mojos/</a> 31-Aug-2007 06:04 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="indexer/">indexer/</a> 22-Jan-2008 02:54 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="j2ee/">j2ee/</a> 22-Jan-2008 02:56 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="junit/">junit/</a> 22-Jan-2008 03:02 -
+<img src="/icons/text.gif" alt="[TXT]"> <a href="maven-metadata.xml">maven-metadata.xml</a> 22-Jan-2008 02:59 780
+<img src="/icons/text.gif" alt="[TXT]"> <a href="maven-metadata.xml.md5">maven-metadata.xml.md5</a> 22-Jan-2008 02:59 32
+<img src="/icons/text.gif" alt="[TXT]"> <a href="maven-metadata.xml.sha1">maven-metadata.xml.sha1</a> 22-Jan-2008 02:59 40
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="mevenide2-parent/">mevenide2-parent/</a> 18-Dec-2007 11:47 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="nb-mvn-embedder/">nb-mvn-embedder/</a> 22-Jan-2008 02:52 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="nb-project/">nb-project/</a> 22-Jan-2008 02:54 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="nb-repo-browser/">nb-repo-browser/</a> 24-Oct-2006 13:06 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="netbeans-debugger-plugin/">netbeans-debugger-plugin/</a> 31-Aug-2007 06:35 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="netbeans-deploy-plugin/">netbeans-deploy-plugin/</a> 31-Aug-2007 06:36 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="netbeans-libs/">netbeans-libs/</a> 22-Jan-2008 02:52 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="netbeans-nbmreload-plugin/">netbeans-nbmreload-plugin/</a> 31-Aug-2007 06:37 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="netbeans-repository/">netbeans-repository/</a> 22-Jan-2008 03:00 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="netbeans-run-plugin/">netbeans-run-plugin/</a> 31-Aug-2007 06:36 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="netbeans/">netbeans/</a> 22-Jan-2008 02:52 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="persistence/">persistence/</a> 22-Jan-2008 02:57 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="plugin-bridges/">plugin-bridges/</a> 22-Jan-2008 02:53 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="plugins/">plugins/</a> 17-May-2006 17:24 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="reload-nbm-bridge/">reload-nbm-bridge/</a> 22-Jan-2008 02:59 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="run-jar-bridge/">run-jar-bridge/</a> 22-Jan-2008 02:53 -
+<hr></pre>
+<address>Apache/2.0.52 (Red Hat) Server at repository.codehaus.org Port 80</address>
+</body></html>
diff --git a/wagon-providers/wagon-http-shared/src/test/resources/filelistings/mirror-wagon.html b/wagon-providers/wagon-http-shared/src/test/resources/filelistings/mirror-wagon.html
index 33da508..787e36a 100644
--- a/wagon-providers/wagon-http-shared/src/test/resources/filelistings/mirror-wagon.html
+++ b/wagon-providers/wagon-http-shared/src/test/resources/filelistings/mirror-wagon.html
@@ -1,112 +1,112 @@
-<?xml version="1.0" encoding="iso-8859-1"?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
-<head>
-<title>Index of /maven2/org/apache/maven/wagon/</title>
-<link rel="stylesheet" type="text/css" href="/css/mirror.css" />
-</head>
-<body>
-<h2>Index of /maven2/org/apache/maven/wagon/</h2>
-<div class="list">
-<table cellpadding="0" cellspacing="0">
-<thead><tr><th class="n">Name</th><th class="m">Last Modified</th><th class="s">Size</th><th class="t">Type</th></tr></thead>
-
-<tbody>
-<tr><td class="n"><a href="../">Parent Directory</a>/</td><td class="m"> </td><td class="s">- </td><td class="t">Directory</td></tr>
-<tr><td class="n"><a href="wagon/">wagon</a>/</td><td class="m">2006-Aug-04 20:01:55</td><td class="s">- </td><td class="t">Directory</td></tr>
-<tr><td class="n"><a href="wagon-file/">wagon-file</a>/</td><td class="m">2006-Aug-04 21:01:11</td><td class="s">- </td><td class="t">Directory</td></tr>
-
-<tr><td class="n"><a href="wagon-ftp/">wagon-ftp</a>/</td><td class="m">2006-Aug-04 21:01:11</td><td class="s">- </td><td class="t">Directory</td></tr>
-<tr><td class="n"><a href="wagon-http/">wagon-http</a>/</td><td class="m">2006-Aug-04 21:01:11</td><td class="s">- </td><td class="t">Directory</td></tr>
-<tr><td class="n"><a href="wagon-http-lightweight/">wagon-http-lightweight</a>/</td><td class="m">2006-Aug-04 21:01:11</td><td class="s">- </td><td class="t">Directory</td></tr>
-
-<tr><td class="n"><a href="wagon-lightweight-http/">wagon-lightweight-http</a>/</td><td class="m">2005-Nov-01 05:17:24</td><td class="s">- </td><td class="t">Directory</td></tr>
-<tr><td class="n"><a href="wagon-provider/">wagon-provider</a>/</td><td class="m">2006-Aug-04 20:01:55</td><td class="s">- </td><td class="t">Directory</td></tr>
-<tr><td class="n"><a href="wagon-provider-api/">wagon-provider-api</a>/</td><td class="m">2006-Aug-04 21:01:11</td><td class="s">- </td><td class="t">Directory</td></tr>
-
-<tr><td class="n"><a href="wagon-provider-test/">wagon-provider-test</a>/</td><td class="m">2006-Aug-04 21:01:11</td><td class="s">- </td><td class="t">Directory</td></tr>
-<tr><td class="n"><a href="wagon-providers/">wagon-providers</a>/</td><td class="m">2006-Aug-04 20:01:55</td><td class="s">- </td><td class="t">Directory</td></tr>
-<tr><td class="n"><a href="wagon-scm/">wagon-scm</a>/</td><td class="m">2006-Aug-04 20:01:55</td><td class="s">- </td><td class="t">Directory</td></tr>
-
-<tr><td class="n"><a href="wagon-ssh/">wagon-ssh</a>/</td><td class="m">2006-Aug-04 20:01:55</td><td class="s">- </td><td class="t">Directory</td></tr>
-<tr><td class="n"><a href="wagon-ssh-external/">wagon-ssh-external</a>/</td><td class="m">2006-Aug-04 20:01:55</td><td class="s">- </td><td class="t">Directory</td></tr>
-<tr><td class="n"><a href="wagon-webdav/">wagon-webdav</a>/</td><td class="m">2006-Aug-04 20:01:55</td><td class="s">- </td><td class="t">Directory</td></tr>
-
-<tr><td class="n"><a href="wagon-1.0-alpha-2.pom">wagon-1.0-alpha-2.pom</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">3.1K</td><td class="t">text/xml</td></tr>
-<tr><td class="n"><a href="wagon-1.0-alpha-2.pom.asc">wagon-1.0-alpha-2.pom.asc</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-<tr><td class="n"><a href="wagon-1.0-alpha-2.pom.md5">wagon-1.0-alpha-2.pom.md5</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-<tr><td class="n"><a href="wagon-1.0-alpha-2.pom.sha1">wagon-1.0-alpha-2.pom.sha1</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-
-<tr><td class="n"><a href="wagon-1.0-alpha-3-20050413.021234-4.pom">wagon-1.0-alpha-3-20050413.021234-4.pom</a></td><td class="m">2005-Nov-08 22:25:32</td><td class="s">3.1K</td><td class="t">text/xml</td></tr>
-<tr><td class="n"><a href="wagon-1.0-alpha-3-20050413.021234-4.pom.md5">wagon-1.0-alpha-3-20050413.021234-4.pom.md5</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-<tr><td class="n"><a href="wagon-1.0-alpha-3-20050413.021234-4.pom.sha1">wagon-1.0-alpha-3-20050413.021234-4.pom.sha1</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-<tr><td class="n"><a href="wagon-1.0-alpha-3-20050419.043745-5.pom">wagon-1.0-alpha-3-20050419.043745-5.pom</a></td><td class="m">2005-Nov-08 22:25:32</td><td class="s">3.1K</td><td class="t">text/xml</td></tr>
-
-<tr><td class="n"><a href="wagon-1.0-alpha-3-20050419.043745-5.pom.md5">wagon-1.0-alpha-3-20050419.043745-5.pom.md5</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-<tr><td class="n"><a href="wagon-1.0-alpha-3-20050419.043745-5.pom.sha1">wagon-1.0-alpha-3-20050419.043745-5.pom.sha1</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-<tr><td class="n"><a href="wagon-1.0-alpha-3-20050419.044035-6.pom">wagon-1.0-alpha-3-20050419.044035-6.pom</a></td><td class="m">2005-Nov-08 22:25:32</td><td class="s">3.1K</td><td class="t">text/xml</td></tr>
-<tr><td class="n"><a href="wagon-1.0-alpha-3-20050419.044035-6.pom.md5">wagon-1.0-alpha-3-20050419.044035-6.pom.md5</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-
-<tr><td class="n"><a href="wagon-1.0-alpha-3-20050419.044035-6.pom.sha1">wagon-1.0-alpha-3-20050419.044035-6.pom.sha1</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-<tr><td class="n"><a href="wagon-1.0-alpha-3-20050421.162738-7.pom">wagon-1.0-alpha-3-20050421.162738-7.pom</a></td><td class="m">2005-Nov-08 22:25:32</td><td class="s">3.1K</td><td class="t">text/xml</td></tr>
-<tr><td class="n"><a href="wagon-1.0-alpha-3-20050421.162738-7.pom.md5">wagon-1.0-alpha-3-20050421.162738-7.pom.md5</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-<tr><td class="n"><a href="wagon-1.0-alpha-3-20050421.162738-7.pom.sha1">wagon-1.0-alpha-3-20050421.162738-7.pom.sha1</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-
-<tr><td class="n"><a href="wagon-1.0-alpha-3-20050422.075233-8.pom">wagon-1.0-alpha-3-20050422.075233-8.pom</a></td><td class="m">2005-Nov-08 22:25:32</td><td class="s">3.1K</td><td class="t">text/xml</td></tr>
-<tr><td class="n"><a href="wagon-1.0-alpha-3-20050422.075233-8.pom.md5">wagon-1.0-alpha-3-20050422.075233-8.pom.md5</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-<tr><td class="n"><a href="wagon-1.0-alpha-3-20050422.075233-8.pom.sha1">wagon-1.0-alpha-3-20050422.075233-8.pom.sha1</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-<tr><td class="n"><a href="wagon-1.0-alpha-3-20050429.051847-9.pom">wagon-1.0-alpha-3-20050429.051847-9.pom</a></td><td class="m">2005-Nov-08 22:25:32</td><td class="s">3.1K</td><td class="t">text/xml</td></tr>
-
-<tr><td class="n"><a href="wagon-1.0-alpha-3-20050429.051847-9.pom.md5">wagon-1.0-alpha-3-20050429.051847-9.pom.md5</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-<tr><td class="n"><a href="wagon-1.0-alpha-3-20050429.051847-9.pom.sha1">wagon-1.0-alpha-3-20050429.051847-9.pom.sha1</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-<tr><td class="n"><a href="wagon-providers-1.0-alpha-2.pom">wagon-providers-1.0-alpha-2.pom</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.9K</td><td class="t">text/xml</td></tr>
-<tr><td class="n"><a href="wagon-providers-1.0-alpha-2.pom.asc">wagon-providers-1.0-alpha-2.pom.asc</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-
-<tr><td class="n"><a href="wagon-providers-1.0-alpha-2.pom.md5">wagon-providers-1.0-alpha-2.pom.md5</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-<tr><td class="n"><a href="wagon-providers-1.0-alpha-2.pom.sha1">wagon-providers-1.0-alpha-2.pom.sha1</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050407.202848-1.pom">wagon-providers-1.0-alpha-3-20050407.202848-1.pom</a></td><td class="m">2005-Nov-08 22:25:32</td><td class="s">0.9K</td><td class="t">text/xml</td></tr>
-<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050407.202848-1.pom.md5">wagon-providers-1.0-alpha-3-20050407.202848-1.pom.md5</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-
-<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050407.202848-1.pom.sha1">wagon-providers-1.0-alpha-3-20050407.202848-1.pom.sha1</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050419.044035-2.pom">wagon-providers-1.0-alpha-3-20050419.044035-2.pom</a></td><td class="m">2005-Nov-08 22:25:32</td><td class="s">0.9K</td><td class="t">text/xml</td></tr>
-<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050419.044035-2.pom.md5">wagon-providers-1.0-alpha-3-20050419.044035-2.pom.md5</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050419.044035-2.pom.sha1">wagon-providers-1.0-alpha-3-20050419.044035-2.pom.sha1</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-
-<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050421.162738-3.pom">wagon-providers-1.0-alpha-3-20050421.162738-3.pom</a></td><td class="m">2005-Nov-08 22:25:32</td><td class="s">0.9K</td><td class="t">text/xml</td></tr>
-<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050421.162738-3.pom.md5">wagon-providers-1.0-alpha-3-20050421.162738-3.pom.md5</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050421.162738-3.pom.sha1">wagon-providers-1.0-alpha-3-20050421.162738-3.pom.sha1</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050422.075233-4.pom">wagon-providers-1.0-alpha-3-20050422.075233-4.pom</a></td><td class="m">2005-Nov-08 22:25:32</td><td class="s">0.9K</td><td class="t">text/xml</td></tr>
-
-<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050422.075233-4.pom.md5">wagon-providers-1.0-alpha-3-20050422.075233-4.pom.md5</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050422.075233-4.pom.sha1">wagon-providers-1.0-alpha-3-20050422.075233-4.pom.sha1</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050429.051847-5.pom">wagon-providers-1.0-alpha-3-20050429.051847-5.pom</a></td><td class="m">2005-Nov-08 22:25:32</td><td class="s">1.0K</td><td class="t">text/xml</td></tr>
-<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050429.051847-5.pom.md5">wagon-providers-1.0-alpha-3-20050429.051847-5.pom.md5</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-
-<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050429.051847-5.pom.sha1">wagon-providers-1.0-alpha-3-20050429.051847-5.pom.sha1</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
-</tbody>
-</table>
-</div>
-<div class="foot"><br />ibiblio.org - Mirror Site<br />
-<a href="mailto:mirror.admin at mirror.com">Mirror Admin</a></div>
-
-</body>
-</html>
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
+<head>
+<title>Index of /maven2/org/apache/maven/wagon/</title>
+<link rel="stylesheet" type="text/css" href="/css/mirror.css" />
+</head>
+<body>
+<h2>Index of /maven2/org/apache/maven/wagon/</h2>
+<div class="list">
+<table cellpadding="0" cellspacing="0">
+<thead><tr><th class="n">Name</th><th class="m">Last Modified</th><th class="s">Size</th><th class="t">Type</th></tr></thead>
+
+<tbody>
+<tr><td class="n"><a href="../">Parent Directory</a>/</td><td class="m"> </td><td class="s">- </td><td class="t">Directory</td></tr>
+<tr><td class="n"><a href="wagon/">wagon</a>/</td><td class="m">2006-Aug-04 20:01:55</td><td class="s">- </td><td class="t">Directory</td></tr>
+<tr><td class="n"><a href="wagon-file/">wagon-file</a>/</td><td class="m">2006-Aug-04 21:01:11</td><td class="s">- </td><td class="t">Directory</td></tr>
+
+<tr><td class="n"><a href="wagon-ftp/">wagon-ftp</a>/</td><td class="m">2006-Aug-04 21:01:11</td><td class="s">- </td><td class="t">Directory</td></tr>
+<tr><td class="n"><a href="wagon-http/">wagon-http</a>/</td><td class="m">2006-Aug-04 21:01:11</td><td class="s">- </td><td class="t">Directory</td></tr>
+<tr><td class="n"><a href="wagon-http-lightweight/">wagon-http-lightweight</a>/</td><td class="m">2006-Aug-04 21:01:11</td><td class="s">- </td><td class="t">Directory</td></tr>
+
+<tr><td class="n"><a href="wagon-lightweight-http/">wagon-lightweight-http</a>/</td><td class="m">2005-Nov-01 05:17:24</td><td class="s">- </td><td class="t">Directory</td></tr>
+<tr><td class="n"><a href="wagon-provider/">wagon-provider</a>/</td><td class="m">2006-Aug-04 20:01:55</td><td class="s">- </td><td class="t">Directory</td></tr>
+<tr><td class="n"><a href="wagon-provider-api/">wagon-provider-api</a>/</td><td class="m">2006-Aug-04 21:01:11</td><td class="s">- </td><td class="t">Directory</td></tr>
+
+<tr><td class="n"><a href="wagon-provider-test/">wagon-provider-test</a>/</td><td class="m">2006-Aug-04 21:01:11</td><td class="s">- </td><td class="t">Directory</td></tr>
+<tr><td class="n"><a href="wagon-providers/">wagon-providers</a>/</td><td class="m">2006-Aug-04 20:01:55</td><td class="s">- </td><td class="t">Directory</td></tr>
+<tr><td class="n"><a href="wagon-scm/">wagon-scm</a>/</td><td class="m">2006-Aug-04 20:01:55</td><td class="s">- </td><td class="t">Directory</td></tr>
+
+<tr><td class="n"><a href="wagon-ssh/">wagon-ssh</a>/</td><td class="m">2006-Aug-04 20:01:55</td><td class="s">- </td><td class="t">Directory</td></tr>
+<tr><td class="n"><a href="wagon-ssh-external/">wagon-ssh-external</a>/</td><td class="m">2006-Aug-04 20:01:55</td><td class="s">- </td><td class="t">Directory</td></tr>
+<tr><td class="n"><a href="wagon-webdav/">wagon-webdav</a>/</td><td class="m">2006-Aug-04 20:01:55</td><td class="s">- </td><td class="t">Directory</td></tr>
+
+<tr><td class="n"><a href="wagon-1.0-alpha-2.pom">wagon-1.0-alpha-2.pom</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">3.1K</td><td class="t">text/xml</td></tr>
+<tr><td class="n"><a href="wagon-1.0-alpha-2.pom.asc">wagon-1.0-alpha-2.pom.asc</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+<tr><td class="n"><a href="wagon-1.0-alpha-2.pom.md5">wagon-1.0-alpha-2.pom.md5</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+<tr><td class="n"><a href="wagon-1.0-alpha-2.pom.sha1">wagon-1.0-alpha-2.pom.sha1</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+
+<tr><td class="n"><a href="wagon-1.0-alpha-3-20050413.021234-4.pom">wagon-1.0-alpha-3-20050413.021234-4.pom</a></td><td class="m">2005-Nov-08 22:25:32</td><td class="s">3.1K</td><td class="t">text/xml</td></tr>
+<tr><td class="n"><a href="wagon-1.0-alpha-3-20050413.021234-4.pom.md5">wagon-1.0-alpha-3-20050413.021234-4.pom.md5</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+<tr><td class="n"><a href="wagon-1.0-alpha-3-20050413.021234-4.pom.sha1">wagon-1.0-alpha-3-20050413.021234-4.pom.sha1</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+<tr><td class="n"><a href="wagon-1.0-alpha-3-20050419.043745-5.pom">wagon-1.0-alpha-3-20050419.043745-5.pom</a></td><td class="m">2005-Nov-08 22:25:32</td><td class="s">3.1K</td><td class="t">text/xml</td></tr>
+
+<tr><td class="n"><a href="wagon-1.0-alpha-3-20050419.043745-5.pom.md5">wagon-1.0-alpha-3-20050419.043745-5.pom.md5</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+<tr><td class="n"><a href="wagon-1.0-alpha-3-20050419.043745-5.pom.sha1">wagon-1.0-alpha-3-20050419.043745-5.pom.sha1</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+<tr><td class="n"><a href="wagon-1.0-alpha-3-20050419.044035-6.pom">wagon-1.0-alpha-3-20050419.044035-6.pom</a></td><td class="m">2005-Nov-08 22:25:32</td><td class="s">3.1K</td><td class="t">text/xml</td></tr>
+<tr><td class="n"><a href="wagon-1.0-alpha-3-20050419.044035-6.pom.md5">wagon-1.0-alpha-3-20050419.044035-6.pom.md5</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+
+<tr><td class="n"><a href="wagon-1.0-alpha-3-20050419.044035-6.pom.sha1">wagon-1.0-alpha-3-20050419.044035-6.pom.sha1</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+<tr><td class="n"><a href="wagon-1.0-alpha-3-20050421.162738-7.pom">wagon-1.0-alpha-3-20050421.162738-7.pom</a></td><td class="m">2005-Nov-08 22:25:32</td><td class="s">3.1K</td><td class="t">text/xml</td></tr>
+<tr><td class="n"><a href="wagon-1.0-alpha-3-20050421.162738-7.pom.md5">wagon-1.0-alpha-3-20050421.162738-7.pom.md5</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+<tr><td class="n"><a href="wagon-1.0-alpha-3-20050421.162738-7.pom.sha1">wagon-1.0-alpha-3-20050421.162738-7.pom.sha1</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+
+<tr><td class="n"><a href="wagon-1.0-alpha-3-20050422.075233-8.pom">wagon-1.0-alpha-3-20050422.075233-8.pom</a></td><td class="m">2005-Nov-08 22:25:32</td><td class="s">3.1K</td><td class="t">text/xml</td></tr>
+<tr><td class="n"><a href="wagon-1.0-alpha-3-20050422.075233-8.pom.md5">wagon-1.0-alpha-3-20050422.075233-8.pom.md5</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+<tr><td class="n"><a href="wagon-1.0-alpha-3-20050422.075233-8.pom.sha1">wagon-1.0-alpha-3-20050422.075233-8.pom.sha1</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+<tr><td class="n"><a href="wagon-1.0-alpha-3-20050429.051847-9.pom">wagon-1.0-alpha-3-20050429.051847-9.pom</a></td><td class="m">2005-Nov-08 22:25:32</td><td class="s">3.1K</td><td class="t">text/xml</td></tr>
+
+<tr><td class="n"><a href="wagon-1.0-alpha-3-20050429.051847-9.pom.md5">wagon-1.0-alpha-3-20050429.051847-9.pom.md5</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+<tr><td class="n"><a href="wagon-1.0-alpha-3-20050429.051847-9.pom.sha1">wagon-1.0-alpha-3-20050429.051847-9.pom.sha1</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+<tr><td class="n"><a href="wagon-providers-1.0-alpha-2.pom">wagon-providers-1.0-alpha-2.pom</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.9K</td><td class="t">text/xml</td></tr>
+<tr><td class="n"><a href="wagon-providers-1.0-alpha-2.pom.asc">wagon-providers-1.0-alpha-2.pom.asc</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+
+<tr><td class="n"><a href="wagon-providers-1.0-alpha-2.pom.md5">wagon-providers-1.0-alpha-2.pom.md5</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+<tr><td class="n"><a href="wagon-providers-1.0-alpha-2.pom.sha1">wagon-providers-1.0-alpha-2.pom.sha1</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050407.202848-1.pom">wagon-providers-1.0-alpha-3-20050407.202848-1.pom</a></td><td class="m">2005-Nov-08 22:25:32</td><td class="s">0.9K</td><td class="t">text/xml</td></tr>
+<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050407.202848-1.pom.md5">wagon-providers-1.0-alpha-3-20050407.202848-1.pom.md5</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+
+<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050407.202848-1.pom.sha1">wagon-providers-1.0-alpha-3-20050407.202848-1.pom.sha1</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050419.044035-2.pom">wagon-providers-1.0-alpha-3-20050419.044035-2.pom</a></td><td class="m">2005-Nov-08 22:25:32</td><td class="s">0.9K</td><td class="t">text/xml</td></tr>
+<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050419.044035-2.pom.md5">wagon-providers-1.0-alpha-3-20050419.044035-2.pom.md5</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050419.044035-2.pom.sha1">wagon-providers-1.0-alpha-3-20050419.044035-2.pom.sha1</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+
+<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050421.162738-3.pom">wagon-providers-1.0-alpha-3-20050421.162738-3.pom</a></td><td class="m">2005-Nov-08 22:25:32</td><td class="s">0.9K</td><td class="t">text/xml</td></tr>
+<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050421.162738-3.pom.md5">wagon-providers-1.0-alpha-3-20050421.162738-3.pom.md5</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050421.162738-3.pom.sha1">wagon-providers-1.0-alpha-3-20050421.162738-3.pom.sha1</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050422.075233-4.pom">wagon-providers-1.0-alpha-3-20050422.075233-4.pom</a></td><td class="m">2005-Nov-08 22:25:32</td><td class="s">0.9K</td><td class="t">text/xml</td></tr>
+
+<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050422.075233-4.pom.md5">wagon-providers-1.0-alpha-3-20050422.075233-4.pom.md5</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050422.075233-4.pom.sha1">wagon-providers-1.0-alpha-3-20050422.075233-4.pom.sha1</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050429.051847-5.pom">wagon-providers-1.0-alpha-3-20050429.051847-5.pom</a></td><td class="m">2005-Nov-08 22:25:32</td><td class="s">1.0K</td><td class="t">text/xml</td></tr>
+<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050429.051847-5.pom.md5">wagon-providers-1.0-alpha-3-20050429.051847-5.pom.md5</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+
+<tr><td class="n"><a href="wagon-providers-1.0-alpha-3-20050429.051847-5.pom.sha1">wagon-providers-1.0-alpha-3-20050429.051847-5.pom.sha1</a></td><td class="m">2006-Aug-04 21:01:11</td><td class="s">0.1K</td><td class="t">text/plain</td></tr>
+</tbody>
+</table>
+</div>
+<div class="foot"><br />ibiblio.org - Mirror Site<br />
+<a href="mailto:mirror.admin at mirror.com">Mirror Admin</a></div>
+
+</body>
+</html>
diff --git a/wagon-providers/wagon-http-shared/src/test/resources/filelistings/nekohtml.html b/wagon-providers/wagon-http-shared/src/test/resources/filelistings/nekohtml.html
index 1738029..e887994 100644
--- a/wagon-providers/wagon-http-shared/src/test/resources/filelistings/nekohtml.html
+++ b/wagon-providers/wagon-http-shared/src/test/resources/filelistings/nekohtml.html
@@ -1,23 +1,23 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
- <head>
- <title>Index of /maven2/nekohtml/nekohtml/1.9.6</title>
- </head>
- <body>
-<h1>Index of /maven2/nekohtml/nekohtml/1.9.6</h1>
-<pre><img src="/icons/blank.gif" alt="Icon "> <a href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr><img src="/icons/back.gif" alt="[DIR]"> <a href="/maven2/nekohtml/nekohtml/">Parent Directory</a> -
-<img src="/icons/unknown.gif" alt="[ ]"> <a href="nekohtml-1.9.6-javadoc.jar">nekohtml-1.9.6-javadoc.jar</a> 02-Jan-2008 15:07 235K
-<img src="/icons/unknown.gif" alt="[ ]"> <a href="nekohtml-1.9.6-javadoc.jar.md5">nekohtml-1.9.6-javadoc.jar.md5</a> 17-Jan-2008 21:35 134
-<img src="/icons/unknown.gif" alt="[ ]"> <a href="nekohtml-1.9.6-javadoc.jar.sha1">nekohtml-1.9.6-javadoc.jar.sha1</a> 17-Jan-2008 21:35 142
-<img src="/icons/unknown.gif" alt="[ ]"> <a href="nekohtml-1.9.6-sources.jar">nekohtml-1.9.6-sources.jar</a> 17-Jan-2008 21:35 88K
-<img src="/icons/unknown.gif" alt="[ ]"> <a href="nekohtml-1.9.6-sources.jar.md5">nekohtml-1.9.6-sources.jar.md5</a> 17-Jan-2008 21:35 134
-<img src="/icons/unknown.gif" alt="[ ]"> <a href="nekohtml-1.9.6-sources.jar.sha1">nekohtml-1.9.6-sources.jar.sha1</a> 17-Jan-2008 21:35 142
-<img src="/icons/unknown.gif" alt="[ ]"> <a href="nekohtml-1.9.6.jar">nekohtml-1.9.6.jar</a> 02-Jan-2008 15:07 108K
-<img src="/icons/unknown.gif" alt="[ ]"> <a href="nekohtml-1.9.6.jar.md5">nekohtml-1.9.6.jar.md5</a> 17-Jan-2008 21:35 126
-<img src="/icons/unknown.gif" alt="[ ]"> <a href="nekohtml-1.9.6.jar.sha1">nekohtml-1.9.6.jar.sha1</a> 17-Jan-2008 21:35 134
-<img src="/icons/text.gif" alt="[TXT]"> <a href="nekohtml-1.9.6.pom">nekohtml-1.9.6.pom</a> 02-Jan-2008 15:07 702
-<img src="/icons/text.gif" alt="[TXT]"> <a href="nekohtml-1.9.6.pom.md5">nekohtml-1.9.6.pom.md5</a> 17-Jan-2008 21:35 126
-<img src="/icons/text.gif" alt="[TXT]"> <a href="nekohtml-1.9.6.pom.sha1">nekohtml-1.9.6.pom.sha1</a> 17-Jan-2008 21:35 134
-<hr></pre>
-<address>Apache/2.0.52 (Red Hat) Server at repo1.maven.org Port 80</address>
-</body></html>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /maven2/nekohtml/nekohtml/1.9.6</title>
+ </head>
+ <body>
+<h1>Index of /maven2/nekohtml/nekohtml/1.9.6</h1>
+<pre><img src="/icons/blank.gif" alt="Icon "> <a href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr><img src="/icons/back.gif" alt="[DIR]"> <a href="/maven2/nekohtml/nekohtml/">Parent Directory</a> -
+<img src="/icons/unknown.gif" alt="[ ]"> <a href="nekohtml-1.9.6-javadoc.jar">nekohtml-1.9.6-javadoc.jar</a> 02-Jan-2008 15:07 235K
+<img src="/icons/unknown.gif" alt="[ ]"> <a href="nekohtml-1.9.6-javadoc.jar.md5">nekohtml-1.9.6-javadoc.jar.md5</a> 17-Jan-2008 21:35 134
+<img src="/icons/unknown.gif" alt="[ ]"> <a href="nekohtml-1.9.6-javadoc.jar.sha1">nekohtml-1.9.6-javadoc.jar.sha1</a> 17-Jan-2008 21:35 142
+<img src="/icons/unknown.gif" alt="[ ]"> <a href="nekohtml-1.9.6-sources.jar">nekohtml-1.9.6-sources.jar</a> 17-Jan-2008 21:35 88K
+<img src="/icons/unknown.gif" alt="[ ]"> <a href="nekohtml-1.9.6-sources.jar.md5">nekohtml-1.9.6-sources.jar.md5</a> 17-Jan-2008 21:35 134
+<img src="/icons/unknown.gif" alt="[ ]"> <a href="nekohtml-1.9.6-sources.jar.sha1">nekohtml-1.9.6-sources.jar.sha1</a> 17-Jan-2008 21:35 142
+<img src="/icons/unknown.gif" alt="[ ]"> <a href="nekohtml-1.9.6.jar">nekohtml-1.9.6.jar</a> 02-Jan-2008 15:07 108K
+<img src="/icons/unknown.gif" alt="[ ]"> <a href="nekohtml-1.9.6.jar.md5">nekohtml-1.9.6.jar.md5</a> 17-Jan-2008 21:35 126
+<img src="/icons/unknown.gif" alt="[ ]"> <a href="nekohtml-1.9.6.jar.sha1">nekohtml-1.9.6.jar.sha1</a> 17-Jan-2008 21:35 134
+<img src="/icons/text.gif" alt="[TXT]"> <a href="nekohtml-1.9.6.pom">nekohtml-1.9.6.pom</a> 02-Jan-2008 15:07 702
+<img src="/icons/text.gif" alt="[TXT]"> <a href="nekohtml-1.9.6.pom.md5">nekohtml-1.9.6.pom.md5</a> 17-Jan-2008 21:35 126
+<img src="/icons/text.gif" alt="[TXT]"> <a href="nekohtml-1.9.6.pom.sha1">nekohtml-1.9.6.pom.sha1</a> 17-Jan-2008 21:35 134
+<hr></pre>
+<address>Apache/2.0.52 (Red Hat) Server at repo1.maven.org Port 80</address>
+</body></html>
diff --git a/wagon-providers/wagon-http-shared/src/test/resources/filelistings/net_sf.html b/wagon-providers/wagon-http-shared/src/test/resources/filelistings/net_sf.html
index eb89c62..e5ebc8b 100644
--- a/wagon-providers/wagon-http-shared/src/test/resources/filelistings/net_sf.html
+++ b/wagon-providers/wagon-http-shared/src/test/resources/filelistings/net_sf.html
@@ -1,71 +1,71 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
- <head>
- <title>Index of /maven2/net/sf</title>
- </head>
- <body>
-<h1>Index of /maven2/net/sf</h1>
-<pre><img src="/icons/blank.gif" alt="Icon "> <a href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr><img src="/icons/back.gif" alt="[DIR]"> <a href="/maven2/net/">Parent Directory</a> -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="a2j/">a2j/</a> 28-Nov-2005 11:32 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="aislib/">aislib/</a> 10-Feb-2008 06:40 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="alchim/">alchim/</a> 22-Nov-2007 08:27 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="antenna/">antenna/</a> 09-Jul-2007 11:45 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="apt-jelly/">apt-jelly/</a> 02-Apr-2007 15:48 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="beanlib/">beanlib/</a> 20-Apr-2006 07:32 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="bluecove/">bluecove/</a> 25-Jan-2007 01:03 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="buildbox/">buildbox/</a> 13-Jan-2008 20:07 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="click/">click/</a> 10-Dec-2005 19:31 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="clirr/">clirr/</a> 11-Feb-2006 20:41 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="datavision/">datavision/</a> 26-Jan-2008 18:46 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="dozer/">dozer/</a> 09-Feb-2006 23:31 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="dtddoc/">dtddoc/</a> 03-Feb-2007 07:32 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="dynpageplus/">dynpageplus/</a> 03-Jan-2006 11:36 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="ehcache/">ehcache/</a> 04-May-2007 20:14 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="ezmorph/">ezmorph/</a> 17-Aug-2006 11:57 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="falcon/">falcon/</a> 31-Jan-2007 11:35 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="grester/">grester/</a> 22-Oct-2007 18:25 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="gwt-widget/">gwt-widget/</a> 17-Sep-2007 12:58 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="hermesftp/">hermesftp/</a> 14-Jun-2006 17:06 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="hibernate/">hibernate/</a> 31-Oct-2005 23:08 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="jcharts/">jcharts/</a> 16-May-2007 17:26 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="jdatabaseimport/">jdatabaseimport/</a> 20-Oct-2006 10:45 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="jeceira/">jeceira/</a> 26-Jun-2007 16:50 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="jfcunit/">jfcunit/</a> 07-Feb-2006 00:49 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="jfig/">jfig/</a> 25-Jan-2007 01:03 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="jguard/">jguard/</a> 31-Jul-2007 18:36 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="jipcam/">jipcam/</a> 02-Mar-2006 15:32 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="jlynx/">jlynx/</a> 02-Aug-2007 22:04 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="jour/">jour/</a> 27-Aug-2007 20:09 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="jpf/">jpf/</a> 26-Apr-2007 10:45 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="json-lib/">json-lib/</a> 11-Feb-2007 19:12 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="jsptest/">jsptest/</a> 07-Aug-2007 16:17 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="jsr107cache/">jsr107cache/</a> 25-Jan-2007 00:45 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="jt400/">jt400/</a> 11-Nov-2005 15:31 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="jxls/">jxls/</a> 29-Jul-2007 17:54 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="kxml/">kxml/</a> 19-Mar-2007 20:25 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="ldaptemplate/">ldaptemplate/</a> 27-Feb-2006 19:41 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="locale4j/">locale4j/</a> 31-Aug-2007 07:23 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="mapasuta/">mapasuta/</a> 12-Nov-2006 12:05 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="maven-har/">maven-har/</a> 24-Aug-2007 07:09 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="maven-sar/">maven-sar/</a> 28-Aug-2007 18:28 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="opencsv/">opencsv/</a> 14-Mar-2007 12:55 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="oval/">oval/</a> 15-Jan-2007 15:30 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="proguard/">proguard/</a> 19-Jan-2006 15:41 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="qdwizard/">qdwizard/</a> 19-Dec-2007 16:02 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="resultsetmapper/">resultsetmapper/</a> 18-Mar-2007 16:23 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="retrotranslator/">retrotranslator/</a> 26-Apr-2006 15:31 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="saxon/">saxon/</a> 04-Apr-2006 23:32 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="shadesdb/">shadesdb/</a> 19-Oct-2006 14:58 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="smc/">smc/</a> 30-May-2006 01:13 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="speculoos/">speculoos/</a> 20-Nov-2006 17:04 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="springlayout/">springlayout/</a> 26-Mar-2007 15:24 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="stat-scm/">stat-scm/</a> 25-Apr-2007 10:56 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="statsvn/">statsvn/</a> 29-Nov-2006 13:55 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="stax/">stax/</a> 31-Oct-2005 23:08 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="struts/">struts/</a> 28-Nov-2005 11:32 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="tacos/">tacos/</a> 19-Dec-2007 04:16 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="testextensions/">testextensions/</a> 21-May-2007 12:54 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="webdav-servlet/">webdav-servlet/</a> 30-Jan-2006 19:36 -
-<hr></pre>
-<address>Apache/2.0.52 (Red Hat) Server at repo1.maven.org Port 80</address>
-</body></html>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /maven2/net/sf</title>
+ </head>
+ <body>
+<h1>Index of /maven2/net/sf</h1>
+<pre><img src="/icons/blank.gif" alt="Icon "> <a href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr><img src="/icons/back.gif" alt="[DIR]"> <a href="/maven2/net/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="a2j/">a2j/</a> 28-Nov-2005 11:32 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="aislib/">aislib/</a> 10-Feb-2008 06:40 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="alchim/">alchim/</a> 22-Nov-2007 08:27 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="antenna/">antenna/</a> 09-Jul-2007 11:45 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="apt-jelly/">apt-jelly/</a> 02-Apr-2007 15:48 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="beanlib/">beanlib/</a> 20-Apr-2006 07:32 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="bluecove/">bluecove/</a> 25-Jan-2007 01:03 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="buildbox/">buildbox/</a> 13-Jan-2008 20:07 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="click/">click/</a> 10-Dec-2005 19:31 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="clirr/">clirr/</a> 11-Feb-2006 20:41 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="datavision/">datavision/</a> 26-Jan-2008 18:46 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="dozer/">dozer/</a> 09-Feb-2006 23:31 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="dtddoc/">dtddoc/</a> 03-Feb-2007 07:32 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="dynpageplus/">dynpageplus/</a> 03-Jan-2006 11:36 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="ehcache/">ehcache/</a> 04-May-2007 20:14 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="ezmorph/">ezmorph/</a> 17-Aug-2006 11:57 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="falcon/">falcon/</a> 31-Jan-2007 11:35 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="grester/">grester/</a> 22-Oct-2007 18:25 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="gwt-widget/">gwt-widget/</a> 17-Sep-2007 12:58 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="hermesftp/">hermesftp/</a> 14-Jun-2006 17:06 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="hibernate/">hibernate/</a> 31-Oct-2005 23:08 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="jcharts/">jcharts/</a> 16-May-2007 17:26 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="jdatabaseimport/">jdatabaseimport/</a> 20-Oct-2006 10:45 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="jeceira/">jeceira/</a> 26-Jun-2007 16:50 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="jfcunit/">jfcunit/</a> 07-Feb-2006 00:49 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="jfig/">jfig/</a> 25-Jan-2007 01:03 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="jguard/">jguard/</a> 31-Jul-2007 18:36 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="jipcam/">jipcam/</a> 02-Mar-2006 15:32 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="jlynx/">jlynx/</a> 02-Aug-2007 22:04 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="jour/">jour/</a> 27-Aug-2007 20:09 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="jpf/">jpf/</a> 26-Apr-2007 10:45 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="json-lib/">json-lib/</a> 11-Feb-2007 19:12 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="jsptest/">jsptest/</a> 07-Aug-2007 16:17 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="jsr107cache/">jsr107cache/</a> 25-Jan-2007 00:45 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="jt400/">jt400/</a> 11-Nov-2005 15:31 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="jxls/">jxls/</a> 29-Jul-2007 17:54 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="kxml/">kxml/</a> 19-Mar-2007 20:25 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="ldaptemplate/">ldaptemplate/</a> 27-Feb-2006 19:41 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="locale4j/">locale4j/</a> 31-Aug-2007 07:23 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="mapasuta/">mapasuta/</a> 12-Nov-2006 12:05 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="maven-har/">maven-har/</a> 24-Aug-2007 07:09 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="maven-sar/">maven-sar/</a> 28-Aug-2007 18:28 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="opencsv/">opencsv/</a> 14-Mar-2007 12:55 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="oval/">oval/</a> 15-Jan-2007 15:30 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="proguard/">proguard/</a> 19-Jan-2006 15:41 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="qdwizard/">qdwizard/</a> 19-Dec-2007 16:02 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="resultsetmapper/">resultsetmapper/</a> 18-Mar-2007 16:23 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="retrotranslator/">retrotranslator/</a> 26-Apr-2006 15:31 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="saxon/">saxon/</a> 04-Apr-2006 23:32 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="shadesdb/">shadesdb/</a> 19-Oct-2006 14:58 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="smc/">smc/</a> 30-May-2006 01:13 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="speculoos/">speculoos/</a> 20-Nov-2006 17:04 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="springlayout/">springlayout/</a> 26-Mar-2007 15:24 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="stat-scm/">stat-scm/</a> 25-Apr-2007 10:56 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="statsvn/">statsvn/</a> 29-Nov-2006 13:55 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="stax/">stax/</a> 31-Oct-2005 23:08 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="struts/">struts/</a> 28-Nov-2005 11:32 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="tacos/">tacos/</a> 19-Dec-2007 04:16 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="testextensions/">testextensions/</a> 21-May-2007 12:54 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="webdav-servlet/">webdav-servlet/</a> 30-Jan-2006 19:36 -
+<hr></pre>
+<address>Apache/2.0.52 (Red Hat) Server at repo1.maven.org Port 80</address>
+</body></html>
diff --git a/wagon-providers/wagon-http-shared/src/test/resources/filelistings/org.apache.maven.html b/wagon-providers/wagon-http-shared/src/test/resources/filelistings/org.apache.maven.html
index fd674c8..e817cd6 100644
--- a/wagon-providers/wagon-http-shared/src/test/resources/filelistings/org.apache.maven.html
+++ b/wagon-providers/wagon-http-shared/src/test/resources/filelistings/org.apache.maven.html
@@ -1,42 +1,42 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
- <head>
- <title>Index of /repo/m2-ibiblio-rsync-repository/org/apache/maven/archiva/archiva-plexus-runtime/1.0.1</title>
- </head>
- <body>
-<h1>Index of /repo/m2-ibiblio-rsync-repository/org/apache/maven/archiva/archiva-plexus-runtime/1.0.1</h1>
-<pre><img src="/icons/blank.gif" alt="Icon "> <a href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr><img src="/icons/back.gif" alt="[DIR]"> <a href="/repo/m2-ibiblio-rsync-repository/org/apache/maven/archiva/archiva-plexus-runtime/">Parent Directory</a> [...]
-<img src="/icons/compressed.gif" alt="[ ]"> <a href="archiva-plexus-runtime-1.0.1-bin.tar.gz">archiva-plexus-runtime-1.0.1-bin.tar.gz</a> 04-Feb-2008 03:40 22M
-<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-bin.tar.gz.asc">archiva-plexus-runtime-1.0.1-bin.tar.gz.asc</a> 04-Feb-2008 03:40 189
-<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-bin.tar.gz.asc.md5">archiva-plexus-runtime-1.0.1-bin.tar.gz.asc.md5</a> 04-Feb-2008 03:40 32
-<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-bin.tar.gz.asc.sha1">archiva-plexus-runtime-1.0.1-bin.tar.gz.asc.sha1</a> 04-Feb-2008 03:40 40
-<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-bin.tar.gz.md5">archiva-plexus-runtime-1.0.1-bin.tar.gz.md5</a> 04-Feb-2008 03:40 32
-<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-bin.tar.gz.sha1">archiva-plexus-runtime-1.0.1-bin.tar.gz.sha1</a> 04-Feb-2008 03:40 40
-<img src="/icons/compressed.gif" alt="[ ]"> <a href="archiva-plexus-runtime-1.0.1-bin.zip">archiva-plexus-runtime-1.0.1-bin.zip</a> 04-Feb-2008 03:40 23M
-<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-bin.zip.asc">archiva-plexus-runtime-1.0.1-bin.zip.asc</a> 04-Feb-2008 03:40 189
-<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-bin.zip.asc.md5">archiva-plexus-runtime-1.0.1-bin.zip.asc.md5</a> 04-Feb-2008 03:40 32
-<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-bin.zip.asc.sha1">archiva-plexus-runtime-1.0.1-bin.zip.asc.sha1</a> 04-Feb-2008 03:40 40
-<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-bin.zip.md5">archiva-plexus-runtime-1.0.1-bin.zip.md5</a> 04-Feb-2008 03:40 32
-<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-bin.zip.sha1">archiva-plexus-runtime-1.0.1-bin.zip.sha1</a> 04-Feb-2008 03:40 40
-<img src="/icons/unknown.gif" alt="[ ]"> <a href="archiva-plexus-runtime-1.0.1-sources.jar">archiva-plexus-runtime-1.0.1-sources.jar</a> 04-Feb-2008 03:40 5.4K
-<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-sources.jar.asc">archiva-plexus-runtime-1.0.1-sources.jar.asc</a> 04-Feb-2008 03:40 189
-<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-sources.jar.asc.md5">archiva-plexus-runtime-1.0.1-sources.jar.asc.md5</a> 04-Feb-2008 03:40 32
-<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-sources.jar.asc.sha1">archiva-plexus-runtime-1.0.1-sources.jar.asc.sha1</a> 04-Feb-2008 03:40 40
-<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-sources.jar.md5">archiva-plexus-runtime-1.0.1-sources.jar.md5</a> 04-Feb-2008 03:40 32
-<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-sources.jar.sha1">archiva-plexus-runtime-1.0.1-sources.jar.sha1</a> 04-Feb-2008 03:40 40
-<img src="/icons/unknown.gif" alt="[ ]"> <a href="archiva-plexus-runtime-1.0.1.jar">archiva-plexus-runtime-1.0.1.jar</a> 04-Feb-2008 03:40 8.0K
-<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1.jar.asc">archiva-plexus-runtime-1.0.1.jar.asc</a> 04-Feb-2008 03:40 189
-<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1.jar.asc.md5">archiva-plexus-runtime-1.0.1.jar.asc.md5</a> 04-Feb-2008 03:40 32
-<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1.jar.asc.sha1">archiva-plexus-runtime-1.0.1.jar.asc.sha1</a> 04-Feb-2008 03:40 40
-<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1.jar.md5">archiva-plexus-runtime-1.0.1.jar.md5</a> 04-Feb-2008 03:40 32
-<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1.jar.sha1">archiva-plexus-runtime-1.0.1.jar.sha1</a> 04-Feb-2008 03:40 40
-<img src="/icons/unknown.gif" alt="[ ]"> <a href="archiva-plexus-runtime-1.0.1.pom">archiva-plexus-runtime-1.0.1.pom</a> 04-Feb-2008 03:40 6.6K
-<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1.pom.asc">archiva-plexus-runtime-1.0.1.pom.asc</a> 04-Feb-2008 03:40 189
-<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1.pom.asc.md5">archiva-plexus-runtime-1.0.1.pom.asc.md5</a> 04-Feb-2008 03:40 32
-<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1.pom.asc.sha1">archiva-plexus-runtime-1.0.1.pom.asc.sha1</a> 04-Feb-2008 03:40 40
-<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1.pom.md5">archiva-plexus-runtime-1.0.1.pom.md5</a> 04-Feb-2008 03:40 32
-<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1.pom.sha1">archiva-plexus-runtime-1.0.1.pom.sha1</a> 04-Feb-2008 03:40 40
-<img src="/icons/text.gif" alt="[TXT]"> <a href="readme%20artifacts.txt">readme artifacts.txt</a> 04-Feb-2008 03:40 40
-<hr></pre>
-<address>Apache/2.2.6 (Unix) DAV/2 mod_ssl/2.2.6 OpenSSL/0.9.7e-p1 Server at people.apache.org Port 80</address>
-</body></html>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /repo/m2-ibiblio-rsync-repository/org/apache/maven/archiva/archiva-plexus-runtime/1.0.1</title>
+ </head>
+ <body>
+<h1>Index of /repo/m2-ibiblio-rsync-repository/org/apache/maven/archiva/archiva-plexus-runtime/1.0.1</h1>
+<pre><img src="/icons/blank.gif" alt="Icon "> <a href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr><img src="/icons/back.gif" alt="[DIR]"> <a href="/repo/m2-ibiblio-rsync-repository/org/apache/maven/archiva/archiva-plexus-runtime/">Parent Directory</a> [...]
+<img src="/icons/compressed.gif" alt="[ ]"> <a href="archiva-plexus-runtime-1.0.1-bin.tar.gz">archiva-plexus-runtime-1.0.1-bin.tar.gz</a> 04-Feb-2008 03:40 22M
+<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-bin.tar.gz.asc">archiva-plexus-runtime-1.0.1-bin.tar.gz.asc</a> 04-Feb-2008 03:40 189
+<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-bin.tar.gz.asc.md5">archiva-plexus-runtime-1.0.1-bin.tar.gz.asc.md5</a> 04-Feb-2008 03:40 32
+<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-bin.tar.gz.asc.sha1">archiva-plexus-runtime-1.0.1-bin.tar.gz.asc.sha1</a> 04-Feb-2008 03:40 40
+<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-bin.tar.gz.md5">archiva-plexus-runtime-1.0.1-bin.tar.gz.md5</a> 04-Feb-2008 03:40 32
+<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-bin.tar.gz.sha1">archiva-plexus-runtime-1.0.1-bin.tar.gz.sha1</a> 04-Feb-2008 03:40 40
+<img src="/icons/compressed.gif" alt="[ ]"> <a href="archiva-plexus-runtime-1.0.1-bin.zip">archiva-plexus-runtime-1.0.1-bin.zip</a> 04-Feb-2008 03:40 23M
+<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-bin.zip.asc">archiva-plexus-runtime-1.0.1-bin.zip.asc</a> 04-Feb-2008 03:40 189
+<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-bin.zip.asc.md5">archiva-plexus-runtime-1.0.1-bin.zip.asc.md5</a> 04-Feb-2008 03:40 32
+<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-bin.zip.asc.sha1">archiva-plexus-runtime-1.0.1-bin.zip.asc.sha1</a> 04-Feb-2008 03:40 40
+<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-bin.zip.md5">archiva-plexus-runtime-1.0.1-bin.zip.md5</a> 04-Feb-2008 03:40 32
+<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-bin.zip.sha1">archiva-plexus-runtime-1.0.1-bin.zip.sha1</a> 04-Feb-2008 03:40 40
+<img src="/icons/unknown.gif" alt="[ ]"> <a href="archiva-plexus-runtime-1.0.1-sources.jar">archiva-plexus-runtime-1.0.1-sources.jar</a> 04-Feb-2008 03:40 5.4K
+<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-sources.jar.asc">archiva-plexus-runtime-1.0.1-sources.jar.asc</a> 04-Feb-2008 03:40 189
+<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-sources.jar.asc.md5">archiva-plexus-runtime-1.0.1-sources.jar.asc.md5</a> 04-Feb-2008 03:40 32
+<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-sources.jar.asc.sha1">archiva-plexus-runtime-1.0.1-sources.jar.asc.sha1</a> 04-Feb-2008 03:40 40
+<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-sources.jar.md5">archiva-plexus-runtime-1.0.1-sources.jar.md5</a> 04-Feb-2008 03:40 32
+<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1-sources.jar.sha1">archiva-plexus-runtime-1.0.1-sources.jar.sha1</a> 04-Feb-2008 03:40 40
+<img src="/icons/unknown.gif" alt="[ ]"> <a href="archiva-plexus-runtime-1.0.1.jar">archiva-plexus-runtime-1.0.1.jar</a> 04-Feb-2008 03:40 8.0K
+<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1.jar.asc">archiva-plexus-runtime-1.0.1.jar.asc</a> 04-Feb-2008 03:40 189
+<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1.jar.asc.md5">archiva-plexus-runtime-1.0.1.jar.asc.md5</a> 04-Feb-2008 03:40 32
+<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1.jar.asc.sha1">archiva-plexus-runtime-1.0.1.jar.asc.sha1</a> 04-Feb-2008 03:40 40
+<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1.jar.md5">archiva-plexus-runtime-1.0.1.jar.md5</a> 04-Feb-2008 03:40 32
+<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1.jar.sha1">archiva-plexus-runtime-1.0.1.jar.sha1</a> 04-Feb-2008 03:40 40
+<img src="/icons/unknown.gif" alt="[ ]"> <a href="archiva-plexus-runtime-1.0.1.pom">archiva-plexus-runtime-1.0.1.pom</a> 04-Feb-2008 03:40 6.6K
+<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1.pom.asc">archiva-plexus-runtime-1.0.1.pom.asc</a> 04-Feb-2008 03:40 189
+<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1.pom.asc.md5">archiva-plexus-runtime-1.0.1.pom.asc.md5</a> 04-Feb-2008 03:40 32
+<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1.pom.asc.sha1">archiva-plexus-runtime-1.0.1.pom.asc.sha1</a> 04-Feb-2008 03:40 40
+<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1.pom.md5">archiva-plexus-runtime-1.0.1.pom.md5</a> 04-Feb-2008 03:40 32
+<img src="/icons/text.gif" alt="[TXT]"> <a href="archiva-plexus-runtime-1.0.1.pom.sha1">archiva-plexus-runtime-1.0.1.pom.sha1</a> 04-Feb-2008 03:40 40
+<img src="/icons/text.gif" alt="[TXT]"> <a href="readme%20artifacts.txt">readme artifacts.txt</a> 04-Feb-2008 03:40 40
+<hr></pre>
+<address>Apache/2.2.6 (Unix) DAV/2 mod_ssl/2.2.6 OpenSSL/0.9.7e-p1 Server at people.apache.org Port 80</address>
+</body></html>
diff --git a/wagon-providers/wagon-http-shared/src/test/resources/filelistings/org.codehaus.html b/wagon-providers/wagon-http-shared/src/test/resources/filelistings/org.codehaus.html
index 57c3439..7181013 100644
--- a/wagon-providers/wagon-http-shared/src/test/resources/filelistings/org.codehaus.html
+++ b/wagon-providers/wagon-http-shared/src/test/resources/filelistings/org.codehaus.html
@@ -1,82 +1,82 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
-<html>
- <head>
- <title>Index of /org/codehaus</title>
- </head>
- <body>
-<h1>Index of /org/codehaus</h1>
-<pre><img src="/icons/blank.gif" alt="Icon "> <a href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr><img src="/icons/back.gif" alt="[DIR]"> <a href="/org/">Parent Directory</a> -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="agilifier/">agilifier/</a> 05-Oct-2006 16:06 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="benji/">benji/</a> 26-Jan-2008 20:04 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="bruce/">bruce/</a> 26-Jun-2007 07:31 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="btm/">btm/</a> 10-Apr-2007 07:08 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="cargo/">cargo/</a> 15-Mar-2007 15:41 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="castor-spring/">castor-spring/</a> 17-Jan-2007 21:49 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="castor/">castor/</a> 04-Feb-2008 16:28 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="cozmos/">cozmos/</a> 18-Dec-2006 12:51 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="dataforge/">dataforge/</a> 12-Jun-2006 21:38 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="dimple/">dimple/</a> 13-Dec-2006 04:59 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="droolsdotnet/">droolsdotnet/</a> 21-Feb-2007 22:50 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="enunciate/">enunciate/</a> 07-Jan-2008 09:37 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="fabric3/">fabric3/</a> 25-Jan-2008 04:55 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="gant/">gant/</a> 08-Dec-2007 03:41 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="grails-plugins/">grails-plugins/</a> 17-Jan-2007 21:43 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="groovy/">groovy/</a> 15-Dec-2007 12:15 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="gsoc/">gsoc/</a> 16-Feb-2007 15:48 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="guessencoding/">guessencoding/</a> 22-Jul-2007 16:13 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="gumtree/">gumtree/</a> 18-Jan-2007 17:54 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="gwt-openlayers/">gwt-openlayers/</a> 14-Sep-2007 17:04 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="haus/">haus/</a> 16-Mar-2007 15:46 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="izpack/">izpack/</a> 04-Feb-2008 05:42 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="javasim/">javasim/</a> 22-Sep-2007 22:02 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="jedi/">jedi/</a> 01-Jun-2007 07:10 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="jequel/">jequel/</a> 09-Nov-2007 08:18 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="jet/">jet/</a> 22-Aug-2006 13:25 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="jettison/">jettison/</a> 09-Nov-2006 04:13 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="jfdi/">jfdi/</a> 15-Sep-2006 21:24 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="jikesrvm/">jikesrvm/</a> 19-Jan-2007 23:07 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="jra/">jra/</a> 23-Oct-2006 13:13 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="jremoting/">jremoting/</a> 08-Jan-2008 10:47 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="jtestme/">jtestme/</a> 01-Sep-2007 17:20 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="jtestr/">jtestr/</a> 07-Dec-2007 18:05 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="labs-ng/">labs-ng/</a> 20-Dec-2007 09:46 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="logicabyss/">logicabyss/</a> 02-Dec-2007 15:57 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="marionette/">marionette/</a> 08-Oct-2007 15:31 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="mevenide/">mevenide/</a> 18-Dec-2007 12:01 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="modello/">modello/</a> 22-Mar-2007 23:52 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="mojo/">mojo/</a> 06-Feb-2008 16:17 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="mvel/">mvel/</a> 05-Feb-2008 08:37 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="mvflex/">mvflex/</a> 29-Dec-2006 20:33 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="native-mojo/">native-mojo/</a> 12-Feb-2007 18:35 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="openim/">openim/</a> 30-Apr-2007 15:47 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="plexus/">plexus/</a> 06-Dec-2007 15:34 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="polymap/">polymap/</a> 02-Dec-2007 15:32 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="prometheus/">prometheus/</a> 28-Mar-2007 10:05 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="prophit/">prophit/</a> 30-Apr-2007 15:44 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="quaere/">quaere/</a> 19-Sep-2007 07:08 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="redback/">redback/</a> 07-Sep-2007 18:57 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="rulessandpit/">rulessandpit/</a> 02-May-2007 16:03 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="rvm/">rvm/</a> 19-Jan-2007 23:13 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="savana/">savana/</a> 09-Nov-2007 07:56 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="scala-ide/">scala-ide/</a> 26-Jun-2007 07:38 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="senro/">senro/</a> 27-Sep-2006 16:22 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="sonar/">sonar/</a> 24-Jan-2008 08:17 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="staxmate/">staxmate/</a> 27-Nov-2007 00:46 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="stomp/">stomp/</a> 02-Mar-2007 10:29 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="svn4j/">svn4j/</a> 17-Nov-2006 12:17 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="swiby/">swiby/</a> 19-Sep-2007 06:09 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="swizzle/">swizzle/</a> 04-Jan-2008 21:04 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="sxc/">sxc/</a> 16-Feb-2007 15:46 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="testdox/">testdox/</a> 12-Jul-2007 07:38 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="wadi/">wadi/</a> 21-Jul-2007 02:03 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="waffle/">waffle/</a> 06-Jan-2008 23:53 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="woodstox/">woodstox/</a> 03-Sep-2006 19:14 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="xdoclet/">xdoclet/</a> 15-Jun-2006 05:04 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="xfire/">xfire/</a> 19-Jun-2006 10:15 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="xharness/">xharness/</a> 24-Oct-2006 15:49 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="xsite/">xsite/</a> 11-Nov-2006 06:08 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="xstream/">xstream/</a> 28-Jul-2006 04:30 -
-<img src="/icons/folder.gif" alt="[DIR]"> <a href="xwire/">xwire/</a> 26-Jul-2006 14:20 -
-<hr></pre>
-<address>Apache/2.0.52 (Red Hat) Server at repository.codehaus.org Port 80</address>
-</body></html>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<html>
+ <head>
+ <title>Index of /org/codehaus</title>
+ </head>
+ <body>
+<h1>Index of /org/codehaus</h1>
+<pre><img src="/icons/blank.gif" alt="Icon "> <a href="?C=N;O=D">Name</a> <a href="?C=M;O=A">Last modified</a> <a href="?C=S;O=A">Size</a> <a href="?C=D;O=A">Description</a><hr><img src="/icons/back.gif" alt="[DIR]"> <a href="/org/">Parent Directory</a> -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="agilifier/">agilifier/</a> 05-Oct-2006 16:06 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="benji/">benji/</a> 26-Jan-2008 20:04 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="bruce/">bruce/</a> 26-Jun-2007 07:31 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="btm/">btm/</a> 10-Apr-2007 07:08 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="cargo/">cargo/</a> 15-Mar-2007 15:41 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="castor-spring/">castor-spring/</a> 17-Jan-2007 21:49 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="castor/">castor/</a> 04-Feb-2008 16:28 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="cozmos/">cozmos/</a> 18-Dec-2006 12:51 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="dataforge/">dataforge/</a> 12-Jun-2006 21:38 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="dimple/">dimple/</a> 13-Dec-2006 04:59 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="droolsdotnet/">droolsdotnet/</a> 21-Feb-2007 22:50 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="enunciate/">enunciate/</a> 07-Jan-2008 09:37 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="fabric3/">fabric3/</a> 25-Jan-2008 04:55 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="gant/">gant/</a> 08-Dec-2007 03:41 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="grails-plugins/">grails-plugins/</a> 17-Jan-2007 21:43 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="groovy/">groovy/</a> 15-Dec-2007 12:15 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="gsoc/">gsoc/</a> 16-Feb-2007 15:48 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="guessencoding/">guessencoding/</a> 22-Jul-2007 16:13 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="gumtree/">gumtree/</a> 18-Jan-2007 17:54 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="gwt-openlayers/">gwt-openlayers/</a> 14-Sep-2007 17:04 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="haus/">haus/</a> 16-Mar-2007 15:46 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="izpack/">izpack/</a> 04-Feb-2008 05:42 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="javasim/">javasim/</a> 22-Sep-2007 22:02 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="jedi/">jedi/</a> 01-Jun-2007 07:10 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="jequel/">jequel/</a> 09-Nov-2007 08:18 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="jet/">jet/</a> 22-Aug-2006 13:25 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="jettison/">jettison/</a> 09-Nov-2006 04:13 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="jfdi/">jfdi/</a> 15-Sep-2006 21:24 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="jikesrvm/">jikesrvm/</a> 19-Jan-2007 23:07 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="jra/">jra/</a> 23-Oct-2006 13:13 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="jremoting/">jremoting/</a> 08-Jan-2008 10:47 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="jtestme/">jtestme/</a> 01-Sep-2007 17:20 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="jtestr/">jtestr/</a> 07-Dec-2007 18:05 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="labs-ng/">labs-ng/</a> 20-Dec-2007 09:46 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="logicabyss/">logicabyss/</a> 02-Dec-2007 15:57 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="marionette/">marionette/</a> 08-Oct-2007 15:31 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="mevenide/">mevenide/</a> 18-Dec-2007 12:01 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="modello/">modello/</a> 22-Mar-2007 23:52 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="mojo/">mojo/</a> 06-Feb-2008 16:17 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="mvel/">mvel/</a> 05-Feb-2008 08:37 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="mvflex/">mvflex/</a> 29-Dec-2006 20:33 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="native-mojo/">native-mojo/</a> 12-Feb-2007 18:35 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="openim/">openim/</a> 30-Apr-2007 15:47 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="plexus/">plexus/</a> 06-Dec-2007 15:34 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="polymap/">polymap/</a> 02-Dec-2007 15:32 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="prometheus/">prometheus/</a> 28-Mar-2007 10:05 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="prophit/">prophit/</a> 30-Apr-2007 15:44 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="quaere/">quaere/</a> 19-Sep-2007 07:08 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="redback/">redback/</a> 07-Sep-2007 18:57 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="rulessandpit/">rulessandpit/</a> 02-May-2007 16:03 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="rvm/">rvm/</a> 19-Jan-2007 23:13 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="savana/">savana/</a> 09-Nov-2007 07:56 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="scala-ide/">scala-ide/</a> 26-Jun-2007 07:38 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="senro/">senro/</a> 27-Sep-2006 16:22 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="sonar/">sonar/</a> 24-Jan-2008 08:17 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="staxmate/">staxmate/</a> 27-Nov-2007 00:46 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="stomp/">stomp/</a> 02-Mar-2007 10:29 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="svn4j/">svn4j/</a> 17-Nov-2006 12:17 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="swiby/">swiby/</a> 19-Sep-2007 06:09 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="swizzle/">swizzle/</a> 04-Jan-2008 21:04 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="sxc/">sxc/</a> 16-Feb-2007 15:46 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="testdox/">testdox/</a> 12-Jul-2007 07:38 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="wadi/">wadi/</a> 21-Jul-2007 02:03 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="waffle/">waffle/</a> 06-Jan-2008 23:53 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="woodstox/">woodstox/</a> 03-Sep-2006 19:14 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="xdoclet/">xdoclet/</a> 15-Jun-2006 05:04 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="xfire/">xfire/</a> 19-Jun-2006 10:15 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="xharness/">xharness/</a> 24-Oct-2006 15:49 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="xsite/">xsite/</a> 11-Nov-2006 06:08 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="xstream/">xstream/</a> 28-Jul-2006 04:30 -
+<img src="/icons/folder.gif" alt="[DIR]"> <a href="xwire/">xwire/</a> 26-Jul-2006 14:20 -
+<hr></pre>
+<address>Apache/2.0.52 (Red Hat) Server at repository.codehaus.org Port 80</address>
+</body></html>
diff --git a/wagon-providers/wagon-http/pom.xml b/wagon-providers/wagon-http/pom.xml
index 1566b42..73d3b18 100644
--- a/wagon-providers/wagon-http/pom.xml
+++ b/wagon-providers/wagon-http/pom.xml
@@ -1,143 +1,174 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-providers</artifactId>
- <version>2.10</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>wagon-http</artifactId>
- <name>Apache Maven Wagon :: Providers :: HTTP Provider</name>
- <description>
- Wagon provider that gets and puts artifacts through HTTP(S) using Apache HttpClient-4.x.
- </description>
-
-
- <dependencies>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>wagon-http-shared</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.1.3</version>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpcore</artifactId>
- </dependency>
-
- <!-- used for the TCK -->
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-tck-http</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-shade-plugin</artifactId>
- <version>1.4</version>
- <executions>
- <execution>
- <phase>package</phase>
- <goals>
- <goal>shade</goal>
- </goals>
- <configuration>
- <shadedArtifactAttached>true</shadedArtifactAttached>
- <shadedClassifierName>shaded</shadedClassifierName>
- <artifactSet>
- <includes>
- <include>org.apache.httpcomponents:httpclient</include>
- <include>org.apache.httpcomponents:httpcore</include>
- <include>commons-logging:commons-logging</include>
- <include>commons-codec:commons-codec</include>
- <include>commons-lang:commons-lang</include>
- <include>commons-io:commons-io</include>
- <include>org.jsoup:jsoup</include>
- <include>org.apache.maven.wagon:wagon-http-shared</include>
- </includes>
- </artifactSet>
- <shadedArtifactAttached>true</shadedArtifactAttached>
- <shadedClassifierName>shaded</shadedClassifierName>
- <relocations>
- <relocation>
- <pattern>org.apache.commons.codec</pattern>
- <shadedPattern>org.apache.maven.wagon.providers.http.commons.codec</shadedPattern>
- </relocation>
- <relocation>
- <pattern>org.apache.commons.lang</pattern>
- <shadedPattern>org.apache.maven.wagon.providers.http.commons.lang</shadedPattern>
- </relocation>
- <relocation>
- <pattern>org.apache.commons.io</pattern>
- <shadedPattern>org.apache.maven.wagon.providers.http.commons.io</shadedPattern>
- </relocation>
- <relocation>
- <pattern>org.jsoup</pattern>
- <shadedPattern>org.apache.maven.wagon.providers.http.org.jsoup</shadedPattern>
- </relocation>
- <relocation>
- <pattern>org.apache.commons.logging</pattern>
- <shadedPattern>org.apache.maven.wagon.providers.http.commons.logging</shadedPattern>
- </relocation>
- <relocation>
- <pattern>org.apache.http</pattern>
- <shadedPattern>org.apache.maven.wagon.providers.http.httpclient</shadedPattern>
- </relocation>
- <relocation>
- <pattern>org.apache.maven.wagon.shared.http</pattern>
- <shadedPattern>org.apache.maven.wagon.providers.http.wagon.shared</shadedPattern>
- </relocation>
- </relocations>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <systemPropertyVariables>
- <maven.wagon.http.ssl.insecure>true</maven.wagon.http.ssl.insecure>
- <maven.wagon.http.ssl.ignore.validity.dates>true</maven.wagon.http.ssl.ignore.validity.dates>
- </systemPropertyVariables>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-providers</artifactId>
+ <version>2.12</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>wagon-http</artifactId>
+ <name>Apache Maven Wagon :: Providers :: HTTP Provider</name>
+ <description>
+ Wagon provider that gets and puts artifacts through HTTP(S) using Apache HttpClient-4.x.
+ </description>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>wagon-http-shared</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <exclusions>
+ <exclusion>
+ <artifactId>commons-logging</artifactId>
+ <groupId>commons-logging</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpcore</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty.aggregate</groupId>
+ <artifactId>jetty-all</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- used for the TCK -->
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-tck-http</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>1.4</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <shadedArtifactAttached>true</shadedArtifactAttached>
+ <shadedClassifierName>shaded</shadedClassifierName>
+ <artifactSet>
+ <includes>
+ <include>org.apache.httpcomponents:httpclient</include>
+ <include>org.apache.httpcomponents:httpcore</include>
+ <include>commons-codec:commons-codec</include>
+ <include>commons-io:commons-io</include>
+ <include>org.jsoup:jsoup</include>
+ <include>org.apache.maven.wagon:wagon-http-shared</include>
+ </includes>
+ </artifactSet>
+ <shadedArtifactAttached>true</shadedArtifactAttached>
+ <shadedClassifierName>shaded</shadedClassifierName>
+ <relocations>
+ <relocation>
+ <pattern>org.apache.commons.codec</pattern>
+ <shadedPattern>org.apache.maven.wagon.providers.http.commons.codec</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>org.apache.commons.io</pattern>
+ <shadedPattern>org.apache.maven.wagon.providers.http.commons.io</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>org.jsoup</pattern>
+ <shadedPattern>org.apache.maven.wagon.providers.http.org.jsoup</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>org.apache.http</pattern>
+ <shadedPattern>org.apache.maven.wagon.providers.http.httpclient</shadedPattern>
+ </relocation>
+ <relocation>
+ <pattern>org.apache.maven.wagon.shared.http</pattern>
+ <shadedPattern>org.apache.maven.wagon.providers.http.wagon.shared</shadedPattern>
+ </relocation>
+ </relocations>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <systemPropertyVariables>
+ <maven.wagon.http.ssl.insecure>true</maven.wagon.http.ssl.insecure>
+ <maven.wagon.http.ssl.ignore.validity.dates>true</maven.wagon.http.ssl.ignore.validity.dates>
+ <org.slf4j.simpleLogger.showDateTime>true</org.slf4j.simpleLogger.showDateTime>
+ <org.slf4j.simpleLogger.dateTimeFormat>yyyy-MM-dd'T'HH:mm:ss.SSS</org.slf4j.simpleLogger.dateTimeFormat>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/AbstractHttpClientWagon.java b/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/AbstractHttpClientWagon.java
old mode 100755
new mode 100644
index f47e5ae..cf842e4
--- a/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/AbstractHttpClientWagon.java
+++ b/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/AbstractHttpClientWagon.java
@@ -1,1146 +1,1148 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.auth.AUTH;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.Credentials;
-import org.apache.http.auth.MalformedChallengeException;
-import org.apache.http.auth.NTCredentials;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.AuthCache;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.config.CookieSpecs;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpHead;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.client.utils.DateUtils;
-import org.apache.http.config.Registry;
-import org.apache.http.config.RegistryBuilder;
-import org.apache.http.conn.HttpClientConnectionManager;
-import org.apache.http.conn.socket.ConnectionSocketFactory;
-import org.apache.http.conn.socket.PlainConnectionSocketFactory;
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.conn.ssl.SSLContextBuilder;
-import org.apache.http.conn.ssl.SSLInitializationException;
-import org.apache.http.entity.AbstractHttpEntity;
-import org.apache.http.impl.auth.BasicScheme;
-import org.apache.http.impl.client.BasicAuthCache;
-import org.apache.http.impl.client.BasicCredentialsProvider;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.util.EntityUtils;
-import org.apache.maven.wagon.InputData;
-import org.apache.maven.wagon.OutputData;
-import org.apache.maven.wagon.PathUtils;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
-import org.apache.maven.wagon.StreamWagon;
-import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.authorization.AuthorizationException;
-import org.apache.maven.wagon.events.TransferEvent;
-import org.apache.maven.wagon.proxy.ProxyInfo;
-import org.apache.maven.wagon.repository.Repository;
-import org.apache.maven.wagon.resource.Resource;
-import org.apache.maven.wagon.shared.http.EncodingUtil;
-import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.StringUtils;
-
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.SSLContext;
-import java.io.ByteArrayInputStream;
-import java.io.Closeable;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Properties;
-import java.util.TimeZone;
-import java.util.concurrent.TimeUnit;
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- * @author <a href="mailto:james at atlassian.com">James William Dumay</a>
- */
-public abstract class AbstractHttpClientWagon
- extends StreamWagon
-{
- private final class RequestEntityImplementation
- extends AbstractHttpEntity
- {
-
- private static final int BUFFER_SIZE = 2048;
-
- private final Resource resource;
-
- private final Wagon wagon;
-
- private ByteBuffer byteBuffer;
-
- private File source;
-
- private long length = -1;
-
- private RequestEntityImplementation( final InputStream stream, final Resource resource, final Wagon wagon,
- final File source )
- throws TransferFailedException
- {
- if ( source != null )
- {
- this.source = source;
- }
- else
- {
- try
- {
- byte[] bytes = IOUtil.toByteArray( stream );
- byteBuffer = ByteBuffer.allocate( bytes.length );
- byteBuffer.put( bytes );
- }
- catch ( IOException e )
- {
- throw new TransferFailedException( e.getMessage(), e );
- }
- }
- this.resource = resource;
- this.length = resource == null ? -1 : resource.getContentLength();
-
- this.wagon = wagon;
- }
-
- public long getContentLength()
- {
- return length;
- }
-
- public InputStream getContent()
- throws IOException, IllegalStateException
- {
- if ( this.source != null )
- {
- return new FileInputStream( this.source );
- }
- return new ByteArrayInputStream( this.byteBuffer.array() );
- }
-
- public boolean isRepeatable()
- {
- return true;
- }
-
- public void writeTo( final OutputStream outstream )
- throws IOException
- {
- if ( outstream == null )
- {
- throw new IllegalArgumentException( "Output stream may not be null" );
- }
- TransferEvent transferEvent =
- new TransferEvent( wagon, resource, TransferEvent.TRANSFER_PROGRESS, TransferEvent.REQUEST_PUT );
- transferEvent.setTimestamp( System.currentTimeMillis() );
- InputStream instream = ( this.source != null )
- ? new FileInputStream( this.source )
- : new ByteArrayInputStream( this.byteBuffer.array() );
- try
- {
- byte[] buffer = new byte[BUFFER_SIZE];
- int l;
- if ( this.length < 0 )
- {
- // until EOF
- while ( ( l = instream.read( buffer ) ) != -1 )
- {
- fireTransferProgress( transferEvent, buffer, -1 );
- outstream.write( buffer, 0, l );
- }
- }
- else
- {
- // no need to consume more than length
- long remaining = this.length;
- while ( remaining > 0 )
- {
- l = instream.read( buffer, 0, (int) Math.min( BUFFER_SIZE, remaining ) );
- if ( l == -1 )
- {
- break;
- }
- fireTransferProgress( transferEvent, buffer, (int) Math.min( BUFFER_SIZE, remaining ) );
- outstream.write( buffer, 0, l );
- remaining -= l;
- }
- }
- }
- finally
- {
- instream.close();
- }
- }
-
- public boolean isStreaming()
- {
- return true;
- }
- }
-
- private static final TimeZone GMT_TIME_ZONE = TimeZone.getTimeZone( "GMT" );
-
- /**
- * use http(s) connection pool mechanism.
- * <b>enabled by default</b>
- */
- private static boolean persistentPool =
- Boolean.valueOf( System.getProperty( "maven.wagon.http.pool", "true" ) );
-
- /**
- * skip failure on certificate validity checks.
- * <b>disabled by default</b>
- */
- private static final boolean SSL_INSECURE =
- Boolean.valueOf( System.getProperty( "maven.wagon.http.ssl.insecure", "false" ) );
-
- /**
- * if using sslInsecure, certificate date issues will be ignored
- * <b>disabled by default</b>
- */
- private static final boolean IGNORE_SSL_VALIDITY_DATES =
- Boolean.valueOf( System.getProperty( "maven.wagon.http.ssl.ignore.validity.dates", "false" ) );
-
- /**
- * If enabled, ssl hostname verifier does not check hostname. Disable this will use a browser compat hostname
- * verifier <b>disabled by default</b>
- */
- private static final boolean SSL_ALLOW_ALL =
- Boolean.valueOf( System.getProperty( "maven.wagon.http.ssl.allowall", "false" ) );
-
-
- /**
- * Maximum concurrent connections per distinct route.
- * <b>20 by default</b>
- */
- private static final int MAX_CONN_PER_ROUTE =
- Integer.parseInt( System.getProperty( "maven.wagon.httpconnectionManager.maxPerRoute", "20" ) );
-
- /**
- * Maximum concurrent connections in total.
- * <b>40 by default</b>
- */
- private static final int MAX_CONN_TOTAL =
- Integer.parseInt( System.getProperty( "maven.wagon.httpconnectionManager.maxTotal", "40" ) );
-
- /**
- * Internal connection manager
- */
- private static HttpClientConnectionManager httpClientConnectionManager = createConnManager();
-
-
- /**
- * See RFC6585
- */
- protected static final int SC_TOO_MANY_REQUESTS = 429;
-
- /**
- * For exponential backoff.
- */
-
- /**
- * Initial seconds to back off when a HTTP 429 received.
- * Subsequent 429 responses result in exponental backoff.
- * <b>5 by default</b>
- *
- * @since 2.7
- */
- private int initialBackoffSeconds =
- Integer.parseInt( System.getProperty( "maven.wagon.httpconnectionManager.backoffSeconds", "5" ) );
-
- /**
- * The maximum amount of time we want to back off in the case of
- * repeated HTTP 429 response codes.
- *
- * @since 2.7
- */
- private static final int MAX_BACKOFF_WAIT_SECONDS =
- Integer.parseInt( System.getProperty( "maven.wagon.httpconnectionManager.maxBackoffSeconds", "180" ) );
-
-
- protected int backoff( int wait, String url )
- throws InterruptedException, TransferFailedException
- {
- TimeUnit.SECONDS.sleep( wait );
- int nextWait = wait * 2;
- if ( nextWait >= getMaxBackoffWaitSeconds() )
- {
- throw new TransferFailedException(
- "Waited too long to access: " + url + ". Return code is: " + SC_TOO_MANY_REQUESTS );
- }
- return nextWait;
- }
-
- @SuppressWarnings( "checkstyle:linelength" )
- private static PoolingHttpClientConnectionManager createConnManager()
- {
-
- String sslProtocolsStr = System.getProperty( "https.protocols" );
- String cipherSuitesStr = System.getProperty( "https.cipherSuites" );
- String[] sslProtocols = sslProtocolsStr != null ? sslProtocolsStr.split( " *, *" ) : null;
- String[] cipherSuites = cipherSuitesStr != null ? cipherSuitesStr.split( " *, *" ) : null;
-
- SSLConnectionSocketFactory sslConnectionSocketFactory;
- if ( SSL_INSECURE )
- {
- try
- {
- SSLContext sslContext = new SSLContextBuilder().useSSL().loadTrustMaterial( null,
- new RelaxedTrustStrategy(
- IGNORE_SSL_VALIDITY_DATES ) ).build();
- sslConnectionSocketFactory = new SSLConnectionSocketFactory( sslContext, sslProtocols, cipherSuites,
- SSL_ALLOW_ALL
- ? SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER
- : SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER );
- }
- catch ( Exception ex )
- {
- throw new SSLInitializationException( ex.getMessage(), ex );
- }
- }
- else
- {
- sslConnectionSocketFactory =
- new SSLConnectionSocketFactory( HttpsURLConnection.getDefaultSSLSocketFactory(), sslProtocols,
- cipherSuites,
- SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER );
- }
-
- Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create().register( "http",
- PlainConnectionSocketFactory.INSTANCE ).register(
- "https", sslConnectionSocketFactory ).build();
-
- PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager( registry );
- if ( persistentPool )
- {
- connManager.setDefaultMaxPerRoute( MAX_CONN_PER_ROUTE );
- connManager.setMaxTotal( MAX_CONN_TOTAL );
- }
- else
- {
- connManager.setMaxTotal( 1 );
- }
- return connManager;
- }
-
- private static final CloseableHttpClient CLIENT = createClient();
-
- private static CloseableHttpClient createClient()
- {
- return HttpClientBuilder.create() //
- .useSystemProperties() //
- .disableConnectionState() //
- .setConnectionManager( httpClientConnectionManager ) //
- .build();
- }
-
- private CredentialsProvider credentialsProvider;
-
- private AuthCache authCache;
-
- private HttpClientContext localContext;
-
- private Closeable closeable;
-
- /**
- * @plexus.configuration
- * @deprecated Use httpConfiguration instead.
- */
- private Properties httpHeaders;
-
- /**
- * @since 1.0-beta-6
- */
- private HttpConfiguration httpConfiguration;
-
- /**
- * Basic auth scope overrides
- * @since 2.8
- */
- private BasicAuthScope basicAuth;
-
- /**
- * Proxy basic auth scope overrides
- * @since 2.8
- */
- private BasicAuthScope proxyAuth;
-
- public void openConnectionInternal()
- {
- repository.setUrl( getURL( repository ) );
-
- localContext = HttpClientContext.create();
- credentialsProvider = new BasicCredentialsProvider();
- authCache = new BasicAuthCache();
- localContext.setCredentialsProvider( credentialsProvider );
- localContext.setAuthCache( authCache );
-
- if ( authenticationInfo != null )
- {
-
- String username = authenticationInfo.getUserName();
- String password = authenticationInfo.getPassword();
-
- if ( StringUtils.isNotEmpty( username ) && StringUtils.isNotEmpty( password ) )
- {
- Credentials creds = new UsernamePasswordCredentials( username, password );
-
- String host = getRepository().getHost();
- int port = getRepository().getPort();
-
- credentialsProvider.setCredentials( getBasicAuthScope().getScope( host, port ), creds );
- }
- }
-
- ProxyInfo proxyInfo = getProxyInfo( getRepository().getProtocol(), getRepository().getHost() );
- if ( proxyInfo != null )
- {
- String proxyUsername = proxyInfo.getUserName();
- String proxyPassword = proxyInfo.getPassword();
- String proxyHost = proxyInfo.getHost();
- String proxyNtlmHost = proxyInfo.getNtlmHost();
- String proxyNtlmDomain = proxyInfo.getNtlmDomain();
- if ( proxyHost != null )
- {
- if ( proxyUsername != null && proxyPassword != null )
- {
- Credentials creds;
- if ( proxyNtlmHost != null || proxyNtlmDomain != null )
- {
- creds = new NTCredentials( proxyUsername, proxyPassword, proxyNtlmHost, proxyNtlmDomain );
- }
- else
- {
- creds = new UsernamePasswordCredentials( proxyUsername, proxyPassword );
- }
-
- int port = proxyInfo.getPort();
-
- AuthScope authScope = getProxyBasicAuthScope().getScope( proxyHost, port );
- credentialsProvider.setCredentials( authScope, creds );
- }
- }
- }
- }
-
- public void closeConnection()
- {
- if ( !persistentPool )
- {
- httpClientConnectionManager.closeIdleConnections( 0, TimeUnit.MILLISECONDS );
- }
- }
-
- public static void setPersistentPool( boolean persistentPool )
- {
- persistentPool = persistentPool;
- }
-
- public static void setPoolingHttpClientConnectionManager(
- PoolingHttpClientConnectionManager poolingHttpClientConnectionManager )
- {
- httpClientConnectionManager = poolingHttpClientConnectionManager;
- }
-
- public void put( File source, String resourceName )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- Resource resource = new Resource( resourceName );
-
- firePutInitiated( resource, source );
-
- resource.setContentLength( source.length() );
-
- resource.setLastModified( source.lastModified() );
-
- put( null, resource, source );
- }
-
- public void putFromStream( final InputStream stream, String destination, long contentLength, long lastModified )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- Resource resource = new Resource( destination );
-
- firePutInitiated( resource, null );
-
- resource.setContentLength( contentLength );
-
- resource.setLastModified( lastModified );
-
- put( stream, resource, null );
- }
-
- private void put( final InputStream stream, Resource resource, File source )
- throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
- {
- put( resource, source, new RequestEntityImplementation( stream, resource, this, source ) );
- }
-
- private void put( Resource resource, File source, HttpEntity httpEntity )
- throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
- {
- put( resource, source, httpEntity, buildUrl( resource ) );
- }
-
- /**
- * Builds a complete URL string from the repository URL and the relative path of the resource passed.
- *
- * @param resource the resource to extract the relative path from.
- * @return the complete URL
- */
- private String buildUrl( Resource resource )
- {
- return EncodingUtil.encodeURLToString( getRepository().getUrl(), resource.getName() );
- }
-
-
- private void put( Resource resource, File source, HttpEntity httpEntity, String url )
- throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
- {
- put( getInitialBackoffSeconds(), resource, source, httpEntity, url );
- }
-
-
- private void put( int wait, Resource resource, File source, HttpEntity httpEntity, String url )
- throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
- {
-
- //Parent directories need to be created before posting
- try
- {
- mkdirs( PathUtils.dirname( resource.getName() ) );
- }
- catch ( HttpException he )
- {
- fireTransferError( resource, he, TransferEvent.REQUEST_GET );
- }
- catch ( IOException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_GET );
- }
-
- // preemptive for put
- // TODO: is it a good idea, though? 'Expect-continue' handshake would serve much better
-
- Repository repo = getRepository();
- HttpHost targetHost = new HttpHost( repo.getHost(), repo.getPort(), repo.getProtocol() );
- AuthScope targetScope = getBasicAuthScope().getScope( targetHost );
-
- if ( credentialsProvider.getCredentials( targetScope ) != null )
- {
- BasicScheme targetAuth = new BasicScheme();
- try
- {
- targetAuth.processChallenge( new BasicHeader( AUTH.WWW_AUTH, "BASIC preemptive" ) );
- authCache.put( targetHost, targetAuth );
- }
- catch ( MalformedChallengeException ignore )
- {
- // ignore
- }
- }
-
- HttpPut putMethod = new HttpPut( url );
-
- firePutStarted( resource, source );
-
- try
- {
- putMethod.setEntity( httpEntity );
-
- CloseableHttpResponse response = execute( putMethod );
- try
- {
- int statusCode = response.getStatusLine().getStatusCode();
- String reasonPhrase = ", ReasonPhrase: " + response.getStatusLine().getReasonPhrase() + ".";
- fireTransferDebug( url + " - Status code: " + statusCode + reasonPhrase );
-
- // Check that we didn't run out of retries.
- switch ( statusCode )
- {
- // Success Codes
- case HttpStatus.SC_OK: // 200
- case HttpStatus.SC_CREATED: // 201
- case HttpStatus.SC_ACCEPTED: // 202
- case HttpStatus.SC_NO_CONTENT: // 204
- break;
- // handle all redirect even if http specs says " the user agent MUST NOT automatically redirect
- // the request unless it can be confirmed by the user"
- case HttpStatus.SC_MOVED_PERMANENTLY: // 301
- case HttpStatus.SC_MOVED_TEMPORARILY: // 302
- case HttpStatus.SC_SEE_OTHER: // 303
- put( resource, source, httpEntity, calculateRelocatedUrl( response ) );
- return;
- case HttpStatus.SC_FORBIDDEN:
- fireSessionConnectionRefused();
- throw new AuthorizationException( "Access denied to: " + url + reasonPhrase );
-
- case HttpStatus.SC_NOT_FOUND:
- throw new ResourceDoesNotExistException( "File: " + url + " does not exist" + reasonPhrase );
-
- case SC_TOO_MANY_REQUESTS:
- put( backoff( wait, url ), resource, source, httpEntity, url );
- break;
- //add more entries here
- default:
- TransferFailedException e = new TransferFailedException(
- "Failed to transfer file: " + url + ". Return code is: " + statusCode + reasonPhrase );
- fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
- throw e;
- }
-
- firePutCompleted( resource, source );
-
- EntityUtils.consume( response.getEntity() );
- }
- finally
- {
- response.close();
- }
- }
- catch ( IOException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
-
- throw new TransferFailedException( e.getMessage(), e );
- }
- catch ( HttpException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
-
- throw new TransferFailedException( e.getMessage(), e );
- }
- catch ( InterruptedException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
-
- throw new TransferFailedException( e.getMessage(), e );
- }
-
- }
-
- protected String calculateRelocatedUrl( HttpResponse response )
- {
- Header locationHeader = response.getFirstHeader( "Location" );
- String locationField = locationHeader.getValue();
- // is it a relative Location or a full ?
- return locationField.startsWith( "http" ) ? locationField : getURL( getRepository() ) + '/' + locationField;
- }
-
- protected void mkdirs( String dirname )
- throws HttpException, IOException
- {
- // nothing to do
- }
-
- public boolean resourceExists( String resourceName )
- throws TransferFailedException, AuthorizationException
- {
- return resourceExists( getInitialBackoffSeconds(), resourceName );
- }
-
-
- private boolean resourceExists( int wait, String resourceName )
- throws TransferFailedException, AuthorizationException
- {
- String repositoryUrl = getRepository().getUrl();
- String url = repositoryUrl + ( repositoryUrl.endsWith( "/" ) ? "" : "/" ) + resourceName;
- HttpHead headMethod = new HttpHead( url );
- try
- {
- CloseableHttpResponse response = execute( headMethod );
- try
- {
- int statusCode = response.getStatusLine().getStatusCode();
- String reasonPhrase = ", ReasonPhrase: " + response.getStatusLine().getReasonPhrase() + ".";
- boolean result;
- switch ( statusCode )
- {
- case HttpStatus.SC_OK:
- result = true;
- break;
- case HttpStatus.SC_NOT_MODIFIED:
- result = true;
- break;
- case HttpStatus.SC_FORBIDDEN:
- throw new AuthorizationException( "Access denied to: " + url + reasonPhrase );
-
- case HttpStatus.SC_UNAUTHORIZED:
- throw new AuthorizationException( "Not authorized " + reasonPhrase );
-
- case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
- throw new AuthorizationException( "Not authorized by proxy " + reasonPhrase );
-
- case HttpStatus.SC_NOT_FOUND:
- result = false;
- break;
-
- case SC_TOO_MANY_REQUESTS:
- return resourceExists( backoff( wait, resourceName ), resourceName );
-
- //add more entries here
- default:
- throw new TransferFailedException(
- "Failed to transfer file: " + url + ". Return code is: " + statusCode + reasonPhrase );
- }
-
- EntityUtils.consume( response.getEntity() );
- return result;
- }
- finally
- {
- response.close();
- }
- }
- catch ( IOException e )
- {
- throw new TransferFailedException( e.getMessage(), e );
- }
- catch ( HttpException e )
- {
- throw new TransferFailedException( e.getMessage(), e );
- }
- catch ( InterruptedException e )
- {
- throw new TransferFailedException( e.getMessage(), e );
- }
-
- }
-
- protected CloseableHttpResponse execute( HttpUriRequest httpMethod )
- throws HttpException, IOException
- {
- setHeaders( httpMethod );
- String userAgent = getUserAgent( httpMethod );
- if ( userAgent != null )
- {
- httpMethod.setHeader( HTTP.USER_AGENT, userAgent );
- }
-
- RequestConfig.Builder requestConfigBuilder = RequestConfig.custom();
- // WAGON-273: default the cookie-policy to browser compatible
- requestConfigBuilder.setCookieSpec( CookieSpecs.BROWSER_COMPATIBILITY );
-
- Repository repo = getRepository();
- ProxyInfo proxyInfo = getProxyInfo( repo.getProtocol(), repo.getHost() );
- if ( proxyInfo != null )
- {
- HttpHost proxy = new HttpHost( proxyInfo.getHost(), proxyInfo.getPort() );
- requestConfigBuilder.setProxy( proxy );
- }
-
- HttpMethodConfiguration config =
- httpConfiguration == null ? null : httpConfiguration.getMethodConfiguration( httpMethod );
-
- if ( config != null )
- {
- ConfigurationUtils.copyConfig( config, requestConfigBuilder );
- }
- else
- {
- requestConfigBuilder.setSocketTimeout( getReadTimeout() );
- }
-
- localContext.setRequestConfig( requestConfigBuilder.build() );
-
- if ( config != null && config.isUsePreemptive() )
- {
- HttpHost targetHost = new HttpHost( repo.getHost(), repo.getPort(), repo.getProtocol() );
- AuthScope targetScope = getBasicAuthScope().getScope( targetHost );
-
- if ( credentialsProvider.getCredentials( targetScope ) != null )
- {
- BasicScheme targetAuth = new BasicScheme();
- targetAuth.processChallenge( new BasicHeader( AUTH.WWW_AUTH, "BASIC preemptive" ) );
- authCache.put( targetHost, targetAuth );
- }
- }
-
- if ( proxyInfo != null )
- {
- if ( proxyInfo.getHost() != null )
- {
- HttpHost proxyHost = new HttpHost( proxyInfo.getHost(), proxyInfo.getPort() );
- AuthScope proxyScope = getProxyBasicAuthScope().getScope( proxyHost );
-
- String proxyUsername = proxyInfo.getUserName();
- String proxyPassword = proxyInfo.getPassword();
- String proxyNtlmHost = proxyInfo.getNtlmHost();
- String proxyNtlmDomain = proxyInfo.getNtlmDomain();
-
- if ( proxyUsername != null && proxyPassword != null )
- {
- Credentials creds;
- if ( proxyNtlmHost != null || proxyNtlmDomain != null )
- {
- creds = new NTCredentials( proxyUsername, proxyPassword, proxyNtlmHost, proxyNtlmDomain );
- }
- else
- {
- creds = new UsernamePasswordCredentials( proxyUsername, proxyPassword );
- }
-
- credentialsProvider.setCredentials( proxyScope, creds );
- BasicScheme proxyAuth = new BasicScheme();
- proxyAuth.processChallenge( new BasicHeader( AUTH.PROXY_AUTH, "BASIC preemptive" ) );
- authCache.put( proxyHost, proxyAuth );
- }
- }
- }
-
- return CLIENT.execute( httpMethod, localContext );
- }
-
- protected void setHeaders( HttpUriRequest method )
- {
- HttpMethodConfiguration config =
- httpConfiguration == null ? null : httpConfiguration.getMethodConfiguration( method );
- if ( config == null || config.isUseDefaultHeaders() )
- {
- // TODO: merge with the other headers and have some better defaults, unify with lightweight headers
- method.addHeader( "Cache-control", "no-cache" );
- method.addHeader( "Cache-store", "no-store" );
- method.addHeader( "Pragma", "no-cache" );
- method.addHeader( "Expires", "0" );
- method.addHeader( "Accept-Encoding", "gzip" );
- }
-
- if ( httpHeaders != null )
- {
- for ( Map.Entry<Object, Object> entry : httpHeaders.entrySet() )
- {
- method.setHeader( (String) entry.getKey(), (String) entry.getValue() );
- }
- }
-
- Header[] headers = config == null ? null : config.asRequestHeaders();
- if ( headers != null )
- {
- for ( Header header : headers )
- {
- method.setHeader( header );
- }
- }
- }
-
- protected String getUserAgent( HttpUriRequest method )
- {
- if ( httpHeaders != null )
- {
- String value = (String) httpHeaders.get( "User-Agent" );
- if ( value != null )
- {
- return value;
- }
- }
- HttpMethodConfiguration config =
- httpConfiguration == null ? null : httpConfiguration.getMethodConfiguration( method );
-
- if ( config != null )
- {
- return (String) config.getHeaders().get( "User-Agent" );
- }
- return null;
- }
-
- /**
- * getUrl
- * Implementors can override this to remove unwanted parts of the url such as role-hints
- *
- * @param repository
- * @return
- */
- protected String getURL( Repository repository )
- {
- return repository.getUrl();
- }
-
- public HttpConfiguration getHttpConfiguration()
- {
- return httpConfiguration;
- }
-
- public void setHttpConfiguration( HttpConfiguration httpConfiguration )
- {
- this.httpConfiguration = httpConfiguration;
- }
-
- /**
- * Get the override values for standard HttpClient AuthScope
- *
- * @return the basicAuth
- */
- public BasicAuthScope getBasicAuthScope()
- {
- if ( basicAuth == null )
- {
- basicAuth = new BasicAuthScope();
- }
- return basicAuth;
- }
-
- /**
- * Set the override values for standard HttpClient AuthScope
- *
- * @param basicAuth the AuthScope to set
- */
- public void setBasicAuthScope( BasicAuthScope basicAuth )
- {
- this.basicAuth = basicAuth;
- }
-
- /**
- * Get the override values for proxy HttpClient AuthScope
- *
- * @return the proxyAuth
- */
- public BasicAuthScope getProxyBasicAuthScope()
- {
- if ( proxyAuth == null )
- {
- proxyAuth = new BasicAuthScope();
- }
- return proxyAuth;
- }
-
- /**
- * Set the override values for proxy HttpClient AuthScope
- *
- * @param proxyAuth the AuthScope to set
- */
- public void setProxyBasicAuthScope( BasicAuthScope proxyAuth )
- {
- this.proxyAuth = proxyAuth;
- }
-
- public void fillInputData( InputData inputData )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- fillInputData( getInitialBackoffSeconds(), inputData );
- }
-
- private void fillInputData( int wait, InputData inputData )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- Resource resource = inputData.getResource();
-
- String repositoryUrl = getRepository().getUrl();
- String url = repositoryUrl + ( repositoryUrl.endsWith( "/" ) ? "" : "/" ) + resource.getName();
- HttpGet getMethod = new HttpGet( url );
- long timestamp = resource.getLastModified();
- if ( timestamp > 0 )
- {
- SimpleDateFormat fmt = new SimpleDateFormat( "EEE, dd-MMM-yy HH:mm:ss zzz", Locale.US );
- fmt.setTimeZone( GMT_TIME_ZONE );
- Header hdr = new BasicHeader( "If-Modified-Since", fmt.format( new Date( timestamp ) ) );
- fireTransferDebug( "sending ==> " + hdr + "(" + timestamp + ")" );
- getMethod.addHeader( hdr );
- }
-
- try
- {
- CloseableHttpResponse response = execute( getMethod );
- closeable = response;
- int statusCode = response.getStatusLine().getStatusCode();
-
- String reasonPhrase = ", ReasonPhrase:" + response.getStatusLine().getReasonPhrase() + ".";
-
- fireTransferDebug( url + " - Status code: " + statusCode + reasonPhrase );
-
- switch ( statusCode )
- {
- case HttpStatus.SC_OK:
- break;
-
- case HttpStatus.SC_NOT_MODIFIED:
- // return, leaving last modified set to original value so getIfNewer should return unmodified
- return;
- case HttpStatus.SC_FORBIDDEN:
- fireSessionConnectionRefused();
- throw new AuthorizationException( "Access denied to: " + url + " " + reasonPhrase );
-
- case HttpStatus.SC_UNAUTHORIZED:
- fireSessionConnectionRefused();
- throw new AuthorizationException( "Not authorized " + reasonPhrase );
-
- case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
- fireSessionConnectionRefused();
- throw new AuthorizationException( "Not authorized by proxy " + reasonPhrase );
-
- case HttpStatus.SC_NOT_FOUND:
- throw new ResourceDoesNotExistException( "File: " + url + " " + reasonPhrase );
-
- case SC_TOO_MANY_REQUESTS:
- fillInputData( backoff( wait, url ), inputData );
- break;
-
- // add more entries here
- default:
- cleanupGetTransfer( resource );
- TransferFailedException e = new TransferFailedException(
- "Failed to transfer file: " + url + ". Return code is: " + statusCode + " " + reasonPhrase );
- fireTransferError( resource, e, TransferEvent.REQUEST_GET );
- throw e;
- }
-
- Header contentLengthHeader = response.getFirstHeader( "Content-Length" );
-
- if ( contentLengthHeader != null )
- {
- try
- {
- long contentLength = Long.parseLong( contentLengthHeader.getValue() );
-
- resource.setContentLength( contentLength );
- }
- catch ( NumberFormatException e )
- {
- fireTransferDebug(
- "error parsing content length header '" + contentLengthHeader.getValue() + "' " + e );
- }
- }
-
- Header lastModifiedHeader = response.getFirstHeader( "Last-Modified" );
- if ( lastModifiedHeader != null )
- {
- Date lastModified = DateUtils.parseDate( lastModifiedHeader.getValue() );
- if ( lastModified != null )
- {
- resource.setLastModified( lastModified.getTime() );
- fireTransferDebug( "last-modified = " + lastModifiedHeader.getValue() + " ("
- + lastModified.getTime() + ")" );
- }
- }
-
- HttpEntity entity = response.getEntity();
- if ( entity != null )
- {
- inputData.setInputStream( entity.getContent() );
- }
- }
- catch ( IOException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_GET );
-
- throw new TransferFailedException( e.getMessage(), e );
- }
- catch ( HttpException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_GET );
-
- throw new TransferFailedException( e.getMessage(), e );
- }
- catch ( InterruptedException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_GET );
-
- throw new TransferFailedException( e.getMessage(), e );
- }
-
- }
-
- protected void cleanupGetTransfer( Resource resource )
- {
- if ( closeable != null )
- {
- try
- {
- closeable.close();
- }
- catch ( IOException ignore )
- {
- // ignore
- }
-
- }
- }
-
-
- @Override
- public void putFromStream( InputStream stream, String destination )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- putFromStream( stream, destination, -1, -1 );
- }
-
- @Override
- protected void putFromStream( InputStream stream, Resource resource )
- throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
- {
- putFromStream( stream, resource.getName(), -1, -1 );
- }
-
- public Properties getHttpHeaders()
- {
- return httpHeaders;
- }
-
- public void setHttpHeaders( Properties httpHeaders )
- {
- this.httpHeaders = httpHeaders;
- }
-
- @Override
- public void fillOutputData( OutputData outputData )
- throws TransferFailedException
- {
- // no needed in this implementation but throw an Exception if used
- throw new IllegalStateException( "this wagon http client must not use fillOutputData" );
- }
-
- public int getInitialBackoffSeconds()
- {
- return initialBackoffSeconds;
- }
-
- public void setInitialBackoffSeconds( int initialBackoffSeconds )
- {
- this.initialBackoffSeconds = initialBackoffSeconds;
- }
-
- public static int getMaxBackoffWaitSeconds()
- {
- return MAX_BACKOFF_WAIT_SECONDS;
- }
-}
\ No newline at end of file
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpException;
+import org.apache.http.HttpHost;
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.ChallengeState;
+import org.apache.http.auth.Credentials;
+import org.apache.http.auth.NTCredentials;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.AuthCache;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.client.config.CookieSpecs;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpHead;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.client.protocol.HttpClientContext;
+import org.apache.http.client.utils.DateUtils;
+import org.apache.http.config.Registry;
+import org.apache.http.config.RegistryBuilder;
+import org.apache.http.conn.HttpClientConnectionManager;
+import org.apache.http.conn.socket.ConnectionSocketFactory;
+import org.apache.http.conn.socket.PlainConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
+import org.apache.http.conn.ssl.SSLContextBuilder;
+import org.apache.http.conn.ssl.SSLInitializationException;
+import org.apache.http.entity.AbstractHttpEntity;
+import org.apache.http.impl.auth.BasicScheme;
+import org.apache.http.impl.client.BasicAuthCache;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.apache.http.message.BasicHeader;
+import org.apache.http.protocol.HTTP;
+import org.apache.http.util.EntityUtils;
+import org.apache.maven.wagon.InputData;
+import org.apache.maven.wagon.OutputData;
+import org.apache.maven.wagon.PathUtils;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.StreamWagon;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.proxy.ProxyInfo;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.resource.Resource;
+import org.apache.maven.wagon.shared.http.EncodingUtil;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.StringUtils;
+
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import java.io.ByteArrayInputStream;
+import java.io.Closeable;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Properties;
+import java.util.TimeZone;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ * @author <a href="mailto:james at atlassian.com">James William Dumay</a>
+ */
+public abstract class AbstractHttpClientWagon
+ extends StreamWagon
+{
+ private final class RequestEntityImplementation
+ extends AbstractHttpEntity
+ {
+
+ private static final int BUFFER_SIZE = 2048;
+
+ private final Resource resource;
+
+ private final Wagon wagon;
+
+ private ByteBuffer byteBuffer;
+
+ private File source;
+
+ private long length = -1;
+
+ private RequestEntityImplementation( final InputStream stream, final Resource resource, final Wagon wagon,
+ final File source )
+ throws TransferFailedException
+ {
+ if ( source != null )
+ {
+ this.source = source;
+ }
+ else
+ {
+ try
+ {
+ byte[] bytes = IOUtil.toByteArray( stream );
+ byteBuffer = ByteBuffer.allocate( bytes.length );
+ byteBuffer.put( bytes );
+ stream.close();
+ }
+ catch ( IOException e )
+ {
+ throw new TransferFailedException( e.getMessage(), e );
+ }
+ finally
+ {
+ IOUtil.close( stream );
+ }
+ }
+ this.resource = resource;
+ this.length = resource == null ? -1 : resource.getContentLength();
+
+ this.wagon = wagon;
+ }
+
+ public long getContentLength()
+ {
+ return length;
+ }
+
+ public InputStream getContent()
+ throws IOException, IllegalStateException
+ {
+ if ( this.source != null )
+ {
+ return new FileInputStream( this.source );
+ }
+ return new ByteArrayInputStream( this.byteBuffer.array() );
+ }
+
+ public boolean isRepeatable()
+ {
+ return true;
+ }
+
+ public void writeTo( final OutputStream outputStream )
+ throws IOException
+ {
+ if ( outputStream == null )
+ {
+ throw new NullPointerException( "outputStream cannot be null" );
+ }
+ TransferEvent transferEvent =
+ new TransferEvent( wagon, resource, TransferEvent.TRANSFER_PROGRESS, TransferEvent.REQUEST_PUT );
+ transferEvent.setTimestamp( System.currentTimeMillis() );
+ InputStream instream = ( this.source != null )
+ ? new FileInputStream( this.source )
+ : new ByteArrayInputStream( this.byteBuffer.array() );
+ try
+ {
+ byte[] buffer = new byte[BUFFER_SIZE];
+ int l;
+ if ( this.length < 0 )
+ {
+ // until EOF
+ while ( ( l = instream.read( buffer ) ) != -1 )
+ {
+ fireTransferProgress( transferEvent, buffer, -1 );
+ outputStream.write( buffer, 0, l );
+ }
+ }
+ else
+ {
+ // no need to consume more than length
+ long remaining = this.length;
+ while ( remaining > 0 )
+ {
+ l = instream.read( buffer, 0, (int) Math.min( BUFFER_SIZE, remaining ) );
+ if ( l == -1 )
+ {
+ break;
+ }
+ fireTransferProgress( transferEvent, buffer, (int) Math.min( BUFFER_SIZE, remaining ) );
+ outputStream.write( buffer, 0, l );
+ remaining -= l;
+ }
+ }
+ }
+ finally
+ {
+ instream.close();
+ }
+ }
+
+ public boolean isStreaming()
+ {
+ return true;
+ }
+ }
+
+ private static final TimeZone GMT_TIME_ZONE = TimeZone.getTimeZone( "GMT" );
+
+ /**
+ * use http(s) connection pool mechanism.
+ * <b>enabled by default</b>
+ */
+ private static boolean persistentPool =
+ Boolean.valueOf( System.getProperty( "maven.wagon.http.pool", "true" ) );
+
+ /**
+ * skip failure on certificate validity checks.
+ * <b>disabled by default</b>
+ */
+ private static final boolean SSL_INSECURE =
+ Boolean.valueOf( System.getProperty( "maven.wagon.http.ssl.insecure", "false" ) );
+
+ /**
+ * if using sslInsecure, certificate date issues will be ignored
+ * <b>disabled by default</b>
+ */
+ private static final boolean IGNORE_SSL_VALIDITY_DATES =
+ Boolean.valueOf( System.getProperty( "maven.wagon.http.ssl.ignore.validity.dates", "false" ) );
+
+ /**
+ * If enabled, ssl hostname verifier does not check hostname. Disable this will use a browser compat hostname
+ * verifier <b>disabled by default</b>
+ */
+ private static final boolean SSL_ALLOW_ALL =
+ Boolean.valueOf( System.getProperty( "maven.wagon.http.ssl.allowall", "false" ) );
+
+
+ /**
+ * Maximum concurrent connections per distinct route.
+ * <b>20 by default</b>
+ */
+ private static final int MAX_CONN_PER_ROUTE =
+ Integer.parseInt( System.getProperty( "maven.wagon.httpconnectionManager.maxPerRoute", "20" ) );
+
+ /**
+ * Maximum concurrent connections in total.
+ * <b>40 by default</b>
+ */
+ private static final int MAX_CONN_TOTAL =
+ Integer.parseInt( System.getProperty( "maven.wagon.httpconnectionManager.maxTotal", "40" ) );
+
+ /**
+ * Internal connection manager
+ */
+ private static HttpClientConnectionManager httpClientConnectionManager = createConnManager();
+
+
+ /**
+ * See RFC6585
+ */
+ protected static final int SC_TOO_MANY_REQUESTS = 429;
+
+ /**
+ * For exponential backoff.
+ */
+
+ /**
+ * Initial seconds to back off when a HTTP 429 received.
+ * Subsequent 429 responses result in exponental backoff.
+ * <b>5 by default</b>
+ *
+ * @since 2.7
+ */
+ private int initialBackoffSeconds =
+ Integer.parseInt( System.getProperty( "maven.wagon.httpconnectionManager.backoffSeconds", "5" ) );
+
+ /**
+ * The maximum amount of time we want to back off in the case of
+ * repeated HTTP 429 response codes.
+ *
+ * @since 2.7
+ */
+ private static final int MAX_BACKOFF_WAIT_SECONDS =
+ Integer.parseInt( System.getProperty( "maven.wagon.httpconnectionManager.maxBackoffSeconds", "180" ) );
+
+
+ protected int backoff( int wait, String url )
+ throws InterruptedException, TransferFailedException
+ {
+ TimeUnit.SECONDS.sleep( wait );
+ int nextWait = wait * 2;
+ if ( nextWait >= getMaxBackoffWaitSeconds() )
+ {
+ throw new TransferFailedException(
+ "Waited too long to access: " + url + ". Return code is: " + SC_TOO_MANY_REQUESTS );
+ }
+ return nextWait;
+ }
+
+ @SuppressWarnings( "checkstyle:linelength" )
+ private static PoolingHttpClientConnectionManager createConnManager()
+ {
+
+ String sslProtocolsStr = System.getProperty( "https.protocols" );
+ String cipherSuitesStr = System.getProperty( "https.cipherSuites" );
+ String[] sslProtocols = sslProtocolsStr != null ? sslProtocolsStr.split( " *, *" ) : null;
+ String[] cipherSuites = cipherSuitesStr != null ? cipherSuitesStr.split( " *, *" ) : null;
+
+ SSLConnectionSocketFactory sslConnectionSocketFactory;
+ if ( SSL_INSECURE )
+ {
+ try
+ {
+ SSLContext sslContext = new SSLContextBuilder().useSSL().loadTrustMaterial( null,
+ new RelaxedTrustStrategy(
+ IGNORE_SSL_VALIDITY_DATES ) ).build();
+ sslConnectionSocketFactory = new SSLConnectionSocketFactory( sslContext, sslProtocols, cipherSuites,
+ SSL_ALLOW_ALL
+ ? SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER
+ : SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER );
+ }
+ catch ( Exception ex )
+ {
+ throw new SSLInitializationException( ex.getMessage(), ex );
+ }
+ }
+ else
+ {
+ sslConnectionSocketFactory =
+ new SSLConnectionSocketFactory( HttpsURLConnection.getDefaultSSLSocketFactory(), sslProtocols,
+ cipherSuites,
+ SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER );
+ }
+
+ Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create().register( "http",
+ PlainConnectionSocketFactory.INSTANCE ).register(
+ "https", sslConnectionSocketFactory ).build();
+
+ PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager( registry );
+ if ( persistentPool )
+ {
+ connManager.setDefaultMaxPerRoute( MAX_CONN_PER_ROUTE );
+ connManager.setMaxTotal( MAX_CONN_TOTAL );
+ }
+ else
+ {
+ connManager.setMaxTotal( 1 );
+ }
+ return connManager;
+ }
+
+ private static CloseableHttpClient httpClient = createClient();
+
+ private static CloseableHttpClient createClient()
+ {
+ return HttpClientBuilder.create() //
+ .useSystemProperties() //
+ .disableConnectionState() //
+ .setConnectionManager( httpClientConnectionManager ) //
+ .build();
+ }
+
+ private CredentialsProvider credentialsProvider;
+
+ private AuthCache authCache;
+
+ private Closeable closeable;
+
+ /**
+ * @plexus.configuration
+ * @deprecated Use httpConfiguration instead.
+ */
+ private Properties httpHeaders;
+
+ /**
+ * @since 1.0-beta-6
+ */
+ private HttpConfiguration httpConfiguration;
+
+ /**
+ * Basic auth scope overrides
+ * @since 2.8
+ */
+ private BasicAuthScope basicAuth;
+
+ /**
+ * Proxy basic auth scope overrides
+ * @since 2.8
+ */
+ private BasicAuthScope proxyAuth;
+
+ public void openConnectionInternal()
+ {
+ repository.setUrl( getURL( repository ) );
+
+ credentialsProvider = new BasicCredentialsProvider();
+ authCache = new BasicAuthCache();
+
+ if ( authenticationInfo != null )
+ {
+
+ String username = authenticationInfo.getUserName();
+ String password = authenticationInfo.getPassword();
+
+ if ( StringUtils.isNotEmpty( username ) && StringUtils.isNotEmpty( password ) )
+ {
+ Credentials creds = new UsernamePasswordCredentials( username, password );
+
+ String host = getRepository().getHost();
+ int port = getRepository().getPort();
+
+ credentialsProvider.setCredentials( getBasicAuthScope().getScope( host, port ), creds );
+ }
+ }
+
+ ProxyInfo proxyInfo = getProxyInfo( getRepository().getProtocol(), getRepository().getHost() );
+ if ( proxyInfo != null )
+ {
+ String proxyUsername = proxyInfo.getUserName();
+ String proxyPassword = proxyInfo.getPassword();
+ String proxyHost = proxyInfo.getHost();
+ String proxyNtlmHost = proxyInfo.getNtlmHost();
+ String proxyNtlmDomain = proxyInfo.getNtlmDomain();
+ if ( proxyHost != null )
+ {
+ if ( proxyUsername != null && proxyPassword != null )
+ {
+ Credentials creds;
+ if ( proxyNtlmHost != null || proxyNtlmDomain != null )
+ {
+ creds = new NTCredentials( proxyUsername, proxyPassword, proxyNtlmHost, proxyNtlmDomain );
+ }
+ else
+ {
+ creds = new UsernamePasswordCredentials( proxyUsername, proxyPassword );
+ }
+
+ int proxyPort = proxyInfo.getPort();
+
+ AuthScope authScope = getProxyBasicAuthScope().getScope( proxyHost, proxyPort );
+ credentialsProvider.setCredentials( authScope, creds );
+ }
+ }
+ }
+ }
+
+ public void closeConnection()
+ {
+ if ( !persistentPool )
+ {
+ httpClientConnectionManager.closeIdleConnections( 0, TimeUnit.MILLISECONDS );
+ }
+
+ if ( authCache != null )
+ {
+ authCache.clear();
+ authCache = null;
+ }
+
+ if ( credentialsProvider != null )
+ {
+ credentialsProvider.clear();
+ credentialsProvider = null;
+ }
+ }
+
+ public static void setPersistentPool( boolean persistentPool )
+ {
+ persistentPool = persistentPool;
+ }
+
+ public static void setPoolingHttpClientConnectionManager(
+ PoolingHttpClientConnectionManager poolingHttpClientConnectionManager )
+ {
+ httpClientConnectionManager = poolingHttpClientConnectionManager;
+ httpClient = createClient();
+ }
+
+ public void put( File source, String resourceName )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ Resource resource = new Resource( resourceName );
+
+ firePutInitiated( resource, source );
+
+ resource.setContentLength( source.length() );
+
+ resource.setLastModified( source.lastModified() );
+
+ put( null, resource, source );
+ }
+
+ public void putFromStream( final InputStream stream, String destination, long contentLength, long lastModified )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ Resource resource = new Resource( destination );
+
+ firePutInitiated( resource, null );
+
+ resource.setContentLength( contentLength );
+
+ resource.setLastModified( lastModified );
+
+ put( stream, resource, null );
+ }
+
+ private void put( final InputStream stream, Resource resource, File source )
+ throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
+ {
+ put( resource, source, new RequestEntityImplementation( stream, resource, this, source ) );
+ }
+
+ private void put( Resource resource, File source, HttpEntity httpEntity )
+ throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
+ {
+ put( resource, source, httpEntity, buildUrl( resource ) );
+ }
+
+ /**
+ * Builds a complete URL string from the repository URL and the relative path of the resource passed.
+ *
+ * @param resource the resource to extract the relative path from.
+ * @return the complete URL
+ */
+ private String buildUrl( Resource resource )
+ {
+ return EncodingUtil.encodeURLToString( getRepository().getUrl(), resource.getName() );
+ }
+
+
+ private void put( Resource resource, File source, HttpEntity httpEntity, String url )
+ throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
+ {
+ put( getInitialBackoffSeconds(), resource, source, httpEntity, url );
+ }
+
+
+ private void put( int wait, Resource resource, File source, HttpEntity httpEntity, String url )
+ throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
+ {
+
+ //Parent directories need to be created before posting
+ try
+ {
+ mkdirs( PathUtils.dirname( resource.getName() ) );
+ }
+ catch ( HttpException he )
+ {
+ fireTransferError( resource, he, TransferEvent.REQUEST_PUT );
+ }
+ catch ( IOException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+ }
+
+ // preemptive for put
+ // TODO: is it a good idea, though? 'Expect-continue' handshake would serve much better
+
+ Repository repo = getRepository();
+ HttpHost targetHost = new HttpHost( repo.getHost(), repo.getPort(), repo.getProtocol() );
+ AuthScope targetScope = getBasicAuthScope().getScope( targetHost );
+
+ if ( credentialsProvider.getCredentials( targetScope ) != null )
+ {
+ BasicScheme targetAuth = new BasicScheme();
+ authCache.put( targetHost, targetAuth );
+ }
+
+ HttpPut putMethod = new HttpPut( url );
+
+ firePutStarted( resource, source );
+
+ try
+ {
+ putMethod.setEntity( httpEntity );
+
+ CloseableHttpResponse response = execute( putMethod );
+ try
+ {
+ int statusCode = response.getStatusLine().getStatusCode();
+ String reasonPhrase = ", ReasonPhrase: " + response.getStatusLine().getReasonPhrase() + ".";
+ fireTransferDebug( url + " - Status code: " + statusCode + reasonPhrase );
+
+ // Check that we didn't run out of retries.
+ switch ( statusCode )
+ {
+ // Success Codes
+ case HttpStatus.SC_OK: // 200
+ case HttpStatus.SC_CREATED: // 201
+ case HttpStatus.SC_ACCEPTED: // 202
+ case HttpStatus.SC_NO_CONTENT: // 204
+ break;
+ // handle all redirect even if http specs says " the user agent MUST NOT automatically redirect
+ // the request unless it can be confirmed by the user"
+ case HttpStatus.SC_MOVED_PERMANENTLY: // 301
+ case HttpStatus.SC_MOVED_TEMPORARILY: // 302
+ case HttpStatus.SC_SEE_OTHER: // 303
+ put( resource, source, httpEntity, calculateRelocatedUrl( response ) );
+ return;
+ case HttpStatus.SC_FORBIDDEN:
+ fireSessionConnectionRefused();
+ throw new AuthorizationException( "Access denied to: " + url + reasonPhrase );
+
+ case HttpStatus.SC_NOT_FOUND:
+ throw new ResourceDoesNotExistException( "File: " + url + " does not exist" + reasonPhrase );
+
+ case SC_TOO_MANY_REQUESTS:
+ put( backoff( wait, url ), resource, source, httpEntity, url );
+ break;
+ //add more entries here
+ default:
+ TransferFailedException e = new TransferFailedException(
+ "Failed to transfer file: " + url + ". Return code is: " + statusCode + reasonPhrase );
+ fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+ throw e;
+ }
+
+ firePutCompleted( resource, source );
+
+ EntityUtils.consume( response.getEntity() );
+ }
+ finally
+ {
+ response.close();
+ }
+ }
+ catch ( IOException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
+ throw new TransferFailedException( e.getMessage(), e );
+ }
+ catch ( HttpException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
+ throw new TransferFailedException( e.getMessage(), e );
+ }
+ catch ( InterruptedException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
+ throw new TransferFailedException( e.getMessage(), e );
+ }
+
+ }
+
+ protected String calculateRelocatedUrl( HttpResponse response )
+ {
+ Header locationHeader = response.getFirstHeader( "Location" );
+ String locationField = locationHeader.getValue();
+ // is it a relative Location or a full ?
+ return locationField.startsWith( "http" ) ? locationField : getURL( getRepository() ) + '/' + locationField;
+ }
+
+ protected void mkdirs( String dirname )
+ throws HttpException, IOException
+ {
+ // nothing to do
+ }
+
+ public boolean resourceExists( String resourceName )
+ throws TransferFailedException, AuthorizationException
+ {
+ return resourceExists( getInitialBackoffSeconds(), resourceName );
+ }
+
+
+ private boolean resourceExists( int wait, String resourceName )
+ throws TransferFailedException, AuthorizationException
+ {
+ String repositoryUrl = getRepository().getUrl();
+ String url = repositoryUrl + ( repositoryUrl.endsWith( "/" ) ? "" : "/" ) + resourceName;
+ HttpHead headMethod = new HttpHead( url );
+ try
+ {
+ CloseableHttpResponse response = execute( headMethod );
+ try
+ {
+ int statusCode = response.getStatusLine().getStatusCode();
+ String reasonPhrase = ", ReasonPhrase: " + response.getStatusLine().getReasonPhrase() + ".";
+ boolean result;
+ switch ( statusCode )
+ {
+ case HttpStatus.SC_OK:
+ result = true;
+ break;
+ case HttpStatus.SC_NOT_MODIFIED:
+ result = true;
+ break;
+ case HttpStatus.SC_FORBIDDEN:
+ throw new AuthorizationException( "Access denied to: " + url + reasonPhrase );
+
+ case HttpStatus.SC_UNAUTHORIZED:
+ throw new AuthorizationException( "Not authorized " + reasonPhrase );
+
+ case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
+ throw new AuthorizationException( "Not authorized by proxy " + reasonPhrase );
+
+ case HttpStatus.SC_NOT_FOUND:
+ result = false;
+ break;
+
+ case SC_TOO_MANY_REQUESTS:
+ return resourceExists( backoff( wait, resourceName ), resourceName );
+
+ //add more entries here
+ default:
+ throw new TransferFailedException(
+ "Failed to transfer file: " + url + ". Return code is: " + statusCode + reasonPhrase );
+ }
+
+ EntityUtils.consume( response.getEntity() );
+ return result;
+ }
+ finally
+ {
+ response.close();
+ }
+ }
+ catch ( IOException e )
+ {
+ throw new TransferFailedException( e.getMessage(), e );
+ }
+ catch ( HttpException e )
+ {
+ throw new TransferFailedException( e.getMessage(), e );
+ }
+ catch ( InterruptedException e )
+ {
+ throw new TransferFailedException( e.getMessage(), e );
+ }
+
+ }
+
+ protected CloseableHttpResponse execute( HttpUriRequest httpMethod )
+ throws HttpException, IOException
+ {
+ setHeaders( httpMethod );
+ String userAgent = getUserAgent( httpMethod );
+ if ( userAgent != null )
+ {
+ httpMethod.setHeader( HTTP.USER_AGENT, userAgent );
+ }
+
+ RequestConfig.Builder requestConfigBuilder = RequestConfig.custom();
+ // WAGON-273: default the cookie-policy to browser compatible
+ requestConfigBuilder.setCookieSpec( CookieSpecs.BROWSER_COMPATIBILITY );
+
+ Repository repo = getRepository();
+ ProxyInfo proxyInfo = getProxyInfo( repo.getProtocol(), repo.getHost() );
+ if ( proxyInfo != null )
+ {
+ HttpHost proxy = new HttpHost( proxyInfo.getHost(), proxyInfo.getPort() );
+ requestConfigBuilder.setProxy( proxy );
+ }
+
+ HttpMethodConfiguration config =
+ httpConfiguration == null ? null : httpConfiguration.getMethodConfiguration( httpMethod );
+
+ if ( config != null )
+ {
+ ConfigurationUtils.copyConfig( config, requestConfigBuilder );
+ }
+ else
+ {
+ requestConfigBuilder.setSocketTimeout( getReadTimeout() );
+ if ( httpMethod instanceof HttpPut )
+ {
+ requestConfigBuilder.setExpectContinueEnabled( true );
+ }
+ }
+
+ if ( httpMethod instanceof HttpPut )
+ {
+ requestConfigBuilder.setRedirectsEnabled( false );
+ }
+
+ HttpClientContext localContext = HttpClientContext.create();
+ localContext.setCredentialsProvider( credentialsProvider );
+ localContext.setAuthCache( authCache );
+ localContext.setRequestConfig( requestConfigBuilder.build() );
+
+ if ( config != null && config.isUsePreemptive() )
+ {
+ HttpHost targetHost = new HttpHost( repo.getHost(), repo.getPort(), repo.getProtocol() );
+ AuthScope targetScope = getBasicAuthScope().getScope( targetHost );
+
+ if ( credentialsProvider.getCredentials( targetScope ) != null )
+ {
+ BasicScheme targetAuth = new BasicScheme();
+ authCache.put( targetHost, targetAuth );
+ }
+ }
+
+ if ( proxyInfo != null )
+ {
+ if ( proxyInfo.getHost() != null )
+ {
+ HttpHost proxyHost = new HttpHost( proxyInfo.getHost(), proxyInfo.getPort() );
+ AuthScope proxyScope = getProxyBasicAuthScope().getScope( proxyHost );
+
+ if ( credentialsProvider.getCredentials( proxyScope ) != null )
+ {
+ /* This is extremely ugly because we need to set challengeState to PROXY, but
+ * the constructor is deprecated. Alternatively, we could subclass BasicScheme
+ * to ProxyBasicScheme and set the state internally in the constructor.
+ */
+ BasicScheme proxyAuth = new BasicScheme( ChallengeState.PROXY );
+ authCache.put( proxyHost, proxyAuth );
+ }
+ }
+ }
+
+ return httpClient.execute( httpMethod, localContext );
+ }
+
+ protected void setHeaders( HttpUriRequest method )
+ {
+ HttpMethodConfiguration config =
+ httpConfiguration == null ? null : httpConfiguration.getMethodConfiguration( method );
+ if ( config == null || config.isUseDefaultHeaders() )
+ {
+ // TODO: merge with the other headers and have some better defaults, unify with lightweight headers
+ method.addHeader( "Cache-control", "no-cache" );
+ method.addHeader( "Cache-store", "no-store" );
+ method.addHeader( "Pragma", "no-cache" );
+ method.addHeader( "Expires", "0" );
+ method.addHeader( "Accept-Encoding", "gzip" );
+ }
+
+ if ( httpHeaders != null )
+ {
+ for ( Map.Entry<Object, Object> entry : httpHeaders.entrySet() )
+ {
+ method.setHeader( (String) entry.getKey(), (String) entry.getValue() );
+ }
+ }
+
+ Header[] headers = config == null ? null : config.asRequestHeaders();
+ if ( headers != null )
+ {
+ for ( Header header : headers )
+ {
+ method.setHeader( header );
+ }
+ }
+ }
+
+ protected String getUserAgent( HttpUriRequest method )
+ {
+ if ( httpHeaders != null )
+ {
+ String value = (String) httpHeaders.get( "User-Agent" );
+ if ( value != null )
+ {
+ return value;
+ }
+ }
+ HttpMethodConfiguration config =
+ httpConfiguration == null ? null : httpConfiguration.getMethodConfiguration( method );
+
+ if ( config != null )
+ {
+ return (String) config.getHeaders().get( "User-Agent" );
+ }
+ return null;
+ }
+
+ /**
+ * getUrl
+ * Implementors can override this to remove unwanted parts of the url such as role-hints
+ *
+ * @param repository
+ * @return
+ */
+ protected String getURL( Repository repository )
+ {
+ return repository.getUrl();
+ }
+
+ public HttpConfiguration getHttpConfiguration()
+ {
+ return httpConfiguration;
+ }
+
+ public void setHttpConfiguration( HttpConfiguration httpConfiguration )
+ {
+ this.httpConfiguration = httpConfiguration;
+ }
+
+ /**
+ * Get the override values for standard HttpClient AuthScope
+ *
+ * @return the basicAuth
+ */
+ public BasicAuthScope getBasicAuthScope()
+ {
+ if ( basicAuth == null )
+ {
+ basicAuth = new BasicAuthScope();
+ }
+ return basicAuth;
+ }
+
+ /**
+ * Set the override values for standard HttpClient AuthScope
+ *
+ * @param basicAuth the AuthScope to set
+ */
+ public void setBasicAuthScope( BasicAuthScope basicAuth )
+ {
+ this.basicAuth = basicAuth;
+ }
+
+ /**
+ * Get the override values for proxy HttpClient AuthScope
+ *
+ * @return the proxyAuth
+ */
+ public BasicAuthScope getProxyBasicAuthScope()
+ {
+ if ( proxyAuth == null )
+ {
+ proxyAuth = new BasicAuthScope();
+ }
+ return proxyAuth;
+ }
+
+ /**
+ * Set the override values for proxy HttpClient AuthScope
+ *
+ * @param proxyAuth the AuthScope to set
+ */
+ public void setProxyBasicAuthScope( BasicAuthScope proxyAuth )
+ {
+ this.proxyAuth = proxyAuth;
+ }
+
+ public void fillInputData( InputData inputData )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ fillInputData( getInitialBackoffSeconds(), inputData );
+ }
+
+ private void fillInputData( int wait, InputData inputData )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ Resource resource = inputData.getResource();
+
+ String repositoryUrl = getRepository().getUrl();
+ String url = repositoryUrl + ( repositoryUrl.endsWith( "/" ) ? "" : "/" ) + resource.getName();
+ HttpGet getMethod = new HttpGet( url );
+ long timestamp = resource.getLastModified();
+ if ( timestamp > 0 )
+ {
+ SimpleDateFormat fmt = new SimpleDateFormat( "EEE, dd-MMM-yy HH:mm:ss zzz", Locale.US );
+ fmt.setTimeZone( GMT_TIME_ZONE );
+ Header hdr = new BasicHeader( "If-Modified-Since", fmt.format( new Date( timestamp ) ) );
+ fireTransferDebug( "sending ==> " + hdr + "(" + timestamp + ")" );
+ getMethod.addHeader( hdr );
+ }
+
+ try
+ {
+ CloseableHttpResponse response = execute( getMethod );
+ closeable = response;
+ int statusCode = response.getStatusLine().getStatusCode();
+
+ String reasonPhrase = ", ReasonPhrase:" + response.getStatusLine().getReasonPhrase() + ".";
+
+ fireTransferDebug( url + " - Status code: " + statusCode + reasonPhrase );
+
+ switch ( statusCode )
+ {
+ case HttpStatus.SC_OK:
+ break;
+
+ case HttpStatus.SC_NOT_MODIFIED:
+ // return, leaving last modified set to original value so getIfNewer should return unmodified
+ return;
+ case HttpStatus.SC_FORBIDDEN:
+ fireSessionConnectionRefused();
+ throw new AuthorizationException( "Access denied to: " + url + " " + reasonPhrase );
+
+ case HttpStatus.SC_UNAUTHORIZED:
+ fireSessionConnectionRefused();
+ throw new AuthorizationException( "Not authorized " + reasonPhrase );
+
+ case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
+ fireSessionConnectionRefused();
+ throw new AuthorizationException( "Not authorized by proxy " + reasonPhrase );
+
+ case HttpStatus.SC_NOT_FOUND:
+ throw new ResourceDoesNotExistException( "File: " + url + " " + reasonPhrase );
+
+ case SC_TOO_MANY_REQUESTS:
+ fillInputData( backoff( wait, url ), inputData );
+ break;
+
+ // add more entries here
+ default:
+ cleanupGetTransfer( resource );
+ TransferFailedException e = new TransferFailedException(
+ "Failed to transfer file: " + url + ". Return code is: " + statusCode + " " + reasonPhrase );
+ fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+ throw e;
+ }
+
+ Header contentLengthHeader = response.getFirstHeader( "Content-Length" );
+
+ if ( contentLengthHeader != null )
+ {
+ try
+ {
+ long contentLength = Long.parseLong( contentLengthHeader.getValue() );
+
+ resource.setContentLength( contentLength );
+ }
+ catch ( NumberFormatException e )
+ {
+ fireTransferDebug(
+ "error parsing content length header '" + contentLengthHeader.getValue() + "' " + e );
+ }
+ }
+
+ Header lastModifiedHeader = response.getFirstHeader( "Last-Modified" );
+ if ( lastModifiedHeader != null )
+ {
+ Date lastModified = DateUtils.parseDate( lastModifiedHeader.getValue() );
+ if ( lastModified != null )
+ {
+ resource.setLastModified( lastModified.getTime() );
+ fireTransferDebug( "last-modified = " + lastModifiedHeader.getValue() + " ("
+ + lastModified.getTime() + ")" );
+ }
+ }
+
+ HttpEntity entity = response.getEntity();
+ if ( entity != null )
+ {
+ inputData.setInputStream( entity.getContent() );
+ }
+ }
+ catch ( IOException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+
+ throw new TransferFailedException( e.getMessage(), e );
+ }
+ catch ( HttpException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+
+ throw new TransferFailedException( e.getMessage(), e );
+ }
+ catch ( InterruptedException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+
+ throw new TransferFailedException( e.getMessage(), e );
+ }
+
+ }
+
+ protected void cleanupGetTransfer( Resource resource )
+ {
+ if ( closeable != null )
+ {
+ try
+ {
+ closeable.close();
+ }
+ catch ( IOException ignore )
+ {
+ // ignore
+ }
+
+ }
+ }
+
+
+ @Override
+ public void putFromStream( InputStream stream, String destination )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ putFromStream( stream, destination, -1, -1 );
+ }
+
+ @Override
+ protected void putFromStream( InputStream stream, Resource resource )
+ throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
+ {
+ putFromStream( stream, resource.getName(), -1, -1 );
+ }
+
+ public Properties getHttpHeaders()
+ {
+ return httpHeaders;
+ }
+
+ public void setHttpHeaders( Properties httpHeaders )
+ {
+ this.httpHeaders = httpHeaders;
+ }
+
+ @Override
+ public void fillOutputData( OutputData outputData )
+ throws TransferFailedException
+ {
+ // no needed in this implementation but throw an Exception if used
+ throw new IllegalStateException( "this wagon http client must not use fillOutputData" );
+ }
+
+ public int getInitialBackoffSeconds()
+ {
+ return initialBackoffSeconds;
+ }
+
+ public void setInitialBackoffSeconds( int initialBackoffSeconds )
+ {
+ this.initialBackoffSeconds = initialBackoffSeconds;
+ }
+
+ public static int getMaxBackoffWaitSeconds()
+ {
+ return MAX_BACKOFF_WAIT_SECONDS;
+ }
+}
diff --git a/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/BasicAuthScope.java b/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/BasicAuthScope.java
index 5bcc2d3..cd6603c 100644
--- a/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/BasicAuthScope.java
+++ b/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/BasicAuthScope.java
@@ -1,168 +1,168 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.http.HttpHost;
-import org.apache.http.auth.AuthScope;
-
-/**
- * @since 2.8
- */
-public class BasicAuthScope
-{
- private String host;
-
- private String port;
-
- private String realm;
-
- /**
- * @return the host
- */
- public String getHost()
- {
- return host;
- }
-
- /**
- * @param host the host to set
- */
- public void setHost( String host )
- {
- this.host = host;
- }
-
- /**
- * @return the realm
- */
- public String getRealm()
- {
- return realm;
- }
-
- /**
- * @param realm the realm to set
- */
- public void setRealm( String realm )
- {
- this.realm = realm;
- }
-
- /**
- * Create an authScope given the /repository/host and /repository/password
- * and the /server/basicAuth or /server/proxyBasicAuth host, port and realm
- * settings. The basicAuth setting should override the repository settings
- * host and/or port if host, port or realm is set to "ANY".
- * <p/>
- * Realm can also be set to a specific string and will be set if
- * /server/basicAuthentication/realm is non-null
- *
- * @param host The server setting's /server/host value
- * @param port The server setting's /server/port value
- * @return
- */
- public AuthScope getScope( String host, int port )
- {
- if ( getHost() != null //
- && "ANY".compareTo( getHost() ) == 0 //
- && getPort() != null //
- && "ANY".compareTo( getPort() ) == 0 //
- && getRealm() != null //
- && "ANY".compareTo( getRealm() ) == 0 )
- {
- return AuthScope.ANY;
- }
- String scopeHost = host;
- if ( getHost() != null )
- {
- if ( "ANY".compareTo( getHost() ) == 0 )
- {
- scopeHost = AuthScope.ANY_HOST;
- }
- else
- {
- scopeHost = getHost();
- }
- }
-
- int scopePort = port > -1 ? port : AuthScope.ANY_PORT;
- // -1 for server/port settings does this, but providing an override here
- // in
- // the BasicAuthScope config
- if ( getPort() != null )
- {
- if ( "ANY".compareTo( getPort() ) == 0 )
- {
- scopePort = AuthScope.ANY_PORT;
- }
- else
- {
- scopePort = Integer.parseInt( getPort() );
- }
- }
-
- String scopeRealm = AuthScope.ANY_REALM;
- if ( getRealm() != null )
- {
- if ( "ANY".compareTo( getRealm() ) != 0 )
- {
- scopeRealm = getRealm();
- }
- else
- {
- scopeRealm = getRealm();
- }
- }
-
- return new AuthScope( scopeHost, scopePort, scopeRealm );
- }
-
- /**
- * @return the port
- */
- public String getPort()
- {
- return port;
- }
-
- /**
- * @param port the port to set
- */
- public void setPort( String port )
- {
- this.port = port;
- }
-
- /**
- * Given a HttpHost, return scope with overrides from appropriate basicAuth
- * configuration.
- * <p>
- * Note: Protocol is ignored. AuthScope impl ignores it as well, but if that
- * changed, there could be a problem.
- * </p>
- *
- * @param targetHost
- * @return
- */
- public AuthScope getScope( HttpHost targetHost )
- {
- return getScope( targetHost.getHostName(), targetHost.getPort() );
- }
-}
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.http.HttpHost;
+import org.apache.http.auth.AuthScope;
+
+/**
+ * @since 2.8
+ */
+public class BasicAuthScope
+{
+ private String host;
+
+ private String port;
+
+ private String realm;
+
+ /**
+ * @return the host
+ */
+ public String getHost()
+ {
+ return host;
+ }
+
+ /**
+ * @param host the host to set
+ */
+ public void setHost( String host )
+ {
+ this.host = host;
+ }
+
+ /**
+ * @return the realm
+ */
+ public String getRealm()
+ {
+ return realm;
+ }
+
+ /**
+ * @param realm the realm to set
+ */
+ public void setRealm( String realm )
+ {
+ this.realm = realm;
+ }
+
+ /**
+ * Create an authScope given the /repository/host and /repository/password
+ * and the /server/basicAuth or /server/proxyBasicAuth host, port and realm
+ * settings. The basicAuth setting should override the repository settings
+ * host and/or port if host, port or realm is set to "ANY".
+ * <p/>
+ * Realm can also be set to a specific string and will be set if
+ * /server/basicAuthentication/realm is non-null
+ *
+ * @param host The server setting's /server/host value
+ * @param port The server setting's /server/port value
+ * @return
+ */
+ public AuthScope getScope( String host, int port )
+ {
+ if ( getHost() != null //
+ && "ANY".compareTo( getHost() ) == 0 //
+ && getPort() != null //
+ && "ANY".compareTo( getPort() ) == 0 //
+ && getRealm() != null //
+ && "ANY".compareTo( getRealm() ) == 0 )
+ {
+ return AuthScope.ANY;
+ }
+ String scopeHost = host;
+ if ( getHost() != null )
+ {
+ if ( "ANY".compareTo( getHost() ) == 0 )
+ {
+ scopeHost = AuthScope.ANY_HOST;
+ }
+ else
+ {
+ scopeHost = getHost();
+ }
+ }
+
+ int scopePort = port > -1 ? port : AuthScope.ANY_PORT;
+ // -1 for server/port settings does this, but providing an override here
+ // in
+ // the BasicAuthScope config
+ if ( getPort() != null )
+ {
+ if ( "ANY".compareTo( getPort() ) == 0 )
+ {
+ scopePort = AuthScope.ANY_PORT;
+ }
+ else
+ {
+ scopePort = Integer.parseInt( getPort() );
+ }
+ }
+
+ String scopeRealm = AuthScope.ANY_REALM;
+ if ( getRealm() != null )
+ {
+ if ( "ANY".compareTo( getRealm() ) != 0 )
+ {
+ scopeRealm = getRealm();
+ }
+ else
+ {
+ scopeRealm = getRealm();
+ }
+ }
+
+ return new AuthScope( scopeHost, scopePort, scopeRealm );
+ }
+
+ /**
+ * @return the port
+ */
+ public String getPort()
+ {
+ return port;
+ }
+
+ /**
+ * @param port the port to set
+ */
+ public void setPort( String port )
+ {
+ this.port = port;
+ }
+
+ /**
+ * Given a HttpHost, return scope with overrides from appropriate basicAuth
+ * configuration.
+ * <p>
+ * Note: Protocol is ignored. AuthScope impl ignores it as well, but if that
+ * changed, there could be a problem.
+ * </p>
+ *
+ * @param targetHost
+ * @return
+ */
+ public AuthScope getScope( HttpHost targetHost )
+ {
+ return getScope( targetHost.getHostName(), targetHost.getPort() );
+ }
+}
diff --git a/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/ConfigurationUtils.java b/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/ConfigurationUtils.java
old mode 100755
new mode 100644
index 4078c8c..37888fe
--- a/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/ConfigurationUtils.java
+++ b/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/ConfigurationUtils.java
@@ -1,230 +1,230 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.http.Header;
-import org.apache.http.HttpHost;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.message.BasicHeader;
-import org.apache.maven.wagon.Wagon;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Arrays;
-import java.util.Map;
-import java.util.Properties;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-class ConfigurationUtils
-{
-
- private static final String SO_TIMEOUT = "http.socket.timeout";
- private static final String STALE_CONNECTION_CHECK = "http.connection.stalecheck";
- private static final String CONNECTION_TIMEOUT = "http.connection.timeout";
- private static final String USE_EXPECT_CONTINUE = "http.protocol.expect-continue";
- private static final String DEFAULT_PROXY = "http.route.default-proxy";
- private static final String LOCAL_ADDRESS = "http.route.local-address";
- private static final String PROXY_AUTH_PREF = "http.auth.proxy-scheme-pref";
- private static final String TARGET_AUTH_PREF = "http.auth.target-scheme-pref";
- private static final String HANDLE_AUTHENTICATION = "http.protocol.handle-authentication";
- private static final String ALLOW_CIRCULAR_REDIRECTS = "http.protocol.allow-circular-redirects";
- private static final String CONN_MANAGER_TIMEOUT = "http.conn-manager.timeout";
- private static final String COOKIE_POLICY = "http.protocol.cookie-policy";
- private static final String MAX_REDIRECTS = "http.protocol.max-redirects";
- private static final String HANDLE_REDIRECTS = "http.protocol.handle-redirects";
- private static final String REJECT_RELATIVE_REDIRECT = "http.protocol.reject-relative-redirect";
-
- private static final String COERCE_PATTERN = "%(\\w+),(.+)";
-
- public static void copyConfig( HttpMethodConfiguration config, RequestConfig.Builder builder )
- {
- if ( config.getConnectionTimeout() > 0 )
- {
- builder.setConnectTimeout( config.getConnectionTimeout() );
- }
- if ( config.getReadTimeout() > 0 )
- {
- builder.setSocketTimeout( config.getReadTimeout() );
- }
- Properties params = config.getParams();
- if ( params != null )
- {
-
- Pattern coercePattern = Pattern.compile( COERCE_PATTERN );
- for ( Map.Entry entry : params.entrySet() )
- {
- String key = (String) entry.getKey();
- String value = (String) entry.getValue();
- Matcher matcher = coercePattern.matcher( value );
- if ( matcher.matches() )
- {
- value = matcher.group( 2 );
- }
-
- if ( key.equals( SO_TIMEOUT ) )
- {
- builder.setSocketTimeout( Integer.parseInt( value ) );
- }
- else if ( key.equals( STALE_CONNECTION_CHECK ) )
- {
- builder.setStaleConnectionCheckEnabled( Boolean.valueOf( value ) );
- }
- else if ( key.equals( CONNECTION_TIMEOUT ) )
- {
- builder.setConnectTimeout( Integer.parseInt( value ) );
- }
- else if ( key.equals( USE_EXPECT_CONTINUE ) )
- {
- builder.setExpectContinueEnabled( Boolean.valueOf( value ) );
- }
- else if ( key.equals( DEFAULT_PROXY ) )
- {
- builder.setProxy( new HttpHost( value ) );
- }
- else if ( key.equals( LOCAL_ADDRESS ) )
- {
- try
- {
- builder.setLocalAddress( InetAddress.getByName( value ) );
- }
- catch ( UnknownHostException ignore )
- {
- // ignore
- }
- }
- else if ( key.equals( PROXY_AUTH_PREF ) )
- {
- builder.setProxyPreferredAuthSchemes( Arrays.asList( value.split( "," ) ) );
- }
- else if ( key.equals( TARGET_AUTH_PREF ) )
- {
- builder.setTargetPreferredAuthSchemes( Arrays.asList( value.split( "," ) ) );
- }
- else if ( key.equals( HANDLE_AUTHENTICATION ) )
- {
- builder.setAuthenticationEnabled( Boolean.valueOf( value ) );
- }
- else if ( key.equals( ALLOW_CIRCULAR_REDIRECTS ) )
- {
- builder.setCircularRedirectsAllowed( Boolean.valueOf( value ) );
- }
- else if ( key.equals( CONN_MANAGER_TIMEOUT ) )
- {
- builder.setConnectionRequestTimeout( Integer.parseInt( value ) );
- }
- else if ( key.equals( COOKIE_POLICY ) )
- {
- builder.setCookieSpec( value );
- }
- else if ( key.equals( MAX_REDIRECTS ) )
- {
- builder.setMaxRedirects( Integer.parseInt( value ) );
- }
- else if ( key.equals( HANDLE_REDIRECTS ) )
- {
- builder.setRedirectsEnabled( Boolean.valueOf( value ) );
- }
- else if ( key.equals( REJECT_RELATIVE_REDIRECT ) )
- {
- builder.setRelativeRedirectsAllowed( !Boolean.valueOf( value ) );
- }
- }
- }
- }
-
- public static Header[] asRequestHeaders( HttpMethodConfiguration config )
- {
- Properties headers = config.getHeaders();
- if ( headers == null )
- {
- return new Header[0];
- }
-
- Header[] result = new Header[headers.size()];
-
- int index = 0;
- for ( Map.Entry entry : headers.entrySet() )
- {
- String key = (String) entry.getKey();
- String value = (String) entry.getValue();
-
- Header header = new BasicHeader( key, value );
- result[index++] = header;
- }
-
- return result;
- }
-
- public static HttpMethodConfiguration merge( HttpMethodConfiguration defaults, HttpMethodConfiguration base,
- HttpMethodConfiguration local )
- {
- HttpMethodConfiguration result = merge( defaults, base );
- return merge( result, local );
- }
-
- public static HttpMethodConfiguration merge( HttpMethodConfiguration base, HttpMethodConfiguration local )
- {
- if ( base == null && local == null )
- {
- return null;
- }
- else if ( base == null )
- {
- return local;
- }
- else if ( local == null )
- {
- return base;
- }
- else
- {
- HttpMethodConfiguration result = base.copy();
-
- if ( local.getConnectionTimeout() != Wagon.DEFAULT_CONNECTION_TIMEOUT )
- {
- result.setConnectionTimeout( local.getConnectionTimeout() );
- }
-
- if ( local.getReadTimeout() != Wagon.DEFAULT_READ_TIMEOUT )
- {
- result.setReadTimeout( local.getReadTimeout() );
- }
-
- if ( local.getHeaders() != null )
- {
- result.getHeaders().putAll( local.getHeaders() );
- }
-
- if ( local.getParams() != null )
- {
- result.getParams().putAll( local.getParams() );
- }
-
- if ( local.getUseDefaultHeaders() != null )
- {
- result.setUseDefaultHeaders( local.isUseDefaultHeaders() );
- }
-
- return result;
- }
- }
-
-}
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.http.Header;
+import org.apache.http.HttpHost;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.message.BasicHeader;
+import org.apache.maven.wagon.Wagon;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Properties;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+class ConfigurationUtils
+{
+
+ private static final String SO_TIMEOUT = "http.socket.timeout";
+ private static final String STALE_CONNECTION_CHECK = "http.connection.stalecheck";
+ private static final String CONNECTION_TIMEOUT = "http.connection.timeout";
+ private static final String USE_EXPECT_CONTINUE = "http.protocol.expect-continue";
+ private static final String DEFAULT_PROXY = "http.route.default-proxy";
+ private static final String LOCAL_ADDRESS = "http.route.local-address";
+ private static final String PROXY_AUTH_PREF = "http.auth.proxy-scheme-pref";
+ private static final String TARGET_AUTH_PREF = "http.auth.target-scheme-pref";
+ private static final String HANDLE_AUTHENTICATION = "http.protocol.handle-authentication";
+ private static final String ALLOW_CIRCULAR_REDIRECTS = "http.protocol.allow-circular-redirects";
+ private static final String CONN_MANAGER_TIMEOUT = "http.conn-manager.timeout";
+ private static final String COOKIE_POLICY = "http.protocol.cookie-policy";
+ private static final String MAX_REDIRECTS = "http.protocol.max-redirects";
+ private static final String HANDLE_REDIRECTS = "http.protocol.handle-redirects";
+ private static final String REJECT_RELATIVE_REDIRECT = "http.protocol.reject-relative-redirect";
+
+ private static final String COERCE_PATTERN = "%(\\w+),(.+)";
+
+ public static void copyConfig( HttpMethodConfiguration config, RequestConfig.Builder builder )
+ {
+ if ( config.getConnectionTimeout() > 0 )
+ {
+ builder.setConnectTimeout( config.getConnectionTimeout() );
+ }
+ if ( config.getReadTimeout() > 0 )
+ {
+ builder.setSocketTimeout( config.getReadTimeout() );
+ }
+ Properties params = config.getParams();
+ if ( params != null )
+ {
+
+ Pattern coercePattern = Pattern.compile( COERCE_PATTERN );
+ for ( Map.Entry entry : params.entrySet() )
+ {
+ String key = (String) entry.getKey();
+ String value = (String) entry.getValue();
+ Matcher matcher = coercePattern.matcher( value );
+ if ( matcher.matches() )
+ {
+ value = matcher.group( 2 );
+ }
+
+ if ( key.equals( SO_TIMEOUT ) )
+ {
+ builder.setSocketTimeout( Integer.parseInt( value ) );
+ }
+ else if ( key.equals( STALE_CONNECTION_CHECK ) )
+ {
+ builder.setStaleConnectionCheckEnabled( Boolean.valueOf( value ) );
+ }
+ else if ( key.equals( CONNECTION_TIMEOUT ) )
+ {
+ builder.setConnectTimeout( Integer.parseInt( value ) );
+ }
+ else if ( key.equals( USE_EXPECT_CONTINUE ) )
+ {
+ builder.setExpectContinueEnabled( Boolean.valueOf( value ) );
+ }
+ else if ( key.equals( DEFAULT_PROXY ) )
+ {
+ builder.setProxy( new HttpHost( value ) );
+ }
+ else if ( key.equals( LOCAL_ADDRESS ) )
+ {
+ try
+ {
+ builder.setLocalAddress( InetAddress.getByName( value ) );
+ }
+ catch ( UnknownHostException ignore )
+ {
+ // ignore
+ }
+ }
+ else if ( key.equals( PROXY_AUTH_PREF ) )
+ {
+ builder.setProxyPreferredAuthSchemes( Arrays.asList( value.split( "," ) ) );
+ }
+ else if ( key.equals( TARGET_AUTH_PREF ) )
+ {
+ builder.setTargetPreferredAuthSchemes( Arrays.asList( value.split( "," ) ) );
+ }
+ else if ( key.equals( HANDLE_AUTHENTICATION ) )
+ {
+ builder.setAuthenticationEnabled( Boolean.valueOf( value ) );
+ }
+ else if ( key.equals( ALLOW_CIRCULAR_REDIRECTS ) )
+ {
+ builder.setCircularRedirectsAllowed( Boolean.valueOf( value ) );
+ }
+ else if ( key.equals( CONN_MANAGER_TIMEOUT ) )
+ {
+ builder.setConnectionRequestTimeout( Integer.parseInt( value ) );
+ }
+ else if ( key.equals( COOKIE_POLICY ) )
+ {
+ builder.setCookieSpec( value );
+ }
+ else if ( key.equals( MAX_REDIRECTS ) )
+ {
+ builder.setMaxRedirects( Integer.parseInt( value ) );
+ }
+ else if ( key.equals( HANDLE_REDIRECTS ) )
+ {
+ builder.setRedirectsEnabled( Boolean.valueOf( value ) );
+ }
+ else if ( key.equals( REJECT_RELATIVE_REDIRECT ) )
+ {
+ builder.setRelativeRedirectsAllowed( !Boolean.valueOf( value ) );
+ }
+ }
+ }
+ }
+
+ public static Header[] asRequestHeaders( HttpMethodConfiguration config )
+ {
+ Properties headers = config.getHeaders();
+ if ( headers == null )
+ {
+ return new Header[0];
+ }
+
+ Header[] result = new Header[headers.size()];
+
+ int index = 0;
+ for ( Map.Entry entry : headers.entrySet() )
+ {
+ String key = (String) entry.getKey();
+ String value = (String) entry.getValue();
+
+ Header header = new BasicHeader( key, value );
+ result[index++] = header;
+ }
+
+ return result;
+ }
+
+ public static HttpMethodConfiguration merge( HttpMethodConfiguration defaults, HttpMethodConfiguration base,
+ HttpMethodConfiguration local )
+ {
+ HttpMethodConfiguration result = merge( defaults, base );
+ return merge( result, local );
+ }
+
+ public static HttpMethodConfiguration merge( HttpMethodConfiguration base, HttpMethodConfiguration local )
+ {
+ if ( base == null && local == null )
+ {
+ return null;
+ }
+ else if ( base == null )
+ {
+ return local;
+ }
+ else if ( local == null )
+ {
+ return base;
+ }
+ else
+ {
+ HttpMethodConfiguration result = base.copy();
+
+ if ( local.getConnectionTimeout() != Wagon.DEFAULT_CONNECTION_TIMEOUT )
+ {
+ result.setConnectionTimeout( local.getConnectionTimeout() );
+ }
+
+ if ( local.getReadTimeout() != Wagon.DEFAULT_READ_TIMEOUT )
+ {
+ result.setReadTimeout( local.getReadTimeout() );
+ }
+
+ if ( local.getHeaders() != null )
+ {
+ result.getHeaders().putAll( local.getHeaders() );
+ }
+
+ if ( local.getParams() != null )
+ {
+ result.getParams().putAll( local.getParams() );
+ }
+
+ if ( local.getUseDefaultHeaders() != null )
+ {
+ result.setUseDefaultHeaders( local.isUseDefaultHeaders() );
+ }
+
+ return result;
+ }
+ }
+
+}
diff --git a/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpConfiguration.java b/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpConfiguration.java
index a7e0b23..6f7fa21 100644
--- a/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpConfiguration.java
+++ b/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpConfiguration.java
@@ -1,107 +1,106 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpHead;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.protocol.HTTP;
-
-/**
- *
- */
-public class HttpConfiguration
-{
-
- private static final HttpMethodConfiguration DEFAULT_PUT =
- new HttpMethodConfiguration().addParam( HTTP.EXPECT_CONTINUE, "%b,true" );
-
- private HttpMethodConfiguration all;
-
- private HttpMethodConfiguration get;
-
- private HttpMethodConfiguration put;
-
- private HttpMethodConfiguration head;
-
- public HttpMethodConfiguration getAll()
- {
- return all;
- }
-
- public HttpConfiguration setAll( HttpMethodConfiguration all )
- {
- this.all = all;
- return this;
- }
-
- public HttpMethodConfiguration getGet()
- {
- return get;
- }
-
- public HttpConfiguration setGet( HttpMethodConfiguration get )
- {
- this.get = get;
- return this;
- }
-
- public HttpMethodConfiguration getPut()
- {
- return put;
- }
-
- public HttpConfiguration setPut( HttpMethodConfiguration put )
- {
- this.put = put;
- return this;
- }
-
- public HttpMethodConfiguration getHead()
- {
- return head;
- }
-
- public HttpConfiguration setHead( HttpMethodConfiguration head )
- {
- this.head = head;
- return this;
- }
-
- public HttpMethodConfiguration getMethodConfiguration( HttpUriRequest method )
- {
- if ( method instanceof HttpGet )
- {
- return ConfigurationUtils.merge( all, get );
- }
- else if ( method instanceof HttpPut )
- {
- return ConfigurationUtils.merge( DEFAULT_PUT, all, put );
- }
- else if ( method instanceof HttpHead )
- {
- return ConfigurationUtils.merge( all, head );
- }
-
- return all;
- }
-
-}
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpHead;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.client.methods.HttpUriRequest;
+
+/**
+ *
+ */
+public class HttpConfiguration
+{
+
+ private static final HttpMethodConfiguration DEFAULT_PUT =
+ new HttpMethodConfiguration().addParam( "http.protocol.expect-continue", "%b,true" );
+
+ private HttpMethodConfiguration all;
+
+ private HttpMethodConfiguration get;
+
+ private HttpMethodConfiguration put;
+
+ private HttpMethodConfiguration head;
+
+ public HttpMethodConfiguration getAll()
+ {
+ return all;
+ }
+
+ public HttpConfiguration setAll( HttpMethodConfiguration all )
+ {
+ this.all = all;
+ return this;
+ }
+
+ public HttpMethodConfiguration getGet()
+ {
+ return get;
+ }
+
+ public HttpConfiguration setGet( HttpMethodConfiguration get )
+ {
+ this.get = get;
+ return this;
+ }
+
+ public HttpMethodConfiguration getPut()
+ {
+ return put;
+ }
+
+ public HttpConfiguration setPut( HttpMethodConfiguration put )
+ {
+ this.put = put;
+ return this;
+ }
+
+ public HttpMethodConfiguration getHead()
+ {
+ return head;
+ }
+
+ public HttpConfiguration setHead( HttpMethodConfiguration head )
+ {
+ this.head = head;
+ return this;
+ }
+
+ public HttpMethodConfiguration getMethodConfiguration( HttpUriRequest method )
+ {
+ if ( method instanceof HttpGet )
+ {
+ return ConfigurationUtils.merge( all, get );
+ }
+ else if ( method instanceof HttpPut )
+ {
+ return ConfigurationUtils.merge( DEFAULT_PUT, all, put );
+ }
+ else if ( method instanceof HttpHead )
+ {
+ return ConfigurationUtils.merge( all, head );
+ }
+
+ return all;
+ }
+
+}
diff --git a/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpMethodConfiguration.java b/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpMethodConfiguration.java
old mode 100755
new mode 100644
index aef7c9c..a1417ee
--- a/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpMethodConfiguration.java
+++ b/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpMethodConfiguration.java
@@ -1,174 +1,174 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.http.Header;
-import org.apache.http.message.BasicHeader;
-import org.apache.maven.wagon.Wagon;
-
-/**
- *
- */
-public class HttpMethodConfiguration
-{
-
- private Boolean useDefaultHeaders;
-
- private Properties headers = new Properties();
-
- private Properties params = new Properties();
-
- private int connectionTimeout = Wagon.DEFAULT_CONNECTION_TIMEOUT;
-
- private int readTimeout =
- Integer.parseInt( System.getProperty( "maven.wagon.rto", Integer.toString( Wagon.DEFAULT_READ_TIMEOUT ) ) );
-
- private boolean usePreemptive = false;
-
- public boolean isUseDefaultHeaders()
- {
- return useDefaultHeaders == null || useDefaultHeaders.booleanValue();
- }
-
- public HttpMethodConfiguration setUseDefaultHeaders( boolean useDefaultHeaders )
- {
- this.useDefaultHeaders = Boolean.valueOf( useDefaultHeaders );
- return this;
- }
-
- public Boolean getUseDefaultHeaders()
- {
- return useDefaultHeaders;
- }
-
- public HttpMethodConfiguration addHeader( String header, String value )
- {
- headers.setProperty( header, value );
- return this;
- }
-
- public Properties getHeaders()
- {
- return headers;
- }
-
- public HttpMethodConfiguration setHeaders( Properties headers )
- {
- this.headers = headers;
- return this;
- }
-
- public HttpMethodConfiguration addParam( String param, String value )
- {
- params.setProperty( param, value );
- return this;
- }
-
- public Properties getParams()
- {
- return params;
- }
-
- public HttpMethodConfiguration setParams( Properties params )
- {
- this.params = params;
- return this;
- }
-
- public int getConnectionTimeout()
- {
- return connectionTimeout;
- }
-
- public HttpMethodConfiguration setConnectionTimeout( int connectionTimeout )
- {
- this.connectionTimeout = connectionTimeout;
- return this;
- }
-
- public int getReadTimeout()
- {
- return readTimeout;
- }
-
- public HttpMethodConfiguration setReadTimeout( int readTimeout )
- {
- this.readTimeout = readTimeout;
- return this;
- }
-
- public boolean isUsePreemptive()
- {
- return usePreemptive;
- }
-
- public HttpMethodConfiguration setUsePreemptive( boolean usePreemptive )
- {
- this.usePreemptive = usePreemptive;
- return this;
- }
-
- public Header[] asRequestHeaders()
- {
- if ( headers == null )
- {
- return new Header[0];
- }
-
- Header[] result = new Header[headers.size()];
-
- int index = 0;
- for ( Map.Entry entry : headers.entrySet() )
- {
- String key = (String) entry.getKey();
- String value = (String) entry.getValue();
-
- Header header = new BasicHeader( key, value );
- result[index++] = header;
- }
-
- return result;
- }
-
- HttpMethodConfiguration copy()
- {
- HttpMethodConfiguration copy = new HttpMethodConfiguration();
-
- copy.setConnectionTimeout( getConnectionTimeout() );
- copy.setReadTimeout( getReadTimeout() );
- if ( getHeaders() != null )
- {
- copy.setHeaders( getHeaders() );
- }
-
- if ( getParams() != null )
- {
- copy.setParams( getParams() );
- }
-
- copy.setUseDefaultHeaders( isUseDefaultHeaders() );
-
- return copy;
- }
-
-}
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Map;
+import java.util.Properties;
+
+import org.apache.http.Header;
+import org.apache.http.message.BasicHeader;
+import org.apache.maven.wagon.Wagon;
+
+/**
+ *
+ */
+public class HttpMethodConfiguration
+{
+
+ private Boolean useDefaultHeaders;
+
+ private Properties headers = new Properties();
+
+ private Properties params = new Properties();
+
+ private int connectionTimeout = Wagon.DEFAULT_CONNECTION_TIMEOUT;
+
+ private int readTimeout =
+ Integer.parseInt( System.getProperty( "maven.wagon.rto", Integer.toString( Wagon.DEFAULT_READ_TIMEOUT ) ) );
+
+ private boolean usePreemptive = false;
+
+ public boolean isUseDefaultHeaders()
+ {
+ return useDefaultHeaders == null || useDefaultHeaders.booleanValue();
+ }
+
+ public HttpMethodConfiguration setUseDefaultHeaders( boolean useDefaultHeaders )
+ {
+ this.useDefaultHeaders = Boolean.valueOf( useDefaultHeaders );
+ return this;
+ }
+
+ public Boolean getUseDefaultHeaders()
+ {
+ return useDefaultHeaders;
+ }
+
+ public HttpMethodConfiguration addHeader( String header, String value )
+ {
+ headers.setProperty( header, value );
+ return this;
+ }
+
+ public Properties getHeaders()
+ {
+ return headers;
+ }
+
+ public HttpMethodConfiguration setHeaders( Properties headers )
+ {
+ this.headers = headers;
+ return this;
+ }
+
+ public HttpMethodConfiguration addParam( String param, String value )
+ {
+ params.setProperty( param, value );
+ return this;
+ }
+
+ public Properties getParams()
+ {
+ return params;
+ }
+
+ public HttpMethodConfiguration setParams( Properties params )
+ {
+ this.params = params;
+ return this;
+ }
+
+ public int getConnectionTimeout()
+ {
+ return connectionTimeout;
+ }
+
+ public HttpMethodConfiguration setConnectionTimeout( int connectionTimeout )
+ {
+ this.connectionTimeout = connectionTimeout;
+ return this;
+ }
+
+ public int getReadTimeout()
+ {
+ return readTimeout;
+ }
+
+ public HttpMethodConfiguration setReadTimeout( int readTimeout )
+ {
+ this.readTimeout = readTimeout;
+ return this;
+ }
+
+ public boolean isUsePreemptive()
+ {
+ return usePreemptive;
+ }
+
+ public HttpMethodConfiguration setUsePreemptive( boolean usePreemptive )
+ {
+ this.usePreemptive = usePreemptive;
+ return this;
+ }
+
+ public Header[] asRequestHeaders()
+ {
+ if ( headers == null )
+ {
+ return new Header[0];
+ }
+
+ Header[] result = new Header[headers.size()];
+
+ int index = 0;
+ for ( Map.Entry entry : headers.entrySet() )
+ {
+ String key = (String) entry.getKey();
+ String value = (String) entry.getValue();
+
+ Header header = new BasicHeader( key, value );
+ result[index++] = header;
+ }
+
+ return result;
+ }
+
+ HttpMethodConfiguration copy()
+ {
+ HttpMethodConfiguration copy = new HttpMethodConfiguration();
+
+ copy.setConnectionTimeout( getConnectionTimeout() );
+ copy.setReadTimeout( getReadTimeout() );
+ if ( getHeaders() != null )
+ {
+ copy.setHeaders( getHeaders() );
+ }
+
+ if ( getParams() != null )
+ {
+ copy.setParams( getParams() );
+ }
+
+ copy.setUseDefaultHeaders( isUseDefaultHeaders() );
+
+ return copy;
+ }
+
+}
diff --git a/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpWagon.java b/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpWagon.java
old mode 100755
new mode 100644
index 9410c8f..42146b3
--- a/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpWagon.java
+++ b/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpWagon.java
@@ -1,125 +1,125 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpException;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
-import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.authorization.AuthorizationException;
-import org.apache.maven.wagon.shared.http.HtmlFileListParser;
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.List;
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- */
-public class HttpWagon
- extends AbstractHttpClientWagon
-{
-
- public List<String> getFileList( String destinationDirectory )
- throws AuthorizationException, ResourceDoesNotExistException, TransferFailedException
- {
- return getFileList( getInitialBackoffSeconds(), destinationDirectory );
- }
-
- private List<String> getFileList( int wait, String destinationDirectory )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- if ( destinationDirectory.length() > 0 && !destinationDirectory.endsWith( "/" ) )
- {
- destinationDirectory += "/";
- }
-
- String url = getRepository().getUrl() + "/" + destinationDirectory;
-
- HttpGet getMethod = new HttpGet( url );
-
- try
- {
- CloseableHttpResponse response = execute( getMethod );
- try
- {
- int statusCode = response.getStatusLine().getStatusCode();
-
- fireTransferDebug( url + " - Status code: " + statusCode );
-
- switch ( statusCode )
- {
- case HttpStatus.SC_OK:
- break;
-
- case HttpStatus.SC_FORBIDDEN:
- throw new AuthorizationException( "Access denied to: " + url );
-
- case HttpStatus.SC_UNAUTHORIZED:
- throw new AuthorizationException( "Not authorized." );
-
- case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
- throw new AuthorizationException( "Not authorized by proxy." );
-
- case HttpStatus.SC_NOT_FOUND:
- throw new ResourceDoesNotExistException( "File: " + url + " does not exist" );
-
- case SC_TOO_MANY_REQUESTS:
- return getFileList( backoff( wait, url ), destinationDirectory );
-
- //add more entries here
- default:
- throw new TransferFailedException(
- "Failed to transfer file: " + url + ". Return code is: " + statusCode );
- }
- HttpEntity entity = response.getEntity();
- if ( entity != null )
- {
- return HtmlFileListParser.parseFileList( url, entity.getContent() );
- }
- else
- {
- return Collections.emptyList();
- }
-
- }
- finally
- {
- response.close();
- }
- }
- catch ( IOException e )
- {
- throw new TransferFailedException( "Could not read response body.", e );
- }
- catch ( HttpException e )
- {
- throw new TransferFailedException( "Could not read response body.", e );
- }
- catch ( InterruptedException e )
- {
- throw new TransferFailedException( "Unable to wait for resource.", e );
- }
- }
-
-}
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpException;
+import org.apache.http.HttpStatus;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.shared.http.HtmlFileListParser;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ */
+public class HttpWagon
+ extends AbstractHttpClientWagon
+{
+
+ public List<String> getFileList( String destinationDirectory )
+ throws AuthorizationException, ResourceDoesNotExistException, TransferFailedException
+ {
+ return getFileList( getInitialBackoffSeconds(), destinationDirectory );
+ }
+
+ private List<String> getFileList( int wait, String destinationDirectory )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ if ( destinationDirectory.length() > 0 && !destinationDirectory.endsWith( "/" ) )
+ {
+ destinationDirectory += "/";
+ }
+
+ String url = getRepository().getUrl() + "/" + destinationDirectory;
+
+ HttpGet getMethod = new HttpGet( url );
+
+ try
+ {
+ CloseableHttpResponse response = execute( getMethod );
+ try
+ {
+ int statusCode = response.getStatusLine().getStatusCode();
+
+ fireTransferDebug( url + " - Status code: " + statusCode );
+
+ switch ( statusCode )
+ {
+ case HttpStatus.SC_OK:
+ break;
+
+ case HttpStatus.SC_FORBIDDEN:
+ throw new AuthorizationException( "Access denied to: " + url );
+
+ case HttpStatus.SC_UNAUTHORIZED:
+ throw new AuthorizationException( "Not authorized." );
+
+ case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
+ throw new AuthorizationException( "Not authorized by proxy." );
+
+ case HttpStatus.SC_NOT_FOUND:
+ throw new ResourceDoesNotExistException( "File: " + url + " does not exist" );
+
+ case SC_TOO_MANY_REQUESTS:
+ return getFileList( backoff( wait, url ), destinationDirectory );
+
+ //add more entries here
+ default:
+ throw new TransferFailedException(
+ "Failed to transfer file: " + url + ". Return code is: " + statusCode );
+ }
+ HttpEntity entity = response.getEntity();
+ if ( entity != null )
+ {
+ return HtmlFileListParser.parseFileList( url, entity.getContent() );
+ }
+ else
+ {
+ return Collections.emptyList();
+ }
+
+ }
+ finally
+ {
+ response.close();
+ }
+ }
+ catch ( IOException e )
+ {
+ throw new TransferFailedException( "Could not read response body.", e );
+ }
+ catch ( HttpException e )
+ {
+ throw new TransferFailedException( "Could not read response body.", e );
+ }
+ catch ( InterruptedException e )
+ {
+ throw new TransferFailedException( "Unable to wait for resource.", e );
+ }
+ }
+
+}
diff --git a/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/RelaxedTrustStrategy.java b/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/RelaxedTrustStrategy.java
index 94a0878..681fcb3 100644
--- a/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/RelaxedTrustStrategy.java
+++ b/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/RelaxedTrustStrategy.java
@@ -1,76 +1,76 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.http.conn.ssl.TrustStrategy;
-
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateExpiredException;
-import java.security.cert.CertificateNotYetValidException;
-import java.security.cert.X509Certificate;
-
-/**
- * Relaxed X509 certificate trust manager: can ignore invalid certificate date.
- *
- * @author Olivier Lamy
- * @since 2.0
- */
-public class RelaxedTrustStrategy
- implements TrustStrategy
-{
- private final boolean ignoreSSLValidityDates;
-
- public RelaxedTrustStrategy( boolean ignoreSSLValidityDates )
- {
- this.ignoreSSLValidityDates = ignoreSSLValidityDates;
- }
-
- public boolean isTrusted( X509Certificate[] certificates, String authType )
- throws CertificateException
- {
- if ( ( certificates != null ) && ( certificates.length == 1 ) )
- {
- try
- {
- certificates[0].checkValidity();
- }
- catch ( CertificateExpiredException e )
- {
- if ( !ignoreSSLValidityDates )
- {
- throw e;
- }
- }
- catch ( CertificateNotYetValidException e )
- {
- if ( !ignoreSSLValidityDates )
- {
- throw e;
- }
- }
- return true;
- }
- else
- {
- return false;
- }
- }
-
-}
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.http.conn.ssl.TrustStrategy;
+
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateExpiredException;
+import java.security.cert.CertificateNotYetValidException;
+import java.security.cert.X509Certificate;
+
+/**
+ * Relaxed X509 certificate trust manager: can ignore invalid certificate date.
+ *
+ * @author Olivier Lamy
+ * @since 2.0
+ */
+public class RelaxedTrustStrategy
+ implements TrustStrategy
+{
+ private final boolean ignoreSSLValidityDates;
+
+ public RelaxedTrustStrategy( boolean ignoreSSLValidityDates )
+ {
+ this.ignoreSSLValidityDates = ignoreSSLValidityDates;
+ }
+
+ public boolean isTrusted( X509Certificate[] certificates, String authType )
+ throws CertificateException
+ {
+ if ( ( certificates != null ) && ( certificates.length == 1 ) )
+ {
+ try
+ {
+ certificates[0].checkValidity();
+ }
+ catch ( CertificateExpiredException e )
+ {
+ if ( !ignoreSSLValidityDates )
+ {
+ throw e;
+ }
+ }
+ catch ( CertificateNotYetValidException e )
+ {
+ if ( !ignoreSSLValidityDates )
+ {
+ throw e;
+ }
+ }
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+}
diff --git a/wagon-providers/wagon-http/src/main/resources/META-INF/plexus/components.xml b/wagon-providers/wagon-http/src/main/resources/META-INF/plexus/components.xml
index 49c61e5..5c770e3 100644
--- a/wagon-providers/wagon-http/src/main/resources/META-INF/plexus/components.xml
+++ b/wagon-providers/wagon-http/src/main/resources/META-INF/plexus/components.xml
@@ -1,35 +1,35 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<component-set>
- <components>
- <component>
- <role>org.apache.maven.wagon.Wagon</role>
- <role-hint>http</role-hint>
- <implementation>org.apache.maven.wagon.providers.http.HttpWagon</implementation>
- <instantiation-strategy>per-lookup</instantiation-strategy>
- </component>
- <component>
- <role>org.apache.maven.wagon.Wagon</role>
- <role-hint>https</role-hint>
- <implementation>org.apache.maven.wagon.providers.http.HttpWagon</implementation>
- <instantiation-strategy>per-lookup</instantiation-strategy>
- </component>
- </components>
-</component-set>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<component-set>
+ <components>
+ <component>
+ <role>org.apache.maven.wagon.Wagon</role>
+ <role-hint>http</role-hint>
+ <implementation>org.apache.maven.wagon.providers.http.HttpWagon</implementation>
+ <instantiation-strategy>per-lookup</instantiation-strategy>
+ </component>
+ <component>
+ <role>org.apache.maven.wagon.Wagon</role>
+ <role-hint>https</role-hint>
+ <implementation>org.apache.maven.wagon.providers.http.HttpWagon</implementation>
+ <instantiation-strategy>per-lookup</instantiation-strategy>
+ </component>
+ </components>
+</component-set>
diff --git a/wagon-providers/wagon-http/src/site/apt/index.apt b/wagon-providers/wagon-http/src/site/apt/index.apt
index 732af58..6f8b22a 100644
--- a/wagon-providers/wagon-http/src/site/apt/index.apt
+++ b/wagon-providers/wagon-http/src/site/apt/index.apt
@@ -1,59 +1,59 @@
- ------
- Maven Wagon HTTP
- ------
- Carlos Sanchez
- Olivier Lamy
- ------
- 2013-02-05
- ------
-
- ~~ Licensed to the Apache Software Foundation (ASF) under one
- ~~ or more contributor license agreements. See the NOTICE file
- ~~ distributed with this work for additional information
- ~~ regarding copyright ownership. The ASF licenses this file
- ~~ to you under the Apache License, Version 2.0 (the
- ~~ "License"); you may not use this file except in compliance
- ~~ with the License. You may obtain a copy of the License at
- ~~
- ~~ http://www.apache.org/licenses/LICENSE-2.0
- ~~
- ~~ Unless required by applicable law or agreed to in writing,
- ~~ software distributed under the License is distributed on an
- ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~~ KIND, either express or implied. See the License for the
- ~~ specific language governing permissions and limitations
- ~~ under the License.
-
- ~~ NOTE: For help with the syntax of this file, see:
- ~~ http://maven.apache.org/doxia/references/apt-format.html
-
-Maven Wagon HTTP
-
- This component is an implementation of Wagon provider for HTTP access.
- It uses {{{http://hc.apache.org/httpcomponents-client-ga/}Apache HttpComponents client}} as lower level layer.
-
- It enables Maven to use remote repositories stored in HTTP servers.
-
-
-Features
-
- Starting with version 2.0, a pooled http connection manager is used.
- You can configure it through the following system properties:
-
- * <<<maven.wagon.http.pool>>> = true/false (default true), enable/disable the pool mechanism.
-
- * <<<maven.wagon.httpconnectionManager.maxPerRoute>>> = integer (default 20), maximum number of http(s) connection per destination.
-
- * <<<maven.wagon.httpconnectionManager.maxTotal>>> = integer (default 40), maximum number of http(s) connection.
-
- []
-
- Other features can be configured through system properties:
-
- * <<<maven.wagon.http.ssl.insecure>>> = true/false (default false), enable/disable use of relaxed ssl check for user generated certificates.
-
- * <<<maven.wagon.http.ssl.allowall>>> = true/false (default false), enable/disable match of the server's X.509 certificate with hostname. If disabled, a browser like check will be used.
-
- * <<<maven.wagon.http.ssl.ignore.validity.dates>>> = true/false (default false), ignore issues with certificate dates.
-
- * <<<maven.wagon.rto>>> = time in ms (default 1800000), read time out.
+ ------
+ Maven Wagon HTTP
+ ------
+ Carlos Sanchez
+ Olivier Lamy
+ ------
+ 2013-02-05
+ ------
+
+ ~~ Licensed to the Apache Software Foundation (ASF) under one
+ ~~ or more contributor license agreements. See the NOTICE file
+ ~~ distributed with this work for additional information
+ ~~ regarding copyright ownership. The ASF licenses this file
+ ~~ to you under the Apache License, Version 2.0 (the
+ ~~ "License"); you may not use this file except in compliance
+ ~~ with the License. You may obtain a copy of the License at
+ ~~
+ ~~ http://www.apache.org/licenses/LICENSE-2.0
+ ~~
+ ~~ Unless required by applicable law or agreed to in writing,
+ ~~ software distributed under the License is distributed on an
+ ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~~ KIND, either express or implied. See the License for the
+ ~~ specific language governing permissions and limitations
+ ~~ under the License.
+
+ ~~ NOTE: For help with the syntax of this file, see:
+ ~~ http://maven.apache.org/doxia/references/apt-format.html
+
+Maven Wagon HTTP
+
+ This component is an implementation of Wagon provider for HTTP access.
+ It uses {{{http://hc.apache.org/httpcomponents-client-ga/}Apache HttpComponents client}} as lower level layer.
+
+ It enables Maven to use remote repositories stored in HTTP servers.
+
+
+Features
+
+ Starting with version 2.0, a pooled http connection manager is used.
+ You can configure it through the following system properties:
+
+ * <<<maven.wagon.http.pool>>> = true/false (default true), enable/disable the pool mechanism.
+
+ * <<<maven.wagon.httpconnectionManager.maxPerRoute>>> = integer (default 20), maximum number of http(s) connection per destination.
+
+ * <<<maven.wagon.httpconnectionManager.maxTotal>>> = integer (default 40), maximum number of http(s) connection.
+
+ []
+
+ Other features can be configured through system properties:
+
+ * <<<maven.wagon.http.ssl.insecure>>> = true/false (default false), enable/disable use of relaxed ssl check for user generated certificates.
+
+ * <<<maven.wagon.http.ssl.allowall>>> = true/false (default false), enable/disable match of the server's X.509 certificate with hostname. If disabled, a browser like check will be used.
+
+ * <<<maven.wagon.http.ssl.ignore.validity.dates>>> = true/false (default false), ignore issues with certificate dates.
+
+ * <<<maven.wagon.rto>>> = time in ms (default 1800000), read time out.
diff --git a/wagon-providers/wagon-http/src/site/site.xml b/wagon-providers/wagon-http/src/site/site.xml
index a0a163d..daf2207 100644
--- a/wagon-providers/wagon-http/src/site/site.xml
+++ b/wagon-providers/wagon-http/src/site/site.xml
@@ -1,33 +1,33 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
- <body>
- <breadcrumbs>
- <item name="HTTP" href="http://maven.apache.org/wagon/wagon-providers/wagon-http/index.html" />
- </breadcrumbs>
-
- <menu ref="parent"/>
- <menu ref="reports"/>
- </body>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
+ <body>
+ <breadcrumbs>
+ <item name="HTTP" href="http://maven.apache.org/wagon/wagon-providers/wagon-http/index.html" />
+ </breadcrumbs>
+
+ <menu ref="parent"/>
+ <menu ref="reports"/>
+ </body>
</project>
\ No newline at end of file
diff --git a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/AbstractHttpClientWagonTest.java b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/AbstractHttpClientWagonTest.java
index c1814f4..62ddb6c 100644
--- a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/AbstractHttpClientWagonTest.java
+++ b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/AbstractHttpClientWagonTest.java
@@ -1,51 +1,53 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.InputData;
-import org.apache.maven.wagon.repository.Repository;
-import org.apache.maven.wagon.resource.Resource;
-import org.junit.Test;
-
-public class AbstractHttpClientWagonTest
-{
- @Test
- public void test()
- throws Exception
- {
- AbstractHttpClientWagon wagon = new AbstractHttpClientWagon()
- {
- };
-
- Repository repository = new Repository( "central", "http://repo.maven.apache.org/maven2" );
-
- wagon.connect( repository );
-
- Resource resource = new Resource();
-
- resource.setName( "junit/junit/maven-metadata.xml" );
-
- InputData inputData = new InputData();
-
- inputData.setResource( resource );
-
- wagon.fillInputData( inputData );
- }
-}
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.InputData;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.resource.Resource;
+import org.junit.Test;
+
+public class AbstractHttpClientWagonTest
+{
+ @Test
+ public void test()
+ throws Exception
+ {
+ AbstractHttpClientWagon wagon = new AbstractHttpClientWagon()
+ {
+ };
+
+ Repository repository = new Repository( "central", "http://repo.maven.apache.org/maven2" );
+
+ wagon.connect( repository );
+
+ Resource resource = new Resource();
+
+ resource.setName( "junit/junit/maven-metadata.xml" );
+
+ InputData inputData = new InputData();
+
+ inputData.setResource( resource );
+
+ wagon.fillInputData( inputData );
+
+ wagon.disconnect();
+ }
+}
diff --git a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/BasicAuthScopeTest.java b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/BasicAuthScopeTest.java
index 9cab689..f03f759 100644
--- a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/BasicAuthScopeTest.java
+++ b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/BasicAuthScopeTest.java
@@ -1,100 +1,100 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.http.auth.AuthScope;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class BasicAuthScopeTest
-{
-
- /**
- * Test AuthScope override with no overriding values set. Nothing should
- * change in original host/port.
- */
- @Test
- public void testGetScopeNothingOverridden()
- {
- BasicAuthScope scope = new BasicAuthScope();
-
- AuthScope authScope = scope.getScope( "original.host.com", 3456 );
- Assert.assertEquals( "original.host.com", authScope.getHost() );
- Assert.assertEquals( 3456, authScope.getPort() );
- Assert.assertEquals( AuthScope.ANY_REALM, authScope.getRealm() );
- }
-
- /**
- * Test AuthScope override for all values overridden
- */
- @Test
- public void testGetScopeAllOverridden()
- {
- BasicAuthScope scope = new BasicAuthScope();
- scope.setHost( "override.host.com" );
- scope.setPort( "1234" );
- scope.setRealm( "override-realm" );
- AuthScope authScope = scope.getScope( "original.host.com", 3456 );
- Assert.assertEquals( "override.host.com", authScope.getHost() );
- Assert.assertEquals( 1234, authScope.getPort() );
- Assert.assertEquals( "override-realm", authScope.getRealm() );
- }
-
- /**
- * Test AuthScope override for all values overridden with "ANY"
- */
- @Test
- public void testGetScopeAllAny()
- {
- BasicAuthScope scope = new BasicAuthScope();
- scope.setHost( "ANY" );
- scope.setPort( "ANY" );
- scope.setRealm( "ANY" );
- AuthScope authScope = scope.getScope( "original.host.com", 3456 );
- Assert.assertEquals( AuthScope.ANY_HOST, authScope.getHost() );
- Assert.assertEquals( AuthScope.ANY_PORT, authScope.getPort() );
- Assert.assertEquals( AuthScope.ANY_REALM, authScope.getRealm() );
- }
-
- /**
- * Test AuthScope override for realm value overridden
- */
- @Test
- public void testGetScopeRealmOverridden()
- {
- BasicAuthScope scope = new BasicAuthScope();
- scope.setRealm( "override-realm" );
- AuthScope authScope = scope.getScope( "original.host.com", 3456 );
- Assert.assertEquals( "original.host.com", authScope.getHost() );
- Assert.assertEquals( 3456, authScope.getPort() );
- Assert.assertEquals( "override-realm", authScope.getRealm() );
- }
-
- /**
- * Test AuthScope where original port is -1, which should result in ANY
- */
- @Test
- public void testGetScopeOriginalPortIsNegativeOne()
- {
- BasicAuthScope scope = new BasicAuthScope();
- AuthScope authScope = scope.getScope( "original.host.com", -1 );
- Assert.assertEquals( AuthScope.ANY_PORT, authScope.getPort() );
- }
-}
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.http.auth.AuthScope;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class BasicAuthScopeTest
+{
+
+ /**
+ * Test AuthScope override with no overriding values set. Nothing should
+ * change in original host/port.
+ */
+ @Test
+ public void testGetScopeNothingOverridden()
+ {
+ BasicAuthScope scope = new BasicAuthScope();
+
+ AuthScope authScope = scope.getScope( "original.host.com", 3456 );
+ Assert.assertEquals( "original.host.com", authScope.getHost() );
+ Assert.assertEquals( 3456, authScope.getPort() );
+ Assert.assertEquals( AuthScope.ANY_REALM, authScope.getRealm() );
+ }
+
+ /**
+ * Test AuthScope override for all values overridden
+ */
+ @Test
+ public void testGetScopeAllOverridden()
+ {
+ BasicAuthScope scope = new BasicAuthScope();
+ scope.setHost( "override.host.com" );
+ scope.setPort( "1234" );
+ scope.setRealm( "override-realm" );
+ AuthScope authScope = scope.getScope( "original.host.com", 3456 );
+ Assert.assertEquals( "override.host.com", authScope.getHost() );
+ Assert.assertEquals( 1234, authScope.getPort() );
+ Assert.assertEquals( "override-realm", authScope.getRealm() );
+ }
+
+ /**
+ * Test AuthScope override for all values overridden with "ANY"
+ */
+ @Test
+ public void testGetScopeAllAny()
+ {
+ BasicAuthScope scope = new BasicAuthScope();
+ scope.setHost( "ANY" );
+ scope.setPort( "ANY" );
+ scope.setRealm( "ANY" );
+ AuthScope authScope = scope.getScope( "original.host.com", 3456 );
+ Assert.assertEquals( AuthScope.ANY_HOST, authScope.getHost() );
+ Assert.assertEquals( AuthScope.ANY_PORT, authScope.getPort() );
+ Assert.assertEquals( AuthScope.ANY_REALM, authScope.getRealm() );
+ }
+
+ /**
+ * Test AuthScope override for realm value overridden
+ */
+ @Test
+ public void testGetScopeRealmOverridden()
+ {
+ BasicAuthScope scope = new BasicAuthScope();
+ scope.setRealm( "override-realm" );
+ AuthScope authScope = scope.getScope( "original.host.com", 3456 );
+ Assert.assertEquals( "original.host.com", authScope.getHost() );
+ Assert.assertEquals( 3456, authScope.getPort() );
+ Assert.assertEquals( "override-realm", authScope.getRealm() );
+ }
+
+ /**
+ * Test AuthScope where original port is -1, which should result in ANY
+ */
+ @Test
+ public void testGetScopeOriginalPortIsNegativeOne()
+ {
+ BasicAuthScope scope = new BasicAuthScope();
+ AuthScope authScope = scope.getScope( "original.host.com", -1 );
+ Assert.assertEquals( AuthScope.ANY_PORT, authScope.getPort() );
+ }
+}
diff --git a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/ErrorWithReasonPhaseServlet.java b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/ErrorWithReasonPhaseServlet.java
index 529c59d..700b852 100644
--- a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/ErrorWithReasonPhaseServlet.java
+++ b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/ErrorWithReasonPhaseServlet.java
@@ -1,63 +1,64 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.log4j.Logger;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-/**
- * User: jdumay
- * Date: 24/01/2008
- * Time: 17:25:27
- */
-public class ErrorWithReasonPhaseServlet
- extends HttpServlet
-{
- public static final String REASON = "it sucks!";
-
- private Logger logger = Logger.getLogger( ErrorWithReasonPhaseServlet.class );
-
- public void service( HttpServletRequest request, HttpServletResponse response )
- throws ServletException, IOException
- {
- if ( request.getRequestURL().toString().contains( "401" ) )
- {
- response.sendError( 401, REASON );
- }
- else if ( request.getRequestURL().toString().contains( "403" ) )
- {
- response.sendError( 403, REASON );
- }
- else if ( request.getRequestURL().toString().contains( "407" ) )
- {
- response.sendError( 407, REASON );
- }
- else if ( request.getRequestURL().toString().contains( "500" ) )
- {
- response.sendError( 500, REASON );
- }
-
- }
-}
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * User: jdumay
+ * Date: 24/01/2008
+ * Time: 17:25:27
+ */
+public class ErrorWithReasonPhaseServlet
+ extends HttpServlet
+{
+ public static final String REASON = "it sucks!";
+
+ private Logger logger = LoggerFactory.getLogger( ErrorWithReasonPhaseServlet.class );
+
+ public void service( HttpServletRequest request, HttpServletResponse response )
+ throws ServletException, IOException
+ {
+ if ( request.getRequestURL().toString().contains( "401" ) )
+ {
+ response.sendError( 401, REASON );
+ }
+ else if ( request.getRequestURL().toString().contains( "403" ) )
+ {
+ response.sendError( 403, REASON );
+ }
+ else if ( request.getRequestURL().toString().contains( "407" ) )
+ {
+ response.sendError( 407, REASON );
+ }
+ else if ( request.getRequestURL().toString().contains( "500" ) )
+ {
+ response.sendError( 500, REASON );
+ }
+
+ }
+}
diff --git a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpClientWagonTest.java b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpClientWagonTest.java
old mode 100755
new mode 100644
index 4634481..54e04a9
--- a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpClientWagonTest.java
+++ b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpClientWagonTest.java
@@ -1,136 +1,136 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-import junit.framework.TestCase;
-
-import org.apache.http.Header;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.methods.HttpHead;
-import org.apache.maven.wagon.OutputData;
-import org.apache.maven.wagon.TransferFailedException;
-
-public class HttpClientWagonTest
- extends TestCase
-{
-
- public void testSetMaxRedirectsParamViaConfig()
- {
- HttpMethodConfiguration methodConfig = new HttpMethodConfiguration();
- int maxRedirects = 2;
- methodConfig.addParam("http.protocol.max-redirects", "%i," + maxRedirects);
-
- HttpConfiguration config = new HttpConfiguration();
- config.setAll(methodConfig);
-
- HttpHead method = new HttpHead();
- RequestConfig.Builder builder = RequestConfig.custom();
- ConfigurationUtils.copyConfig( config.getMethodConfiguration( method ), builder );
- RequestConfig requestConfig = builder.build();
-
- assertEquals(2, requestConfig.getMaxRedirects());
- }
-
- public void testDefaultHeadersUsedByDefault()
- {
- HttpConfiguration config = new HttpConfiguration();
- config.setAll( new HttpMethodConfiguration() );
-
- TestWagon wagon = new TestWagon();
- wagon.setHttpConfiguration( config );
-
- HttpHead method = new HttpHead();
- wagon.setHeaders( method );
-
- // these are the default headers.
- // method.addRequestHeader( "Cache-control", "no-cache" );
- // method.addRequestHeader( "Cache-store", "no-store" );
- // method.addRequestHeader( "Pragma", "no-cache" );
- // method.addRequestHeader( "Expires", "0" );
- // method.addRequestHeader( "Accept-Encoding", "gzip" );
-
- Header header = method.getFirstHeader( "Cache-control" );
- assertNotNull( header );
- assertEquals( "no-cache", header.getValue() );
-
- header = method.getFirstHeader( "Cache-store" );
- assertNotNull( header );
- assertEquals( "no-store", header.getValue() );
-
- header = method.getFirstHeader( "Pragma" );
- assertNotNull( header );
- assertEquals( "no-cache", header.getValue() );
-
- header = method.getFirstHeader( "Expires" );
- assertNotNull( header );
- assertEquals( "0", header.getValue() );
-
- header = method.getFirstHeader( "Accept-Encoding" );
- assertNotNull( header );
- assertEquals( "gzip", header.getValue() );
- }
-
- public void testTurnOffDefaultHeaders()
- {
- HttpConfiguration config = new HttpConfiguration();
- config.setAll( new HttpMethodConfiguration().setUseDefaultHeaders( false ) );
-
- TestWagon wagon = new TestWagon();
- wagon.setHttpConfiguration( config );
-
- HttpHead method = new HttpHead();
- wagon.setHeaders( method );
-
- // these are the default headers.
- // method.addRequestHeader( "Cache-control", "no-cache" );
- // method.addRequestHeader( "Cache-store", "no-store" );
- // method.addRequestHeader( "Pragma", "no-cache" );
- // method.addRequestHeader( "Expires", "0" );
- // method.addRequestHeader( "Accept-Encoding", "gzip" );
-
- Header header = method.getFirstHeader( "Cache-control" );
- assertNull( header );
-
- header = method.getFirstHeader( "Cache-store" );
- assertNull( header );
-
- header = method.getFirstHeader( "Pragma" );
- assertNull( header );
-
- header = method.getFirstHeader( "Expires" );
- assertNull( header );
-
- header = method.getFirstHeader( "Accept-Encoding" );
- assertNull( header );
- }
-
- private static final class TestWagon
- extends AbstractHttpClientWagon
- {
- @Override
- public void fillOutputData( OutputData outputData )
- throws TransferFailedException
- {
-
- }
- }
-
-}
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+import junit.framework.TestCase;
+
+import org.apache.http.Header;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.HttpHead;
+import org.apache.maven.wagon.OutputData;
+import org.apache.maven.wagon.TransferFailedException;
+
+public class HttpClientWagonTest
+ extends TestCase
+{
+
+ public void testSetMaxRedirectsParamViaConfig()
+ {
+ HttpMethodConfiguration methodConfig = new HttpMethodConfiguration();
+ int maxRedirects = 2;
+ methodConfig.addParam("http.protocol.max-redirects", "%i," + maxRedirects);
+
+ HttpConfiguration config = new HttpConfiguration();
+ config.setAll(methodConfig);
+
+ HttpHead method = new HttpHead();
+ RequestConfig.Builder builder = RequestConfig.custom();
+ ConfigurationUtils.copyConfig( config.getMethodConfiguration( method ), builder );
+ RequestConfig requestConfig = builder.build();
+
+ assertEquals(2, requestConfig.getMaxRedirects());
+ }
+
+ public void testDefaultHeadersUsedByDefault()
+ {
+ HttpConfiguration config = new HttpConfiguration();
+ config.setAll( new HttpMethodConfiguration() );
+
+ TestWagon wagon = new TestWagon();
+ wagon.setHttpConfiguration( config );
+
+ HttpHead method = new HttpHead();
+ wagon.setHeaders( method );
+
+ // these are the default headers.
+ // method.addRequestHeader( "Cache-control", "no-cache" );
+ // method.addRequestHeader( "Cache-store", "no-store" );
+ // method.addRequestHeader( "Pragma", "no-cache" );
+ // method.addRequestHeader( "Expires", "0" );
+ // method.addRequestHeader( "Accept-Encoding", "gzip" );
+
+ Header header = method.getFirstHeader( "Cache-control" );
+ assertNotNull( header );
+ assertEquals( "no-cache", header.getValue() );
+
+ header = method.getFirstHeader( "Cache-store" );
+ assertNotNull( header );
+ assertEquals( "no-store", header.getValue() );
+
+ header = method.getFirstHeader( "Pragma" );
+ assertNotNull( header );
+ assertEquals( "no-cache", header.getValue() );
+
+ header = method.getFirstHeader( "Expires" );
+ assertNotNull( header );
+ assertEquals( "0", header.getValue() );
+
+ header = method.getFirstHeader( "Accept-Encoding" );
+ assertNotNull( header );
+ assertEquals( "gzip", header.getValue() );
+ }
+
+ public void testTurnOffDefaultHeaders()
+ {
+ HttpConfiguration config = new HttpConfiguration();
+ config.setAll( new HttpMethodConfiguration().setUseDefaultHeaders( false ) );
+
+ TestWagon wagon = new TestWagon();
+ wagon.setHttpConfiguration( config );
+
+ HttpHead method = new HttpHead();
+ wagon.setHeaders( method );
+
+ // these are the default headers.
+ // method.addRequestHeader( "Cache-control", "no-cache" );
+ // method.addRequestHeader( "Cache-store", "no-store" );
+ // method.addRequestHeader( "Pragma", "no-cache" );
+ // method.addRequestHeader( "Expires", "0" );
+ // method.addRequestHeader( "Accept-Encoding", "gzip" );
+
+ Header header = method.getFirstHeader( "Cache-control" );
+ assertNull( header );
+
+ header = method.getFirstHeader( "Cache-store" );
+ assertNull( header );
+
+ header = method.getFirstHeader( "Pragma" );
+ assertNull( header );
+
+ header = method.getFirstHeader( "Expires" );
+ assertNull( header );
+
+ header = method.getFirstHeader( "Accept-Encoding" );
+ assertNull( header );
+ }
+
+ private static final class TestWagon
+ extends AbstractHttpClientWagon
+ {
+ @Override
+ public void fillOutputData( OutputData outputData )
+ throws TransferFailedException
+ {
+
+ }
+ }
+
+}
diff --git a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonHttpServerTestCase.java b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonHttpServerTestCase.java
index b5ef1e8..2208945 100644
--- a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonHttpServerTestCase.java
+++ b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonHttpServerTestCase.java
@@ -1,71 +1,71 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.Wagon;
-import org.codehaus.plexus.PlexusTestCase;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.handler.ResourceHandler;
-import org.mortbay.jetty.servlet.Context;
-
-/**
- * User: jdumay Date: 24/01/2008 Time: 18:15:53
- */
-public abstract class HttpWagonHttpServerTestCase
- extends PlexusTestCase
-{
- protected final int httpServerPort = 10008;
-
- private Server server;
-
- protected ResourceHandler resourceHandler;
-
- protected Context context;
-
- protected void setUp()
- throws Exception
- {
- super.setUp();
- server = new Server( httpServerPort );
-
- context = new Context( server, "/", Context.SESSIONS );
-
- resourceHandler = new ResourceHandler();
- server.addHandler( resourceHandler );
- }
-
- protected Wagon getWagon()
- throws Exception
- {
- return (Wagon) lookup( HttpWagon.ROLE );
- }
-
- protected void startServer()
- throws Exception
- {
- server.start();
- }
-
- protected void stopServer()
- throws Exception
- {
- server.stop();
- }
-}
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.Wagon;
+import org.codehaus.plexus.PlexusTestCase;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.handler.ResourceHandler;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+
+/**
+ * User: jdumay Date: 24/01/2008 Time: 18:15:53
+ */
+public abstract class HttpWagonHttpServerTestCase
+ extends PlexusTestCase
+{
+ protected final int httpServerPort = 10008;
+
+ private Server server;
+
+ protected ResourceHandler resourceHandler;
+
+ protected ServletContextHandler context;
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+ server = new Server( httpServerPort );
+
+ context = new ServletContextHandler( ServletContextHandler.SESSIONS );
+ resourceHandler = new ResourceHandler();
+ context.setHandler( resourceHandler );
+ server.setHandler( context );
+ }
+
+ protected Wagon getWagon()
+ throws Exception
+ {
+ return (Wagon) lookup( HttpWagon.ROLE );
+ }
+
+ protected void startServer()
+ throws Exception
+ {
+ server.start();
+ }
+
+ protected void stopServer()
+ throws Exception
+ {
+ server.stop();
+ }
+}
diff --git a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonPreemptiveTest.java b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonPreemptiveTest.java
index f8c8be5..0959876 100644
--- a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonPreemptiveTest.java
+++ b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonPreemptiveTest.java
@@ -1,58 +1,58 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.Wagon;
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class HttpWagonPreemptiveTest
- extends HttpWagonTest
-{
- @Override
- protected Wagon getWagon()
- throws Exception
- {
- HttpWagon wagon = (HttpWagon) super.getWagon();
- wagon.setHttpConfiguration(
- new HttpConfiguration().setAll( new HttpMethodConfiguration().setUsePreemptive( true ) ) );
- return wagon;
- }
-
- @Override
- protected boolean supportPreemptiveAuthenticationPut()
- {
- return true;
- }
-
- @Override
- protected boolean supportPreemptiveAuthenticationGet()
- {
- return true;
- }
-
- @Override
- protected boolean supportProxyPreemptiveAuthentication()
- {
- return true;
- }
-}
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.Wagon;
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class HttpWagonPreemptiveTest
+ extends HttpWagonTest
+{
+ @Override
+ protected Wagon getWagon()
+ throws Exception
+ {
+ HttpWagon wagon = (HttpWagon) super.getWagon();
+ wagon.setHttpConfiguration(
+ new HttpConfiguration().setAll( new HttpMethodConfiguration().setUsePreemptive( true ) ) );
+ return wagon;
+ }
+
+ @Override
+ protected boolean supportPreemptiveAuthenticationPut()
+ {
+ return true;
+ }
+
+ @Override
+ protected boolean supportPreemptiveAuthenticationGet()
+ {
+ return true;
+ }
+
+ @Override
+ protected boolean supportProxyPreemptiveAuthentication()
+ {
+ return true;
+ }
+}
diff --git a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonReasonPhraseTest.java b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonReasonPhraseTest.java
index 32cbf32..6c8a094 100644
--- a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonReasonPhraseTest.java
+++ b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonReasonPhraseTest.java
@@ -1,186 +1,186 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.FileTestUtils;
-import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.authorization.AuthorizationException;
-import org.apache.maven.wagon.repository.Repository;
-import org.mortbay.jetty.servlet.ServletHolder;
-
-import java.io.File;
-
-/**
- * User: jdumay Date: 24/01/2008 Time: 17:17:34
- */
-public class HttpWagonReasonPhraseTest
- extends HttpWagonHttpServerTestCase
-{
- protected void setUp()
- throws Exception
- {
- super.setUp();
- ServletHolder servlets = new ServletHolder( new ErrorWithReasonPhaseServlet() );
- context.addServlet( servlets, "/*" );
- startServer();
- }
-
- public void testGetReasonPhase401()
- throws Exception
- {
- Exception thrown = null;
-
- try
- {
- Wagon wagon = getWagon();
-
- Repository testRepository = new Repository();
- testRepository.setUrl( "http://localhost:" + httpServerPort );
-
- wagon.connect( testRepository );
-
- File destFile = FileTestUtils.createUniqueFile( getName(), getName() );
- destFile.deleteOnExit();
-
- wagon.get( "/401", destFile );
-
- wagon.disconnect();
- }
- catch ( Exception e )
- {
- thrown = e;
- }
- finally
- {
- stopServer();
- }
-
- assertNotNull( thrown );
- assertEquals( AuthorizationException.class, thrown.getClass() );
- assertTrue( thrown.getMessage().contains( ErrorWithReasonPhaseServlet.REASON ) );
- }
-
- public void testGetReasonPhase403()
- throws Exception
- {
- Exception thrown = null;
-
- try
- {
- Wagon wagon = getWagon();
-
- Repository testRepository = new Repository();
- testRepository.setUrl( "http://localhost:" + httpServerPort );
-
- wagon.connect( testRepository );
-
- File destFile = FileTestUtils.createUniqueFile( getName(), getName() );
- destFile.deleteOnExit();
-
- wagon.get( "/403", destFile );
-
- wagon.disconnect();
- }
- catch ( Exception e )
- {
- thrown = e;
- }
- finally
- {
- stopServer();
- }
-
- assertNotNull( thrown );
- assertEquals( AuthorizationException.class, thrown.getClass() );
- assertTrue( thrown.getMessage().contains( ErrorWithReasonPhaseServlet.REASON ) );
- }
-
-
- public void testGetReasonPhase407()
- throws Exception
- {
- Exception thrown = null;
-
- try
- {
- Wagon wagon = getWagon();
-
- Repository testRepository = new Repository();
- testRepository.setUrl( "http://localhost:" + httpServerPort );
-
- wagon.connect( testRepository );
-
- File destFile = FileTestUtils.createUniqueFile( getName(), getName() );
- destFile.deleteOnExit();
-
- wagon.get( "/407", destFile );
-
- wagon.disconnect();
- }
- catch ( Exception e )
- {
- thrown = e;
- }
- finally
- {
- stopServer();
- }
-
- assertNotNull( thrown );
- assertEquals( AuthorizationException.class, thrown.getClass() );
- assertTrue( thrown.getMessage().contains( ErrorWithReasonPhaseServlet.REASON ) );
- }
-
- public void testGetReasonPhase500()
- throws Exception
- {
- Exception thrown = null;
-
- try
- {
- Wagon wagon = getWagon();
-
- Repository testRepository = new Repository();
- testRepository.setUrl( "http://localhost:" + httpServerPort );
-
- wagon.connect( testRepository );
-
- File destFile = FileTestUtils.createUniqueFile( getName(), getName() );
- destFile.deleteOnExit();
-
- wagon.get( "/500", destFile );
-
- wagon.disconnect();
- }
- catch ( Exception e )
- {
- thrown = e;
- }
- finally
- {
- stopServer();
- }
-
- assertNotNull( thrown );
- assertEquals( TransferFailedException.class, thrown.getClass() );
- assertTrue( thrown.getMessage().contains( ErrorWithReasonPhaseServlet.REASON ) );
- }
-}
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.FileTestUtils;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.repository.Repository;
+import org.eclipse.jetty.servlet.ServletHolder;
+
+import java.io.File;
+
+/**
+ * User: jdumay Date: 24/01/2008 Time: 17:17:34
+ */
+public class HttpWagonReasonPhraseTest
+ extends HttpWagonHttpServerTestCase
+{
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+ ServletHolder servlets = new ServletHolder( new ErrorWithReasonPhaseServlet() );
+ context.addServlet( servlets, "/*" );
+ startServer();
+ }
+
+ public void testGetReasonPhase401()
+ throws Exception
+ {
+ Exception thrown = null;
+
+ try
+ {
+ Wagon wagon = getWagon();
+
+ Repository testRepository = new Repository();
+ testRepository.setUrl( "http://localhost:" + httpServerPort );
+
+ wagon.connect( testRepository );
+
+ File destFile = FileTestUtils.createUniqueFile( getName(), getName() );
+ destFile.deleteOnExit();
+
+ wagon.get( "/401", destFile );
+
+ wagon.disconnect();
+ }
+ catch ( Exception e )
+ {
+ thrown = e;
+ }
+ finally
+ {
+ stopServer();
+ }
+
+ assertNotNull( thrown );
+ assertEquals( AuthorizationException.class, thrown.getClass() );
+ assertTrue( thrown.getMessage().contains( ErrorWithReasonPhaseServlet.REASON ) );
+ }
+
+ public void testGetReasonPhase403()
+ throws Exception
+ {
+ Exception thrown = null;
+
+ try
+ {
+ Wagon wagon = getWagon();
+
+ Repository testRepository = new Repository();
+ testRepository.setUrl( "http://localhost:" + httpServerPort );
+
+ wagon.connect( testRepository );
+
+ File destFile = FileTestUtils.createUniqueFile( getName(), getName() );
+ destFile.deleteOnExit();
+
+ wagon.get( "/403", destFile );
+
+ wagon.disconnect();
+ }
+ catch ( Exception e )
+ {
+ thrown = e;
+ }
+ finally
+ {
+ stopServer();
+ }
+
+ assertNotNull( thrown );
+ assertEquals( AuthorizationException.class, thrown.getClass() );
+ assertTrue( thrown.getMessage().contains( ErrorWithReasonPhaseServlet.REASON ) );
+ }
+
+
+ public void testGetReasonPhase407()
+ throws Exception
+ {
+ Exception thrown = null;
+
+ try
+ {
+ Wagon wagon = getWagon();
+
+ Repository testRepository = new Repository();
+ testRepository.setUrl( "http://localhost:" + httpServerPort );
+
+ wagon.connect( testRepository );
+
+ File destFile = FileTestUtils.createUniqueFile( getName(), getName() );
+ destFile.deleteOnExit();
+
+ wagon.get( "/407", destFile );
+
+ wagon.disconnect();
+ }
+ catch ( Exception e )
+ {
+ thrown = e;
+ }
+ finally
+ {
+ stopServer();
+ }
+
+ assertNotNull( thrown );
+ assertEquals( AuthorizationException.class, thrown.getClass() );
+ assertTrue( thrown.getMessage().contains( ErrorWithReasonPhaseServlet.REASON ) );
+ }
+
+ public void testGetReasonPhase500()
+ throws Exception
+ {
+ Exception thrown = null;
+
+ try
+ {
+ Wagon wagon = getWagon();
+
+ Repository testRepository = new Repository();
+ testRepository.setUrl( "http://localhost:" + httpServerPort );
+
+ wagon.connect( testRepository );
+
+ File destFile = FileTestUtils.createUniqueFile( getName(), getName() );
+ destFile.deleteOnExit();
+
+ wagon.get( "/500", destFile );
+
+ wagon.disconnect();
+ }
+ catch ( Exception e )
+ {
+ thrown = e;
+ }
+ finally
+ {
+ stopServer();
+ }
+
+ assertNotNull( thrown );
+ assertEquals( TransferFailedException.class, thrown.getClass() );
+ assertTrue( thrown.getMessage().contains( ErrorWithReasonPhaseServlet.REASON ) );
+ }
+}
diff --git a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java
old mode 100755
new mode 100644
index bcfaf2e..a1f2bae
--- a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java
+++ b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.java
@@ -1,70 +1,70 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.util.Properties;
-
-import org.apache.maven.wagon.StreamingWagon;
-import org.apache.maven.wagon.http.HttpWagonTestCase;
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- */
-public class HttpWagonTest
- extends HttpWagonTestCase
-{
- protected String getProtocol()
- {
- return "http";
- }
-
- protected String getTestRepositoryUrl()
- {
- return getProtocol() + "://localhost:" + getTestRepositoryPort();
- }
-
- protected void setHttpHeaders( StreamingWagon wagon, Properties properties )
- {
- HttpConfiguration config = new HttpConfiguration();
-
- HttpMethodConfiguration methodConfiguration = new HttpMethodConfiguration();
- methodConfiguration.setHeaders( properties );
- config.setAll( methodConfiguration );
- ( (HttpWagon) wagon ).setHttpConfiguration( config );
- }
-
- @Override
- protected boolean supportPreemptiveAuthenticationPut()
- {
- return true;
- }
-
- @Override
- protected boolean supportPreemptiveAuthenticationGet()
- {
- return false;
- }
-
- @Override
- protected boolean supportProxyPreemptiveAuthentication()
- {
- return true;
- }
-}
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Properties;
+
+import org.apache.maven.wagon.StreamingWagon;
+import org.apache.maven.wagon.http.HttpWagonTestCase;
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ */
+public class HttpWagonTest
+ extends HttpWagonTestCase
+{
+ protected String getProtocol()
+ {
+ return "http";
+ }
+
+ protected String getTestRepositoryUrl()
+ {
+ return getProtocol() + "://localhost:" + getTestRepositoryPort();
+ }
+
+ protected void setHttpHeaders( StreamingWagon wagon, Properties properties )
+ {
+ HttpConfiguration config = new HttpConfiguration();
+
+ HttpMethodConfiguration methodConfiguration = new HttpMethodConfiguration();
+ methodConfiguration.setHeaders( properties );
+ config.setAll( methodConfiguration );
+ ( (HttpWagon) wagon ).setHttpConfiguration( config );
+ }
+
+ @Override
+ protected boolean supportPreemptiveAuthenticationPut()
+ {
+ return true;
+ }
+
+ @Override
+ protected boolean supportPreemptiveAuthenticationGet()
+ {
+ return false;
+ }
+
+ @Override
+ protected boolean supportProxyPreemptiveAuthentication()
+ {
+ return true;
+ }
+}
diff --git a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTimeoutTest.java b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTimeoutTest.java
index c223f23..ada6a49 100644
--- a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTimeoutTest.java
+++ b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTimeoutTest.java
@@ -1,218 +1,220 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.FileTestUtils;
-import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.repository.Repository;
-import org.mortbay.jetty.servlet.ServletHolder;
-
-import java.io.File;
-import java.util.Random;
-
-/**
- * User: jdumay Date: 24/01/2008 Time: 17:17:34
- */
-public class HttpWagonTimeoutTest
- extends HttpWagonHttpServerTestCase
-{
- protected void setUp()
- throws Exception
- {
- super.setUp();
- ServletHolder servlets = new ServletHolder( new WaitForeverServlet() );
- context.addServlet( servlets, "/*" );
- startServer();
- }
-
- public void testGetTimeout()
- throws Exception
- {
- Exception thrown = null;
-
- try
- {
- Wagon wagon = getWagon();
- wagon.setReadTimeout( 1000 );
-
- Repository testRepository = new Repository();
- testRepository.setUrl( "http://localhost:" + httpServerPort );
-
- wagon.connect( testRepository );
-
- File destFile = FileTestUtils.createUniqueFile( getName(), getName() );
- destFile.deleteOnExit();
-
- wagon.get( "/timeoutfile", destFile );
-
- wagon.disconnect();
- }
- catch ( Exception e )
- {
- thrown = e;
- }
- finally
- {
- stopServer();
- }
-
- assertNotNull( thrown );
- assertEquals( TransferFailedException.class, thrown.getClass() );
- }
-
- public void testResourceExits()
- throws Exception
- {
- Exception thrown = null;
-
- try
- {
- Wagon wagon = getWagon();
- wagon.setReadTimeout( 1000 );
-
- Repository testRepository = new Repository();
- testRepository.setUrl( "http://localhost:" + httpServerPort );
-
- wagon.connect( testRepository );
-
- wagon.resourceExists( "/timeoutfile" );
-
- wagon.disconnect();
- }
- catch ( Exception e )
- {
- thrown = e;
- }
- finally
- {
- stopServer();
- }
-
- assertNotNull( thrown );
- assertEquals( TransferFailedException.class, thrown.getClass() );
- }
-
- public void testGetFileList()
- throws Exception
- {
- Exception thrown = null;
-
- try
- {
- Wagon wagon = getWagon();
- wagon.setReadTimeout( 1000 );
-
- Repository testRepository = new Repository();
- testRepository.setUrl( "http://localhost:" + httpServerPort );
-
- wagon.connect( testRepository );
-
- wagon.getFileList( "/timeoutfile" );
-
- wagon.disconnect();
- }
- catch ( Exception e )
- {
- thrown = e;
- }
- finally
- {
- stopServer();
- }
-
- assertNotNull( thrown );
- assertEquals( TransferFailedException.class, thrown.getClass() );
- }
-
- public void testPutTimeout()
- throws Exception
- {
- Exception thrown = null;
-
- try
- {
- Wagon wagon = getWagon();
- wagon.setReadTimeout( 1000 );
-
- Repository testRepository = new Repository();
- testRepository.setUrl( "http://localhost:" + httpServerPort );
-
- wagon.connect( testRepository );
-
- File destFile = File.createTempFile( "Hello", null );
- destFile.deleteOnExit();
-
- wagon.put( destFile, "/timeoutfile" );
-
- wagon.disconnect();
- }
- catch ( Exception e )
- {
- thrown = e;
- }
- finally
- {
- stopServer();
- }
-
- assertNotNull( thrown );
- assertEquals( TransferFailedException.class, thrown.getClass() );
- }
-
- public void testConnectionTimeout()
- throws Exception
- {
- Exception thrown = null;
-
- try
- {
- HttpWagon wagon = (HttpWagon) getWagon();
- wagon.setHttpConfiguration(
- new HttpConfiguration().setAll( new HttpMethodConfiguration().setConnectionTimeout( 500 ) ) );
-
- Repository testRepository = new Repository();
- Random random = new Random( );
- testRepository.setUrl( "http://localhost:" + random.nextInt( 2048 ));
-
- wagon.connect( testRepository );
-
- long start = System.currentTimeMillis();
- wagon.getFileList( "/foobar" );
- long end = System.currentTimeMillis();
-
- // validate we have a default time out 60000
- assertTrue( (end - start) >= 500 && (end - start) < 1000 );
-
- }
- catch ( Exception e )
- {
- thrown = e;
- }
- finally
- {
- stopServer();
- }
-
- assertNotNull( thrown );
- assertEquals( TransferFailedException.class, thrown.getClass() );
- }
-
-}
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.FileTestUtils;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.repository.Repository;
+import org.eclipse.jetty.servlet.ServletHolder;
+
+import java.io.File;
+import java.util.Random;
+
+/**
+ * User: jdumay Date: 24/01/2008 Time: 17:17:34
+ */
+public class HttpWagonTimeoutTest
+ extends HttpWagonHttpServerTestCase
+{
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+ ServletHolder servlets = new ServletHolder( new WaitForeverServlet() );
+ context.addServlet( servlets, "/*" );
+ startServer();
+ }
+
+ public void testGetTimeout()
+ throws Exception
+ {
+ Exception thrown = null;
+
+ try
+ {
+ Wagon wagon = getWagon();
+ wagon.setReadTimeout( 1000 );
+
+ Repository testRepository = new Repository();
+ testRepository.setUrl( "http://localhost:" + httpServerPort );
+
+ wagon.connect( testRepository );
+
+ File destFile = FileTestUtils.createUniqueFile( getName(), getName() );
+ destFile.deleteOnExit();
+
+ wagon.get( "/timeoutfile", destFile );
+
+ wagon.disconnect();
+ }
+ catch ( Exception e )
+ {
+ thrown = e;
+ }
+ finally
+ {
+ stopServer();
+ }
+
+ assertNotNull( thrown );
+ assertEquals( TransferFailedException.class, thrown.getClass() );
+ }
+
+ public void testResourceExits()
+ throws Exception
+ {
+ Exception thrown = null;
+
+ try
+ {
+ Wagon wagon = getWagon();
+ wagon.setReadTimeout( 1000 );
+
+ Repository testRepository = new Repository();
+ testRepository.setUrl( "http://localhost:" + httpServerPort );
+
+ wagon.connect( testRepository );
+
+ wagon.resourceExists( "/timeoutfile" );
+
+ wagon.disconnect();
+ }
+ catch ( Exception e )
+ {
+ thrown = e;
+ }
+ finally
+ {
+ stopServer();
+ }
+
+ assertNotNull( thrown );
+ assertEquals( TransferFailedException.class, thrown.getClass() );
+ }
+
+ public void testGetFileList()
+ throws Exception
+ {
+ Exception thrown = null;
+
+ try
+ {
+ Wagon wagon = getWagon();
+ wagon.setReadTimeout( 1000 );
+
+ Repository testRepository = new Repository();
+ testRepository.setUrl( "http://localhost:" + httpServerPort );
+
+ wagon.connect( testRepository );
+
+ wagon.getFileList( "/timeoutfile" );
+
+ wagon.disconnect();
+ }
+ catch ( Exception e )
+ {
+ thrown = e;
+ }
+ finally
+ {
+ stopServer();
+ }
+
+ assertNotNull( thrown );
+ assertEquals( TransferFailedException.class, thrown.getClass() );
+ }
+
+ public void testPutTimeout()
+ throws Exception
+ {
+ Exception thrown = null;
+
+ try
+ {
+ Wagon wagon = getWagon();
+ wagon.setReadTimeout( 1000 );
+
+ Repository testRepository = new Repository();
+ testRepository.setUrl( "http://localhost:" + httpServerPort );
+
+ wagon.connect( testRepository );
+
+ File destFile = File.createTempFile( "Hello", null );
+ destFile.deleteOnExit();
+
+ wagon.put( destFile, "/timeoutfile" );
+
+ wagon.disconnect();
+ }
+ catch ( Exception e )
+ {
+ thrown = e;
+ }
+ finally
+ {
+ stopServer();
+ }
+
+ assertNotNull( thrown );
+ assertEquals( TransferFailedException.class, thrown.getClass() );
+ }
+
+ public void testConnectionTimeout()
+ throws Exception
+ {
+ Exception thrown = null;
+
+ try
+ {
+ HttpWagon wagon = (HttpWagon) getWagon();
+ wagon.setHttpConfiguration(
+ new HttpConfiguration().setAll( new HttpMethodConfiguration().setConnectionTimeout( 500 ) ) );
+
+ Repository testRepository = new Repository();
+ Random random = new Random( );
+ testRepository.setUrl( "http://localhost:" + random.nextInt( 2048 ));
+
+ wagon.connect( testRepository );
+
+ long start = System.currentTimeMillis();
+ wagon.getFileList( "/foobar" );
+ long end = System.currentTimeMillis();
+
+ wagon.disconnect();
+
+ // validate we have a default time out 60000
+ assertTrue( (end - start) >= 500 && (end - start) < 1000 );
+
+ }
+ catch ( Exception e )
+ {
+ thrown = e;
+ }
+ finally
+ {
+ stopServer();
+ }
+
+ assertNotNull( thrown );
+ assertEquals( TransferFailedException.class, thrown.getClass() );
+ }
+
+}
diff --git a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonPreemptiveTest.java b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonPreemptiveTest.java
index 396823b..e83d511 100644
--- a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonPreemptiveTest.java
+++ b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonPreemptiveTest.java
@@ -1,83 +1,83 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.Wagon;
-import org.mortbay.jetty.Connector;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.security.SslSocketConnector;
-
-public class HttpsWagonPreemptiveTest
- extends HttpWagonTest
-{
- protected String getProtocol()
- {
- return "https";
- }
-
- protected void addConnectors( Server server )
- {
- System.setProperty( "javax.net.ssl.trustStore",
- getTestFile( "src/test/resources/ssl/keystore" ).getAbsolutePath() );
-
- SslSocketConnector connector = new SslSocketConnector();
- connector.setPort( server.getConnectors()[0].getPort() );
- connector.setKeystore( getTestPath( "src/test/resources/ssl/keystore" ) );
- connector.setPassword( "wagonhttp" );
- connector.setKeyPassword( "wagonhttp" );
- connector.setTruststore( getTestPath( "src/test/resources/ssl/keystore" ) );
- connector.setTrustPassword( "wagonhttp" );
- server.setConnectors( new Connector[]{ connector } );
- }
-
- @Override
- protected Wagon getWagon()
- throws Exception
- {
- HttpWagon wagon = (HttpWagon) super.getWagon();
- wagon.setHttpConfiguration(
- new HttpConfiguration().setAll( new HttpMethodConfiguration().setUsePreemptive( true ) ) );
- return wagon;
- }
-
- @Override
- protected boolean supportPreemptiveAuthenticationPut()
- {
- return true;
- }
-
- @Override
- protected boolean supportPreemptiveAuthenticationGet()
- {
- return true;
- }
-
- @Override
- protected boolean supportProxyPreemptiveAuthentication()
- {
- return true;
- }
-
- @Override
- protected boolean assertOnTransferProgress()
- {
- return false;
- }
-}
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.Wagon;
+import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.ssl.SslSocketConnector;
+
+public class HttpsWagonPreemptiveTest
+ extends HttpWagonTest
+{
+ protected String getProtocol()
+ {
+ return "https";
+ }
+
+ protected void addConnectors( Server server )
+ {
+ System.setProperty( "javax.net.ssl.trustStore",
+ getTestFile( "src/test/resources/ssl/keystore" ).getAbsolutePath() );
+
+ SslSocketConnector connector = new SslSocketConnector();
+ connector.setPort( server.getConnectors()[0].getPort() );
+ connector.setKeystore( getTestPath( "src/test/resources/ssl/keystore" ) );
+ connector.setPassword( "wagonhttp" );
+ connector.setKeyPassword( "wagonhttp" );
+ connector.setTruststore( getTestPath( "src/test/resources/ssl/keystore" ) );
+ connector.setTrustPassword( "wagonhttp" );
+ server.setConnectors( new Connector[]{ connector } );
+ }
+
+ @Override
+ protected Wagon getWagon()
+ throws Exception
+ {
+ HttpWagon wagon = (HttpWagon) super.getWagon();
+ wagon.setHttpConfiguration(
+ new HttpConfiguration().setAll( new HttpMethodConfiguration().setUsePreemptive( true ) ) );
+ return wagon;
+ }
+
+ @Override
+ protected boolean supportPreemptiveAuthenticationPut()
+ {
+ return true;
+ }
+
+ @Override
+ protected boolean supportPreemptiveAuthenticationGet()
+ {
+ return true;
+ }
+
+ @Override
+ protected boolean supportProxyPreemptiveAuthentication()
+ {
+ return true;
+ }
+
+ @Override
+ protected boolean assertOnTransferProgress()
+ {
+ return false;
+ }
+}
diff --git a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonTest.java b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonTest.java
index c22b3ef..f19fa00 100644
--- a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonTest.java
+++ b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonTest.java
@@ -1,53 +1,53 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.mortbay.jetty.Connector;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.security.SslSocketConnector;
-
-public class HttpsWagonTest
- extends HttpWagonTest
-{
- protected String getProtocol()
- {
- return "https";
- }
-
- protected boolean assertOnTransferProgress()
- {
- return false;
- }
-
- protected void addConnectors( Server server )
- {
- System.setProperty( "javax.net.ssl.trustStore",
- getTestFile( "src/test/resources/ssl/keystore" ).getAbsolutePath() );
-
- SslSocketConnector connector = new SslSocketConnector();
- connector.setPort( server.getConnectors()[0].getPort() );
- connector.setKeystore( getTestPath( "src/test/resources/ssl/keystore" ) );
- connector.setPassword( "wagonhttp" );
- connector.setKeyPassword( "wagonhttp" );
- connector.setTruststore( getTestPath( "src/test/resources/ssl/keystore" ) );
- connector.setTrustPassword( "wagonhttp" );
- server.setConnectors( new Connector[]{ connector } );
- }
-}
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.ssl.SslSocketConnector;
+
+public class HttpsWagonTest
+ extends HttpWagonTest
+{
+ protected String getProtocol()
+ {
+ return "https";
+ }
+
+ protected boolean assertOnTransferProgress()
+ {
+ return false;
+ }
+
+ protected void addConnectors( Server server )
+ {
+ System.setProperty( "javax.net.ssl.trustStore",
+ getTestFile( "src/test/resources/ssl/keystore" ).getAbsolutePath() );
+
+ SslSocketConnector connector = new SslSocketConnector();
+ connector.setPort( server.getConnectors()[0].getPort() );
+ connector.setKeystore( getTestPath( "src/test/resources/ssl/keystore" ) );
+ connector.setPassword( "wagonhttp" );
+ connector.setKeyPassword( "wagonhttp" );
+ connector.setTruststore( getTestPath( "src/test/resources/ssl/keystore" ) );
+ connector.setTrustPassword( "wagonhttp" );
+ server.setConnectors( new Connector[]{ connector } );
+ }
+}
diff --git a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HugeFileDownloadTest.java b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HugeFileDownloadTest.java
index 0b6566d..3b1736f 100644
--- a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HugeFileDownloadTest.java
+++ b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HugeFileDownloadTest.java
@@ -1,176 +1,192 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.Assert;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.observers.Debug;
-import org.apache.maven.wagon.repository.Repository;
-import org.codehaus.plexus.PlexusTestCase;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.servlet.Context;
-import org.mortbay.jetty.servlet.DefaultServlet;
-import org.mortbay.jetty.servlet.ServletHolder;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-
-/**
- * @author Olivier Lamy
- */
-public class HugeFileDownloadTest
- extends PlexusTestCase
-{
-
- private static long HUGE_FILE_SIZE =
- Integer.valueOf( Integer.MAX_VALUE ).longValue() + Integer.valueOf( Integer.MAX_VALUE ).longValue();
-
- private Server server;
-
- public void testDownloadHugeFileWithContentLength()
- throws Exception
- {
- File hugeFile = new File( getBasedir(), "target/hugefile.txt" );
- if ( !hugeFile.exists() || hugeFile.length() < HUGE_FILE_SIZE )
- {
- makeHugeFile( hugeFile );
- }
-
- server = new Server( 0 );
-
- Context root = new Context( server, "/", Context.SESSIONS );
- root.setResourceBase( new File( getBasedir(), "target" ).getAbsolutePath() );
- ServletHolder servletHolder = new ServletHolder( new DefaultServlet() );
- root.addServlet( servletHolder, "/*" );
-
- server.start();
-
- File dest = null;
- try
- {
- Wagon wagon = getWagon();
- wagon.connect( new Repository( "id", "http://localhost:" + server.getConnectors()[0].getLocalPort() ) );
-
- dest = File.createTempFile( "huge", "txt" );
-
- wagon.get( "hugefile.txt", dest );
-
- Assert.assertTrue( dest.length() >= HUGE_FILE_SIZE );
-
- wagon.disconnect();
- }
- finally
- {
- server.start();
- dest.delete();
- hugeFile.delete();
- }
-
-
- }
-
- public void testDownloadHugeFileWithChunked()
- throws Exception
- {
- final File hugeFile = new File( getBasedir(), "target/hugefile.txt" );
- if ( !hugeFile.exists() || hugeFile.length() < HUGE_FILE_SIZE )
- {
- makeHugeFile( hugeFile );
- }
-
- server = new Server( 0 );
-
- Context root = new Context( server, "/", Context.SESSIONS );
- root.setResourceBase( new File( getBasedir(), "target" ).getAbsolutePath() );
- ServletHolder servletHolder = new ServletHolder( new HttpServlet()
- {
- @Override
- protected void doGet( HttpServletRequest req, HttpServletResponse resp )
- throws ServletException, IOException
- {
- FileInputStream fis = new FileInputStream( hugeFile );
-
- byte[] buffer = new byte[8192];
- int len = 0;
- while ( ( len = fis.read( buffer ) ) != -1 )
- {
- resp.getOutputStream().write( buffer, 0, len );
- }
- fis.close();
- }
- } );
- root.addServlet( servletHolder, "/*" );
-
- server.start();
-
- File dest = null;
- try
- {
- Wagon wagon = getWagon();
- wagon.connect( new Repository( "id", "http://localhost:" + server.getConnectors()[0].getLocalPort() ) );
-
- dest = File.createTempFile( "huge", "txt" );
-
- wagon.get( "hugefile.txt", dest );
-
- Assert.assertTrue( dest.length() >= HUGE_FILE_SIZE );
-
- wagon.disconnect();
- }
- finally
- {
- server.start();
- dest.delete();
- hugeFile.delete();
- }
-
-
- }
-
-
- protected Wagon getWagon()
- throws Exception
- {
- Wagon wagon = (Wagon) lookup( Wagon.ROLE, "http" );
-
- Debug debug = new Debug();
-
- wagon.addSessionListener( debug );
-
- return wagon;
- }
-
- private void makeHugeFile( File hugeFile )
- throws Exception
- {
- RandomAccessFile ra = new RandomAccessFile( hugeFile.getPath(), "rw" );
- ra.setLength( HUGE_FILE_SIZE + 1 );
- ra.seek( HUGE_FILE_SIZE );
- ra.write( 1 );
-
- }
-
-}
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.Assert;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.observers.Debug;
+import org.apache.maven.wagon.repository.Repository;
+import org.codehaus.plexus.PlexusTestCase;
+import org.codehaus.plexus.util.IOUtil;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+
+/**
+ * @author Olivier Lamy
+ */
+public class HugeFileDownloadTest
+ extends PlexusTestCase
+{
+
+ private static final Logger LOGGER = LoggerFactory.getLogger( HugeFileDownloadTest.class );
+
+ private static long HUGE_FILE_SIZE =
+ Integer.valueOf( Integer.MAX_VALUE ).longValue() + Integer.valueOf( Integer.MAX_VALUE ).longValue();
+
+ private Server server;
+
+ public void testDownloadHugeFileWithContentLength()
+ throws Exception
+ {
+ final File hugeFile = new File( getBasedir(), "target/hugefile.txt" );
+ if ( !hugeFile.exists() || hugeFile.length() < HUGE_FILE_SIZE )
+ {
+ makeHugeFile( hugeFile );
+ }
+
+ server = new Server( 0 );
+
+ ServletContextHandler root = new ServletContextHandler( ServletContextHandler.SESSIONS );
+ root.setResourceBase( new File( getBasedir(), "target" ).getAbsolutePath() );
+ ServletHolder servletHolder = new ServletHolder( new HttpServlet()
+ {
+ @Override
+ protected void doGet( HttpServletRequest req, HttpServletResponse resp )
+ throws ServletException, IOException
+ {
+ FileInputStream fis = new FileInputStream( hugeFile );
+
+ resp.addHeader( "Content-Length", String.valueOf( hugeFile.length() ) );
+ IOUtil.copy( fis, resp.getOutputStream() );
+ fis.close();
+ }
+ } );
+ root.addServlet( servletHolder, "/*" );
+ server.setHandler( root );
+
+ server.start();
+
+ File dest = null;
+ try
+ {
+ Wagon wagon = getWagon();
+ wagon.connect( new Repository( "id", "http://localhost:" + server.getConnectors()[0].getLocalPort() ) );
+
+ dest = File.createTempFile( "huge", "txt" );
+
+ LOGGER.info( "Fetching 'hugefile.txt' with content length" );
+ wagon.get( "hugefile.txt", dest );
+
+ Assert.assertTrue( dest.length() >= HUGE_FILE_SIZE );
+ LOGGER.info( "The file was successfully fetched" );
+
+ wagon.disconnect();
+ }
+ finally
+ {
+ server.stop();
+ dest.delete();
+ hugeFile.delete();
+ }
+
+ }
+
+ public void testDownloadHugeFileWithChunked()
+ throws Exception
+ {
+ final File hugeFile = new File( getBasedir(), "target/hugefile.txt" );
+ if ( !hugeFile.exists() || hugeFile.length() < HUGE_FILE_SIZE )
+ {
+ makeHugeFile( hugeFile );
+ }
+
+ server = new Server( 0 );
+
+ ServletContextHandler root = new ServletContextHandler( ServletContextHandler.SESSIONS );
+ root.setResourceBase( new File( getBasedir(), "target" ).getAbsolutePath() );
+ ServletHolder servletHolder = new ServletHolder( new HttpServlet()
+ {
+ @Override
+ protected void doGet( HttpServletRequest req, HttpServletResponse resp )
+ throws ServletException, IOException
+ {
+ FileInputStream fis = new FileInputStream( hugeFile );
+
+ IOUtil.copy( fis, resp.getOutputStream() );
+ fis.close();
+ }
+ } );
+ root.addServlet( servletHolder, "/*" );
+ server.setHandler( root );
+
+ server.start();
+
+ File dest = null;
+ try
+ {
+ Wagon wagon = getWagon();
+ wagon.connect( new Repository( "id", "http://localhost:" + server.getConnectors()[0].getLocalPort() ) );
+
+ dest = File.createTempFile( "huge", "txt" );
+
+ LOGGER.info( "Fetching 'hugefile.txt' in chunks" );
+ wagon.get( "hugefile.txt", dest );
+
+ Assert.assertTrue( dest.length() >= HUGE_FILE_SIZE );
+ LOGGER.info( "The file was successfully fetched" );
+
+ wagon.disconnect();
+ }
+ finally
+ {
+ server.stop();
+ dest.delete();
+ hugeFile.delete();
+ }
+
+ }
+
+ protected Wagon getWagon()
+ throws Exception
+ {
+ Wagon wagon = (Wagon) lookup( Wagon.ROLE, "http" );
+
+ Debug debug = new Debug();
+
+ wagon.addSessionListener( debug );
+
+ return wagon;
+ }
+
+ private void makeHugeFile( File hugeFile )
+ throws Exception
+ {
+ LOGGER.info( "Creating test file" );
+ RandomAccessFile ra = new RandomAccessFile( hugeFile.getPath(), "rw" );
+ ra.setLength( HUGE_FILE_SIZE + 1L );
+ ra.seek( HUGE_FILE_SIZE );
+ ra.write( 1 );
+ ra.close();
+ LOGGER.info( "Test file created" );
+ }
+
+}
diff --git a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/TckTest.java b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/TckTest.java
index dc56e31..3369e47 100644
--- a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/TckTest.java
+++ b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/TckTest.java
@@ -1,35 +1,35 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.tck.http.GetWagonTests;
-import org.apache.maven.wagon.tck.http.HttpsGetWagonTests;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * This test will run the TCK suite on wagon-http-lightweight
- */
- at RunWith( Suite.class )
- at Suite.SuiteClasses( { GetWagonTests.class, HttpsGetWagonTests.class } )
-public class TckTest
-{
- // no op
-}
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.tck.http.GetWagonTests;
+import org.apache.maven.wagon.tck.http.HttpsGetWagonTests;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * This test will run the TCK suite on wagon-http-lightweight
+ */
+ at RunWith( Suite.class )
+ at Suite.SuiteClasses( { GetWagonTests.class, HttpsGetWagonTests.class } )
+public class TckTest
+{
+ // no op
+}
diff --git a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/WaitForeverServlet.java b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/WaitForeverServlet.java
index 9ca3b98..fb07fae 100644
--- a/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/WaitForeverServlet.java
+++ b/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/WaitForeverServlet.java
@@ -1,54 +1,55 @@
-package org.apache.maven.wagon.providers.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.log4j.Logger;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-/**
- * User: jdumay
- * Date: 24/01/2008
- * Time: 17:25:27
- */
-public class WaitForeverServlet
- extends HttpServlet
-{
-
- private Logger logger = Logger.getLogger( WaitForeverServlet.class );
-
- public void service( HttpServletRequest request, HttpServletResponse response )
- throws ServletException, IOException
- {
- logger.info( "Calling WaitForeverServlet" );
- try
- {
- Thread.sleep( 2000 );
- }
- catch ( InterruptedException e )
- {
- //eat
- }
- }
-}
+package org.apache.maven.wagon.providers.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * User: jdumay
+ * Date: 24/01/2008
+ * Time: 17:25:27
+ */
+public class WaitForeverServlet
+ extends HttpServlet
+{
+
+ private Logger logger = LoggerFactory.getLogger( WaitForeverServlet.class );
+
+ public void service( HttpServletRequest request, HttpServletResponse response )
+ throws ServletException, IOException
+ {
+ logger.info( "Calling WaitForeverServlet" );
+ try
+ {
+ Thread.sleep( 2000 );
+ }
+ catch ( InterruptedException e )
+ {
+ //eat
+ }
+ }
+}
diff --git a/wagon-providers/wagon-http/src/test/resources/META-INF/plexus/components.xml b/wagon-providers/wagon-http/src/test/resources/META-INF/plexus/components.xml
index 8c4cc2f..fdc761b 100644
--- a/wagon-providers/wagon-http/src/test/resources/META-INF/plexus/components.xml
+++ b/wagon-providers/wagon-http/src/test/resources/META-INF/plexus/components.xml
@@ -1,38 +1,38 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<component-set>
- <components>
- <component>
- <role>org.apache.maven.wagon.tck.http.WagonTestCaseConfigurator</role>
- <implementation>org.apache.maven.wagon.tck.http.WagonTestCaseConfigurator</implementation>
- <configuration>
- <wagonHint>http</wagonHint>
- <useCaseConfigs>
- <highLatencyLowTimeout>
- <unsupported/>
- </highLatencyLowTimeout>
- <inifiniteLatencyTimeout>
- <unsupported/>
- </inifiniteLatencyTimeout>
- </useCaseConfigs>
- </configuration>
- </component>
- </components>
-</component-set>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<component-set>
+ <components>
+ <component>
+ <role>org.apache.maven.wagon.tck.http.WagonTestCaseConfigurator</role>
+ <implementation>org.apache.maven.wagon.tck.http.WagonTestCaseConfigurator</implementation>
+ <configuration>
+ <wagonHint>http</wagonHint>
+ <useCaseConfigs>
+ <highLatencyLowTimeout>
+ <unsupported/>
+ </highLatencyLowTimeout>
+ <inifiniteLatencyTimeout>
+ <unsupported/>
+ </inifiniteLatencyTimeout>
+ </useCaseConfigs>
+ </configuration>
+ </component>
+ </components>
+</component-set>
diff --git a/wagon-providers/wagon-http/src/test/resources/log4j.xml b/wagon-providers/wagon-http/src/test/resources/log4j.xml
index dd6eb4f..9982a14 100644
--- a/wagon-providers/wagon-http/src/test/resources/log4j.xml
+++ b/wagon-providers/wagon-http/src/test/resources/log4j.xml
@@ -1,47 +1,47 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
-
- <appender name="console" class="org.apache.log4j.ConsoleAppender">
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d [%t] %-5p %c %x - %m%n"/>
- </layout>
- </appender>
-
- <logger name="org.apache.http.headers">
- <level value="debug"/>
- </logger>
-
- <logger name="org.apache.http">
- <level value="info"/>
- </logger>
-
- <logger name="org.apache.http.wire">
- <level value="info"/>
- </logger>
-
- <root>
- <priority value ="info" />
- <appender-ref ref="console" />
- </root>
-
-</log4j:configuration>
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d [%t] %-5p %c %x - %m%n"/>
+ </layout>
+ </appender>
+
+ <logger name="org.apache.http.headers">
+ <level value="debug"/>
+ </logger>
+
+ <logger name="org.apache.http">
+ <level value="info"/>
+ </logger>
+
+ <logger name="org.apache.http.wire">
+ <level value="info"/>
+ </logger>
+
+ <root>
+ <priority value ="info" />
+ <appender-ref ref="console" />
+ </root>
+
+</log4j:configuration>
diff --git a/wagon-providers/wagon-scm/pom.xml b/wagon-providers/wagon-scm/pom.xml
index 37154ef..d48b189 100644
--- a/wagon-providers/wagon-scm/pom.xml
+++ b/wagon-providers/wagon-scm/pom.xml
@@ -1,85 +1,87 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-providers</artifactId>
- <version>2.10</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>wagon-scm</artifactId>
- <name>Apache Maven Wagon :: Providers :: SCM Provider</name>
- <description>
- Wagon provider that gets and puts artifacts using a Source Control Management system
- </description>
-
- <properties>
- <mavenScmVersion>1.5</mavenScmVersion>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.maven.scm</groupId>
- <artifactId>maven-scm-api</artifactId>
- <version>${mavenScmVersion}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.scm</groupId>
- <artifactId>maven-scm-manager-plexus</artifactId>
- <version>${mavenScmVersion}</version>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.scm</groupId>
- <artifactId>maven-scm-test</artifactId>
- <version>${mavenScmVersion}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.scm</groupId>
- <artifactId>maven-scm-provider-cvsexe</artifactId>
- <version>${mavenScmVersion}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.scm</groupId>
- <artifactId>maven-scm-provider-svnexe</artifactId>
- <version>${mavenScmVersion}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <excludes>
- <!-- disable testing the CVS SCM as CVS is broken -->
- <exclude>**/*Cvs*.java</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-providers</artifactId>
+ <version>2.12</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>wagon-scm</artifactId>
+ <name>Apache Maven Wagon :: Providers :: SCM Provider</name>
+ <description>
+ Wagon provider that gets and puts artifacts using a Source Control Management system
+ </description>
+
+ <properties>
+ <mavenScmVersion>1.9.5</mavenScmVersion>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.scm</groupId>
+ <artifactId>maven-scm-api</artifactId>
+ <version>${mavenScmVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.scm</groupId>
+ <artifactId>maven-scm-manager-plexus</artifactId>
+ <version>${mavenScmVersion}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.scm</groupId>
+ <artifactId>maven-scm-provider-cvsexe</artifactId>
+ <version>${mavenScmVersion}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.scm</groupId>
+ <artifactId>maven-scm-provider-svnexe</artifactId>
+ <version>${mavenScmVersion}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <!-- disable testing the CVS SCM as CVS is broken -->
+ <exclude>**/*Cvs*.java</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/wagon-providers/wagon-scm/src/main/java/org/apache/maven/wagon/providers/scm/ScmWagon.java b/wagon-providers/wagon-scm/src/main/java/org/apache/maven/wagon/providers/scm/ScmWagon.java
index edbb061..d9e0330 100644
--- a/wagon-providers/wagon-scm/src/main/java/org/apache/maven/wagon/providers/scm/ScmWagon.java
+++ b/wagon-providers/wagon-scm/src/main/java/org/apache/maven/wagon/providers/scm/ScmWagon.java
@@ -1,778 +1,778 @@
-package org.apache.maven.wagon.providers.scm;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.scm.ScmBranch;
-import org.apache.maven.scm.ScmException;
-import org.apache.maven.scm.ScmFile;
-import org.apache.maven.scm.ScmFileSet;
-import org.apache.maven.scm.ScmResult;
-import org.apache.maven.scm.ScmRevision;
-import org.apache.maven.scm.ScmTag;
-import org.apache.maven.scm.ScmVersion;
-import org.apache.maven.scm.command.add.AddScmResult;
-import org.apache.maven.scm.command.checkout.CheckOutScmResult;
-import org.apache.maven.scm.command.list.ListScmResult;
-import org.apache.maven.scm.manager.NoSuchScmProviderException;
-import org.apache.maven.scm.manager.ScmManager;
-import org.apache.maven.scm.provider.ScmProvider;
-import org.apache.maven.scm.provider.ScmProviderRepository;
-import org.apache.maven.scm.provider.ScmProviderRepositoryWithHost;
-import org.apache.maven.scm.repository.ScmRepository;
-import org.apache.maven.scm.repository.ScmRepositoryException;
-import org.apache.maven.wagon.AbstractWagon;
-import org.apache.maven.wagon.ConnectionException;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
-import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.authorization.AuthorizationException;
-import org.apache.maven.wagon.events.TransferEvent;
-import org.apache.maven.wagon.resource.Resource;
-import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.StringUtils;
-
-import java.io.File;
-import java.io.IOException;
-import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Random;
-import java.util.Stack;
-
-/**
- * Wagon provider to get and put files from and to SCM systems, using Maven-SCM as underlying transport.
- * <p/>
- * TODO it probably creates problems if the same wagon is used in two different SCM protocols, as instance variables can
- * keep incorrect state.
- * TODO: For doing releases, we either have to be able to add files with checking out the repository structure which may not be
- * possible, or the checkout directory needs to be a constant. Doing releases won't scale if you have to checkout the
- * whole repository structure in order to add 3 files.
- *
- * @author <a href="brett at apache.org">Brett Porter</a>
- * @author <a href="evenisse at apache.org">Emmanuel Venisse</a>
- * @author <a href="carlos at apache.org">Carlos Sanchez</a>
- * @author Jason van Zyl
- *
- * @plexus.component role="org.apache.maven.wagon.Wagon" role-hint="scm" instantiation-strategy="per-lookup"
- */
-public class ScmWagon
- extends AbstractWagon
-{
- /**
- * @plexus.requirement
- */
- private volatile ScmManager scmManager;
-
- /**
- * The SCM version, if any.
- *
- * @parameter
- */
- private String scmVersion;
-
- /**
- * The SCM version type, if any. Defaults to "branch".
- *
- * @parameter
- */
- private String scmVersionType;
-
- private File checkoutDirectory;
-
- /**
- * Get the {@link ScmManager} used in this Wagon
- *
- * @return the {@link ScmManager}
- */
- public ScmManager getScmManager()
- {
- return scmManager;
- }
-
- /**
- * Set the {@link ScmManager} used in this Wagon
- *
- * @param scmManager
- */
- public void setScmManager( ScmManager scmManager )
- {
- this.scmManager = scmManager;
- }
-
- /**
- * Get the scmVersion used in this Wagon
- *
- * @return the scmVersion
- */
- public String getScmVersion()
- {
- return scmVersion;
- }
-
- /**
- * Set the scmVersion
- *
- * @param scmVersion the scmVersion to set
- */
- public void setScmVersion( String scmVersion )
- {
- this.scmVersion = scmVersion;
- }
-
- /**
- * Get the scmVersionType used in this Wagon
- *
- * @return the scmVersionType
- */
- public String getScmVersionType()
- {
- return scmVersionType;
- }
-
- /**
- * Set the scmVersionType
- *
- * @param scmVersionType the scmVersionType to set
- */
- public void setScmVersionType( String scmVersionType )
- {
- this.scmVersionType = scmVersionType;
- }
-
- /**
- * Get the directory where Wagon will checkout files from SCM. This directory will be deleted!
- *
- * @return directory
- */
- public File getCheckoutDirectory()
- {
- return checkoutDirectory;
- }
-
- /**
- * Set the directory where Wagon will checkout files from SCM. This directory will be deleted!
- *
- * @param checkoutDirectory
- */
- public void setCheckoutDirectory( File checkoutDirectory )
- {
- this.checkoutDirectory = checkoutDirectory;
- }
-
- /**
- * Convenience method to get the {@link ScmProvider} implementation to handle the provided SCM type
- *
- * @param scmType type of SCM, eg. <code>svn</code>, <code>cvs</code>
- * @return the {@link ScmProvider} that will handle provided SCM type
- * @throws NoSuchScmProviderException if there is no {@link ScmProvider} able to handle that SCM type
- */
- public ScmProvider getScmProvider( String scmType )
- throws NoSuchScmProviderException
- {
- return getScmManager().getProviderByType( scmType );
- }
-
- /**
- * This will cleanup the checkout directory
- */
- public void openConnectionInternal()
- throws ConnectionException
- {
- if ( checkoutDirectory == null )
- {
- checkoutDirectory = createCheckoutDirectory();
- }
-
- if ( checkoutDirectory.exists() )
- {
- removeCheckoutDirectory();
- }
-
- checkoutDirectory.mkdirs();
- }
-
- private File createCheckoutDirectory()
- {
- File checkoutDirectory;
-
- DecimalFormat fmt = new DecimalFormat( "#####" );
-
- Random rand = new Random( System.currentTimeMillis() + Runtime.getRuntime().freeMemory() );
-
- synchronized ( rand )
- {
- do
- {
- checkoutDirectory = new File( System.getProperty( "java.io.tmpdir" ),
- "wagon-scm" + fmt.format( Math.abs( rand.nextInt() ) ) + ".checkout" );
- }
- while ( checkoutDirectory.exists() );
- }
-
- return checkoutDirectory;
- }
-
-
- private void removeCheckoutDirectory()
- throws ConnectionException
- {
- if ( checkoutDirectory == null )
- {
- return; // Silently return.
- }
-
- try
- {
- FileUtils.deleteDirectory( checkoutDirectory );
- }
- catch ( IOException e )
- {
- throw new ConnectionException( "Unable to cleanup checkout directory", e );
- }
- }
-
- /**
- * Construct the ScmVersion to use for operations.
- * <p/>
- * <p>If scmVersion is supplied, scmVersionType must also be supplied to
- * take effect.</p>
- */
- private ScmVersion makeScmVersion()
- {
- if ( StringUtils.isBlank( scmVersion ) )
- {
- return null;
- }
- if ( scmVersion.length() > 0 )
- {
- if ( "revision".equals( scmVersionType ) )
- {
- return new ScmRevision( scmVersion );
- }
- else if ( "tag".equals( scmVersionType ) )
- {
- return new ScmTag( scmVersion );
- }
- else if ( "branch".equals( scmVersionType ) )
- {
- return new ScmBranch( scmVersion );
- }
- }
-
- return null;
- }
-
- private ScmRepository getScmRepository( String url )
- throws ScmRepositoryException, NoSuchScmProviderException
- {
- String username = null;
-
- String password = null;
-
- String privateKey = null;
-
- String passphrase = null;
-
- if ( authenticationInfo != null )
- {
- username = authenticationInfo.getUserName();
-
- password = authenticationInfo.getPassword();
-
- privateKey = authenticationInfo.getPrivateKey();
-
- passphrase = authenticationInfo.getPassphrase();
- }
-
- ScmRepository scmRepository = getScmManager().makeScmRepository( url );
-
- ScmProviderRepository providerRepository = scmRepository.getProviderRepository();
-
- if ( StringUtils.isNotEmpty( username ) )
- {
- providerRepository.setUser( username );
- }
-
- if ( StringUtils.isNotEmpty( password ) )
- {
- providerRepository.setPassword( password );
- }
-
- if ( providerRepository instanceof ScmProviderRepositoryWithHost )
- {
- ScmProviderRepositoryWithHost providerRepo = (ScmProviderRepositoryWithHost) providerRepository;
-
- if ( StringUtils.isNotEmpty( privateKey ) )
- {
- providerRepo.setPrivateKey( privateKey );
- }
-
- if ( StringUtils.isNotEmpty( passphrase ) )
- {
- providerRepo.setPassphrase( passphrase );
- }
- }
-
- return scmRepository;
- }
-
- public void put( File source, String targetName )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- if ( source.isDirectory() )
- {
- throw new IllegalArgumentException( "Source is a directory: " + source );
- }
- putInternal( source, targetName );
- }
-
- /**
- * Puts both files and directories
- *
- * @param source
- * @param targetName
- * @throws TransferFailedException
- */
- private void putInternal( File source, String targetName )
- throws TransferFailedException
- {
- Resource target = new Resource( targetName );
-
- firePutInitiated( target, source );
-
- try
- {
- ScmRepository scmRepository = getScmRepository( getRepository().getUrl() );
-
- target.setContentLength( source.length() );
- target.setLastModified( source.lastModified() );
-
- firePutStarted( target, source );
-
- String msg = "Wagon: Adding " + source.getName() + " to repository";
-
- ScmProvider scmProvider = getScmProvider( scmRepository.getProvider() );
-
- String checkoutTargetName = source.isDirectory() ? targetName : getDirname( targetName );
- String relPath = checkOut( scmProvider, scmRepository, checkoutTargetName, target );
-
- File newCheckoutDirectory = new File( checkoutDirectory, relPath );
-
- File scmFile = new File( newCheckoutDirectory, source.isDirectory() ? "" : getFilename( targetName ) );
-
- boolean fileAlreadyInScm = scmFile.exists();
-
- if ( !scmFile.equals( source ) )
- {
- if ( source.isDirectory() )
- {
- FileUtils.copyDirectoryStructure( source, scmFile );
- }
- else
- {
- FileUtils.copyFile( source, scmFile );
- }
- }
-
- if ( !fileAlreadyInScm || scmFile.isDirectory() )
- {
- int addedFiles = addFiles( scmProvider, scmRepository, newCheckoutDirectory,
- source.isDirectory() ? "" : scmFile.getName() );
-
- if ( !fileAlreadyInScm && addedFiles == 0 )
- {
- throw new ScmException(
- "Unable to add file to SCM: " + scmFile + "; see error messages above for more information" );
- }
- }
-
- ScmResult result =
- scmProvider.checkIn( scmRepository, new ScmFileSet( checkoutDirectory ), makeScmVersion(), msg );
-
- checkScmResult( result );
- }
- catch ( ScmException e )
- {
- fireTransferError( target, e, TransferEvent.REQUEST_GET );
-
- throw new TransferFailedException( "Error interacting with SCM: " + e.getMessage(), e );
- }
- catch ( IOException e )
- {
- fireTransferError( target, e, TransferEvent.REQUEST_GET );
-
- throw new TransferFailedException( "Error interacting with SCM: " + e.getMessage(), e );
- }
-
- if ( source.isFile() )
- {
- postProcessListeners( target, source, TransferEvent.REQUEST_PUT );
- }
-
- firePutCompleted( target, source );
- }
-
- /**
- * Returns the relative path to targetName in the checkout dir. If the targetName already exists in the scm, this
- * will be the empty string.
- *
- * @param scmProvider
- * @param scmRepository
- * @param targetName
- * @return
- * @throws TransferFailedException
- */
- private String checkOut( ScmProvider scmProvider, ScmRepository scmRepository, String targetName,
- Resource resource )
- throws TransferFailedException
- {
- checkoutDirectory = createCheckoutDirectory();
-
- Stack<String> stack = new Stack<String>();
-
- String target = targetName;
-
- // totally ignore scmRepository parent stuff since that is not supported by all scms.
- // Instead, assume that that url exists. If not, then that's an error.
- // Check whether targetName, which is a relative path into the scm, exists.
- // If it doesn't, check the parent, etc.
-
- try
- {
- while ( target.length() > 0 && !scmProvider.list( scmRepository,
- new ScmFileSet( new File( "." ), new File( target ) ),
- false, makeScmVersion() ).isSuccess() )
- {
- stack.push( getFilename( target ) );
- target = getDirname( target );
- }
- }
- catch ( ScmException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
-
- throw new TransferFailedException( "Error listing repository: " + e.getMessage(), e );
- }
-
- // ok, we've established that target exists, or is empty.
- // Check the resource out; if it doesn't exist, that means we're in the svn repo url root,
- // and the configuration is incorrect. We will not try repo.getParent since most scm's don't
- // implement that.
-
- try
- {
- String repoUrl = getRepository().getUrl();
- if ( "svn".equals( scmProvider.getScmType() ) )
- {
- // Subversion is the only SCM that adds path structure to represent tags and branches.
- // The rest use scmVersion and scmVersionType.
- repoUrl += "/" + target.replace( '\\', '/' );
- }
- scmRepository = getScmRepository( repoUrl );
- CheckOutScmResult ret =
- scmProvider.checkOut( scmRepository, new ScmFileSet( new File( checkoutDirectory, "" ) ),
- makeScmVersion(), false );
-
- checkScmResult( ret );
- }
- catch ( ScmException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
-
- throw new TransferFailedException( "Error checking out: " + e.getMessage(), e );
- }
-
- // now create the subdirs in target, if it's a parent of targetName
-
- String relPath = "";
-
- while ( !stack.isEmpty() )
- {
- String p = stack.pop();
- relPath += p + "/";
-
- File newDir = new File( checkoutDirectory, relPath );
- if ( !newDir.mkdirs() )
- {
- throw new TransferFailedException(
- "Failed to create directory " + newDir.getAbsolutePath() + "; parent should exist: "
- + checkoutDirectory );
- }
-
- try
- {
- addFiles( scmProvider, scmRepository, checkoutDirectory, relPath );
- }
- catch ( ScmException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
-
- throw new TransferFailedException( "Failed to add directory " + newDir + " to working copy", e );
- }
- }
-
- return relPath;
- }
-
- /**
- * Add a file or directory to a SCM repository. If it's a directory all its contents are added recursively.
- * <p/>
- * TODO this is less than optimal, SCM API should provide a way to add a directory recursively
- *
- * @param scmProvider SCM provider
- * @param scmRepository SCM repository
- * @param basedir local directory corresponding to scmRepository
- * @param scmFilePath path of the file or directory to add, relative to basedir
- * @return the number of files added.
- * @throws ScmException
- */
- private int addFiles( ScmProvider scmProvider, ScmRepository scmRepository, File basedir, String scmFilePath )
- throws ScmException
- {
- int addedFiles = 0;
-
- File scmFile = new File( basedir, scmFilePath );
-
- if ( scmFilePath.length() != 0 )
- {
- AddScmResult result = scmProvider.add( scmRepository, new ScmFileSet( basedir, new File( scmFilePath ) ) );
-
- /*
- * TODO dirty fix to work around files with property svn:eol-style=native if a file has that property, first
- * time file is added it fails, second time it succeeds the solution is check if the scm provider is svn and
- * unset that property when the SCM API allows it
- */
- if ( !result.isSuccess() )
- {
- result = scmProvider.add( scmRepository, new ScmFileSet( basedir, new File( scmFilePath ) ) );
- }
-
- addedFiles = result.getAddedFiles().size();
- }
-
- String reservedScmFile = scmProvider.getScmSpecificFilename();
-
- if ( scmFile.isDirectory() )
- {
- for ( File file : scmFile.listFiles() )
- {
- if ( reservedScmFile != null && !reservedScmFile.equals( file.getName() ) )
- {
- addedFiles += addFiles( scmProvider, scmRepository, basedir,
- ( scmFilePath.length() == 0 ? "" : scmFilePath + "/" )
- + file.getName() );
- }
- }
- }
-
- return addedFiles;
- }
-
- /**
- * @return true
- */
- public boolean supportsDirectoryCopy()
- {
- return true;
- }
-
- public void putDirectory( File sourceDirectory, String destinationDirectory )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- if ( !sourceDirectory.isDirectory() )
- {
- throw new IllegalArgumentException( "Source is not a directory: " + sourceDirectory );
- }
-
- putInternal( sourceDirectory, destinationDirectory );
- }
-
- /**
- * Check that the ScmResult was a successful operation
- *
- * @param result
- * @throws TransferFailedException if result was not a successful operation
- * @throws ScmException
- */
- private void checkScmResult( ScmResult result )
- throws ScmException
- {
- if ( !result.isSuccess() )
- {
- throw new ScmException(
- "Unable to commit file. " + result.getProviderMessage() + " " + ( result.getCommandOutput() == null
- ? ""
- : result.getCommandOutput() ) );
- }
- }
-
- public void closeConnection()
- throws ConnectionException
- {
- removeCheckoutDirectory();
- }
-
- /**
- * Not implemented
- *
- * @throws UnsupportedOperationException always
- */
- public boolean getIfNewer( String resourceName, File destination, long timestamp )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- throw new UnsupportedOperationException( "Not currently supported: getIfNewer" );
- }
-
- public void get( String resourceName, File destination )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- Resource resource = new Resource( resourceName );
-
- fireGetInitiated( resource, destination );
-
- String url = getRepository().getUrl() + "/" + resourceName;
-
- // remove the file
- url = url.substring( 0, url.lastIndexOf( '/' ) );
-
- try
- {
- ScmRepository scmRepository = getScmRepository( url );
-
- fireGetStarted( resource, destination );
-
- // TODO: limitations:
- // - destination filename must match that in the repository - should allow the "-d" CVS equiv to be passed
- // in
- // - we don't get granular exceptions from SCM (ie, auth, not found)
- // - need to make it non-recursive to save time
- // - exists() check doesn't test if it is in SCM already
-
- File scmFile = new File( checkoutDirectory, resourceName );
-
- File basedir = scmFile.getParentFile();
-
- ScmProvider scmProvider = getScmProvider( scmRepository.getProvider() );
-
- String reservedScmFile = scmProvider.getScmSpecificFilename();
-
- if ( reservedScmFile != null && new File( basedir, reservedScmFile ).exists() )
- {
- scmProvider.update( scmRepository, new ScmFileSet( basedir ), makeScmVersion() );
- }
- else
- {
- // TODO: this should be checking out a full hierarchy (requires the -d equiv)
- basedir.mkdirs();
-
- scmProvider.checkOut( scmRepository, new ScmFileSet( basedir ), makeScmVersion() );
- }
-
- if ( !scmFile.exists() )
- {
- throw new ResourceDoesNotExistException( "Unable to find resource " + destination + " after checkout" );
- }
-
- if ( !scmFile.equals( destination ) )
- {
- FileUtils.copyFile( scmFile, destination );
- }
- }
- catch ( ScmException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_GET );
-
- throw new TransferFailedException( "Error getting file from SCM", e );
- }
- catch ( IOException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_GET );
-
- throw new TransferFailedException( "Error getting file from SCM", e );
- }
-
- postProcessListeners( resource, destination, TransferEvent.REQUEST_GET );
-
- fireGetCompleted( resource, destination );
- }
-
- /**
- * @return a List<String> with filenames/directories at the resourcepath.
- * @see org.apache.maven.wagon.AbstractWagon#getFileList(java.lang.String)
- */
- public List<String> getFileList( String resourcePath )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- try
- {
- ScmRepository repository = getScmRepository( getRepository().getUrl() );
-
- ScmProvider provider = getScmProvider( repository.getProvider() );
-
- ListScmResult result =
- provider.list( repository, new ScmFileSet( new File( "." ), new File( resourcePath ) ), false,
- makeScmVersion() );
-
- if ( !result.isSuccess() )
- {
- throw new ResourceDoesNotExistException( result.getProviderMessage() );
- }
-
- List<String> files = new ArrayList<String>();
-
- for ( ScmFile f : result.getFiles() )
- {
- files.add( f.getPath() );
- }
-
- return files;
- }
- catch ( ScmException e )
- {
- throw new TransferFailedException( "Error getting filelist from SCM", e );
- }
- }
-
- public boolean resourceExists( String resourceName )
- throws TransferFailedException, AuthorizationException
- {
- try
- {
- getFileList( resourceName );
-
- return true;
- }
- catch ( ResourceDoesNotExistException e )
- {
- return false;
- }
- }
-
- private String getFilename( String filename )
- {
- String fname = StringUtils.replace( filename, "/", File.separator );
- return FileUtils.filename( fname );
- }
-
- private String getDirname( String filename )
- {
- String fname = StringUtils.replace( filename, "/", File.separator );
- return FileUtils.dirname( fname );
- }
-}
+package org.apache.maven.wagon.providers.scm;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.scm.ScmBranch;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFile;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.ScmRevision;
+import org.apache.maven.scm.ScmTag;
+import org.apache.maven.scm.ScmVersion;
+import org.apache.maven.scm.command.add.AddScmResult;
+import org.apache.maven.scm.command.checkout.CheckOutScmResult;
+import org.apache.maven.scm.command.list.ListScmResult;
+import org.apache.maven.scm.manager.NoSuchScmProviderException;
+import org.apache.maven.scm.manager.ScmManager;
+import org.apache.maven.scm.provider.ScmProvider;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.ScmProviderRepositoryWithHost;
+import org.apache.maven.scm.repository.ScmRepository;
+import org.apache.maven.scm.repository.ScmRepositoryException;
+import org.apache.maven.wagon.AbstractWagon;
+import org.apache.maven.wagon.ConnectionException;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.resource.Resource;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+import java.util.Stack;
+
+/**
+ * Wagon provider to get and put files from and to SCM systems, using Maven-SCM as underlying transport.
+ * <p/>
+ * TODO it probably creates problems if the same wagon is used in two different SCM protocols, as instance variables can
+ * keep incorrect state.
+ * TODO: For doing releases, we either have to be able to add files with checking out the repository structure which may not be
+ * possible, or the checkout directory needs to be a constant. Doing releases won't scale if you have to checkout the
+ * whole repository structure in order to add 3 files.
+ *
+ * @author <a href="brett at apache.org">Brett Porter</a>
+ * @author <a href="evenisse at apache.org">Emmanuel Venisse</a>
+ * @author <a href="carlos at apache.org">Carlos Sanchez</a>
+ * @author Jason van Zyl
+ *
+ * @plexus.component role="org.apache.maven.wagon.Wagon" role-hint="scm" instantiation-strategy="per-lookup"
+ */
+public class ScmWagon
+ extends AbstractWagon
+{
+ /**
+ * @plexus.requirement
+ */
+ private volatile ScmManager scmManager;
+
+ /**
+ * The SCM version, if any.
+ *
+ * @parameter
+ */
+ private String scmVersion;
+
+ /**
+ * The SCM version type, if any. Defaults to "branch".
+ *
+ * @parameter
+ */
+ private String scmVersionType;
+
+ private File checkoutDirectory;
+
+ /**
+ * Get the {@link ScmManager} used in this Wagon
+ *
+ * @return the {@link ScmManager}
+ */
+ public ScmManager getScmManager()
+ {
+ return scmManager;
+ }
+
+ /**
+ * Set the {@link ScmManager} used in this Wagon
+ *
+ * @param scmManager
+ */
+ public void setScmManager( ScmManager scmManager )
+ {
+ this.scmManager = scmManager;
+ }
+
+ /**
+ * Get the scmVersion used in this Wagon
+ *
+ * @return the scmVersion
+ */
+ public String getScmVersion()
+ {
+ return scmVersion;
+ }
+
+ /**
+ * Set the scmVersion
+ *
+ * @param scmVersion the scmVersion to set
+ */
+ public void setScmVersion( String scmVersion )
+ {
+ this.scmVersion = scmVersion;
+ }
+
+ /**
+ * Get the scmVersionType used in this Wagon
+ *
+ * @return the scmVersionType
+ */
+ public String getScmVersionType()
+ {
+ return scmVersionType;
+ }
+
+ /**
+ * Set the scmVersionType
+ *
+ * @param scmVersionType the scmVersionType to set
+ */
+ public void setScmVersionType( String scmVersionType )
+ {
+ this.scmVersionType = scmVersionType;
+ }
+
+ /**
+ * Get the directory where Wagon will checkout files from SCM. This directory will be deleted!
+ *
+ * @return directory
+ */
+ public File getCheckoutDirectory()
+ {
+ return checkoutDirectory;
+ }
+
+ /**
+ * Set the directory where Wagon will checkout files from SCM. This directory will be deleted!
+ *
+ * @param checkoutDirectory
+ */
+ public void setCheckoutDirectory( File checkoutDirectory )
+ {
+ this.checkoutDirectory = checkoutDirectory;
+ }
+
+ /**
+ * Convenience method to get the {@link ScmProvider} implementation to handle the provided SCM type
+ *
+ * @param scmType type of SCM, eg. <code>svn</code>, <code>cvs</code>
+ * @return the {@link ScmProvider} that will handle provided SCM type
+ * @throws NoSuchScmProviderException if there is no {@link ScmProvider} able to handle that SCM type
+ */
+ public ScmProvider getScmProvider( String scmType )
+ throws NoSuchScmProviderException
+ {
+ return getScmManager().getProviderByType( scmType );
+ }
+
+ /**
+ * This will cleanup the checkout directory
+ */
+ public void openConnectionInternal()
+ throws ConnectionException
+ {
+ if ( checkoutDirectory == null )
+ {
+ checkoutDirectory = createCheckoutDirectory();
+ }
+
+ if ( checkoutDirectory.exists() )
+ {
+ removeCheckoutDirectory();
+ }
+
+ checkoutDirectory.mkdirs();
+ }
+
+ private File createCheckoutDirectory()
+ {
+ File checkoutDirectory;
+
+ DecimalFormat fmt = new DecimalFormat( "#####" );
+
+ Random rand = new Random( System.currentTimeMillis() + Runtime.getRuntime().freeMemory() );
+
+ synchronized ( rand )
+ {
+ do
+ {
+ checkoutDirectory = new File( System.getProperty( "java.io.tmpdir" ),
+ "wagon-scm" + fmt.format( Math.abs( rand.nextInt() ) ) + ".checkout" );
+ }
+ while ( checkoutDirectory.exists() );
+ }
+
+ return checkoutDirectory;
+ }
+
+
+ private void removeCheckoutDirectory()
+ throws ConnectionException
+ {
+ if ( checkoutDirectory == null )
+ {
+ return; // Silently return.
+ }
+
+ try
+ {
+ FileUtils.deleteDirectory( checkoutDirectory );
+ }
+ catch ( IOException e )
+ {
+ throw new ConnectionException( "Unable to cleanup checkout directory", e );
+ }
+ }
+
+ /**
+ * Construct the ScmVersion to use for operations.
+ * <p/>
+ * <p>If scmVersion is supplied, scmVersionType must also be supplied to
+ * take effect.</p>
+ */
+ private ScmVersion makeScmVersion()
+ {
+ if ( StringUtils.isBlank( scmVersion ) )
+ {
+ return null;
+ }
+ if ( scmVersion.length() > 0 )
+ {
+ if ( "revision".equals( scmVersionType ) )
+ {
+ return new ScmRevision( scmVersion );
+ }
+ else if ( "tag".equals( scmVersionType ) )
+ {
+ return new ScmTag( scmVersion );
+ }
+ else if ( "branch".equals( scmVersionType ) )
+ {
+ return new ScmBranch( scmVersion );
+ }
+ }
+
+ return null;
+ }
+
+ private ScmRepository getScmRepository( String url )
+ throws ScmRepositoryException, NoSuchScmProviderException
+ {
+ String username = null;
+
+ String password = null;
+
+ String privateKey = null;
+
+ String passphrase = null;
+
+ if ( authenticationInfo != null )
+ {
+ username = authenticationInfo.getUserName();
+
+ password = authenticationInfo.getPassword();
+
+ privateKey = authenticationInfo.getPrivateKey();
+
+ passphrase = authenticationInfo.getPassphrase();
+ }
+
+ ScmRepository scmRepository = getScmManager().makeScmRepository( url );
+
+ ScmProviderRepository providerRepository = scmRepository.getProviderRepository();
+
+ if ( StringUtils.isNotEmpty( username ) )
+ {
+ providerRepository.setUser( username );
+ }
+
+ if ( StringUtils.isNotEmpty( password ) )
+ {
+ providerRepository.setPassword( password );
+ }
+
+ if ( providerRepository instanceof ScmProviderRepositoryWithHost )
+ {
+ ScmProviderRepositoryWithHost providerRepo = (ScmProviderRepositoryWithHost) providerRepository;
+
+ if ( StringUtils.isNotEmpty( privateKey ) )
+ {
+ providerRepo.setPrivateKey( privateKey );
+ }
+
+ if ( StringUtils.isNotEmpty( passphrase ) )
+ {
+ providerRepo.setPassphrase( passphrase );
+ }
+ }
+
+ return scmRepository;
+ }
+
+ public void put( File source, String targetName )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ if ( source.isDirectory() )
+ {
+ throw new IllegalArgumentException( "Source is a directory: " + source );
+ }
+ putInternal( source, targetName );
+ }
+
+ /**
+ * Puts both files and directories
+ *
+ * @param source
+ * @param targetName
+ * @throws TransferFailedException
+ */
+ private void putInternal( File source, String targetName )
+ throws TransferFailedException
+ {
+ Resource target = new Resource( targetName );
+
+ firePutInitiated( target, source );
+
+ try
+ {
+ ScmRepository scmRepository = getScmRepository( getRepository().getUrl() );
+
+ target.setContentLength( source.length() );
+ target.setLastModified( source.lastModified() );
+
+ firePutStarted( target, source );
+
+ String msg = "Wagon: Adding " + source.getName() + " to repository";
+
+ ScmProvider scmProvider = getScmProvider( scmRepository.getProvider() );
+
+ String checkoutTargetName = source.isDirectory() ? targetName : getDirname( targetName );
+ String relPath = checkOut( scmProvider, scmRepository, checkoutTargetName, target );
+
+ File newCheckoutDirectory = new File( checkoutDirectory, relPath );
+
+ File scmFile = new File( newCheckoutDirectory, source.isDirectory() ? "" : getFilename( targetName ) );
+
+ boolean fileAlreadyInScm = scmFile.exists();
+
+ if ( !scmFile.equals( source ) )
+ {
+ if ( source.isDirectory() )
+ {
+ FileUtils.copyDirectoryStructure( source, scmFile );
+ }
+ else
+ {
+ FileUtils.copyFile( source, scmFile );
+ }
+ }
+
+ if ( !fileAlreadyInScm || scmFile.isDirectory() )
+ {
+ int addedFiles = addFiles( scmProvider, scmRepository, newCheckoutDirectory,
+ source.isDirectory() ? "" : scmFile.getName() );
+
+ if ( !fileAlreadyInScm && addedFiles == 0 )
+ {
+ throw new ScmException(
+ "Unable to add file to SCM: " + scmFile + "; see error messages above for more information" );
+ }
+ }
+
+ ScmResult result =
+ scmProvider.checkIn( scmRepository, new ScmFileSet( checkoutDirectory ), makeScmVersion(), msg );
+
+ checkScmResult( result );
+ }
+ catch ( ScmException e )
+ {
+ fireTransferError( target, e, TransferEvent.REQUEST_PUT );
+
+ throw new TransferFailedException( "Error interacting with SCM: " + e.getMessage(), e );
+ }
+ catch ( IOException e )
+ {
+ fireTransferError( target, e, TransferEvent.REQUEST_PUT );
+
+ throw new TransferFailedException( "Error interacting with SCM: " + e.getMessage(), e );
+ }
+
+ if ( source.isFile() )
+ {
+ postProcessListeners( target, source, TransferEvent.REQUEST_PUT );
+ }
+
+ firePutCompleted( target, source );
+ }
+
+ /**
+ * Returns the relative path to targetName in the checkout dir. If the targetName already exists in the scm, this
+ * will be the empty string.
+ *
+ * @param scmProvider
+ * @param scmRepository
+ * @param targetName
+ * @return
+ * @throws TransferFailedException
+ */
+ private String checkOut( ScmProvider scmProvider, ScmRepository scmRepository, String targetName,
+ Resource resource )
+ throws TransferFailedException
+ {
+ checkoutDirectory = createCheckoutDirectory();
+
+ Stack<String> stack = new Stack<String>();
+
+ String target = targetName;
+
+ // totally ignore scmRepository parent stuff since that is not supported by all scms.
+ // Instead, assume that that url exists. If not, then that's an error.
+ // Check whether targetName, which is a relative path into the scm, exists.
+ // If it doesn't, check the parent, etc.
+
+ try
+ {
+ while ( target.length() > 0 && !scmProvider.list( scmRepository,
+ new ScmFileSet( new File( "." ), new File( target ) ),
+ false, makeScmVersion() ).isSuccess() )
+ {
+ stack.push( getFilename( target ) );
+ target = getDirname( target );
+ }
+ }
+ catch ( ScmException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+
+ throw new TransferFailedException( "Error listing repository: " + e.getMessage(), e );
+ }
+
+ // ok, we've established that target exists, or is empty.
+ // Check the resource out; if it doesn't exist, that means we're in the svn repo url root,
+ // and the configuration is incorrect. We will not try repo.getParent since most scm's don't
+ // implement that.
+
+ try
+ {
+ String repoUrl = getRepository().getUrl();
+ if ( "svn".equals( scmProvider.getScmType() ) )
+ {
+ // Subversion is the only SCM that adds path structure to represent tags and branches.
+ // The rest use scmVersion and scmVersionType.
+ repoUrl += "/" + target.replace( '\\', '/' );
+ }
+ scmRepository = getScmRepository( repoUrl );
+ CheckOutScmResult ret =
+ scmProvider.checkOut( scmRepository, new ScmFileSet( new File( checkoutDirectory, "" ) ),
+ makeScmVersion(), false );
+
+ checkScmResult( ret );
+ }
+ catch ( ScmException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+
+ throw new TransferFailedException( "Error checking out: " + e.getMessage(), e );
+ }
+
+ // now create the subdirs in target, if it's a parent of targetName
+
+ String relPath = "";
+
+ while ( !stack.isEmpty() )
+ {
+ String p = stack.pop();
+ relPath += p + "/";
+
+ File newDir = new File( checkoutDirectory, relPath );
+ if ( !newDir.mkdirs() )
+ {
+ throw new TransferFailedException(
+ "Failed to create directory " + newDir.getAbsolutePath() + "; parent should exist: "
+ + checkoutDirectory );
+ }
+
+ try
+ {
+ addFiles( scmProvider, scmRepository, checkoutDirectory, relPath );
+ }
+ catch ( ScmException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
+ throw new TransferFailedException( "Failed to add directory " + newDir + " to working copy", e );
+ }
+ }
+
+ return relPath;
+ }
+
+ /**
+ * Add a file or directory to a SCM repository. If it's a directory all its contents are added recursively.
+ * <p/>
+ * TODO this is less than optimal, SCM API should provide a way to add a directory recursively
+ *
+ * @param scmProvider SCM provider
+ * @param scmRepository SCM repository
+ * @param basedir local directory corresponding to scmRepository
+ * @param scmFilePath path of the file or directory to add, relative to basedir
+ * @return the number of files added.
+ * @throws ScmException
+ */
+ private int addFiles( ScmProvider scmProvider, ScmRepository scmRepository, File basedir, String scmFilePath )
+ throws ScmException
+ {
+ int addedFiles = 0;
+
+ File scmFile = new File( basedir, scmFilePath );
+
+ if ( scmFilePath.length() != 0 )
+ {
+ AddScmResult result = scmProvider.add( scmRepository, new ScmFileSet( basedir, new File( scmFilePath ) ) );
+
+ /*
+ * TODO dirty fix to work around files with property svn:eol-style=native if a file has that property, first
+ * time file is added it fails, second time it succeeds the solution is check if the scm provider is svn and
+ * unset that property when the SCM API allows it
+ */
+ if ( !result.isSuccess() )
+ {
+ result = scmProvider.add( scmRepository, new ScmFileSet( basedir, new File( scmFilePath ) ) );
+ }
+
+ addedFiles = result.getAddedFiles().size();
+ }
+
+ String reservedScmFile = scmProvider.getScmSpecificFilename();
+
+ if ( scmFile.isDirectory() )
+ {
+ for ( File file : scmFile.listFiles() )
+ {
+ if ( reservedScmFile != null && !reservedScmFile.equals( file.getName() ) )
+ {
+ addedFiles += addFiles( scmProvider, scmRepository, basedir,
+ ( scmFilePath.length() == 0 ? "" : scmFilePath + "/" )
+ + file.getName() );
+ }
+ }
+ }
+
+ return addedFiles;
+ }
+
+ /**
+ * @return true
+ */
+ public boolean supportsDirectoryCopy()
+ {
+ return true;
+ }
+
+ public void putDirectory( File sourceDirectory, String destinationDirectory )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ if ( !sourceDirectory.isDirectory() )
+ {
+ throw new IllegalArgumentException( "Source is not a directory: " + sourceDirectory );
+ }
+
+ putInternal( sourceDirectory, destinationDirectory );
+ }
+
+ /**
+ * Check that the ScmResult was a successful operation
+ *
+ * @param result
+ * @throws TransferFailedException if result was not a successful operation
+ * @throws ScmException
+ */
+ private void checkScmResult( ScmResult result )
+ throws ScmException
+ {
+ if ( !result.isSuccess() )
+ {
+ throw new ScmException(
+ "Unable to commit file. " + result.getProviderMessage() + " " + ( result.getCommandOutput() == null
+ ? ""
+ : result.getCommandOutput() ) );
+ }
+ }
+
+ public void closeConnection()
+ throws ConnectionException
+ {
+ removeCheckoutDirectory();
+ }
+
+ /**
+ * Not implemented
+ *
+ * @throws UnsupportedOperationException always
+ */
+ public boolean getIfNewer( String resourceName, File destination, long timestamp )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ throw new UnsupportedOperationException( "Not currently supported: getIfNewer" );
+ }
+
+ public void get( String resourceName, File destination )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ Resource resource = new Resource( resourceName );
+
+ fireGetInitiated( resource, destination );
+
+ String url = getRepository().getUrl() + "/" + resourceName;
+
+ // remove the file
+ url = url.substring( 0, url.lastIndexOf( '/' ) );
+
+ try
+ {
+ ScmRepository scmRepository = getScmRepository( url );
+
+ fireGetStarted( resource, destination );
+
+ // TODO: limitations:
+ // - destination filename must match that in the repository - should allow the "-d" CVS equiv to be passed
+ // in
+ // - we don't get granular exceptions from SCM (ie, auth, not found)
+ // - need to make it non-recursive to save time
+ // - exists() check doesn't test if it is in SCM already
+
+ File scmFile = new File( checkoutDirectory, resourceName );
+
+ File basedir = scmFile.getParentFile();
+
+ ScmProvider scmProvider = getScmProvider( scmRepository.getProvider() );
+
+ String reservedScmFile = scmProvider.getScmSpecificFilename();
+
+ if ( reservedScmFile != null && new File( basedir, reservedScmFile ).exists() )
+ {
+ scmProvider.update( scmRepository, new ScmFileSet( basedir ), makeScmVersion() );
+ }
+ else
+ {
+ // TODO: this should be checking out a full hierarchy (requires the -d equiv)
+ basedir.mkdirs();
+
+ scmProvider.checkOut( scmRepository, new ScmFileSet( basedir ), makeScmVersion() );
+ }
+
+ if ( !scmFile.exists() )
+ {
+ throw new ResourceDoesNotExistException( "Unable to find resource " + destination + " after checkout" );
+ }
+
+ if ( !scmFile.equals( destination ) )
+ {
+ FileUtils.copyFile( scmFile, destination );
+ }
+ }
+ catch ( ScmException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+
+ throw new TransferFailedException( "Error getting file from SCM", e );
+ }
+ catch ( IOException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+
+ throw new TransferFailedException( "Error getting file from SCM", e );
+ }
+
+ postProcessListeners( resource, destination, TransferEvent.REQUEST_GET );
+
+ fireGetCompleted( resource, destination );
+ }
+
+ /**
+ * @return a List<String> with filenames/directories at the resourcepath.
+ * @see org.apache.maven.wagon.AbstractWagon#getFileList(java.lang.String)
+ */
+ public List<String> getFileList( String resourcePath )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ try
+ {
+ ScmRepository repository = getScmRepository( getRepository().getUrl() );
+
+ ScmProvider provider = getScmProvider( repository.getProvider() );
+
+ ListScmResult result =
+ provider.list( repository, new ScmFileSet( new File( "." ), new File( resourcePath ) ), false,
+ makeScmVersion() );
+
+ if ( !result.isSuccess() )
+ {
+ throw new ResourceDoesNotExistException( result.getProviderMessage() );
+ }
+
+ List<String> files = new ArrayList<String>();
+
+ for ( ScmFile f : result.getFiles() )
+ {
+ files.add( f.getPath() );
+ }
+
+ return files;
+ }
+ catch ( ScmException e )
+ {
+ throw new TransferFailedException( "Error getting filelist from SCM", e );
+ }
+ }
+
+ public boolean resourceExists( String resourceName )
+ throws TransferFailedException, AuthorizationException
+ {
+ try
+ {
+ getFileList( resourceName );
+
+ return true;
+ }
+ catch ( ResourceDoesNotExistException e )
+ {
+ return false;
+ }
+ }
+
+ private String getFilename( String filename )
+ {
+ String fname = StringUtils.replace( filename, "/", File.separator );
+ return FileUtils.filename( fname );
+ }
+
+ private String getDirname( String filename )
+ {
+ String fname = StringUtils.replace( filename, "/", File.separator );
+ return FileUtils.dirname( fname );
+ }
+}
diff --git a/wagon-providers/wagon-scm/src/site/apt/index.apt b/wagon-providers/wagon-scm/src/site/apt/index.apt
index 56ba227..989887d 100644
--- a/wagon-providers/wagon-scm/src/site/apt/index.apt
+++ b/wagon-providers/wagon-scm/src/site/apt/index.apt
@@ -1,54 +1,54 @@
- ------
- Introduction
- ------
- Carlos Sanchez
- ------
- 2006-03-07
- ------
-
- ~~ Licensed to the Apache Software Foundation (ASF) under one
- ~~ or more contributor license agreements. See the NOTICE file
- ~~ distributed with this work for additional information
- ~~ regarding copyright ownership. The ASF licenses this file
- ~~ to you under the Apache License, Version 2.0 (the
- ~~ "License"); you may not use this file except in compliance
- ~~ with the License. You may obtain a copy of the License at
- ~~
- ~~ http://www.apache.org/licenses/LICENSE-2.0
- ~~
- ~~ Unless required by applicable law or agreed to in writing,
- ~~ software distributed under the License is distributed on an
- ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~~ KIND, either express or implied. See the License for the
- ~~ specific language governing permissions and limitations
- ~~ under the License.
-
- ~~ NOTE: For help with the syntax of this file, see:
- ~~ http://maven.apache.org/doxia/references/apt-format.html
-
-Maven Wagon SCM
-
- This component is an implementation of Wagon provider for SCM (Source Control Management) systems,
- using {{{http://maven.apache.org/scm}Maven SCM}}.
-
- It enables Maven to use remote repositories stored in SCM systems (Subversion, CVS, ...)
- and to store Maven sites in SCMs.
-
-Features
-
- * Deploy files and directories to several SCM using Maven SCM (only tested with CVS and SVN)
-
- * Get files from several SCM using Maven SCM (only tested with CVS and SVN)
-
-
-Known issues
-
- * If the file is changed by the SCM, the checksum calculation may not work
-
- * SVN: when a file has properties svn:eol-style or svn:keywords set
-
- * CVS: when keywords are expanded
-
- * Generated site may have inconsistent newlines (see {{{http://jira.codehaus.org/browse/MSITE-121}MSITE-121}}),
- preventing SCM check-in: prefer {{{http://maven.apache.org/plugins/maven-scm-publish-plugin/}maven-scm-publish-plugin}} to
- publish your site to SCM
+ ------
+ Introduction
+ ------
+ Carlos Sanchez
+ ------
+ 2006-03-07
+ ------
+
+ ~~ Licensed to the Apache Software Foundation (ASF) under one
+ ~~ or more contributor license agreements. See the NOTICE file
+ ~~ distributed with this work for additional information
+ ~~ regarding copyright ownership. The ASF licenses this file
+ ~~ to you under the Apache License, Version 2.0 (the
+ ~~ "License"); you may not use this file except in compliance
+ ~~ with the License. You may obtain a copy of the License at
+ ~~
+ ~~ http://www.apache.org/licenses/LICENSE-2.0
+ ~~
+ ~~ Unless required by applicable law or agreed to in writing,
+ ~~ software distributed under the License is distributed on an
+ ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~~ KIND, either express or implied. See the License for the
+ ~~ specific language governing permissions and limitations
+ ~~ under the License.
+
+ ~~ NOTE: For help with the syntax of this file, see:
+ ~~ http://maven.apache.org/doxia/references/apt-format.html
+
+Maven Wagon SCM
+
+ This component is an implementation of Wagon provider for SCM (Source Control Management) systems,
+ using {{{http://maven.apache.org/scm}Maven SCM}}.
+
+ It enables Maven to use remote repositories stored in SCM systems (Subversion, CVS, ...)
+ and to store Maven sites in SCMs.
+
+Features
+
+ * Deploy files and directories to several SCM using Maven SCM (only tested with CVS and SVN)
+
+ * Get files from several SCM using Maven SCM (only tested with CVS and SVN)
+
+
+Known issues
+
+ * If the file is changed by the SCM, the checksum calculation may not work
+
+ * SVN: when a file has properties svn:eol-style or svn:keywords set
+
+ * CVS: when keywords are expanded
+
+ * Generated site may have inconsistent newlines (see {{{http://jira.codehaus.org/browse/MSITE-121}MSITE-121}}),
+ preventing SCM check-in: prefer {{{http://maven.apache.org/plugins/maven-scm-publish-plugin/}maven-scm-publish-plugin}} to
+ publish your site to SCM
diff --git a/wagon-providers/wagon-scm/src/site/apt/usage.apt.vm b/wagon-providers/wagon-scm/src/site/apt/usage.apt.vm
index 246fa09..fd26456 100644
--- a/wagon-providers/wagon-scm/src/site/apt/usage.apt.vm
+++ b/wagon-providers/wagon-scm/src/site/apt/usage.apt.vm
@@ -1,188 +1,188 @@
- ------
- Maven Wagon SCM
- ------
- Carlos Sanchez
- ------
- 2011-09-22
- ------
-
- ~~ Licensed to the Apache Software Foundation (ASF) under one
- ~~ or more contributor license agreements. See the NOTICE file
- ~~ distributed with this work for additional information
- ~~ regarding copyright ownership. The ASF licenses this file
- ~~ to you under the Apache License, Version 2.0 (the
- ~~ "License"); you may not use this file except in compliance
- ~~ with the License. You may obtain a copy of the License at
- ~~
- ~~ http://www.apache.org/licenses/LICENSE-2.0
- ~~
- ~~ Unless required by applicable law or agreed to in writing,
- ~~ software distributed under the License is distributed on an
- ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~~ KIND, either express or implied. See the License for the
- ~~ specific language governing permissions and limitations
- ~~ under the License.
-
- ~~ NOTE: For help with the syntax of this file, see:
- ~~ http://maven.apache.org/doxia/references/apt-format.html
-
-Maven Wagon SCM Usage
-
- You need to add some extensions to your pom:
-
- * <<<wagon-scm>>>,
-
- * {{{http://maven.apache.org/scm/maven-scm-managers/maven-scm-manager-plexus/index.html}<<<maven-scm-manager-plexus>>>}}
-
- * and the {{{http://maven.apache.org/scm/maven-scm-providers/index.html}Maven SCM Provider}} for your SCM system,
-
- []
-
- and use URLs in the {{{http://maven.apache.org/scm/scm-url-format.html}SCM format}}.
-
- For non-subversion SCM, you can include the elements <<<scmVersionType>>> and <<<scmVersion>>> in your <<<settings.xml>>> file to
- specify a branch or tag to use. The value of <<<scmVersionType>>> must be one of <<<branch>>> or <<<tag>>>.
- There is no default value for <<<scmVersionType>>> so you <MUST> specify it with <<<scmVersion>>> in order
- to have any effect.
-
-
-Deploying your Maven site to SCM
-
- There are some shortcomings to simply using Wagon SCM provider with site plugin:
-
- * generated site may have inconsistent newlines (see {{{http://jira.codehaus.org/browse/MSITE-121}MSITE-121}}),
- preventing SCM check-in,
-
- * deploying site to SCM will require obsolete pages deletion, which is not done,
-
- * site plugin way make one commit per file.
-
- Prefer {{{http://maven.apache.org/plugins/maven-scm-publish-plugin/}maven-scm-publish-plugin}} to
- publish your site to SCM
-
- <<Note for Maven 3 users:>> The site plugin behaves differently, require these
- be added as dependencies instead of extensions. See
- {{{http://maven.apache.org/plugins/maven-site-plugin/examples/adding-deploy-protocol.html}
- Adding a Protocol to Deploy the Site}}.
-
-* Deploying your Maven site to Subversion
-
- Add the following extensions to your pom and use a wagon-scm url in the distributionManagement site url.
-
-------
- <build>
- <extensions>
- <extension>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-scm</artifactId>
- <version>${project.version}</version>
- </extension>
- <extension>
- <groupId>org.apache.maven.scm</groupId>
- <artifactId>maven-scm-manager-plexus</artifactId>
- <version>${mavenScmVersion}</version>
- </extension>
- <extension>
- <groupId>org.apache.maven.scm</groupId>
- <artifactId>maven-scm-provider-svnexe</artifactId>
- <version>${mavenScmVersion}</version>
- </extension>
- </extensions>
- </build>
- <distributionManagement>
- <site>
- <id>my.svn.server</id>
- <url>scm:svn:https://username@svn.apache.org/svn/root/module</url>
- </site>
- </distributionManagement>
-------
-
-
-* Deploying your Maven site to CVS
-
- Same as before, but changing svnexe to cvsexe and using a CVS svn url.
-
-------
- <build>
- <extensions>
- <extension>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-scm</artifactId>
- <version>${project.version}</version>
- </extension>
- <extension>
- <groupId>org.apache.maven.scm</groupId>
- <artifactId>maven-scm-manager-plexus</artifactId>
- <version>${mavenScmVersion}</version>
- </extension>
- <extension>
- <groupId>org.apache.maven.scm</groupId>
- <artifactId>maven-scm-provider-cvsexe</artifactId>
- <version>${mavenScmVersion}</version>
- </extension>
- </extensions>
- </build>
- <distributionManagement>
- <site>
- <id>my.cvs.server</id>
- <url>scm:cvs:ext:username at cvs.apache.org:/cvs/root:module</url>
- </site>
- </distributionManagement>
-------
-
-
-* Deploying your Maven site to GitHub's gh-pages
-
- Same as before, but changing svnexe to gitexe and using a Git svn url.
-
-------
- <build>
- <extensions>
- <extension>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-scm</artifactId>
- <version>${project.version}</version>
- </extension>
- <extension>
- <groupId>org.apache.maven.scm</groupId>
- <artifactId>maven-scm-manager-plexus</artifactId>
- <version>${project.version}</version>
- </extension>
- <extension>
- <groupId>org.apache.maven.scm</groupId>
- <artifactId>maven-scm-provider-gitexe</artifactId>
- <version>${project.version}</version>
- </extension>
- </extensions>
- </build>
- <distributionManagement>
- <site>
- <id>my.git.server</id>
- <url>scm:git:ssh://git@github.com/myuser/myproject.git</url>
- </site>
- </distributionManagement>
-------
-
- And in your settings.xml file:
-
-------
- <server>
- <id>my.git.server</id>
- <username>git</username>
- <scmVersionType>branch</scmVersionType>
- <scmVersion>gh-pages</scmVersion>
- </server>
-------
-
-
-Using a SCM-based remote repository in Maven 2
-
-
-* Using a Subversion-based remote repository in Maven 2
-
- Not tested yet
-
-
-* Using a CVS-based remote repository in Maven 2
-
- Not tested yet
+ ------
+ Maven Wagon SCM
+ ------
+ Carlos Sanchez
+ ------
+ 2011-09-22
+ ------
+
+ ~~ Licensed to the Apache Software Foundation (ASF) under one
+ ~~ or more contributor license agreements. See the NOTICE file
+ ~~ distributed with this work for additional information
+ ~~ regarding copyright ownership. The ASF licenses this file
+ ~~ to you under the Apache License, Version 2.0 (the
+ ~~ "License"); you may not use this file except in compliance
+ ~~ with the License. You may obtain a copy of the License at
+ ~~
+ ~~ http://www.apache.org/licenses/LICENSE-2.0
+ ~~
+ ~~ Unless required by applicable law or agreed to in writing,
+ ~~ software distributed under the License is distributed on an
+ ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~~ KIND, either express or implied. See the License for the
+ ~~ specific language governing permissions and limitations
+ ~~ under the License.
+
+ ~~ NOTE: For help with the syntax of this file, see:
+ ~~ http://maven.apache.org/doxia/references/apt-format.html
+
+Maven Wagon SCM Usage
+
+ You need to add some extensions to your pom:
+
+ * <<<wagon-scm>>>,
+
+ * {{{http://maven.apache.org/scm/maven-scm-managers/maven-scm-manager-plexus/index.html}<<<maven-scm-manager-plexus>>>}}
+
+ * and the {{{http://maven.apache.org/scm/maven-scm-providers/index.html}Maven SCM Provider}} for your SCM system,
+
+ []
+
+ and use URLs in the {{{http://maven.apache.org/scm/scm-url-format.html}SCM format}}.
+
+ For non-subversion SCM, you can include the elements <<<scmVersionType>>> and <<<scmVersion>>> in your <<<settings.xml>>> file to
+ specify a branch or tag to use. The value of <<<scmVersionType>>> must be one of <<<branch>>> or <<<tag>>>.
+ There is no default value for <<<scmVersionType>>> so you <MUST> specify it with <<<scmVersion>>> in order
+ to have any effect.
+
+
+Deploying your Maven site to SCM
+
+ There are some shortcomings to simply using Wagon SCM provider with site plugin:
+
+ * generated site may have inconsistent newlines (see {{{http://jira.codehaus.org/browse/MSITE-121}MSITE-121}}),
+ preventing SCM check-in,
+
+ * deploying site to SCM will require obsolete pages deletion, which is not done,
+
+ * site plugin way make one commit per file.
+
+ Prefer {{{http://maven.apache.org/plugins/maven-scm-publish-plugin/}maven-scm-publish-plugin}} to
+ publish your site to SCM
+
+ <<Note for Maven 3 users:>> The site plugin behaves differently, require these
+ be added as dependencies instead of extensions. See
+ {{{http://maven.apache.org/plugins/maven-site-plugin/examples/adding-deploy-protocol.html}
+ Adding a Protocol to Deploy the Site}}.
+
+* Deploying your Maven site to Subversion
+
+ Add the following extensions to your pom and use a wagon-scm url in the distributionManagement site url.
+
+------
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-scm</artifactId>
+ <version>${project.version}</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.maven.scm</groupId>
+ <artifactId>maven-scm-manager-plexus</artifactId>
+ <version>${mavenScmVersion}</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.maven.scm</groupId>
+ <artifactId>maven-scm-provider-svnexe</artifactId>
+ <version>${mavenScmVersion}</version>
+ </extension>
+ </extensions>
+ </build>
+ <distributionManagement>
+ <site>
+ <id>my.svn.server</id>
+ <url>scm:svn:https://username@svn.apache.org/svn/root/module</url>
+ </site>
+ </distributionManagement>
+------
+
+
+* Deploying your Maven site to CVS
+
+ Same as before, but changing svnexe to cvsexe and using a CVS svn url.
+
+------
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-scm</artifactId>
+ <version>${project.version}</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.maven.scm</groupId>
+ <artifactId>maven-scm-manager-plexus</artifactId>
+ <version>${mavenScmVersion}</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.maven.scm</groupId>
+ <artifactId>maven-scm-provider-cvsexe</artifactId>
+ <version>${mavenScmVersion}</version>
+ </extension>
+ </extensions>
+ </build>
+ <distributionManagement>
+ <site>
+ <id>my.cvs.server</id>
+ <url>scm:cvs:ext:username at cvs.apache.org:/cvs/root:module</url>
+ </site>
+ </distributionManagement>
+------
+
+
+* Deploying your Maven site to GitHub's gh-pages
+
+ Same as before, but changing svnexe to gitexe and using a Git svn url.
+
+------
+ <build>
+ <extensions>
+ <extension>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-scm</artifactId>
+ <version>${project.version}</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.maven.scm</groupId>
+ <artifactId>maven-scm-manager-plexus</artifactId>
+ <version>${mavenScmVersion}</version>
+ </extension>
+ <extension>
+ <groupId>org.apache.maven.scm</groupId>
+ <artifactId>maven-scm-provider-gitexe</artifactId>
+ <version>${mavenScmVersion}</version>
+ </extension>
+ </extensions>
+ </build>
+ <distributionManagement>
+ <site>
+ <id>my.git.server</id>
+ <url>scm:git:ssh://git@github.com/myuser/myproject.git</url>
+ </site>
+ </distributionManagement>
+------
+
+ And in your settings.xml file:
+
+------
+ <server>
+ <id>my.git.server</id>
+ <username>git</username>
+ <scmVersionType>branch</scmVersionType>
+ <scmVersion>gh-pages</scmVersion>
+ </server>
+------
+
+
+Using a SCM-based remote repository in Maven 2
+
+
+* Using a Subversion-based remote repository in Maven 2
+
+ Not tested yet
+
+
+* Using a CVS-based remote repository in Maven 2
+
+ Not tested yet
diff --git a/wagon-providers/wagon-scm/src/site/site.xml b/wagon-providers/wagon-scm/src/site/site.xml
index 958df23..b2127ce 100644
--- a/wagon-providers/wagon-scm/src/site/site.xml
+++ b/wagon-providers/wagon-scm/src/site/site.xml
@@ -1,37 +1,37 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
- <body>
- <breadcrumbs>
- <item name="SCM" href="http://maven.apache.org/wagon/wagon-providers/wagon-scm/index.html" />
- </breadcrumbs>
-
- <menu ref="parent"/>
- <menu name="Overview">
- <item name="Introduction" href="index.html"/>
- <item name="Usage" href="usage.html"/>
- </menu>
- <menu ref="reports"/>
- </body>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
+ <body>
+ <breadcrumbs>
+ <item name="SCM" href="http://maven.apache.org/wagon/wagon-providers/wagon-scm/index.html" />
+ </breadcrumbs>
+
+ <menu ref="parent"/>
+ <menu name="Overview">
+ <item name="Introduction" href="index.html"/>
+ <item name="Usage" href="usage.html"/>
+ </menu>
+ <menu ref="reports"/>
+ </body>
+</project>
diff --git a/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmCvsWagonTest.java b/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmCvsWagonTest.java
index fc7b7f8..5ca0a4a 100644
--- a/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmCvsWagonTest.java
+++ b/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmCvsWagonTest.java
@@ -1,46 +1,46 @@
-package org.apache.maven.wagon.providers.scm;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-
-/**
- * Test for ScmWagon using CVS as underlying SCM
- *
- * @author <a href="brett at apache.org">Brett Porter</a>
- *
- */
-public abstract class AbstractScmCvsWagonTest
- extends AbstractScmWagonTest
-{
-
- protected String getScmId()
- {
- return "cvs";
- }
-
- protected String getTestRepositoryUrl()
- throws IOException
- {
- String repository = getTestFile( "target/test-classes/test-repo-cvs" ).getAbsolutePath();
-
- return "scm:cvs|local|" + repository + "|repository/newfolder";
- }
-}
+package org.apache.maven.wagon.providers.scm;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.IOException;
+
+/**
+ * Test for ScmWagon using CVS as underlying SCM
+ *
+ * @author <a href="brett at apache.org">Brett Porter</a>
+ *
+ */
+public abstract class AbstractScmCvsWagonTest
+ extends AbstractScmWagonTest
+{
+
+ protected String getScmId()
+ {
+ return "cvs";
+ }
+
+ protected String getTestRepositoryUrl()
+ throws IOException
+ {
+ String repository = getTestFile( "target/test-classes/test-repo-cvs" ).getAbsolutePath();
+
+ return "scm:cvs|local|" + repository + "|repository/newfolder";
+ }
+}
diff --git a/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmSvnWagonTest.java b/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmSvnWagonTest.java
index 2b4c7bd..eb296b2 100644
--- a/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmSvnWagonTest.java
+++ b/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmSvnWagonTest.java
@@ -1,79 +1,79 @@
-package org.apache.maven.wagon.providers.scm;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-
-import org.codehaus.plexus.util.FileUtils;
-
-/**
- * Test for ScmWagon using SVN as underlying SCM
- *
- * @author <a href="brett at apache.org">Brett Porter</a>
- *
- */
-public abstract class AbstractScmSvnWagonTest
- extends AbstractScmWagonTest
-{
- private String repository;
-
- protected void setUp()
- throws Exception
- {
- super.setUp();
-
- // copy the repo for the test
-
- File origRepo = getTestFile( "target/test-classes/test-repo-svn" );
-
- File testRepo = getTestFile( "target/test-classes/test-repo-svn-test" );
-
- FileUtils.deleteDirectory( testRepo );
-
- FileUtils.copyDirectoryStructure( origRepo, testRepo );
-
- repository = testRepo.getAbsolutePath();
-
- // TODO: this is a hack for windows
- // Note: why not use File.toURL() ?
- if ( repository.contains( ":" ) )
- {
- repository = "/" + repository;
- }
- repository = repository.replace( '\\', '/' );
-
- repository = "scm:svn:file://" + repository;
- }
-
- protected String getScmId()
- {
- return "svn";
- }
-
- protected String getTestRepositoryUrl()
- {
- return repository;
- }
-
- protected boolean supportsGetIfNewer()
- {
- return false;
- }
-}
+package org.apache.maven.wagon.providers.scm;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+
+import org.codehaus.plexus.util.FileUtils;
+
+/**
+ * Test for ScmWagon using SVN as underlying SCM
+ *
+ * @author <a href="brett at apache.org">Brett Porter</a>
+ *
+ */
+public abstract class AbstractScmSvnWagonTest
+ extends AbstractScmWagonTest
+{
+ private String repository;
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ // copy the repo for the test
+
+ File origRepo = getTestFile( "target/test-classes/test-repo-svn" );
+
+ File testRepo = getTestFile( "target/test-classes/test-repo-svn-test" );
+
+ FileUtils.deleteDirectory( testRepo );
+
+ FileUtils.copyDirectoryStructure( origRepo, testRepo );
+
+ repository = testRepo.getAbsolutePath();
+
+ // TODO: this is a hack for windows
+ // Note: why not use File.toURL() ?
+ if ( repository.contains( ":" ) )
+ {
+ repository = "/" + repository;
+ }
+ repository = repository.replace( '\\', '/' );
+
+ repository = "scm:svn:file://" + repository;
+ }
+
+ protected String getScmId()
+ {
+ return "svn";
+ }
+
+ protected String getTestRepositoryUrl()
+ {
+ return repository;
+ }
+
+ protected boolean supportsGetIfNewer()
+ {
+ return false;
+ }
+}
diff --git a/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmWagonTest.java b/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmWagonTest.java
index 3028997..cf4db42 100644
--- a/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmWagonTest.java
+++ b/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmWagonTest.java
@@ -1,145 +1,145 @@
-package org.apache.maven.wagon.providers.scm;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.scm.manager.plexus.DefaultScmManager;
-import org.apache.maven.scm.provider.ScmProvider;
-import org.apache.maven.wagon.FileTestUtils;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
-import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.WagonConstants;
-import org.apache.maven.wagon.WagonTestCase;
-import org.apache.maven.wagon.authorization.AuthorizationException;
-import org.apache.maven.wagon.repository.Repository;
-import org.apache.maven.wagon.resource.Resource;
-import org.codehaus.plexus.util.FileUtils;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-
-/**
- * Test for {@link ScmWagon}. You need a subclass for each SCM provider you want to test.
- *
- * @author <a href="carlos at apache.org">Carlos Sanchez</a>
- *
- */
-public abstract class AbstractScmWagonTest
- extends WagonTestCase
-{
-
- private ScmWagon wagon;
-
- private String providerClassName;
-
- protected void setUp()
- throws Exception
- {
- super.setUp();
-
- FileUtils.deleteDirectory( getCheckoutDirectory() );
-
- if ( wagon == null )
- {
- wagon = (ScmWagon) super.getWagon();
-
- DefaultScmManager scmManager = (DefaultScmManager) wagon.getScmManager();
-
- if ( getScmProvider() != null )
- {
- scmManager.setScmProvider( getScmId(), getScmProvider() );
-
- providerClassName = getScmProvider().getClass().getName();
- }
- else
- {
- providerClassName = scmManager.getProviderByType( getScmId() ).getClass().getName();
- }
-
- wagon.setCheckoutDirectory( getCheckoutDirectory() );
- }
- }
-
- /**
- * Allows overriding the {@link ScmProvider} injected by default in the {@link ScmWagon}.
- * Useful to force the implementation to use for a particular SCM type.
- * If this method returns <code>null</code> {@link ScmWagon} will use the default {@link ScmProvider}.
- *
- * @return the {@link ScmProvider} to use in the {@link ScmWagon}
- */
- protected ScmProvider getScmProvider()
- {
- return null;
- }
-
- @Override
- protected int getTestRepositoryPort()
- {
- return 0; // not used
- }
-
- protected Wagon getWagon()
- throws Exception
- {
- return wagon;
- }
-
- private File getCheckoutDirectory()
- {
- return new File( FileTestUtils.getTestOutputDir(), "/checkout-" + providerClassName );
- }
-
- protected int getExpectedContentLengthOnGet( int expectedSize )
- {
- return WagonConstants.UNKNOWN_LENGTH;
- }
-
- protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
- {
- return 0;
- }
-
- /**
- * The SCM id, eg. <code>svn</code>, <code>cvs</code>
- *
- * @return the SCM id
- */
- protected abstract String getScmId();
-
- protected String getProtocol()
- {
- return "scm";
- }
-
- protected void createDirectory( Wagon wagon, String resourceToCreate, String dirName )
- throws Exception
- {
- super.createDirectory( wagon, resourceToCreate, dirName );
- FileUtils.deleteDirectory( getCheckoutDirectory() );
- }
-
- protected void assertResourcesAreInRemoteSide( Wagon wagon, List<String> resourceNames )
- throws IOException, TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- FileUtils.deleteDirectory( getCheckoutDirectory() );
- super.assertResourcesAreInRemoteSide( wagon, resourceNames );
- }
-}
+package org.apache.maven.wagon.providers.scm;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.scm.manager.plexus.DefaultScmManager;
+import org.apache.maven.scm.provider.ScmProvider;
+import org.apache.maven.wagon.FileTestUtils;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.WagonConstants;
+import org.apache.maven.wagon.WagonTestCase;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.resource.Resource;
+import org.codehaus.plexus.util.FileUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * Test for {@link ScmWagon}. You need a subclass for each SCM provider you want to test.
+ *
+ * @author <a href="carlos at apache.org">Carlos Sanchez</a>
+ *
+ */
+public abstract class AbstractScmWagonTest
+ extends WagonTestCase
+{
+
+ private ScmWagon wagon;
+
+ private String providerClassName;
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ FileUtils.deleteDirectory( getCheckoutDirectory() );
+
+ if ( wagon == null )
+ {
+ wagon = (ScmWagon) super.getWagon();
+
+ DefaultScmManager scmManager = (DefaultScmManager) wagon.getScmManager();
+
+ if ( getScmProvider() != null )
+ {
+ scmManager.setScmProvider( getScmId(), getScmProvider() );
+
+ providerClassName = getScmProvider().getClass().getName();
+ }
+ else
+ {
+ providerClassName = scmManager.getProviderByType( getScmId() ).getClass().getName();
+ }
+
+ wagon.setCheckoutDirectory( getCheckoutDirectory() );
+ }
+ }
+
+ /**
+ * Allows overriding the {@link ScmProvider} injected by default in the {@link ScmWagon}.
+ * Useful to force the implementation to use for a particular SCM type.
+ * If this method returns <code>null</code> {@link ScmWagon} will use the default {@link ScmProvider}.
+ *
+ * @return the {@link ScmProvider} to use in the {@link ScmWagon}
+ */
+ protected ScmProvider getScmProvider()
+ {
+ return null;
+ }
+
+ @Override
+ protected int getTestRepositoryPort()
+ {
+ return 0; // not used
+ }
+
+ protected Wagon getWagon()
+ throws Exception
+ {
+ return wagon;
+ }
+
+ private File getCheckoutDirectory()
+ {
+ return new File( FileTestUtils.getTestOutputDir(), "/checkout-" + providerClassName );
+ }
+
+ protected int getExpectedContentLengthOnGet( int expectedSize )
+ {
+ return WagonConstants.UNKNOWN_LENGTH;
+ }
+
+ protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
+ {
+ return 0;
+ }
+
+ /**
+ * The SCM id, eg. <code>svn</code>, <code>cvs</code>
+ *
+ * @return the SCM id
+ */
+ protected abstract String getScmId();
+
+ protected String getProtocol()
+ {
+ return "scm";
+ }
+
+ protected void createDirectory( Wagon wagon, String resourceToCreate, String dirName )
+ throws Exception
+ {
+ super.createDirectory( wagon, resourceToCreate, dirName );
+ FileUtils.deleteDirectory( getCheckoutDirectory() );
+ }
+
+ protected void assertResourcesAreInRemoteSide( Wagon wagon, List<String> resourceNames )
+ throws IOException, TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ FileUtils.deleteDirectory( getCheckoutDirectory() );
+ super.assertResourcesAreInRemoteSide( wagon, resourceNames );
+ }
+}
diff --git a/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/ScmCvsExeWagonTest.java b/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/ScmCvsExeWagonTest.java
index 8839faf..60754e3 100644
--- a/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/ScmCvsExeWagonTest.java
+++ b/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/ScmCvsExeWagonTest.java
@@ -1,64 +1,64 @@
-package org.apache.maven.wagon.providers.scm;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.scm.provider.ScmProvider;
-import org.apache.maven.scm.provider.cvslib.cvsexe.CvsExeScmProvider;
-
-/**
- * Test for ScmWagon using CVS Exe as underlying SCM
- *
- * @author <a href="carlos at apache.org">Carlos Sanchez</a>
- *
- */
-public class ScmCvsExeWagonTest
- extends AbstractScmCvsWagonTest
-{
-
- protected ScmProvider getScmProvider()
- {
- return new CvsExeScmProvider();
- }
-
- public void testFailedGet()
- throws Exception
- {
- // Not ready yet
- }
-
- public void testWagon()
- throws Exception
- {
- // Not ready yet
- }
-
- public void testWagonPutDirectory()
- throws Exception
- {
- // Not ready yet
- }
-
- public void testWagonPutDirectoryWhenDirectoryAlreadyExists()
- throws Exception
- {
- // Not ready yet
- }
-
-}
+package org.apache.maven.wagon.providers.scm;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.scm.provider.ScmProvider;
+import org.apache.maven.scm.provider.cvslib.cvsexe.CvsExeScmProvider;
+
+/**
+ * Test for ScmWagon using CVS Exe as underlying SCM
+ *
+ * @author <a href="carlos at apache.org">Carlos Sanchez</a>
+ *
+ */
+public class ScmCvsExeWagonTest
+ extends AbstractScmCvsWagonTest
+{
+
+ protected ScmProvider getScmProvider()
+ {
+ return new CvsExeScmProvider();
+ }
+
+ public void testFailedGet()
+ throws Exception
+ {
+ // Not ready yet
+ }
+
+ public void testWagon()
+ throws Exception
+ {
+ // Not ready yet
+ }
+
+ public void testWagonPutDirectory()
+ throws Exception
+ {
+ // Not ready yet
+ }
+
+ public void testWagonPutDirectoryWhenDirectoryAlreadyExists()
+ throws Exception
+ {
+ // Not ready yet
+ }
+
+}
diff --git a/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/ScmSvnExeWagonTest.java b/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/ScmSvnExeWagonTest.java
index d7b9e7f..cd26125 100644
--- a/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/ScmSvnExeWagonTest.java
+++ b/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/ScmSvnExeWagonTest.java
@@ -1,40 +1,40 @@
-package org.apache.maven.wagon.providers.scm;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.scm.provider.ScmProvider;
-import org.apache.maven.scm.provider.svn.svnexe.SvnExeScmProvider;
-
-/**
- * Test for ScmWagon using SVN Exe as underlying SCM
- *
- * @author <a href="carlos at apache.org">Carlos Sanchez</a>
- *
- */
-public class ScmSvnExeWagonTest
- extends AbstractScmSvnWagonTest
-{
-
- protected ScmProvider getScmProvider()
- {
- return new SvnExeScmProvider();
- }
-
-}
+package org.apache.maven.wagon.providers.scm;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.scm.provider.ScmProvider;
+import org.apache.maven.scm.provider.svn.svnexe.SvnExeScmProvider;
+
+/**
+ * Test for ScmWagon using SVN Exe as underlying SCM
+ *
+ * @author <a href="carlos at apache.org">Carlos Sanchez</a>
+ *
+ */
+public class ScmSvnExeWagonTest
+ extends AbstractScmSvnWagonTest
+{
+
+ protected ScmProvider getScmProvider()
+ {
+ return new SvnExeScmProvider();
+ }
+
+}
diff --git a/wagon-providers/wagon-ssh-common-test/pom.xml b/wagon-providers/wagon-ssh-common-test/pom.xml
index 867f354..0f71304 100644
--- a/wagon-providers/wagon-ssh-common-test/pom.xml
+++ b/wagon-providers/wagon-ssh-common-test/pom.xml
@@ -1,62 +1,72 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-providers</artifactId>
- <version>2.10</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>wagon-ssh-common-test</artifactId>
- <name>Apache Maven Wagon :: Providers :: SSH Common Tests</name>
-
- <dependencies>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-container-default</artifactId>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-provider-test</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-ssh-common</artifactId>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sshd</groupId>
- <artifactId>sshd-core</artifactId>
- <scope>compile</scope>
- </dependency>
- </dependencies>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-providers</artifactId>
+ <version>2.12</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>wagon-ssh-common-test</artifactId>
+ <name>Apache Maven Wagon :: Providers :: SSH Common Tests</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-provider-test</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-ssh-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sshd</groupId>
+ <artifactId>sshd-core</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.mina</groupId>
+ <artifactId>mina-core</artifactId>
+ <version>2.0.5</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractEmbeddedScpWagonTest.java b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractEmbeddedScpWagonTest.java
index 0c01331..312e842 100644
--- a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractEmbeddedScpWagonTest.java
+++ b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractEmbeddedScpWagonTest.java
@@ -1,101 +1,101 @@
-package org.apache.maven.wagon.providers.ssh;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.StreamingWagonTestCase;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
-import org.apache.maven.wagon.repository.Repository;
-import org.apache.maven.wagon.resource.Resource;
-
-import java.io.File;
-import java.util.Arrays;
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public abstract class AbstractEmbeddedScpWagonTest
- extends StreamingWagonTestCase
-{
-
- SshServerEmbedded sshServer;
-
- @Override
- protected void setUp()
- throws Exception
- {
- super.setUp();
-
- String sshKeyResource = "ssh-keys/id_rsa";
-
- sshServer = new SshServerEmbedded( getProtocol(), Arrays.asList( sshKeyResource ), false );
-
- sshServer.start();
- System.out.println( "sshd on port " + sshServer.getPort() );
- }
-
- @Override
- @SuppressWarnings( "checkstyle:linelength" )
- protected void tearDownWagonTestingFixtures()
- throws Exception
- {
-
- for ( TestPasswordAuthenticator.PasswordAuthenticatorRequest request : sshServer.passwordAuthenticator.requests )
- {
- assertEquals( TestData.getUserName(), request.getUsername() );
- assertEquals( TestData.getUserPassword(), request.getPassword() );
- }
- sshServer.stop();
- }
-
- protected abstract String getProtocol();
-
- @Override
- protected int getTestRepositoryPort()
- {
- return sshServer.getPort();
- }
-
-
- public String getTestRepositoryUrl()
- {
- return TestData.getTestRepositoryUrl( sshServer.getPort() );
- }
-
- protected AuthenticationInfo getAuthInfo()
- {
- AuthenticationInfo authInfo = super.getAuthInfo();
-
- authInfo.setUserName( TestData.getUserName() );
- authInfo.setPassword( TestData.getUserPassword() );
-
- return authInfo;
- }
-
- protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
- {
- return new File( repository.getBasedir(), resource.getName() ).lastModified();
- }
-
-
- @Override
- protected abstract boolean supportsGetIfNewer();
-
-}
+package org.apache.maven.wagon.providers.ssh;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.StreamingWagonTestCase;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.resource.Resource;
+
+import java.io.File;
+import java.util.Arrays;
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public abstract class AbstractEmbeddedScpWagonTest
+ extends StreamingWagonTestCase
+{
+
+ SshServerEmbedded sshServer;
+
+ @Override
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ String sshKeyResource = "ssh-keys/id_rsa";
+
+ sshServer = new SshServerEmbedded( getProtocol(), Arrays.asList( sshKeyResource ), false );
+
+ sshServer.start();
+ System.out.println( "sshd on port " + sshServer.getPort() );
+ }
+
+ @Override
+ @SuppressWarnings( "checkstyle:linelength" )
+ protected void tearDownWagonTestingFixtures()
+ throws Exception
+ {
+
+ for ( TestPasswordAuthenticator.PasswordAuthenticatorRequest request : sshServer.passwordAuthenticator.requests )
+ {
+ assertEquals( TestData.getUserName(), request.getUsername() );
+ assertEquals( TestData.getUserPassword(), request.getPassword() );
+ }
+ sshServer.stop();
+ }
+
+ protected abstract String getProtocol();
+
+ @Override
+ protected int getTestRepositoryPort()
+ {
+ return sshServer.getPort();
+ }
+
+
+ public String getTestRepositoryUrl()
+ {
+ return TestData.getTestRepositoryUrl( sshServer.getPort() );
+ }
+
+ protected AuthenticationInfo getAuthInfo()
+ {
+ AuthenticationInfo authInfo = super.getAuthInfo();
+
+ authInfo.setUserName( TestData.getUserName() );
+ authInfo.setPassword( TestData.getUserPassword() );
+
+ return authInfo;
+ }
+
+ protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
+ {
+ return new File( repository.getBasedir(), resource.getName() ).lastModified();
+ }
+
+
+ @Override
+ protected abstract boolean supportsGetIfNewer();
+
+}
diff --git a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractEmbeddedScpWagonWithKeyTest.java b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractEmbeddedScpWagonWithKeyTest.java
index 3651fc1..ac6d6fc 100644
--- a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractEmbeddedScpWagonWithKeyTest.java
+++ b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/AbstractEmbeddedScpWagonWithKeyTest.java
@@ -1,168 +1,168 @@
-package org.apache.maven.wagon.providers.ssh;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.StreamingWagonTestCase;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
-import org.apache.maven.wagon.repository.Repository;
-import org.apache.maven.wagon.resource.Resource;
-import org.codehaus.plexus.util.FileUtils;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public abstract class AbstractEmbeddedScpWagonWithKeyTest
- extends StreamingWagonTestCase
-{
-
- SshServerEmbedded sshServerEmbedded;
-
-
- @Override
- protected void setUp()
- throws Exception
- {
- super.setUp();
-
- String sshKeyResource = "ssh-keys/id_rsa.pub";
-
- sshServerEmbedded = new SshServerEmbedded( getProtocol(), Arrays.asList( sshKeyResource ), true );
-
- sshServerEmbedded.start();
- System.out.println( "sshd on port " + sshServerEmbedded.getPort() );
- }
-
- @Override
- protected void tearDownWagonTestingFixtures()
- throws Exception
- {
-
- sshServerEmbedded.stop();
- }
-
- protected abstract String getProtocol();
-
- @Override
- protected int getTestRepositoryPort()
- {
- return sshServerEmbedded.getPort();
- }
-
-
- public String getTestRepositoryUrl()
- {
- return TestData.getTestRepositoryUrl( sshServerEmbedded.getPort() );
- }
-
- protected AuthenticationInfo getAuthInfo()
- {
- AuthenticationInfo authInfo = super.getAuthInfo();
- // user : guest/guest123 - passphrase : toto01
- authInfo.setUserName( "guest" );
- //authInfo.setPassword( TestData.getUserPassword() );
- authInfo.setPrivateKey( new File( "src/test/ssh-keys/id_rsa" ).getPath() );
-
- return authInfo;
- }
-
- protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
- {
- return new File( repository.getBasedir(), resource.getName() ).lastModified();
- }
-
- public void testConnect()
- throws Exception
- {
- getWagon().connect( new Repository( "foo", getTestRepositoryUrl() ), getAuthInfo() );
- assertTrue( true );
- }
-
-
- @Override
- protected boolean supportsGetIfNewer()
- {
- return false;
- }
-
- public void testWithSpaces()
- throws Exception
- {
- String dir = "foo test";
- File spaceDirectory = new File( TestData.getRepoPath(), dir );
- if ( spaceDirectory.exists() )
- {
- FileUtils.deleteDirectory( spaceDirectory );
- }
- spaceDirectory.mkdirs();
-
- String subDir = "foo bar";
- File sub = new File( spaceDirectory, subDir );
- if ( sub.exists() )
- {
- FileUtils.deleteDirectory( sub );
- }
- sub.mkdirs();
-
- File dummy = new File( "src/test/resources/dummy.txt" );
- FileUtils.copyFileToDirectory( dummy, sub );
-
- String url = getTestRepositoryUrl() + "/" + dir;
- Repository repo = new Repository( "foo", url );
- Wagon wagon = getWagon();
- wagon.connect( repo, getAuthInfo() );
- List<String> files = wagon.getFileList( subDir );
- assertNotNull( files );
- assertEquals( 1, files.size() );
- assertTrue( files.contains( "dummy.txt" ) );
-
- wagon.put( new File( "src/test/resources/dummy.txt" ), subDir + "/newdummy.txt" );
-
- files = wagon.getFileList( subDir );
- assertNotNull( files );
- assertEquals( 2, files.size() );
- assertTrue( files.contains( "dummy.txt" ) );
- assertTrue( files.contains( "newdummy.txt" ) );
-
- File sourceWithSpace = new File( "target/directory with spaces" );
- if ( sourceWithSpace.exists() )
- {
- FileUtils.deleteDirectory( sourceWithSpace );
- }
- File resources = new File( "src/test/resources" );
-
- FileUtils.copyDirectory( resources, sourceWithSpace );
-
- wagon.putDirectory( sourceWithSpace, "target with spaces" );
-
- files = wagon.getFileList( "target with spaces" );
-
- assertNotNull( files );
- assertTrue( files.contains( "dummy.txt" ) );
- assertFalse( files.contains( "newdummy.txt" ) );
- assertTrue( files.contains( "log4j.xml" ) );
- }
-
-}
+package org.apache.maven.wagon.providers.ssh;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.StreamingWagonTestCase;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.resource.Resource;
+import org.codehaus.plexus.util.FileUtils;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public abstract class AbstractEmbeddedScpWagonWithKeyTest
+ extends StreamingWagonTestCase
+{
+
+ SshServerEmbedded sshServerEmbedded;
+
+
+ @Override
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+
+ String sshKeyResource = "ssh-keys/id_rsa.pub";
+
+ sshServerEmbedded = new SshServerEmbedded( getProtocol(), Arrays.asList( sshKeyResource ), true );
+
+ sshServerEmbedded.start();
+ System.out.println( "sshd on port " + sshServerEmbedded.getPort() );
+ }
+
+ @Override
+ protected void tearDownWagonTestingFixtures()
+ throws Exception
+ {
+
+ sshServerEmbedded.stop();
+ }
+
+ protected abstract String getProtocol();
+
+ @Override
+ protected int getTestRepositoryPort()
+ {
+ return sshServerEmbedded.getPort();
+ }
+
+
+ public String getTestRepositoryUrl()
+ {
+ return TestData.getTestRepositoryUrl( sshServerEmbedded.getPort() );
+ }
+
+ protected AuthenticationInfo getAuthInfo()
+ {
+ AuthenticationInfo authInfo = super.getAuthInfo();
+ // user : guest/guest123 - passphrase : toto01
+ authInfo.setUserName( "guest" );
+ //authInfo.setPassword( TestData.getUserPassword() );
+ authInfo.setPrivateKey( new File( "src/test/ssh-keys/id_rsa" ).getPath() );
+
+ return authInfo;
+ }
+
+ protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
+ {
+ return new File( repository.getBasedir(), resource.getName() ).lastModified();
+ }
+
+ public void testConnect()
+ throws Exception
+ {
+ getWagon().connect( new Repository( "foo", getTestRepositoryUrl() ), getAuthInfo() );
+ assertTrue( true );
+ }
+
+
+ @Override
+ protected boolean supportsGetIfNewer()
+ {
+ return false;
+ }
+
+ public void testWithSpaces()
+ throws Exception
+ {
+ String dir = "foo test";
+ File spaceDirectory = new File( TestData.getRepoPath(), dir );
+ if ( spaceDirectory.exists() )
+ {
+ FileUtils.deleteDirectory( spaceDirectory );
+ }
+ spaceDirectory.mkdirs();
+
+ String subDir = "foo bar";
+ File sub = new File( spaceDirectory, subDir );
+ if ( sub.exists() )
+ {
+ FileUtils.deleteDirectory( sub );
+ }
+ sub.mkdirs();
+
+ File dummy = new File( "src/test/resources/dummy.txt" );
+ FileUtils.copyFileToDirectory( dummy, sub );
+
+ String url = getTestRepositoryUrl() + "/" + dir;
+ Repository repo = new Repository( "foo", url );
+ Wagon wagon = getWagon();
+ wagon.connect( repo, getAuthInfo() );
+ List<String> files = wagon.getFileList( subDir );
+ assertNotNull( files );
+ assertEquals( 1, files.size() );
+ assertTrue( files.contains( "dummy.txt" ) );
+
+ wagon.put( new File( "src/test/resources/dummy.txt" ), subDir + "/newdummy.txt" );
+
+ files = wagon.getFileList( subDir );
+ assertNotNull( files );
+ assertEquals( 2, files.size() );
+ assertTrue( files.contains( "dummy.txt" ) );
+ assertTrue( files.contains( "newdummy.txt" ) );
+
+ File sourceWithSpace = new File( "target/directory with spaces" );
+ if ( sourceWithSpace.exists() )
+ {
+ FileUtils.deleteDirectory( sourceWithSpace );
+ }
+ File resources = new File( "src/test/resources" );
+
+ FileUtils.copyDirectory( resources, sourceWithSpace );
+
+ wagon.putDirectory( sourceWithSpace, "target with spaces" );
+
+ files = wagon.getFileList( "target with spaces" );
+
+ assertNotNull( files );
+ assertTrue( files.contains( "dummy.txt" ) );
+ assertFalse( files.contains( "newdummy.txt" ) );
+ assertTrue( files.contains( "log4j.xml" ) );
+ }
+
+}
diff --git a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/ScpCommand.java b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/ScpCommand.java
index bdd80f5..e127c53 100644
--- a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/ScpCommand.java
+++ b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/ScpCommand.java
@@ -1,588 +1,588 @@
-package org.apache.maven.wagon.providers.ssh;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.sshd.common.util.DirectoryScanner;
-import org.apache.sshd.server.Command;
-import org.apache.sshd.server.Environment;
-import org.apache.sshd.server.ExitCallback;
-import org.apache.sshd.server.FileSystemAware;
-import org.apache.sshd.server.FileSystemView;
-import org.apache.sshd.server.SshFile;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.ByteArrayOutputStream;
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Arrays;
-
-/**
- * This commands provide SCP support on both server and client side.
- * Permissions and preservation of access / modification times on files
- * are not supported.
- * olamy : copy of a class from mina for changing return codes in case of file not found 1 warning instead of 2
- *
- * @author <a href="mailto:dev at mina.apache.org">Apache MINA SSHD Project</a>
- */
-public class ScpCommand
- implements Command, Runnable, FileSystemAware
-{
-
- protected static final Logger LOG = LoggerFactory.getLogger( ScpCommand.class );
-
- protected static final int OK = 0;
-
- protected static final int WARNING = 1;
-
- protected static final int ERROR = 2;
-
- protected String name;
-
- protected boolean optR;
-
- protected boolean optT;
-
- protected boolean optF;
-
- protected boolean optV;
-
- protected boolean optD;
-
- protected boolean optP;
-
- protected FileSystemView root;
-
- protected String path;
-
- protected InputStream in;
-
- protected OutputStream out;
-
- protected OutputStream err;
-
- protected ExitCallback callback;
-
- protected IOException error;
-
- public ScpCommand( String[] args )
- {
- name = Arrays.asList( args ).toString();
- if ( LOG.isDebugEnabled() )
- {
- LOG.debug( "Executing command {}", name );
- }
- path = ".";
- for ( int i = 1; i < args.length; i++ )
- {
- if ( args[i].charAt( 0 ) == '-' )
- {
- for ( int j = 1; j < args[i].length(); j++ )
- {
- switch ( args[i].charAt( j ) )
- {
- case 'f':
- optF = true;
- break;
- case 'p':
- optP = true;
- break;
- case 'r':
- optR = true;
- break;
- case 't':
- optT = true;
- break;
- case 'v':
- optV = true;
- break;
- case 'd':
- optD = true;
- break;
- default:
-// error = new IOException("Unsupported option: " + args[i].charAt(j));
-// return;
- }
- }
- }
- else if ( i == args.length - 1 )
- {
- path = args[args.length - 1];
- }
- }
- if ( !optF && !optT )
- {
- error = new IOException( "Either -f or -t option should be set" );
- }
- }
-
- public void setInputStream( InputStream in )
- {
- this.in = in;
- }
-
- public void setOutputStream( OutputStream out )
- {
- this.out = out;
- }
-
- public void setErrorStream( OutputStream err )
- {
- this.err = err;
- }
-
- public void setExitCallback( ExitCallback callback )
- {
- this.callback = callback;
- }
-
- public void start( Environment env )
- throws IOException
- {
- if ( error != null )
- {
- throw error;
- }
- new Thread( this, "ScpCommand: " + name ).start();
- }
-
- public void destroy()
- {
- }
-
- public void run()
- {
- int exitValue = OK;
- String exitMessage = null;
-
- try
- {
- if ( optT )
- {
- ack();
- for (; ; )
- {
- String line;
- boolean isDir = false;
- int c = readAck( true );
- switch ( c )
- {
- case -1:
- return;
- case 'D':
- isDir = true;
- case 'C':
- line = ( (char) c ) + readLine();
- break;
- case 'E':
- readLine();
- return;
- default:
- //a real ack that has been acted upon already
- continue;
- }
-
- if ( optR && isDir )
- {
- writeDir( line, root.getFile( path ) );
- }
- else
- {
- writeFile( line, root.getFile( path ) );
- }
- }
- }
- else if ( optF )
- {
- String pattern = path;
- int idx = pattern.indexOf( '*' );
- if ( idx >= 0 )
- {
- String basedir = "";
- int lastSep = pattern.substring( 0, idx ).lastIndexOf( '/' );
- if ( lastSep >= 0 )
- {
- basedir = pattern.substring( 0, lastSep );
- pattern = pattern.substring( lastSep + 1 );
- }
- String[] included = new DirectoryScanner( basedir, pattern ).scan();
- for ( String path : included )
- {
- SshFile file = root.getFile( basedir + "/" + path );
- if ( file.isFile() )
- {
- readFile( file );
- }
- else if ( file.isDirectory() )
- {
- if ( !optR )
- {
- out.write( WARNING );
- out.write( ( path + " not a regular file\n" ).getBytes() );
- }
- else
- {
- readDir( file );
- }
- }
- else
- {
- out.write( WARNING );
- out.write( ( path + " unknown file type\n" ).getBytes() );
- }
- }
- }
- else
- {
- String basedir = "";
- int lastSep = pattern.lastIndexOf( '/' );
- if ( lastSep >= 0 )
- {
- basedir = pattern.substring( 0, lastSep );
- pattern = pattern.substring( lastSep + 1 );
- }
- SshFile file = root.getFile( basedir + "/" + pattern );
- if ( !file.doesExist() )
- {
- exitValue = WARNING;
- throw new IOException( file + ": no such file or directory" );
- }
- if ( file.isFile() )
- {
- readFile( file );
- }
- else if ( file.isDirectory() )
- {
- if ( !optR )
- {
- throw new IOException( file + " not a regular file" );
- }
- else
- {
- readDir( file );
- }
- }
- else
- {
- throw new IOException( file + ": unknown file type" );
- }
- }
- }
- else
- {
- throw new IOException( "Unsupported mode" );
- }
- }
- catch ( IOException e )
- {
- try
- {
- exitValue = ( exitValue != OK ? exitValue : ERROR );
- exitMessage = e.getMessage();
- out.write( exitValue );
- out.write( exitMessage.getBytes() );
- out.write( '\n' );
- out.flush();
- }
- catch ( IOException e2 )
- {
- // Ignore
- }
- LOG.info( "Error in scp command", e );
- }
- finally
- {
- if ( callback != null )
- {
- callback.onExit( exitValue, exitMessage );
- }
- }
- }
-
- protected void writeDir( String header, SshFile path )
- throws IOException
- {
- if ( LOG.isDebugEnabled() )
- {
- LOG.debug( "Writing dir {}", path );
- }
- if ( !header.startsWith( "D" ) )
- {
- throw new IOException( "Expected a D message but got '" + header + "'" );
- }
-
- String perms = header.substring( 1, 5 );
- int length = Integer.parseInt( header.substring( 6, header.indexOf( ' ', 6 ) ) );
- String name = header.substring( header.indexOf( ' ', 6 ) + 1 );
-
- if ( length != 0 )
- {
- throw new IOException( "Expected 0 length for directory but got " + length );
- }
- SshFile file;
- if ( path.doesExist() && path.isDirectory() )
- {
- file = root.getFile( path, name );
- }
- else if ( !path.doesExist() && path.getParentFile().doesExist() && path.getParentFile().isDirectory() )
- {
- file = path;
- }
- else
- {
- throw new IOException( "Can not write to " + path );
- }
- if ( !( file.doesExist() && file.isDirectory() ) && !file.mkdir() )
- {
- throw new IOException( "Could not create directory " + file );
- }
-
- ack();
-
- for (; ; )
- {
- header = readLine();
- if ( header.startsWith( "C" ) )
- {
- writeFile( header, file );
- }
- else if ( header.startsWith( "D" ) )
- {
- writeDir( header, file );
- }
- else if ( header.equals( "E" ) )
- {
- ack();
- break;
- }
- else
- {
- throw new IOException( "Unexpected message: '" + header + "'" );
- }
- }
-
- }
-
- protected void writeFile( String header, SshFile path )
- throws IOException
- {
- if ( LOG.isDebugEnabled() )
- {
- LOG.debug( "Writing file {}", path );
- }
- if ( !header.startsWith( "C" ) )
- {
- throw new IOException( "Expected a C message but got '" + header + "'" );
- }
-
- String perms = header.substring( 1, 5 );
- long length = Long.parseLong( header.substring( 6, header.indexOf( ' ', 6 ) ) );
- String name = header.substring( header.indexOf( ' ', 6 ) + 1 );
-
- SshFile file;
- if ( path.doesExist() && path.isDirectory() )
- {
- file = root.getFile( path, name );
- }
- else if ( path.doesExist() && path.isFile() )
- {
- file = path;
- }
- else if ( !path.doesExist() && path.getParentFile().doesExist() && path.getParentFile().isDirectory() )
- {
- file = path;
- }
- else
- {
- throw new IOException( "Can not write to " + path );
- }
- if ( file.doesExist() && file.isDirectory() )
- {
- throw new IOException( "File is a directory: " + file );
- }
- else if ( file.doesExist() && !file.isWritable() )
- {
- throw new IOException( "Can not write to file: " + file );
- }
- OutputStream os = file.createOutputStream( 0 );
- try
- {
- ack();
-
- byte[] buffer = new byte[8 * 1024];
- while ( length > 0 )
- {
- int len = (int) Math.min( length, buffer.length );
- len = in.read( buffer, 0, len );
- if ( len <= 0 )
- {
- throw new IOException( "End of stream reached" );
- }
- os.write( buffer, 0, len );
- length -= len;
- }
- }
- finally
- {
- os.close();
- }
-
- ack();
- readAck( false );
- }
-
- protected String readLine()
- throws IOException
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- for (; ; )
- {
- int c = in.read();
- if ( c == '\n' )
- {
- return baos.toString();
- }
- else if ( c == -1 )
- {
- throw new IOException( "End of stream" );
- }
- else
- {
- baos.write( c );
- }
- }
- }
-
- protected void readFile( SshFile path )
- throws IOException
- {
- if ( LOG.isDebugEnabled() )
- {
- LOG.debug( "Reading file {}", path );
- }
- StringBuilder buf = new StringBuilder();
- buf.append( "C" );
- buf.append( "0644" ); // what about perms
- buf.append( " " );
- buf.append( path.getSize() ); // length
- buf.append( " " );
- buf.append( path.getName() );
- buf.append( "\n" );
- out.write( buf.toString().getBytes() );
- out.flush();
- readAck( false );
-
- InputStream is = path.createInputStream( 0 );
- try
- {
- byte[] buffer = new byte[8 * 1024];
- for (; ; )
- {
- int len = is.read( buffer, 0, buffer.length );
- if ( len == -1 )
- {
- break;
- }
- out.write( buffer, 0, len );
- }
- }
- finally
- {
- is.close();
- }
- ack();
- readAck( false );
- }
-
- protected void readDir( SshFile path )
- throws IOException
- {
- if ( LOG.isDebugEnabled() )
- {
- LOG.debug( "Reading directory {}", path );
- }
- StringBuilder buf = new StringBuilder();
- buf.append( "D" );
- buf.append( "0755" ); // what about perms
- buf.append( " " );
- buf.append( "0" ); // length
- buf.append( " " );
- buf.append( path.getName() );
- buf.append( "\n" );
- out.write( buf.toString().getBytes() );
- out.flush();
- readAck( false );
-
- for ( SshFile child : path.listSshFiles() )
- {
- if ( child.isFile() )
- {
- readFile( child );
- }
- else if ( child.isDirectory() )
- {
- readDir( child );
- }
- }
-
- out.write( "E\n".getBytes() );
- out.flush();
- readAck( false );
- }
-
- protected void ack()
- throws IOException
- {
- out.write( 0 );
- out.flush();
- }
-
- protected int readAck( boolean canEof )
- throws IOException
- {
- int c = in.read();
- switch ( c )
- {
- case -1:
- if ( !canEof )
- {
- throw new EOFException();
- }
- break;
- case OK:
- break;
- case WARNING:
- LOG.warn( "Received warning: " + readLine() );
- break;
- case ERROR:
- throw new IOException( "Received nack: " + readLine() );
- default:
- break;
- }
- return c;
- }
-
- public void setFileSystemView( FileSystemView view )
- {
- this.root = view;
- }
-}
+package org.apache.maven.wagon.providers.ssh;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.sshd.common.util.DirectoryScanner;
+import org.apache.sshd.server.Command;
+import org.apache.sshd.server.Environment;
+import org.apache.sshd.server.ExitCallback;
+import org.apache.sshd.server.FileSystemAware;
+import org.apache.sshd.server.FileSystemView;
+import org.apache.sshd.server.SshFile;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.ByteArrayOutputStream;
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Arrays;
+
+/**
+ * This commands provide SCP support on both server and client side.
+ * Permissions and preservation of access / modification times on files
+ * are not supported.
+ * olamy : copy of a class from mina for changing return codes in case of file not found 1 warning instead of 2
+ *
+ * @author <a href="mailto:dev at mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class ScpCommand
+ implements Command, Runnable, FileSystemAware
+{
+
+ protected static final Logger LOG = LoggerFactory.getLogger( ScpCommand.class );
+
+ protected static final int OK = 0;
+
+ protected static final int WARNING = 1;
+
+ protected static final int ERROR = 2;
+
+ protected String name;
+
+ protected boolean optR;
+
+ protected boolean optT;
+
+ protected boolean optF;
+
+ protected boolean optV;
+
+ protected boolean optD;
+
+ protected boolean optP;
+
+ protected FileSystemView root;
+
+ protected String path;
+
+ protected InputStream in;
+
+ protected OutputStream out;
+
+ protected OutputStream err;
+
+ protected ExitCallback callback;
+
+ protected IOException error;
+
+ public ScpCommand( String[] args )
+ {
+ name = Arrays.asList( args ).toString();
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( "Executing command {}", name );
+ }
+ path = ".";
+ for ( int i = 1; i < args.length; i++ )
+ {
+ if ( args[i].charAt( 0 ) == '-' )
+ {
+ for ( int j = 1; j < args[i].length(); j++ )
+ {
+ switch ( args[i].charAt( j ) )
+ {
+ case 'f':
+ optF = true;
+ break;
+ case 'p':
+ optP = true;
+ break;
+ case 'r':
+ optR = true;
+ break;
+ case 't':
+ optT = true;
+ break;
+ case 'v':
+ optV = true;
+ break;
+ case 'd':
+ optD = true;
+ break;
+ default:
+// error = new IOException("Unsupported option: " + args[i].charAt(j));
+// return;
+ }
+ }
+ }
+ else if ( i == args.length - 1 )
+ {
+ path = args[args.length - 1];
+ }
+ }
+ if ( !optF && !optT )
+ {
+ error = new IOException( "Either -f or -t option should be set" );
+ }
+ }
+
+ public void setInputStream( InputStream in )
+ {
+ this.in = in;
+ }
+
+ public void setOutputStream( OutputStream out )
+ {
+ this.out = out;
+ }
+
+ public void setErrorStream( OutputStream err )
+ {
+ this.err = err;
+ }
+
+ public void setExitCallback( ExitCallback callback )
+ {
+ this.callback = callback;
+ }
+
+ public void start( Environment env )
+ throws IOException
+ {
+ if ( error != null )
+ {
+ throw error;
+ }
+ new Thread( this, "ScpCommand: " + name ).start();
+ }
+
+ public void destroy()
+ {
+ }
+
+ public void run()
+ {
+ int exitValue = OK;
+ String exitMessage = null;
+
+ try
+ {
+ if ( optT )
+ {
+ ack();
+ for (; ; )
+ {
+ String line;
+ boolean isDir = false;
+ int c = readAck( true );
+ switch ( c )
+ {
+ case -1:
+ return;
+ case 'D':
+ isDir = true;
+ case 'C':
+ line = ( (char) c ) + readLine();
+ break;
+ case 'E':
+ readLine();
+ return;
+ default:
+ //a real ack that has been acted upon already
+ continue;
+ }
+
+ if ( optR && isDir )
+ {
+ writeDir( line, root.getFile( path ) );
+ }
+ else
+ {
+ writeFile( line, root.getFile( path ) );
+ }
+ }
+ }
+ else if ( optF )
+ {
+ String pattern = path;
+ int idx = pattern.indexOf( '*' );
+ if ( idx >= 0 )
+ {
+ String basedir = "";
+ int lastSep = pattern.substring( 0, idx ).lastIndexOf( '/' );
+ if ( lastSep >= 0 )
+ {
+ basedir = pattern.substring( 0, lastSep );
+ pattern = pattern.substring( lastSep + 1 );
+ }
+ String[] included = new DirectoryScanner( basedir, pattern ).scan();
+ for ( String path : included )
+ {
+ SshFile file = root.getFile( basedir + "/" + path );
+ if ( file.isFile() )
+ {
+ readFile( file );
+ }
+ else if ( file.isDirectory() )
+ {
+ if ( !optR )
+ {
+ out.write( WARNING );
+ out.write( ( path + " not a regular file\n" ).getBytes() );
+ }
+ else
+ {
+ readDir( file );
+ }
+ }
+ else
+ {
+ out.write( WARNING );
+ out.write( ( path + " unknown file type\n" ).getBytes() );
+ }
+ }
+ }
+ else
+ {
+ String basedir = "";
+ int lastSep = pattern.lastIndexOf( '/' );
+ if ( lastSep >= 0 )
+ {
+ basedir = pattern.substring( 0, lastSep );
+ pattern = pattern.substring( lastSep + 1 );
+ }
+ SshFile file = root.getFile( basedir + "/" + pattern );
+ if ( !file.doesExist() )
+ {
+ exitValue = WARNING;
+ throw new IOException( file + ": no such file or directory" );
+ }
+ if ( file.isFile() )
+ {
+ readFile( file );
+ }
+ else if ( file.isDirectory() )
+ {
+ if ( !optR )
+ {
+ throw new IOException( file + " not a regular file" );
+ }
+ else
+ {
+ readDir( file );
+ }
+ }
+ else
+ {
+ throw new IOException( file + ": unknown file type" );
+ }
+ }
+ }
+ else
+ {
+ throw new IOException( "Unsupported mode" );
+ }
+ }
+ catch ( IOException e )
+ {
+ try
+ {
+ exitValue = ( exitValue != OK ? exitValue : ERROR );
+ exitMessage = e.getMessage();
+ out.write( exitValue );
+ out.write( exitMessage.getBytes() );
+ out.write( '\n' );
+ out.flush();
+ }
+ catch ( IOException e2 )
+ {
+ // Ignore
+ }
+ LOG.info( "Error in scp command", e );
+ }
+ finally
+ {
+ if ( callback != null )
+ {
+ callback.onExit( exitValue, exitMessage );
+ }
+ }
+ }
+
+ protected void writeDir( String header, SshFile path )
+ throws IOException
+ {
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( "Writing dir {}", path );
+ }
+ if ( !header.startsWith( "D" ) )
+ {
+ throw new IOException( "Expected a D message but got '" + header + "'" );
+ }
+
+ String perms = header.substring( 1, 5 );
+ int length = Integer.parseInt( header.substring( 6, header.indexOf( ' ', 6 ) ) );
+ String name = header.substring( header.indexOf( ' ', 6 ) + 1 );
+
+ if ( length != 0 )
+ {
+ throw new IOException( "Expected 0 length for directory but got " + length );
+ }
+ SshFile file;
+ if ( path.doesExist() && path.isDirectory() )
+ {
+ file = root.getFile( path, name );
+ }
+ else if ( !path.doesExist() && path.getParentFile().doesExist() && path.getParentFile().isDirectory() )
+ {
+ file = path;
+ }
+ else
+ {
+ throw new IOException( "Can not write to " + path );
+ }
+ if ( !( file.doesExist() && file.isDirectory() ) && !file.mkdir() )
+ {
+ throw new IOException( "Could not create directory " + file );
+ }
+
+ ack();
+
+ for (; ; )
+ {
+ header = readLine();
+ if ( header.startsWith( "C" ) )
+ {
+ writeFile( header, file );
+ }
+ else if ( header.startsWith( "D" ) )
+ {
+ writeDir( header, file );
+ }
+ else if ( header.equals( "E" ) )
+ {
+ ack();
+ break;
+ }
+ else
+ {
+ throw new IOException( "Unexpected message: '" + header + "'" );
+ }
+ }
+
+ }
+
+ protected void writeFile( String header, SshFile path )
+ throws IOException
+ {
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( "Writing file {}", path );
+ }
+ if ( !header.startsWith( "C" ) )
+ {
+ throw new IOException( "Expected a C message but got '" + header + "'" );
+ }
+
+ String perms = header.substring( 1, 5 );
+ long length = Long.parseLong( header.substring( 6, header.indexOf( ' ', 6 ) ) );
+ String name = header.substring( header.indexOf( ' ', 6 ) + 1 );
+
+ SshFile file;
+ if ( path.doesExist() && path.isDirectory() )
+ {
+ file = root.getFile( path, name );
+ }
+ else if ( path.doesExist() && path.isFile() )
+ {
+ file = path;
+ }
+ else if ( !path.doesExist() && path.getParentFile().doesExist() && path.getParentFile().isDirectory() )
+ {
+ file = path;
+ }
+ else
+ {
+ throw new IOException( "Can not write to " + path );
+ }
+ if ( file.doesExist() && file.isDirectory() )
+ {
+ throw new IOException( "File is a directory: " + file );
+ }
+ else if ( file.doesExist() && !file.isWritable() )
+ {
+ throw new IOException( "Can not write to file: " + file );
+ }
+ OutputStream os = file.createOutputStream( 0 );
+ try
+ {
+ ack();
+
+ byte[] buffer = new byte[8 * 1024];
+ while ( length > 0 )
+ {
+ int len = (int) Math.min( length, buffer.length );
+ len = in.read( buffer, 0, len );
+ if ( len <= 0 )
+ {
+ throw new IOException( "End of stream reached" );
+ }
+ os.write( buffer, 0, len );
+ length -= len;
+ }
+ }
+ finally
+ {
+ os.close();
+ }
+
+ ack();
+ readAck( false );
+ }
+
+ protected String readLine()
+ throws IOException
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ for (; ; )
+ {
+ int c = in.read();
+ if ( c == '\n' )
+ {
+ return baos.toString();
+ }
+ else if ( c == -1 )
+ {
+ throw new IOException( "End of stream" );
+ }
+ else
+ {
+ baos.write( c );
+ }
+ }
+ }
+
+ protected void readFile( SshFile path )
+ throws IOException
+ {
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( "Reading file {}", path );
+ }
+ StringBuilder buf = new StringBuilder();
+ buf.append( "C" );
+ buf.append( "0644" ); // what about perms
+ buf.append( " " );
+ buf.append( path.getSize() ); // length
+ buf.append( " " );
+ buf.append( path.getName() );
+ buf.append( "\n" );
+ out.write( buf.toString().getBytes() );
+ out.flush();
+ readAck( false );
+
+ InputStream is = path.createInputStream( 0 );
+ try
+ {
+ byte[] buffer = new byte[8 * 1024];
+ for (; ; )
+ {
+ int len = is.read( buffer, 0, buffer.length );
+ if ( len == -1 )
+ {
+ break;
+ }
+ out.write( buffer, 0, len );
+ }
+ }
+ finally
+ {
+ is.close();
+ }
+ ack();
+ readAck( false );
+ }
+
+ protected void readDir( SshFile path )
+ throws IOException
+ {
+ if ( LOG.isDebugEnabled() )
+ {
+ LOG.debug( "Reading directory {}", path );
+ }
+ StringBuilder buf = new StringBuilder();
+ buf.append( "D" );
+ buf.append( "0755" ); // what about perms
+ buf.append( " " );
+ buf.append( "0" ); // length
+ buf.append( " " );
+ buf.append( path.getName() );
+ buf.append( "\n" );
+ out.write( buf.toString().getBytes() );
+ out.flush();
+ readAck( false );
+
+ for ( SshFile child : path.listSshFiles() )
+ {
+ if ( child.isFile() )
+ {
+ readFile( child );
+ }
+ else if ( child.isDirectory() )
+ {
+ readDir( child );
+ }
+ }
+
+ out.write( "E\n".getBytes() );
+ out.flush();
+ readAck( false );
+ }
+
+ protected void ack()
+ throws IOException
+ {
+ out.write( 0 );
+ out.flush();
+ }
+
+ protected int readAck( boolean canEof )
+ throws IOException
+ {
+ int c = in.read();
+ switch ( c )
+ {
+ case -1:
+ if ( !canEof )
+ {
+ throw new EOFException();
+ }
+ break;
+ case OK:
+ break;
+ case WARNING:
+ LOG.warn( "Received warning: " + readLine() );
+ break;
+ case ERROR:
+ throw new IOException( "Received nack: " + readLine() );
+ default:
+ break;
+ }
+ return c;
+ }
+
+ public void setFileSystemView( FileSystemView view )
+ {
+ this.root = view;
+ }
+}
diff --git a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/ScpCommandFactory.java b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/ScpCommandFactory.java
index e16904e..1c0bd1b 100644
--- a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/ScpCommandFactory.java
+++ b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/ScpCommandFactory.java
@@ -1,112 +1,112 @@
-package org.apache.maven.wagon.providers.ssh;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.sshd.server.Command;
-import org.apache.sshd.server.CommandFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * This <code>CommandFactory</code> can be used as a standalone command factory
- * or can be used to augment another <code>CommandFactory</code> and provides
- * <code>SCP</code> support.
- *
- * @see ScpCommand
- *
- * @author <a href="mailto:dev at mina.apache.org">Apache MINA SSHD Project</a>
- */
-public class ScpCommandFactory
- implements CommandFactory
-{
-
- private CommandFactory delegate;
-
- public ScpCommandFactory()
- {
- }
-
- public ScpCommandFactory( CommandFactory delegate )
- {
- this.delegate = delegate;
- }
-
- /**
- * Parses a command string and verifies that the basic syntax is
- * correct. If parsing fails the responsibility is delegated to
- * the configured {@link org.apache.sshd.server.CommandFactory} instance; if one exist.
- *
- * @param command command to parse
- * @return configured {@link org.apache.sshd.server.Command} instance
- * @throws IllegalArgumentException
- */
- public Command createCommand( String command )
- {
- try
- {
- return new ScpCommand( splitCommandString( command ) );
- }
- catch ( IllegalArgumentException iae )
- {
- if ( delegate != null )
- {
- return delegate.createCommand( command );
- }
- throw iae;
- }
- }
-
- private String[] splitCommandString( String command )
- {
- if ( !command.trim().startsWith( "scp" ) )
- {
- throw new IllegalArgumentException( "Unknown command, does not begin with 'scp'" );
- }
-
- String[] args = command.split( " " );
- List<String> parts = new ArrayList<String>();
- parts.add( args[0] );
- for ( int i = 1; i < args.length; i++ )
- {
- if ( !args[i].trim().startsWith( "-" ) )
- {
- parts.add( concatenateWithSpace( args, i ) );
- break;
- }
- else
- {
- parts.add( args[i] );
- }
- }
- return parts.toArray( new String[parts.size()] );
- }
-
- private String concatenateWithSpace( String[] args, int from )
- {
- StringBuilder sb = new StringBuilder();
-
- for ( int i = from; i < args.length; i++ )
- {
- sb.append( args[i] + " " );
- }
- return sb.toString().trim();
- }
-}
+package org.apache.maven.wagon.providers.ssh;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.sshd.server.Command;
+import org.apache.sshd.server.CommandFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This <code>CommandFactory</code> can be used as a standalone command factory
+ * or can be used to augment another <code>CommandFactory</code> and provides
+ * <code>SCP</code> support.
+ *
+ * @see ScpCommand
+ *
+ * @author <a href="mailto:dev at mina.apache.org">Apache MINA SSHD Project</a>
+ */
+public class ScpCommandFactory
+ implements CommandFactory
+{
+
+ private CommandFactory delegate;
+
+ public ScpCommandFactory()
+ {
+ }
+
+ public ScpCommandFactory( CommandFactory delegate )
+ {
+ this.delegate = delegate;
+ }
+
+ /**
+ * Parses a command string and verifies that the basic syntax is
+ * correct. If parsing fails the responsibility is delegated to
+ * the configured {@link org.apache.sshd.server.CommandFactory} instance; if one exist.
+ *
+ * @param command command to parse
+ * @return configured {@link org.apache.sshd.server.Command} instance
+ * @throws IllegalArgumentException
+ */
+ public Command createCommand( String command )
+ {
+ try
+ {
+ return new ScpCommand( splitCommandString( command ) );
+ }
+ catch ( IllegalArgumentException iae )
+ {
+ if ( delegate != null )
+ {
+ return delegate.createCommand( command );
+ }
+ throw iae;
+ }
+ }
+
+ private String[] splitCommandString( String command )
+ {
+ if ( !command.trim().startsWith( "scp" ) )
+ {
+ throw new IllegalArgumentException( "Unknown command, does not begin with 'scp'" );
+ }
+
+ String[] args = command.split( " " );
+ List<String> parts = new ArrayList<String>();
+ parts.add( args[0] );
+ for ( int i = 1; i < args.length; i++ )
+ {
+ if ( !args[i].trim().startsWith( "-" ) )
+ {
+ parts.add( concatenateWithSpace( args, i ) );
+ break;
+ }
+ else
+ {
+ parts.add( args[i] );
+ }
+ }
+ return parts.toArray( new String[parts.size()] );
+ }
+
+ private String concatenateWithSpace( String[] args, int from )
+ {
+ StringBuilder sb = new StringBuilder();
+
+ for ( int i = from; i < args.length; i++ )
+ {
+ sb.append( args[i] + " " );
+ }
+ return sb.toString().trim();
+ }
+}
diff --git a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/ShellCommand.java b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/ShellCommand.java
index 1783829..9509173 100644
--- a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/ShellCommand.java
+++ b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/ShellCommand.java
@@ -1,171 +1,171 @@
-package org.apache.maven.wagon.providers.ssh;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.sshd.server.Command;
-import org.apache.sshd.server.Environment;
-import org.apache.sshd.server.ExitCallback;
-import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.cli.CommandLineUtils;
-import org.codehaus.plexus.util.cli.Commandline;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * @author Olivier Lamy
- */
-public class ShellCommand implements Command
-{
-protected static final int OK = 0;
-
- protected static final int WARNING = 1;
-
- protected static final int ERROR = 2;
-
- private InputStream in;
-
- private OutputStream out;
-
- private OutputStream err;
-
- private ExitCallback callback;
-
- private Thread thread;
-
- private String commandLine;
-
- public ShellCommand( String commandLine )
- {
- this.commandLine = commandLine;
- }
-
- public void setInputStream( InputStream in )
- {
- this.in = in;
- }
-
- public void setOutputStream( OutputStream out )
- {
- this.out = out;
- }
-
- public void setErrorStream( OutputStream err )
- {
- this.err = err;
- }
-
- public void setExitCallback( ExitCallback callback )
- {
- this.callback = callback;
- }
-
- public void start( Environment env )
- throws IOException
- {
- File tmpFile = File.createTempFile( "wagon", "test-sh" );
- tmpFile.deleteOnExit();
- int exitValue = 0;
- CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
- CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();
- try
- {
-
- // hackhish defaut commandline tools not support ; or && so write a file with the script
- // and "/bin/sh -e " + tmpFile.getPath();
- FileUtils.fileWrite( tmpFile, commandLine );
-
- Commandline cl = new Commandline();
- cl.setExecutable( "/bin/sh" );
- //cl.createArg().setValue( "-e" );
- //cl.createArg().setValue( tmpFile.getPath() );
- cl.createArg().setFile( tmpFile );
-
- exitValue = CommandLineUtils.executeCommandLine( cl, stdout, stderr );
- System.out.println( "exit value " + exitValue );
- /*
- if ( exitValue == 0 )
- {
- out.write( stdout.getOutput().getBytes() );
- out.write( '\n' );
- out.flush();
-
- }
- else
- {
- out.write( stderr.getOutput().getBytes() );
- out.write( '\n' );
- out.flush();
-
- }*/
-
- }
- catch ( Exception e )
- {
- exitValue = ERROR;
- e.printStackTrace();
- }
- finally
- {
- deleteQuietly( tmpFile );
- if ( exitValue != 0 )
- {
- err.write( stderr.getOutput().getBytes() );
- err.write( '\n' );
- err.flush();
- callback.onExit( exitValue, stderr.getOutput() );
- }
- else
- {
- out.write( stdout.getOutput().getBytes() );
- out.write( '\n' );
- out.flush();
- callback.onExit( exitValue, stdout.getOutput() );
- }
-
- }
- /*
- out.write( exitValue );
- out.write( '\n' );
-
- */
- out.flush();
- }
-
- public void destroy()
- {
-
- }
-
- private void deleteQuietly( File f )
- {
-
- try
- {
- f.delete();
- }
- catch ( Exception e )
- {
- // ignore
- }
- }
-}
+package org.apache.maven.wagon.providers.ssh;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.sshd.server.Command;
+import org.apache.sshd.server.Environment;
+import org.apache.sshd.server.ExitCallback;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
+import org.codehaus.plexus.util.cli.Commandline;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * @author Olivier Lamy
+ */
+public class ShellCommand implements Command
+{
+protected static final int OK = 0;
+
+ protected static final int WARNING = 1;
+
+ protected static final int ERROR = 2;
+
+ private InputStream in;
+
+ private OutputStream out;
+
+ private OutputStream err;
+
+ private ExitCallback callback;
+
+ private Thread thread;
+
+ private String commandLine;
+
+ public ShellCommand( String commandLine )
+ {
+ this.commandLine = commandLine;
+ }
+
+ public void setInputStream( InputStream in )
+ {
+ this.in = in;
+ }
+
+ public void setOutputStream( OutputStream out )
+ {
+ this.out = out;
+ }
+
+ public void setErrorStream( OutputStream err )
+ {
+ this.err = err;
+ }
+
+ public void setExitCallback( ExitCallback callback )
+ {
+ this.callback = callback;
+ }
+
+ public void start( Environment env )
+ throws IOException
+ {
+ File tmpFile = File.createTempFile( "wagon", "test-sh" );
+ tmpFile.deleteOnExit();
+ int exitValue = 0;
+ CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
+ CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();
+ try
+ {
+
+ // hackhish defaut commandline tools not support ; or && so write a file with the script
+ // and "/bin/sh -e " + tmpFile.getPath();
+ FileUtils.fileWrite( tmpFile, commandLine );
+
+ Commandline cl = new Commandline();
+ cl.setExecutable( "/bin/sh" );
+ //cl.createArg().setValue( "-e" );
+ //cl.createArg().setValue( tmpFile.getPath() );
+ cl.createArg().setFile( tmpFile );
+
+ exitValue = CommandLineUtils.executeCommandLine( cl, stdout, stderr );
+ System.out.println( "exit value " + exitValue );
+ /*
+ if ( exitValue == 0 )
+ {
+ out.write( stdout.getOutput().getBytes() );
+ out.write( '\n' );
+ out.flush();
+
+ }
+ else
+ {
+ out.write( stderr.getOutput().getBytes() );
+ out.write( '\n' );
+ out.flush();
+
+ }*/
+
+ }
+ catch ( Exception e )
+ {
+ exitValue = ERROR;
+ e.printStackTrace();
+ }
+ finally
+ {
+ deleteQuietly( tmpFile );
+ if ( exitValue != 0 )
+ {
+ err.write( stderr.getOutput().getBytes() );
+ err.write( '\n' );
+ err.flush();
+ callback.onExit( exitValue, stderr.getOutput() );
+ }
+ else
+ {
+ out.write( stdout.getOutput().getBytes() );
+ out.write( '\n' );
+ out.flush();
+ callback.onExit( exitValue, stdout.getOutput() );
+ }
+
+ }
+ /*
+ out.write( exitValue );
+ out.write( '\n' );
+
+ */
+ out.flush();
+ }
+
+ public void destroy()
+ {
+
+ }
+
+ private void deleteQuietly( File f )
+ {
+
+ try
+ {
+ f.delete();
+ }
+ catch ( Exception e )
+ {
+ // ignore
+ }
+ }
+}
diff --git a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/SshServerEmbedded.java b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/SshServerEmbedded.java
index d988451..c04dce4 100644
--- a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/SshServerEmbedded.java
+++ b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/SshServerEmbedded.java
@@ -1,208 +1,208 @@
-package org.apache.maven.wagon.providers.ssh;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.mina.core.session.IoSession;
-import org.apache.sshd.SshServer;
-import org.apache.sshd.common.Session;
-import org.apache.sshd.common.session.AbstractSession;
-import org.apache.sshd.server.Command;
-import org.apache.sshd.server.CommandFactory;
-import org.apache.sshd.server.FileSystemFactory;
-import org.apache.sshd.server.FileSystemView;
-import org.apache.sshd.server.PasswordAuthenticator;
-import org.apache.sshd.server.SshFile;
-import org.apache.sshd.server.auth.UserAuthPassword;
-import org.apache.sshd.server.auth.UserAuthPublicKey;
-import org.apache.sshd.server.filesystem.NativeSshFile;
-import org.apache.sshd.server.keyprovider.PEMGeneratorHostKeyProvider;
-import org.apache.sshd.server.session.SessionFactory;
-import org.apache.sshd.server.shell.ProcessShellFactory;
-import org.codehaus.plexus.util.FileUtils;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * @author Olivier Lamy
- */
-public class SshServerEmbedded
-{
- private String wagonProtocol;
-
- private int port;
-
- private SshServer sshd;
-
- private List<String> sshKeysResources = new ArrayList<String>();
-
- private TestPublickeyAuthenticator publickeyAuthenticator;
-
- TestPasswordAuthenticator passwordAuthenticator = new TestPasswordAuthenticator();
-
- private boolean keyAuthz;
-
-
- /**
- * @param wagonProtocol scp scpexe
- * @param sshKeysResources paths in the classlaoder with ssh keys
- */
- public SshServerEmbedded( String wagonProtocol, List<String> sshKeysResources, boolean keyAuthz )
- {
- this.wagonProtocol = wagonProtocol;
-
- this.sshKeysResources = sshKeysResources;
-
- this.sshd = SshServer.setUpDefaultServer();
-
- //this.sshd.setKeyExchangeFactories( );
-
- this.keyAuthz = keyAuthz;
-
- publickeyAuthenticator = new TestPublickeyAuthenticator( this.keyAuthz );
- }
-
- /**
- * @return random port used
- */
- public int start()
- throws IOException
- {
- sshd.setPort( 0 );
-
- sshd.setUserAuthFactories( Arrays.asList( new UserAuthPublicKey.Factory(), new UserAuthPassword.Factory() ) );
-
- sshd.setPublickeyAuthenticator( this.publickeyAuthenticator );
-
- sshd.setPasswordAuthenticator( this.passwordAuthenticator );
-
- sshd.setUserAuthFactories( Arrays.asList( new UserAuthPublicKey.Factory(), new UserAuthPassword.Factory() ) );
-
- //ResourceKeyPairProvider resourceKeyPairProvider =
- // new ResourceKeyPairProvider( sshKeysResources.toArray( new String[sshKeysResources.size()] ) );
-
- File path = new File( "target/keys" );
- path.mkdirs();
- path = new File( path, "simple.key" );
- path.delete();
-
- PEMGeneratorHostKeyProvider provider = new PEMGeneratorHostKeyProvider();
- provider.setAlgorithm( "RSA" );
- provider.setKeySize( 1024 );
- provider.setPath( path.getPath() );
-
- sshd.setKeyPairProvider( provider );
- SessionFactory sessionFactory = new SessionFactory()
- {
- @Override
- protected AbstractSession doCreateSession( IoSession ioSession )
- throws Exception
- {
- return super.doCreateSession( ioSession );
- }
- };
- sshd.setSessionFactory( sessionFactory );
-
- //sshd.setFileSystemFactory( );
-
- final ProcessShellFactory processShellFactory =
- new ProcessShellFactory( new String[]{ "/bin/sh", "-i", "-l" } );
- sshd.setShellFactory( processShellFactory );
-
- CommandFactory delegateCommandFactory = new CommandFactory()
- {
- public Command createCommand( String command )
- {
- return new ShellCommand( command );
- }
- };
-
- ScpCommandFactory commandFactory = new ScpCommandFactory( delegateCommandFactory );
- sshd.setCommandFactory( commandFactory );
-
- FileSystemFactory fileSystemFactory = new FileSystemFactory()
- {
- public FileSystemView createFileSystemView( Session session )
- throws IOException
- {
- return new FileSystemView()
- {
- public SshFile getFile( String file )
- {
- file = file.replace( "\\", "" );
- file = file.replace( "\"", "" );
- File f = new File( FileUtils.normalize( file ) );
-
- return new SshServerEmbedded.TestSshFile( f.getAbsolutePath(), f,
- System.getProperty( "user.name" ) );
- }
-
- public SshFile getFile( SshFile baseDir, String file )
- {
- file = file.replace( "\\", "" );
- file = file.replace( "\"", "" );
- File f = new File( FileUtils.normalize( file ) );
- return new SshServerEmbedded.TestSshFile( f.getAbsolutePath(), f,
- System.getProperty( "user.name" ) );
- }
- };
- }
- };
- sshd.setNioWorkers( 0 );
- //sshd.setScheduledExecutorService( );
- sshd.setFileSystemFactory( fileSystemFactory );
- sshd.start();
- this.port = sshd.getPort();
- return this.port;
- }
-
-
- public void stop()
- throws InterruptedException
- {
- sshd.stop( Boolean.getBoolean( "sshd.stopImmediatly" ) );
- }
-
- public int getPort()
- {
- return port;
- }
-
- public PasswordAuthenticator getPasswordAuthenticator()
- {
- return passwordAuthenticator;
- }
- /**
- *
- */
- public static class TestSshFile
- extends NativeSshFile
- {
- public TestSshFile( String fileName, File file, String userName )
- {
-
- super( FileUtils.normalize( fileName ), file, userName );
- }
- }
-
-}
+package org.apache.maven.wagon.providers.ssh;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.mina.core.session.IoSession;
+import org.apache.sshd.SshServer;
+import org.apache.sshd.common.Session;
+import org.apache.sshd.common.session.AbstractSession;
+import org.apache.sshd.server.Command;
+import org.apache.sshd.server.CommandFactory;
+import org.apache.sshd.server.FileSystemFactory;
+import org.apache.sshd.server.FileSystemView;
+import org.apache.sshd.server.PasswordAuthenticator;
+import org.apache.sshd.server.SshFile;
+import org.apache.sshd.server.auth.UserAuthPassword;
+import org.apache.sshd.server.auth.UserAuthPublicKey;
+import org.apache.sshd.server.filesystem.NativeSshFile;
+import org.apache.sshd.server.keyprovider.PEMGeneratorHostKeyProvider;
+import org.apache.sshd.server.session.SessionFactory;
+import org.apache.sshd.server.shell.ProcessShellFactory;
+import org.codehaus.plexus.util.FileUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ */
+public class SshServerEmbedded
+{
+ private String wagonProtocol;
+
+ private int port;
+
+ private SshServer sshd;
+
+ private List<String> sshKeysResources = new ArrayList<String>();
+
+ private TestPublickeyAuthenticator publickeyAuthenticator;
+
+ TestPasswordAuthenticator passwordAuthenticator = new TestPasswordAuthenticator();
+
+ private boolean keyAuthz;
+
+
+ /**
+ * @param wagonProtocol scp scpexe
+ * @param sshKeysResources paths in the classlaoder with ssh keys
+ */
+ public SshServerEmbedded( String wagonProtocol, List<String> sshKeysResources, boolean keyAuthz )
+ {
+ this.wagonProtocol = wagonProtocol;
+
+ this.sshKeysResources = sshKeysResources;
+
+ this.sshd = SshServer.setUpDefaultServer();
+
+ //this.sshd.setKeyExchangeFactories( );
+
+ this.keyAuthz = keyAuthz;
+
+ publickeyAuthenticator = new TestPublickeyAuthenticator( this.keyAuthz );
+ }
+
+ /**
+ * @return random port used
+ */
+ public int start()
+ throws IOException
+ {
+ sshd.setPort( 0 );
+
+ sshd.setUserAuthFactories( Arrays.asList( new UserAuthPublicKey.Factory(), new UserAuthPassword.Factory() ) );
+
+ sshd.setPublickeyAuthenticator( this.publickeyAuthenticator );
+
+ sshd.setPasswordAuthenticator( this.passwordAuthenticator );
+
+ sshd.setUserAuthFactories( Arrays.asList( new UserAuthPublicKey.Factory(), new UserAuthPassword.Factory() ) );
+
+ //ResourceKeyPairProvider resourceKeyPairProvider =
+ // new ResourceKeyPairProvider( sshKeysResources.toArray( new String[sshKeysResources.size()] ) );
+
+ File path = new File( "target/keys" );
+ path.mkdirs();
+ path = new File( path, "simple.key" );
+ path.delete();
+
+ PEMGeneratorHostKeyProvider provider = new PEMGeneratorHostKeyProvider();
+ provider.setAlgorithm( "RSA" );
+ provider.setKeySize( 1024 );
+ provider.setPath( path.getPath() );
+
+ sshd.setKeyPairProvider( provider );
+ SessionFactory sessionFactory = new SessionFactory()
+ {
+ @Override
+ protected AbstractSession doCreateSession( IoSession ioSession )
+ throws Exception
+ {
+ return super.doCreateSession( ioSession );
+ }
+ };
+ sshd.setSessionFactory( sessionFactory );
+
+ //sshd.setFileSystemFactory( );
+
+ final ProcessShellFactory processShellFactory =
+ new ProcessShellFactory( new String[]{ "/bin/sh", "-i", "-l" } );
+ sshd.setShellFactory( processShellFactory );
+
+ CommandFactory delegateCommandFactory = new CommandFactory()
+ {
+ public Command createCommand( String command )
+ {
+ return new ShellCommand( command );
+ }
+ };
+
+ ScpCommandFactory commandFactory = new ScpCommandFactory( delegateCommandFactory );
+ sshd.setCommandFactory( commandFactory );
+
+ FileSystemFactory fileSystemFactory = new FileSystemFactory()
+ {
+ public FileSystemView createFileSystemView( Session session )
+ throws IOException
+ {
+ return new FileSystemView()
+ {
+ public SshFile getFile( String file )
+ {
+ file = file.replace( "\\", "" );
+ file = file.replace( "\"", "" );
+ File f = new File( FileUtils.normalize( file ) );
+
+ return new SshServerEmbedded.TestSshFile( f.getAbsolutePath(), f,
+ System.getProperty( "user.name" ) );
+ }
+
+ public SshFile getFile( SshFile baseDir, String file )
+ {
+ file = file.replace( "\\", "" );
+ file = file.replace( "\"", "" );
+ File f = new File( FileUtils.normalize( file ) );
+ return new SshServerEmbedded.TestSshFile( f.getAbsolutePath(), f,
+ System.getProperty( "user.name" ) );
+ }
+ };
+ }
+ };
+ sshd.setNioWorkers( 0 );
+ //sshd.setScheduledExecutorService( );
+ sshd.setFileSystemFactory( fileSystemFactory );
+ sshd.start();
+ this.port = sshd.getPort();
+ return this.port;
+ }
+
+
+ public void stop()
+ throws InterruptedException
+ {
+ sshd.stop( Boolean.getBoolean( "sshd.stopImmediatly" ) );
+ }
+
+ public int getPort()
+ {
+ return port;
+ }
+
+ public PasswordAuthenticator getPasswordAuthenticator()
+ {
+ return passwordAuthenticator;
+ }
+ /**
+ *
+ */
+ public static class TestSshFile
+ extends NativeSshFile
+ {
+ public TestSshFile( String fileName, File file, String userName )
+ {
+
+ super( FileUtils.normalize( fileName ), file, userName );
+ }
+ }
+
+}
diff --git a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestData.java b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestData.java
index 39a71c1..fa73a9d 100644
--- a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestData.java
+++ b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestData.java
@@ -1,81 +1,81 @@
-package org.apache.maven.wagon.providers.ssh;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.codehaus.plexus.util.FileUtils;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * @author <a href="michal at codehaus.org">Michal Maczka</a>
- *
- */
-public class TestData
-{
- public static String getTempDirectory()
- {
- return System.getProperty( "java.io.tmpdir", "target" );
- }
-
- public static String getTestRepositoryUrl( int port )
- {
- return "scp://" + getHostname() + ":" + port + getRepoPath();
- }
-
- public static String getRepoPath()
- {
- return getTempDirectory() + "/wagon-ssh-test/" + getUserName();
- }
-
- public static String getUserName()
- {
- return System.getProperty( "test.user", System.getProperty( "user.name" ) );
- }
-
- public static String getUserPassword()
- {
- return "comeonFrance!:-)";
- }
-
- public static File getPrivateKey()
- {
- return new File( System.getProperty( "sshKeysPath", "src/test/ssh-keys" ), "id_rsa" );
- }
-
- public static String getHostname()
- {
- return System.getProperty( "test.host", "localhost" );
- }
-
- public static String getHostKey()
- {
- try
- {
- return FileUtils.fileRead(
- new File( System.getProperty( "sshKeysPath" ), "id_rsa.pub" ).getPath() ).substring(
- "ssh-rsa".length() ).trim();
- }
- catch ( IOException e )
- {
- return null;
- }
- }
-}
+package org.apache.maven.wagon.providers.ssh;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.codehaus.plexus.util.FileUtils;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * @author <a href="michal at codehaus.org">Michal Maczka</a>
+ *
+ */
+public class TestData
+{
+ public static String getTempDirectory()
+ {
+ return System.getProperty( "java.io.tmpdir", "target" );
+ }
+
+ public static String getTestRepositoryUrl( int port )
+ {
+ return "scp://" + getHostname() + ":" + port + getRepoPath();
+ }
+
+ public static String getRepoPath()
+ {
+ return getTempDirectory() + "/wagon-ssh-test/" + getUserName();
+ }
+
+ public static String getUserName()
+ {
+ return System.getProperty( "test.user", System.getProperty( "user.name" ) );
+ }
+
+ public static String getUserPassword()
+ {
+ return "comeonFrance!:-)";
+ }
+
+ public static File getPrivateKey()
+ {
+ return new File( System.getProperty( "sshKeysPath", "src/test/ssh-keys" ), "id_rsa" );
+ }
+
+ public static String getHostname()
+ {
+ return System.getProperty( "test.host", "localhost" );
+ }
+
+ public static String getHostKey()
+ {
+ try
+ {
+ return FileUtils.fileRead(
+ new File( System.getProperty( "sshKeysPath" ), "id_rsa.pub" ).getPath() ).substring(
+ "ssh-rsa".length() ).trim();
+ }
+ catch ( IOException e )
+ {
+ return null;
+ }
+ }
+}
diff --git a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestPasswordAuthenticator.java b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestPasswordAuthenticator.java
index 83cca13..2b872ff 100644
--- a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestPasswordAuthenticator.java
+++ b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestPasswordAuthenticator.java
@@ -1,81 +1,81 @@
-package org.apache.maven.wagon.providers.ssh;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.sshd.server.PasswordAuthenticator;
-import org.apache.sshd.server.session.ServerSession;
-import org.codehaus.plexus.util.StringUtils;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Olivier Lamy
- */
-public class TestPasswordAuthenticator
- implements PasswordAuthenticator
-{
- List<PasswordAuthenticatorRequest> requests =
- new ArrayList<PasswordAuthenticatorRequest>();
-
- public boolean authenticate( String username, String password, ServerSession session )
- {
- requests.add( new PasswordAuthenticatorRequest( username, password ) );
- return StringUtils.equals( username, TestData.getUserName() )
- && StringUtils.equals( password, TestData.getUserPassword() );
- }
-
- /**
- *
- */
- public static class PasswordAuthenticatorRequest
- {
- private String username;
-
- private String password;
-
- public PasswordAuthenticatorRequest( String username, String password )
- {
- this.username = username;
- this.password = password;
- }
-
- @Override
- public String toString()
- {
- final StringBuilder sb = new StringBuilder();
- sb.append( "PasswordAuthenticatorRequest" );
- sb.append( "{username='" ).append( username ).append( '\'' );
- sb.append( ", password='" ).append( password ).append( '\'' );
- sb.append( '}' );
- return sb.toString();
- }
-
- public String getUsername()
- {
- return username;
- }
-
- public String getPassword()
- {
- return password;
- }
- }
-}
+package org.apache.maven.wagon.providers.ssh;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.sshd.server.PasswordAuthenticator;
+import org.apache.sshd.server.session.ServerSession;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ */
+public class TestPasswordAuthenticator
+ implements PasswordAuthenticator
+{
+ List<PasswordAuthenticatorRequest> requests =
+ new ArrayList<PasswordAuthenticatorRequest>();
+
+ public boolean authenticate( String username, String password, ServerSession session )
+ {
+ requests.add( new PasswordAuthenticatorRequest( username, password ) );
+ return StringUtils.equals( username, TestData.getUserName() )
+ && StringUtils.equals( password, TestData.getUserPassword() );
+ }
+
+ /**
+ *
+ */
+ public static class PasswordAuthenticatorRequest
+ {
+ private String username;
+
+ private String password;
+
+ public PasswordAuthenticatorRequest( String username, String password )
+ {
+ this.username = username;
+ this.password = password;
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "PasswordAuthenticatorRequest" );
+ sb.append( "{username='" ).append( username ).append( '\'' );
+ sb.append( ", password='" ).append( password ).append( '\'' );
+ sb.append( '}' );
+ return sb.toString();
+ }
+
+ public String getUsername()
+ {
+ return username;
+ }
+
+ public String getPassword()
+ {
+ return password;
+ }
+ }
+}
diff --git a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestPublickeyAuthenticator.java b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestPublickeyAuthenticator.java
index 1ed8632..f791d83 100644
--- a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestPublickeyAuthenticator.java
+++ b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestPublickeyAuthenticator.java
@@ -1,184 +1,191 @@
-package org.apache.maven.wagon.providers.ssh;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.mina.util.Base64;
-import org.apache.sshd.server.PublickeyAuthenticator;
-import org.apache.sshd.server.session.ServerSession;
-import org.codehaus.plexus.util.IOUtil;
-
-import javax.crypto.Cipher;
-import java.io.InputStream;
-import java.math.BigInteger;
-import java.security.KeyFactory;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.interfaces.RSAPublicKey;
-import java.security.spec.DSAPublicKeySpec;
-import java.security.spec.RSAPublicKeySpec;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Olivier Lamy
- */
-public class TestPublickeyAuthenticator
- implements PublickeyAuthenticator
-{
- private List<PublickeyAuthenticatorRequest> publickeyAuthenticatorRequests =
- new ArrayList<PublickeyAuthenticatorRequest>();
-
- private boolean keyAuthz;
-
- public TestPublickeyAuthenticator( boolean keyAuthz )
- {
- this.keyAuthz = keyAuthz;
- }
-
- public boolean authenticate( String username, PublicKey key, ServerSession session )
- {
- if ( !keyAuthz )
- {
- return false;
- }
- try
- {
- InputStream is =
- Thread.currentThread().getContextClassLoader().getResourceAsStream( "ssh-keys/id_rsa.pub" );
- PublicKey publicKey = decodePublicKey( IOUtil.toString( is ) );
- publickeyAuthenticatorRequests.add( new PublickeyAuthenticatorRequest( username, key ) );
-
- return ( (RSAPublicKey) publicKey ).getModulus().equals( ( (RSAPublicKey) publicKey ).getModulus() );
- }
- catch ( Exception e )
- {
- throw new RuntimeException( e.getMessage(), e );
- }
- }
-
- public static byte[] decrypt( byte[] text, PrivateKey key )
- throws Exception
- {
- byte[] dectyptedText = null;
- Cipher cipher = Cipher.getInstance( "RSA/ECB/PKCS1Padding" );
- cipher.init( Cipher.DECRYPT_MODE, key );
- dectyptedText = cipher.doFinal( text );
- return dectyptedText;
- }
-
- /**
- *
- */
- public static class PublickeyAuthenticatorRequest
- {
- private String username;
-
- private PublicKey publicKey;
-
- public PublickeyAuthenticatorRequest( String username, PublicKey publicKey )
- {
- this.username = username;
- this.publicKey = publicKey;
- }
-
- @Override
- public String toString()
- {
- final StringBuilder sb = new StringBuilder();
- sb.append( "PublickeyAuthenticatorRequest" );
- sb.append( "{username='" ).append( username ).append( '\'' );
- sb.append( ", publicKey=" ).append( publicKey );
- sb.append( '}' );
- return sb.toString();
- }
- }
-
- private byte[] bytes;
-
- private int pos;
-
- public PublicKey decodePublicKey( String keyLine )
- throws Exception
- {
- bytes = null;
- pos = 0;
-
- for ( String part : keyLine.split( " " ) )
- {
- if ( part.startsWith( "AAAA" ) )
- {
- bytes = Base64.decodeBase64( part.getBytes() );
- break;
- }
- }
- if ( bytes == null )
- {
- throw new IllegalArgumentException( "no Base64 part to decode" );
- }
-
- String type = decodeType();
- if ( type.equals( "ssh-rsa" ) )
- {
- BigInteger e = decodeBigInt();
- BigInteger m = decodeBigInt();
- RSAPublicKeySpec spec = new RSAPublicKeySpec( m, e );
- return KeyFactory.getInstance( "RSA" ).generatePublic( spec );
- }
- else if ( type.equals( "ssh-dss" ) )
- {
- BigInteger p = decodeBigInt();
- BigInteger q = decodeBigInt();
- BigInteger g = decodeBigInt();
- BigInteger y = decodeBigInt();
- DSAPublicKeySpec spec = new DSAPublicKeySpec( y, p, q, g );
- return KeyFactory.getInstance( "DSA" ).generatePublic( spec );
- }
- else
- {
- throw new IllegalArgumentException( "unknown type " + type );
- }
- }
-
- private String decodeType()
- {
- int len = decodeInt();
- String type = new String( bytes, pos, len );
- pos += len;
- return type;
- }
-
- private int decodeInt()
- {
- // CHECKSTYLE_OFF: MagicNumber
- return ( ( bytes[pos++] & 0xFF ) << 24 ) | ( ( bytes[pos++] & 0xFF ) << 16 ) | ( ( bytes[pos++] & 0xFF ) << 8 )
- | ( bytes[pos++] & 0xFF );
- // CHECKSTYLE_ON: MagicNumber
- }
-
- private BigInteger decodeBigInt()
- {
- int len = decodeInt();
- byte[] bigIntBytes = new byte[len];
- System.arraycopy( bytes, pos, bigIntBytes, 0, len );
- pos += len;
- return new BigInteger( bigIntBytes );
- }
-
-}
+package org.apache.maven.wagon.providers.ssh;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.mina.util.Base64;
+import org.apache.sshd.server.PublickeyAuthenticator;
+import org.apache.sshd.server.session.ServerSession;
+import org.codehaus.plexus.util.IOUtil;
+
+import javax.crypto.Cipher;
+import java.io.InputStream;
+import java.math.BigInteger;
+import java.security.KeyFactory;
+import java.security.PrivateKey;
+import java.security.PublicKey;
+import java.security.interfaces.RSAPublicKey;
+import java.security.spec.DSAPublicKeySpec;
+import java.security.spec.RSAPublicKeySpec;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Olivier Lamy
+ */
+public class TestPublickeyAuthenticator
+ implements PublickeyAuthenticator
+{
+ private List<PublickeyAuthenticatorRequest> publickeyAuthenticatorRequests =
+ new ArrayList<PublickeyAuthenticatorRequest>();
+
+ private boolean keyAuthz;
+
+ public TestPublickeyAuthenticator( boolean keyAuthz )
+ {
+ this.keyAuthz = keyAuthz;
+ }
+
+ public boolean authenticate( String username, PublicKey key, ServerSession session )
+ {
+ if ( !keyAuthz )
+ {
+ return false;
+ }
+ InputStream in = null;
+ try
+ {
+ in = Thread.currentThread().getContextClassLoader().getResourceAsStream( "ssh-keys/id_rsa.pub" );
+ PublicKey publicKey = decodePublicKey( IOUtil.toString( in ) );
+ in.close();
+ in = null;
+
+ publickeyAuthenticatorRequests.add( new PublickeyAuthenticatorRequest( username, key ) );
+
+ return ( (RSAPublicKey) publicKey ).getModulus().equals( ( (RSAPublicKey) publicKey ).getModulus() );
+ }
+ catch ( Exception e )
+ {
+ throw new RuntimeException( e.getMessage(), e );
+ }
+ finally
+ {
+ IOUtil.close( in );
+ }
+ }
+
+ public static byte[] decrypt( byte[] text, PrivateKey key )
+ throws Exception
+ {
+ byte[] dectyptedText = null;
+ Cipher cipher = Cipher.getInstance( "RSA/ECB/PKCS1Padding" );
+ cipher.init( Cipher.DECRYPT_MODE, key );
+ dectyptedText = cipher.doFinal( text );
+ return dectyptedText;
+ }
+
+ /**
+ *
+ */
+ public static class PublickeyAuthenticatorRequest
+ {
+ private String username;
+
+ private PublicKey publicKey;
+
+ public PublickeyAuthenticatorRequest( String username, PublicKey publicKey )
+ {
+ this.username = username;
+ this.publicKey = publicKey;
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "PublickeyAuthenticatorRequest" );
+ sb.append( "{username='" ).append( username ).append( '\'' );
+ sb.append( ", publicKey=" ).append( publicKey );
+ sb.append( '}' );
+ return sb.toString();
+ }
+ }
+
+ private byte[] bytes;
+
+ private int pos;
+
+ public PublicKey decodePublicKey( String keyLine )
+ throws Exception
+ {
+ bytes = null;
+ pos = 0;
+
+ for ( String part : keyLine.split( " " ) )
+ {
+ if ( part.startsWith( "AAAA" ) )
+ {
+ bytes = Base64.decodeBase64( part.getBytes() );
+ break;
+ }
+ }
+ if ( bytes == null )
+ {
+ throw new IllegalArgumentException( "no Base64 part to decode" );
+ }
+
+ String type = decodeType();
+ if ( type.equals( "ssh-rsa" ) )
+ {
+ BigInteger e = decodeBigInt();
+ BigInteger m = decodeBigInt();
+ RSAPublicKeySpec spec = new RSAPublicKeySpec( m, e );
+ return KeyFactory.getInstance( "RSA" ).generatePublic( spec );
+ }
+ else if ( type.equals( "ssh-dss" ) )
+ {
+ BigInteger p = decodeBigInt();
+ BigInteger q = decodeBigInt();
+ BigInteger g = decodeBigInt();
+ BigInteger y = decodeBigInt();
+ DSAPublicKeySpec spec = new DSAPublicKeySpec( y, p, q, g );
+ return KeyFactory.getInstance( "DSA" ).generatePublic( spec );
+ }
+ else
+ {
+ throw new IllegalArgumentException( "unknown type " + type );
+ }
+ }
+
+ private String decodeType()
+ {
+ int len = decodeInt();
+ String type = new String( bytes, pos, len );
+ pos += len;
+ return type;
+ }
+
+ private int decodeInt()
+ {
+ // CHECKSTYLE_OFF: MagicNumber
+ return ( ( bytes[pos++] & 0xFF ) << 24 ) | ( ( bytes[pos++] & 0xFF ) << 16 ) | ( ( bytes[pos++] & 0xFF ) << 8 )
+ | ( bytes[pos++] & 0xFF );
+ // CHECKSTYLE_ON: MagicNumber
+ }
+
+ private BigInteger decodeBigInt()
+ {
+ int len = decodeInt();
+ byte[] bigIntBytes = new byte[len];
+ System.arraycopy( bytes, pos, bigIntBytes, 0, len );
+ pos += len;
+ return new BigInteger( bigIntBytes );
+ }
+
+}
diff --git a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/KnownHostsProviderTestCase.java b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/KnownHostsProviderTestCase.java
index 77bb067..8b38e8d 100644
--- a/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/KnownHostsProviderTestCase.java
+++ b/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/KnownHostsProviderTestCase.java
@@ -1,126 +1,126 @@
-package org.apache.maven.wagon.providers.ssh.knownhost;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.providers.ssh.SshWagon;
-import org.apache.maven.wagon.providers.ssh.TestData;
-import org.apache.maven.wagon.repository.Repository;
-import org.codehaus.plexus.PlexusTestCase;
-
-/**
- *
- */
-public class KnownHostsProviderTestCase
- extends PlexusTestCase
-{
- protected KnownHostsProvider okHostsProvider;
-
- protected KnownHostsProvider failHostsProvider;
-
- protected KnownHostsProvider changedHostsProvider;
-
- private SshWagon wagon;
-
- private Repository source;
-
- private static final String CORRECT_KEY = TestData.getHostKey();
-
- private static final String CHANGED_KEY =
- "AAAAB3NzaC1yc2EAAAABIwAAAQEA8VLKkfHl2CNqW+m0603z07dyweWzzdVGQlMPUX4z1264E7M/h+6lPKiOo+u49CL7eQVA+FtW"
- + "TZoJ3oBAMABcKnHx41TnSpQUkbdR6rzyC6IG1lXiVtEjG2w7DUnxpCtVo5PaQuJobwoXv5NNL3vx03THPgcDJquLPWvGnDWhnXoEh"
- + "3/6c7rprwT+PrjZ6LIT35ZCUGajoehhF151oNbFMQHllfR6EAiZIP0z0nIVI+Jiv6g+XZapumVPVYjdOfxvLKQope1H9HJamT3bDI"
- + "m8mkebUB10DzQJYxFt4/0wiNH3L4jsIFn+CiW1/IQm5yyff1CUO87OqVbtp9BlaXZNmw==";
-
- /**
- * tests what happens if the remote host has a different key than the one
- * we expect
- *
- * @throws Exception on error
- */
- public void testIncorrectKey()
- throws Exception
- {
- wagon.setKnownHostsProvider( failHostsProvider );
-
- try
- {
- wagon.connect( source );
-
- fail( "Should not have successfully connected - host is not known" );
- }
- catch ( UnknownHostException e )
- {
- // ok
- }
- }
-
- /**
- * tests what happens if the remote host has changed since being recorded.
- *
- * @throws Exception on error
- */
- public void testChangedKey()
- throws Exception
- {
- wagon.setKnownHostsProvider( changedHostsProvider );
-
- try
- {
- wagon.connect( source );
-
- fail( "Should not have successfully connected - host is changed" );
- }
- catch ( KnownHostChangedException e )
- {
- // ok
- }
- }
-
- /**
- * tests what happens if the remote host has the expected key
- *
- * @throws Exception on error
- */
- public void testCorrectKey()
- throws Exception
- {
- wagon.setKnownHostsProvider( okHostsProvider );
-
- wagon.connect( source );
-
- assertTrue( true );
- }
-
- protected void setUp()
- throws Exception
- {
- super.setUp();
- source =
- new Repository( "test", "scp://" + TestData.getUserName() + "@" + TestData.getHostname() + "/tmp/foo" );
-
- wagon = (SshWagon) lookup( Wagon.ROLE, "scp" );
- wagon.setInteractive( false );
-
- this.okHostsProvider = new SingleKnownHostProvider( TestData.getHostname(), CORRECT_KEY );
- this.failHostsProvider = new SingleKnownHostProvider( "beaver.codehaus.org", CORRECT_KEY );
- this.changedHostsProvider = new SingleKnownHostProvider( TestData.getHostname(), CHANGED_KEY );
- }
-}
+package org.apache.maven.wagon.providers.ssh.knownhost;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.providers.ssh.SshWagon;
+import org.apache.maven.wagon.providers.ssh.TestData;
+import org.apache.maven.wagon.repository.Repository;
+import org.codehaus.plexus.PlexusTestCase;
+
+/**
+ *
+ */
+public class KnownHostsProviderTestCase
+ extends PlexusTestCase
+{
+ protected KnownHostsProvider okHostsProvider;
+
+ protected KnownHostsProvider failHostsProvider;
+
+ protected KnownHostsProvider changedHostsProvider;
+
+ private SshWagon wagon;
+
+ private Repository source;
+
+ private static final String CORRECT_KEY = TestData.getHostKey();
+
+ private static final String CHANGED_KEY =
+ "AAAAB3NzaC1yc2EAAAABIwAAAQEA8VLKkfHl2CNqW+m0603z07dyweWzzdVGQlMPUX4z1264E7M/h+6lPKiOo+u49CL7eQVA+FtW"
+ + "TZoJ3oBAMABcKnHx41TnSpQUkbdR6rzyC6IG1lXiVtEjG2w7DUnxpCtVo5PaQuJobwoXv5NNL3vx03THPgcDJquLPWvGnDWhnXoEh"
+ + "3/6c7rprwT+PrjZ6LIT35ZCUGajoehhF151oNbFMQHllfR6EAiZIP0z0nIVI+Jiv6g+XZapumVPVYjdOfxvLKQope1H9HJamT3bDI"
+ + "m8mkebUB10DzQJYxFt4/0wiNH3L4jsIFn+CiW1/IQm5yyff1CUO87OqVbtp9BlaXZNmw==";
+
+ /**
+ * tests what happens if the remote host has a different key than the one
+ * we expect
+ *
+ * @throws Exception on error
+ */
+ public void testIncorrectKey()
+ throws Exception
+ {
+ wagon.setKnownHostsProvider( failHostsProvider );
+
+ try
+ {
+ wagon.connect( source );
+
+ fail( "Should not have successfully connected - host is not known" );
+ }
+ catch ( UnknownHostException e )
+ {
+ // ok
+ }
+ }
+
+ /**
+ * tests what happens if the remote host has changed since being recorded.
+ *
+ * @throws Exception on error
+ */
+ public void testChangedKey()
+ throws Exception
+ {
+ wagon.setKnownHostsProvider( changedHostsProvider );
+
+ try
+ {
+ wagon.connect( source );
+
+ fail( "Should not have successfully connected - host is changed" );
+ }
+ catch ( KnownHostChangedException e )
+ {
+ // ok
+ }
+ }
+
+ /**
+ * tests what happens if the remote host has the expected key
+ *
+ * @throws Exception on error
+ */
+ public void testCorrectKey()
+ throws Exception
+ {
+ wagon.setKnownHostsProvider( okHostsProvider );
+
+ wagon.connect( source );
+
+ assertTrue( true );
+ }
+
+ protected void setUp()
+ throws Exception
+ {
+ super.setUp();
+ source =
+ new Repository( "test", "scp://" + TestData.getUserName() + "@" + TestData.getHostname() + "/tmp/foo" );
+
+ wagon = (SshWagon) lookup( Wagon.ROLE, "scp" );
+ wagon.setInteractive( false );
+
+ this.okHostsProvider = new SingleKnownHostProvider( TestData.getHostname(), CORRECT_KEY );
+ this.failHostsProvider = new SingleKnownHostProvider( "beaver.codehaus.org", CORRECT_KEY );
+ this.changedHostsProvider = new SingleKnownHostProvider( TestData.getHostname(), CHANGED_KEY );
+ }
+}
diff --git a/wagon-providers/wagon-ssh-common-test/src/site/site.xml b/wagon-providers/wagon-ssh-common-test/src/site/site.xml
index 487c523..5d9afe5 100644
--- a/wagon-providers/wagon-ssh-common-test/src/site/site.xml
+++ b/wagon-providers/wagon-ssh-common-test/src/site/site.xml
@@ -1,33 +1,33 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
- <body>
- <breadcrumbs>
- <item name="SSH Common Test" href="http://maven.apache.org/wagon/wagon-providers/wagon-ssh-common-test/index.html" />
- </breadcrumbs>
-
- <menu ref="parent"/>
- <menu ref="reports"/>
- </body>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
+ <body>
+ <breadcrumbs>
+ <item name="SSH Common Test" href="http://maven.apache.org/wagon/wagon-providers/wagon-ssh-common-test/index.html" />
+ </breadcrumbs>
+
+ <menu ref="parent"/>
+ <menu ref="reports"/>
+ </body>
</project>
\ No newline at end of file
diff --git a/wagon-providers/wagon-ssh-common/pom.xml b/wagon-providers/wagon-ssh-common/pom.xml
index fc67f2d..2f854db 100644
--- a/wagon-providers/wagon-ssh-common/pom.xml
+++ b/wagon-providers/wagon-ssh-common/pom.xml
@@ -1,49 +1,54 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-providers</artifactId>
- <version>2.10</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>wagon-ssh-common</artifactId>
- <name>Apache Maven Wagon :: Providers :: SSH Common Library</name>
-
- <dependencies>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-interactivity-api</artifactId>
- <exclusions>
- <exclusion>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- </dependencies>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-providers</artifactId>
+ <version>2.12</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>wagon-ssh-common</artifactId>
+ <name>Apache Maven Wagon :: Providers :: SSH Common Library</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-interactivity-api</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-api</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/CommandExecutorStreamProcessor.java b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/CommandExecutorStreamProcessor.java
index ebd5967..4d8e2a7 100644
--- a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/CommandExecutorStreamProcessor.java
+++ b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/CommandExecutorStreamProcessor.java
@@ -1,89 +1,89 @@
-package org.apache.maven.wagon.providers.ssh;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.Streams;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-
-/**
- * CommandExecutorStreamProcessor
- *
- * @author <a href="mailto:joakim at erdfelt.com">Joakim Erdfelt</a>
- *
- */
-public class CommandExecutorStreamProcessor
-{
- private CommandExecutorStreamProcessor()
- {
- // shoo!
- }
-
- public static Streams processStreams( BufferedReader stderrReader, BufferedReader stdoutReader )
- throws IOException
- {
- Streams streams = new Streams();
- while ( true )
- {
- String line = stdoutReader.readLine();
-
- if ( line == null )
- {
- break;
- }
-
- streams.setOut( streams.getOut() + line + "\n" );
- }
-
- // drain the output stream.
- // TODO: we'll save this for the 1.0-alpha-8 line, so we can test it more. the -q arg in the
- // unzip command should keep us until then...
-// int avail = in.available();
-// byte[] trashcan = new byte[1024];
-//
-// while( ( avail = in.available() ) > 0 )
-// {
-// in.read( trashcan, 0, avail );
-// }
-
- // drain stderr next, if stream size is more than the allowed buffer size
- // ( ie jsch has a hardcoded 32K size), the remote shell may be blocked. See WAGON-431
- while ( true )
- {
- String line = stderrReader.readLine();
-
- if ( line == null )
- {
- break;
- }
-
- // TODO: I think we need to deal with exit codes instead, but IIRC there are some cases of errors that
- // don't have exit codes ignore this error. TODO: output a warning
- if ( !line.startsWith( "Could not chdir to home directory" )
- && !line.endsWith( "ttyname: Operation not supported" ) )
- {
- streams.setErr( streams.getErr() + line + "\n" );
- }
- }
-
- return streams;
- }
-}
+package org.apache.maven.wagon.providers.ssh;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.Streams;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+
+/**
+ * CommandExecutorStreamProcessor
+ *
+ * @author <a href="mailto:joakim at erdfelt.com">Joakim Erdfelt</a>
+ *
+ */
+public class CommandExecutorStreamProcessor
+{
+ private CommandExecutorStreamProcessor()
+ {
+ // shoo!
+ }
+
+ public static Streams processStreams( BufferedReader stderrReader, BufferedReader stdoutReader )
+ throws IOException
+ {
+ Streams streams = new Streams();
+ while ( true )
+ {
+ String line = stdoutReader.readLine();
+
+ if ( line == null )
+ {
+ break;
+ }
+
+ streams.setOut( streams.getOut() + line + "\n" );
+ }
+
+ // drain the output stream.
+ // TODO: we'll save this for the 1.0-alpha-8 line, so we can test it more. the -q arg in the
+ // unzip command should keep us until then...
+// int avail = in.available();
+// byte[] trashcan = new byte[1024];
+//
+// while( ( avail = in.available() ) > 0 )
+// {
+// in.read( trashcan, 0, avail );
+// }
+
+ // drain stderr next, if stream size is more than the allowed buffer size
+ // ( ie jsch has a hardcoded 32K size), the remote shell may be blocked. See WAGON-431
+ while ( true )
+ {
+ String line = stderrReader.readLine();
+
+ if ( line == null )
+ {
+ break;
+ }
+
+ // TODO: I think we need to deal with exit codes instead, but IIRC there are some cases of errors that
+ // don't have exit codes ignore this error. TODO: output a warning
+ if ( !line.startsWith( "Could not chdir to home directory" )
+ && !line.endsWith( "ttyname: Operation not supported" ) )
+ {
+ streams.setErr( streams.getErr() + line + "\n" );
+ }
+ }
+
+ return streams;
+ }
+}
diff --git a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/LSParser.java b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/LSParser.java
index 49d009e..8d052af 100644
--- a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/LSParser.java
+++ b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/LSParser.java
@@ -1,96 +1,96 @@
-package org.apache.maven.wagon.providers.ssh;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.TransferFailedException;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Parser for the output of <code>ls</code> command from any ssh server on any OS.
- *
- * @author <a href="mailto:joakim at erdfelt.com">Joakim Erdfelt</a>
- *
- */
-public class LSParser
-{
- /**
- * output samples see LSParserTest:
- * <ul></ul>
- * <li>osx "-rw-r--r-- 1 joakim joakim 1194 Dec 11 09:25 pom.xml"</li>
- * <li>osx fr : "-rw-r--r-- 1 olamy staff 19 21 sep 00:34 more-resources.dat"</li>
- * <li>cygwin : "drwxr-xr-x+ 5 joakim None 0 Dec 11 10:30 pom.xml"</li>
- * <li>linux : "-rw-r--r-- 1 joakim joakim 1194 2006-12-11 09:25 pom.xml"</li>
- * </ul>
- */
- private static final Pattern PATTERN = Pattern.compile( ".+\\s+[0-9]+\\s+.+\\s+.+\\s+[0-9]+\\s+"
- //2006-12-11
- + "([0-9]{4}-[0-9]{2}-[0-9]{2}"
- // Dec 11
- + "|.+\\s+[0-9]+"
- // 21 sep
- + "|.+\\s+.+)"
- // 09:25 pom.xml
- + "\\s+[0-9:]+\\s+(.+?)" );
-
- /**
- * Parse a raw "ls -FlA", and obtain the list of files.
- *
- * @param rawLS the raw LS to parse.
- * @return the list of files found.
- * @throws TransferFailedException
- * @todo use ls -1a and do away with the method all together
- */
- public List<String> parseFiles( String rawLS )
- throws TransferFailedException
- {
- List<String> ret = new ArrayList<String>();
- try
- {
- BufferedReader br = new BufferedReader( new StringReader( rawLS ) );
-
- String line = br.readLine();
-
- while ( line != null )
- {
- line = line.trim();
-
- Matcher m = PATTERN.matcher( line );
- if ( m.matches() )
- {
- ret.add( m.group( 2 ) );
- }
- line = br.readLine();
- }
- }
- catch ( IOException e )
- {
- throw new TransferFailedException( "Error parsing file listing.", e );
- }
-
- return ret;
- }
-}
+package org.apache.maven.wagon.providers.ssh;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.TransferFailedException;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Parser for the output of <code>ls</code> command from any ssh server on any OS.
+ *
+ * @author <a href="mailto:joakim at erdfelt.com">Joakim Erdfelt</a>
+ *
+ */
+public class LSParser
+{
+ /**
+ * output samples see LSParserTest:
+ * <ul></ul>
+ * <li>osx "-rw-r--r-- 1 joakim joakim 1194 Dec 11 09:25 pom.xml"</li>
+ * <li>osx fr : "-rw-r--r-- 1 olamy staff 19 21 sep 00:34 more-resources.dat"</li>
+ * <li>cygwin : "drwxr-xr-x+ 5 joakim None 0 Dec 11 10:30 pom.xml"</li>
+ * <li>linux : "-rw-r--r-- 1 joakim joakim 1194 2006-12-11 09:25 pom.xml"</li>
+ * </ul>
+ */
+ private static final Pattern PATTERN = Pattern.compile( ".+\\s+[0-9]+\\s+.+\\s+.+\\s+[0-9]+\\s+"
+ //2006-12-11
+ + "([0-9]{4}-[0-9]{2}-[0-9]{2}"
+ // Dec 11
+ + "|.+\\s+[0-9]+"
+ // 21 sep
+ + "|.+\\s+.+)"
+ // 09:25 pom.xml
+ + "\\s+[0-9:]+\\s+(.+?)" );
+
+ /**
+ * Parse a raw "ls -FlA", and obtain the list of files.
+ *
+ * @param rawLS the raw LS to parse.
+ * @return the list of files found.
+ * @throws TransferFailedException
+ * @todo use ls -1a and do away with the method all together
+ */
+ public List<String> parseFiles( String rawLS )
+ throws TransferFailedException
+ {
+ List<String> ret = new ArrayList<String>();
+ try
+ {
+ BufferedReader br = new BufferedReader( new StringReader( rawLS ) );
+
+ String line = br.readLine();
+
+ while ( line != null )
+ {
+ line = line.trim();
+
+ Matcher m = PATTERN.matcher( line );
+ if ( m.matches() )
+ {
+ ret.add( m.group( 2 ) );
+ }
+ line = br.readLine();
+ }
+ }
+ catch ( IOException e )
+ {
+ throw new TransferFailedException( "Error parsing file listing.", e );
+ }
+
+ return ret;
+ }
+}
diff --git a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/ScpHelper.java b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/ScpHelper.java
index 7f5b862..6e7f76b 100644
--- a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/ScpHelper.java
+++ b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/ScpHelper.java
@@ -1,361 +1,365 @@
-package org.apache.maven.wagon.providers.ssh;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.CommandExecutionException;
-import org.apache.maven.wagon.CommandExecutor;
-import org.apache.maven.wagon.PathUtils;
-import org.apache.maven.wagon.PermissionModeUtils;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
-import org.apache.maven.wagon.Streams;
-import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
-import org.apache.maven.wagon.authorization.AuthorizationException;
-import org.apache.maven.wagon.repository.Repository;
-import org.apache.maven.wagon.repository.RepositoryPermissions;
-import org.apache.maven.wagon.resource.Resource;
-import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.StringUtils;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.List;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
-/**
- * Scp helper for general algorithms on ssh server.
- * See {@link #putDirectory(Wagon, File, String) putDirectory(...)} for more info on bulk directory upload.
- */
-public class ScpHelper
-{
- public static final char PATH_SEPARATOR = '/';
-
- public static final int DEFAULT_SSH_PORT = 22;
-
- private final CommandExecutor executor;
-
- public ScpHelper( CommandExecutor executor )
- {
- this.executor = executor;
- }
-
- public static String getResourceDirectory( String resourceName )
- {
- String dir = PathUtils.dirname( resourceName );
- dir = StringUtils.replace( dir, "\\", "/" );
- return dir;
- }
-
- public static String getResourceFilename( String r )
- {
- String filename;
- if ( r.lastIndexOf( PATH_SEPARATOR ) > 0 )
- {
- filename = r.substring( r.lastIndexOf( PATH_SEPARATOR ) + 1 );
- }
- else
- {
- filename = r;
- }
- return filename;
- }
-
- public static Resource getResource( String resourceName )
- {
- String r = StringUtils.replace( resourceName, "\\", "/" );
- return new Resource( r );
- }
-
- public static File getPrivateKey( AuthenticationInfo authenticationInfo )
- throws FileNotFoundException
- {
- // If user don't define a password, he want to use a private key
- File privateKey = null;
- if ( authenticationInfo.getPassword() == null )
- {
-
- if ( authenticationInfo.getPrivateKey() != null )
- {
- privateKey = new File( authenticationInfo.getPrivateKey() );
- if ( !privateKey.exists() )
- {
- throw new FileNotFoundException( "Private key '" + privateKey + "' not found" );
- }
- }
- else
- {
- privateKey = findPrivateKey();
- }
-
- if ( privateKey != null && privateKey.exists() )
- {
- if ( authenticationInfo.getPassphrase() == null )
- {
- authenticationInfo.setPassphrase( "" );
- }
- }
- }
- return privateKey;
- }
-
- private static File findPrivateKey()
- {
- String privateKeyDirectory = System.getProperty( "wagon.privateKeyDirectory" );
-
- if ( privateKeyDirectory == null )
- {
- privateKeyDirectory = System.getProperty( "user.home" );
- }
-
- File privateKey = new File( privateKeyDirectory, ".ssh/id_dsa" );
-
- if ( !privateKey.exists() )
- {
- privateKey = new File( privateKeyDirectory, ".ssh/id_rsa" );
- if ( !privateKey.exists() )
- {
- privateKey = null;
- }
- }
-
- return privateKey;
- }
-
- public static void createZip( List<String> files, File zipName, File basedir )
- throws IOException
- {
- ZipOutputStream zos = new ZipOutputStream( new FileOutputStream( zipName ) );
-
- try
- {
- for ( String file : files )
- {
- file = file.replace( '\\', '/' );
-
- writeZipEntry( zos, new File( basedir, file ), file );
- }
- }
- finally
- {
- IOUtil.close( zos );
- }
- }
-
- private static void writeZipEntry( ZipOutputStream jar, File source, String entryName )
- throws IOException
- {
- byte[] buffer = new byte[1024];
-
- int bytesRead;
-
- FileInputStream is = new FileInputStream( source );
-
- try
- {
- ZipEntry entry = new ZipEntry( entryName );
-
- jar.putNextEntry( entry );
-
- while ( ( bytesRead = is.read( buffer ) ) != -1 )
- {
- jar.write( buffer, 0, bytesRead );
- }
- }
- finally
- {
- is.close();
- }
- }
-
- protected static String getPath( String basedir, String dir )
- {
- String path;
- path = basedir;
- if ( !basedir.endsWith( "/" ) && !dir.startsWith( "/" ) )
- {
- path += "/";
- }
- path += dir;
- return path;
- }
-
- /**
- * Put a whole directory content, by transferring a unique zip file and uncompressing it
- * on the target ssh server with <code>unzip</code> command.
- */
- public void putDirectory( Wagon wagon, File sourceDirectory, String destinationDirectory )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- Repository repository = wagon.getRepository();
-
- String basedir = repository.getBasedir();
-
- String destDir = StringUtils.replace( destinationDirectory, "\\", "/" );
-
- String path = getPath( basedir, destDir );
- try
- {
- if ( repository.getPermissions() != null )
- {
- String dirPerms = repository.getPermissions().getDirectoryMode();
-
- if ( dirPerms != null )
- {
- String umaskCmd = "umask " + PermissionModeUtils.getUserMaskFor( dirPerms );
- executor.executeCommand( umaskCmd );
- }
- }
-
- //String mkdirCmd = "mkdir -p " + path;
- String mkdirCmd = "mkdir -p \"" + path + "\"";
-
- executor.executeCommand( mkdirCmd );
- }
- catch ( CommandExecutionException e )
- {
- throw new TransferFailedException( "Error performing commands for file transfer", e );
- }
-
- File zipFile;
- try
- {
- zipFile = File.createTempFile( "wagon", ".zip" );
- zipFile.deleteOnExit();
-
- List<String> files = FileUtils.getFileNames( sourceDirectory, "**/**", "", false );
-
- createZip( files, zipFile, sourceDirectory );
- }
- catch ( IOException e )
- {
- throw new TransferFailedException( "Unable to create ZIP archive of directory", e );
- }
-
- wagon.put( zipFile, getPath( destDir, zipFile.getName() ) );
-
- try
- {
- //executor.executeCommand(
- // "cd " + path + "; unzip -q -o " + zipFile.getName() + "; rm -f " + zipFile.getName() );
- executor.executeCommand( "cd \"" + path + "\"; unzip -q -o \"" + zipFile.getName() + "\"; rm -f \""
- + zipFile.getName() + "\"" );
-
- zipFile.delete();
-
- RepositoryPermissions permissions = repository.getPermissions();
-
- if ( permissions != null && permissions.getGroup() != null )
- {
- //executor.executeCommand( "chgrp -Rf " + permissions.getGroup() + " " + path );
- executor.executeCommand( "chgrp -Rf " + permissions.getGroup() + " \"" + path + "\"" );
- }
-
- if ( permissions != null && permissions.getFileMode() != null )
- {
- //executor.executeCommand( "chmod -Rf " + permissions.getFileMode() + " " + path );
- executor.executeCommand( "chmod -Rf " + permissions.getFileMode() + " \"" + path + "\"" );
- }
- }
- catch ( CommandExecutionException e )
- {
- throw new TransferFailedException( "Error performing commands for file transfer", e );
- }
- }
-
- public List<String> getFileList( String destinationDirectory, Repository repository )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- try
- {
- String path = getPath( repository.getBasedir(), destinationDirectory );
- //Streams streams = executor.executeCommand( "ls -FlA " + path, false );
- Streams streams = executor.executeCommand( "ls -FlA \"" + path + "\"", false );
-
- return new LSParser().parseFiles( streams.getOut() );
- }
- catch ( CommandExecutionException e )
- {
- if ( e.getMessage().trim().endsWith( "No such file or directory" ) )
- {
- throw new ResourceDoesNotExistException( e.getMessage().trim(), e );
- }
- else if ( e.getMessage().trim().endsWith( "Not a directory" ) )
- {
- throw new ResourceDoesNotExistException( e.getMessage().trim(), e );
- }
- else
- {
- throw new TransferFailedException( "Error performing file listing.", e );
- }
- }
- }
-
- public boolean resourceExists( String resourceName, Repository repository )
- throws TransferFailedException, AuthorizationException
- {
- try
- {
- String path = getPath( repository.getBasedir(), resourceName );
- //executor.executeCommand( "ls " + path, false );
- executor.executeCommand( "ls \"" + path + "\"" );
-
- // Parsing of output not really needed. As a failed ls results in a
- // CommandExectionException on the 'ls' command.
-
- return true;
- }
- catch ( CommandExecutionException e )
- {
- // Error? Then the 'ls' command failed. No such file found.
- return false;
- }
- }
-
- public void createRemoteDirectories( String path, RepositoryPermissions permissions )
- throws CommandExecutionException
- {
- String umaskCmd = null;
- if ( permissions != null )
- {
- String dirPerms = permissions.getDirectoryMode();
-
- if ( dirPerms != null )
- {
- umaskCmd = "umask " + PermissionModeUtils.getUserMaskFor( dirPerms );
- }
- }
-
- //String mkdirCmd = "mkdir -p " + path;
- String mkdirCmd = "mkdir -p \"" + path + "\"";
-
- if ( umaskCmd != null )
- {
- mkdirCmd = umaskCmd + "; " + mkdirCmd;
- }
-
- executor.executeCommand( mkdirCmd );
- }
-}
+package org.apache.maven.wagon.providers.ssh;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.CommandExecutionException;
+import org.apache.maven.wagon.CommandExecutor;
+import org.apache.maven.wagon.PathUtils;
+import org.apache.maven.wagon.PermissionModeUtils;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.Streams;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.repository.RepositoryPermissions;
+import org.apache.maven.wagon.resource.Resource;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.StringUtils;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.List;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+/**
+ * Scp helper for general algorithms on ssh server.
+ * See {@link #putDirectory(Wagon, File, String) putDirectory(...)} for more info on bulk directory upload.
+ */
+public class ScpHelper
+{
+ public static final char PATH_SEPARATOR = '/';
+
+ public static final int DEFAULT_SSH_PORT = 22;
+
+ private final CommandExecutor executor;
+
+ public ScpHelper( CommandExecutor executor )
+ {
+ this.executor = executor;
+ }
+
+ public static String getResourceDirectory( String resourceName )
+ {
+ String dir = PathUtils.dirname( resourceName );
+ dir = StringUtils.replace( dir, "\\", "/" );
+ return dir;
+ }
+
+ public static String getResourceFilename( String r )
+ {
+ String filename;
+ if ( r.lastIndexOf( PATH_SEPARATOR ) > 0 )
+ {
+ filename = r.substring( r.lastIndexOf( PATH_SEPARATOR ) + 1 );
+ }
+ else
+ {
+ filename = r;
+ }
+ return filename;
+ }
+
+ public static Resource getResource( String resourceName )
+ {
+ String r = StringUtils.replace( resourceName, "\\", "/" );
+ return new Resource( r );
+ }
+
+ public static File getPrivateKey( AuthenticationInfo authenticationInfo )
+ throws FileNotFoundException
+ {
+ // If user don't define a password, he want to use a private key
+ File privateKey = null;
+ if ( authenticationInfo.getPassword() == null )
+ {
+
+ if ( authenticationInfo.getPrivateKey() != null )
+ {
+ privateKey = new File( authenticationInfo.getPrivateKey() );
+ if ( !privateKey.exists() )
+ {
+ throw new FileNotFoundException( "Private key '" + privateKey + "' not found" );
+ }
+ }
+ else
+ {
+ privateKey = findPrivateKey();
+ }
+
+ if ( privateKey != null && privateKey.exists() )
+ {
+ if ( authenticationInfo.getPassphrase() == null )
+ {
+ authenticationInfo.setPassphrase( "" );
+ }
+ }
+ }
+ return privateKey;
+ }
+
+ private static File findPrivateKey()
+ {
+ String privateKeyDirectory = System.getProperty( "wagon.privateKeyDirectory" );
+
+ if ( privateKeyDirectory == null )
+ {
+ privateKeyDirectory = System.getProperty( "user.home" );
+ }
+
+ File privateKey = new File( privateKeyDirectory, ".ssh/id_dsa" );
+
+ if ( !privateKey.exists() )
+ {
+ privateKey = new File( privateKeyDirectory, ".ssh/id_rsa" );
+ if ( !privateKey.exists() )
+ {
+ privateKey = null;
+ }
+ }
+
+ return privateKey;
+ }
+
+ public static void createZip( List<String> files, File zipName, File basedir )
+ throws IOException
+ {
+ ZipOutputStream zos = null;
+ try
+ {
+ zos = new ZipOutputStream( new FileOutputStream( zipName ) );
+
+ for ( String file : files )
+ {
+ file = file.replace( '\\', '/' );
+
+ writeZipEntry( zos, new File( basedir, file ), file );
+ }
+
+ zos.close();
+ zos = null;
+ }
+ finally
+ {
+ IOUtil.close( zos );
+ }
+ }
+
+ private static void writeZipEntry( ZipOutputStream jar, File source, String entryName )
+ throws IOException
+ {
+ byte[] buffer = new byte[1024];
+
+ int bytesRead;
+
+ FileInputStream is = new FileInputStream( source );
+
+ try
+ {
+ ZipEntry entry = new ZipEntry( entryName );
+
+ jar.putNextEntry( entry );
+
+ while ( ( bytesRead = is.read( buffer ) ) != -1 )
+ {
+ jar.write( buffer, 0, bytesRead );
+ }
+ }
+ finally
+ {
+ is.close();
+ }
+ }
+
+ protected static String getPath( String basedir, String dir )
+ {
+ String path;
+ path = basedir;
+ if ( !basedir.endsWith( "/" ) && !dir.startsWith( "/" ) )
+ {
+ path += "/";
+ }
+ path += dir;
+ return path;
+ }
+
+ /**
+ * Put a whole directory content, by transferring a unique zip file and uncompressing it
+ * on the target ssh server with <code>unzip</code> command.
+ */
+ public void putDirectory( Wagon wagon, File sourceDirectory, String destinationDirectory )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ Repository repository = wagon.getRepository();
+
+ String basedir = repository.getBasedir();
+
+ String destDir = StringUtils.replace( destinationDirectory, "\\", "/" );
+
+ String path = getPath( basedir, destDir );
+ try
+ {
+ if ( repository.getPermissions() != null )
+ {
+ String dirPerms = repository.getPermissions().getDirectoryMode();
+
+ if ( dirPerms != null )
+ {
+ String umaskCmd = "umask " + PermissionModeUtils.getUserMaskFor( dirPerms );
+ executor.executeCommand( umaskCmd );
+ }
+ }
+
+ //String mkdirCmd = "mkdir -p " + path;
+ String mkdirCmd = "mkdir -p \"" + path + "\"";
+
+ executor.executeCommand( mkdirCmd );
+ }
+ catch ( CommandExecutionException e )
+ {
+ throw new TransferFailedException( "Error performing commands for file transfer", e );
+ }
+
+ File zipFile;
+ try
+ {
+ zipFile = File.createTempFile( "wagon", ".zip" );
+ zipFile.deleteOnExit();
+
+ List<String> files = FileUtils.getFileNames( sourceDirectory, "**/**", "", false );
+
+ createZip( files, zipFile, sourceDirectory );
+ }
+ catch ( IOException e )
+ {
+ throw new TransferFailedException( "Unable to create ZIP archive of directory", e );
+ }
+
+ wagon.put( zipFile, getPath( destDir, zipFile.getName() ) );
+
+ try
+ {
+ //executor.executeCommand(
+ // "cd " + path + "; unzip -q -o " + zipFile.getName() + "; rm -f " + zipFile.getName() );
+ executor.executeCommand( "cd \"" + path + "\"; unzip -q -o \"" + zipFile.getName() + "\"; rm -f \""
+ + zipFile.getName() + "\"" );
+
+ zipFile.delete();
+
+ RepositoryPermissions permissions = repository.getPermissions();
+
+ if ( permissions != null && permissions.getGroup() != null )
+ {
+ //executor.executeCommand( "chgrp -Rf " + permissions.getGroup() + " " + path );
+ executor.executeCommand( "chgrp -Rf " + permissions.getGroup() + " \"" + path + "\"" );
+ }
+
+ if ( permissions != null && permissions.getFileMode() != null )
+ {
+ //executor.executeCommand( "chmod -Rf " + permissions.getFileMode() + " " + path );
+ executor.executeCommand( "chmod -Rf " + permissions.getFileMode() + " \"" + path + "\"" );
+ }
+ }
+ catch ( CommandExecutionException e )
+ {
+ throw new TransferFailedException( "Error performing commands for file transfer", e );
+ }
+ }
+
+ public List<String> getFileList( String destinationDirectory, Repository repository )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ try
+ {
+ String path = getPath( repository.getBasedir(), destinationDirectory );
+ //Streams streams = executor.executeCommand( "ls -FlA " + path, false );
+ Streams streams = executor.executeCommand( "ls -FlA \"" + path + "\"", false );
+
+ return new LSParser().parseFiles( streams.getOut() );
+ }
+ catch ( CommandExecutionException e )
+ {
+ if ( e.getMessage().trim().endsWith( "No such file or directory" ) )
+ {
+ throw new ResourceDoesNotExistException( e.getMessage().trim(), e );
+ }
+ else if ( e.getMessage().trim().endsWith( "Not a directory" ) )
+ {
+ throw new ResourceDoesNotExistException( e.getMessage().trim(), e );
+ }
+ else
+ {
+ throw new TransferFailedException( "Error performing file listing.", e );
+ }
+ }
+ }
+
+ public boolean resourceExists( String resourceName, Repository repository )
+ throws TransferFailedException, AuthorizationException
+ {
+ try
+ {
+ String path = getPath( repository.getBasedir(), resourceName );
+ //executor.executeCommand( "ls " + path, false );
+ executor.executeCommand( "ls \"" + path + "\"" );
+
+ // Parsing of output not really needed. As a failed ls results in a
+ // CommandExectionException on the 'ls' command.
+
+ return true;
+ }
+ catch ( CommandExecutionException e )
+ {
+ // Error? Then the 'ls' command failed. No such file found.
+ return false;
+ }
+ }
+
+ public void createRemoteDirectories( String path, RepositoryPermissions permissions )
+ throws CommandExecutionException
+ {
+ String umaskCmd = null;
+ if ( permissions != null )
+ {
+ String dirPerms = permissions.getDirectoryMode();
+
+ if ( dirPerms != null )
+ {
+ umaskCmd = "umask " + PermissionModeUtils.getUserMaskFor( dirPerms );
+ }
+ }
+
+ //String mkdirCmd = "mkdir -p " + path;
+ String mkdirCmd = "mkdir -p \"" + path + "\"";
+
+ if ( umaskCmd != null )
+ {
+ mkdirCmd = umaskCmd + "; " + mkdirCmd;
+ }
+
+ executor.executeCommand( mkdirCmd );
+ }
+}
diff --git a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/SshWagon.java b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/SshWagon.java
index 16a38cb..55fbe98 100644
--- a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/SshWagon.java
+++ b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/SshWagon.java
@@ -1,37 +1,37 @@
-package org.apache.maven.wagon.providers.ssh;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider;
-
-/**
- * SshWagon - identifier for 100% java implementations of Ssh.
- *
- * NOTE: External or native ssh implementations cannot use this interface.
- *
- * @author <a href="mailto:joakim at erdfelt.com">Joakim Erdfelt</a>
- *
- */
-public interface SshWagon
- extends Wagon
-{
- void setKnownHostsProvider( KnownHostsProvider knownHostsProvider );
-}
+package org.apache.maven.wagon.providers.ssh;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider;
+
+/**
+ * SshWagon - identifier for 100% java implementations of Ssh.
+ *
+ * NOTE: External or native ssh implementations cannot use this interface.
+ *
+ * @author <a href="mailto:joakim at erdfelt.com">Joakim Erdfelt</a>
+ *
+ */
+public interface SshWagon
+ extends Wagon
+{
+ void setKnownHostsProvider( KnownHostsProvider knownHostsProvider );
+}
diff --git a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/ConsoleInteractiveUserInfo.java b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/ConsoleInteractiveUserInfo.java
index a104810..2c1e9ac 100644
--- a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/ConsoleInteractiveUserInfo.java
+++ b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/ConsoleInteractiveUserInfo.java
@@ -1,102 +1,102 @@
-package org.apache.maven.wagon.providers.ssh.interactive;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.codehaus.plexus.components.interactivity.Prompter;
-import org.codehaus.plexus.components.interactivity.PrompterException;
-
-import java.util.Arrays;
-
-/**
- * Shows messages to System.out, and ask replies using an InputHandler
- *
- * @author Juan F. Codagnone
- * @since Sep 12, 2005
- *
- * @plexus.component role="org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo"
- * instantiation-strategy="per-lookup"
- */
-public class ConsoleInteractiveUserInfo
- implements InteractiveUserInfo
-{
- /**
- * @plexus.requirement role-hint="default"
- */
- private volatile Prompter prompter;
-
- public ConsoleInteractiveUserInfo()
- {
- }
-
- public ConsoleInteractiveUserInfo( Prompter prompter )
- {
- this.prompter = prompter;
- }
-
- /**
- * @see InteractiveUserInfo#promptYesNo(String)
- */
- public boolean promptYesNo( String message )
- {
- String ret;
- try
- {
- ret = prompter.prompt( message, Arrays.asList( "yes", "no" ) );
- }
- catch ( PrompterException e )
- {
- // no op
- ret = null;
- }
- return "yes".equalsIgnoreCase( ret );
- }
-
- /**
- * @see InteractiveUserInfo#showMessage(String)
- */
- public void showMessage( String message )
- {
- try
- {
- prompter.showMessage( message );
- }
- catch ( PrompterException e )
- {
- // no op
- }
- }
-
- public String promptPassword( String message )
- {
- try
- {
- return prompter.promptForPassword( message );
- }
- catch ( PrompterException e )
- {
- return null;
- }
- }
-
- public String promptPassphrase( String message )
- {
- return promptPassword( message );
- }
-}
+package org.apache.maven.wagon.providers.ssh.interactive;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.codehaus.plexus.components.interactivity.Prompter;
+import org.codehaus.plexus.components.interactivity.PrompterException;
+
+import java.util.Arrays;
+
+/**
+ * Shows messages to System.out, and ask replies using an InputHandler
+ *
+ * @author Juan F. Codagnone
+ * @since Sep 12, 2005
+ *
+ * @plexus.component role="org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo"
+ * instantiation-strategy="per-lookup"
+ */
+public class ConsoleInteractiveUserInfo
+ implements InteractiveUserInfo
+{
+ /**
+ * @plexus.requirement role-hint="default"
+ */
+ private volatile Prompter prompter;
+
+ public ConsoleInteractiveUserInfo()
+ {
+ }
+
+ public ConsoleInteractiveUserInfo( Prompter prompter )
+ {
+ this.prompter = prompter;
+ }
+
+ /**
+ * @see InteractiveUserInfo#promptYesNo(String)
+ */
+ public boolean promptYesNo( String message )
+ {
+ String ret;
+ try
+ {
+ ret = prompter.prompt( message, Arrays.asList( "yes", "no" ) );
+ }
+ catch ( PrompterException e )
+ {
+ // no op
+ ret = null;
+ }
+ return "yes".equalsIgnoreCase( ret );
+ }
+
+ /**
+ * @see InteractiveUserInfo#showMessage(String)
+ */
+ public void showMessage( String message )
+ {
+ try
+ {
+ prompter.showMessage( message );
+ }
+ catch ( PrompterException e )
+ {
+ // no op
+ }
+ }
+
+ public String promptPassword( String message )
+ {
+ try
+ {
+ return prompter.promptForPassword( message );
+ }
+ catch ( PrompterException e )
+ {
+ return null;
+ }
+ }
+
+ public String promptPassphrase( String message )
+ {
+ return promptPassword( message );
+ }
+}
diff --git a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/InteractiveUserInfo.java b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/InteractiveUserInfo.java
index e9c4e92..79d28e1 100644
--- a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/InteractiveUserInfo.java
+++ b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/InteractiveUserInfo.java
@@ -1,40 +1,40 @@
-package org.apache.maven.wagon.providers.ssh.interactive;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Interactive part for <code>UserInfo</code>
- *
- * @author Juan F. Codagnone
- * @see com.jcraft.jsch.UserInfo
- * @since Sep 12, 2005
- */
-public interface InteractiveUserInfo
-{
- String ROLE = InteractiveUserInfo.class.getName();
-
- boolean promptYesNo( String message );
-
- void showMessage( String message );
-
- String promptPassword( String message );
-
- String promptPassphrase( String message );
-}
+package org.apache.maven.wagon.providers.ssh.interactive;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Interactive part for <code>UserInfo</code>
+ *
+ * @author Juan F. Codagnone
+ * @see com.jcraft.jsch.UserInfo
+ * @since Sep 12, 2005
+ */
+public interface InteractiveUserInfo
+{
+ String ROLE = InteractiveUserInfo.class.getName();
+
+ boolean promptYesNo( String message );
+
+ void showMessage( String message );
+
+ String promptPassword( String message );
+
+ String promptPassphrase( String message );
+}
diff --git a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/NullInteractiveUserInfo.java b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/NullInteractiveUserInfo.java
index 7a1b887..c923230 100644
--- a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/NullInteractiveUserInfo.java
+++ b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/NullInteractiveUserInfo.java
@@ -1,79 +1,79 @@
-package org.apache.maven.wagon.providers.ssh.interactive;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Dummy Implementation for <code>InteractiveUserInfo</code>, nice for
- * non-Interactive environments
- *
- * @author Juan F. Codagnone
- * @see org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo
- * @since Sep 12, 2005
- */
-public class NullInteractiveUserInfo
- implements InteractiveUserInfo
-{
- private final boolean promptYesNoResult;
-
- /**
- * @see #NullInteractiveUserInfo(boolean)
- */
- public NullInteractiveUserInfo()
- {
- this( false ); // the safest value
- }
-
- /**
- * Creates a <code>NullInteractiveUserInfo</code> with a hardcoded
- * prompYesNo result
- *
- * @param promptYesNoResult the hardcoded result
- */
- public NullInteractiveUserInfo( final boolean promptYesNoResult )
- {
- this.promptYesNoResult = promptYesNoResult;
- }
-
- /**
- * @see InteractiveUserInfo#promptYesNo(java.lang.String)
- */
- public boolean promptYesNo( final String message )
- {
- return promptYesNoResult;
- }
-
- /**
- * @see InteractiveUserInfo#showMessage(java.lang.String)
- */
- public void showMessage( final String message )
- {
- // nothing to do
- }
-
- public String promptPassword( String message )
- {
- return null;
- }
-
- public String promptPassphrase( String message )
- {
- return null;
- }
-}
+package org.apache.maven.wagon.providers.ssh.interactive;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Dummy Implementation for <code>InteractiveUserInfo</code>, nice for
+ * non-Interactive environments
+ *
+ * @author Juan F. Codagnone
+ * @see org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo
+ * @since Sep 12, 2005
+ */
+public class NullInteractiveUserInfo
+ implements InteractiveUserInfo
+{
+ private final boolean promptYesNoResult;
+
+ /**
+ * @see #NullInteractiveUserInfo(boolean)
+ */
+ public NullInteractiveUserInfo()
+ {
+ this( false ); // the safest value
+ }
+
+ /**
+ * Creates a <code>NullInteractiveUserInfo</code> with a hardcoded
+ * prompYesNo result
+ *
+ * @param promptYesNoResult the hardcoded result
+ */
+ public NullInteractiveUserInfo( final boolean promptYesNoResult )
+ {
+ this.promptYesNoResult = promptYesNoResult;
+ }
+
+ /**
+ * @see InteractiveUserInfo#promptYesNo(java.lang.String)
+ */
+ public boolean promptYesNo( final String message )
+ {
+ return promptYesNoResult;
+ }
+
+ /**
+ * @see InteractiveUserInfo#showMessage(java.lang.String)
+ */
+ public void showMessage( final String message )
+ {
+ // nothing to do
+ }
+
+ public String promptPassword( String message )
+ {
+ return null;
+ }
+
+ public String promptPassphrase( String message )
+ {
+ return null;
+ }
+}
diff --git a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/AbstractKnownHostsProvider.java b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/AbstractKnownHostsProvider.java
index 19c9f3f..4305778 100644
--- a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/AbstractKnownHostsProvider.java
+++ b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/AbstractKnownHostsProvider.java
@@ -1,70 +1,75 @@
-package org.apache.maven.wagon.providers.ssh.knownhost;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Common base for known hosts providers.
- *
- * @author <a href="mailto:brett at apache.org">Brett Porter</a>
- *
- */
-public abstract class AbstractKnownHostsProvider
- implements KnownHostsProvider
-{
- /**
- * Valid values are ask, yes, no.
- *
- * @plexus.configuration default-value="ask"
- */
- private String hostKeyChecking = "ask";
-
- /**
- * the known hosts, in the openssh format
- */
- protected String contents;
-
- protected Set<KnownHostEntry> knownHosts = new HashSet<KnownHostEntry>();
-
- public void setHostKeyChecking( String hostKeyChecking )
- {
- this.hostKeyChecking = hostKeyChecking;
- }
-
- public String getHostKeyChecking()
- {
- return hostKeyChecking;
- }
-
- public String getContents()
- {
- return contents;
- }
-
- public void storeKnownHosts( String contents )
- throws IOException
- {
- }
-
-
-}
+package org.apache.maven.wagon.providers.ssh.knownhost;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Common base for known hosts providers.
+ *
+ * @author <a href="mailto:brett at apache.org">Brett Porter</a>
+ *
+ */
+public abstract class AbstractKnownHostsProvider
+ implements KnownHostsProvider
+{
+ /**
+ * Valid values are ask, yes, no.
+ *
+ * @plexus.configuration default-value="ask"
+ */
+ private String hostKeyChecking = "ask";
+
+ /**
+ * the known hosts, in the openssh format
+ */
+ protected String contents;
+
+ protected Set<KnownHostEntry> knownHosts = new HashSet<KnownHostEntry>();
+
+ public void setHostKeyChecking( String hostKeyChecking )
+ {
+ this.hostKeyChecking = hostKeyChecking;
+ }
+
+ public String getHostKeyChecking()
+ {
+ return hostKeyChecking;
+ }
+
+ public String getContents()
+ {
+ return contents;
+ }
+
+ public void storeKnownHosts( String contents )
+ throws IOException
+ {
+ }
+
+ public void addKnownHost( KnownHostEntry knownHost )
+ throws IOException
+ {
+ }
+
+
+}
diff --git a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/FileKnownHostsProvider.java b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/FileKnownHostsProvider.java
index 399c1d2..c56f80b 100644
--- a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/FileKnownHostsProvider.java
+++ b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/FileKnownHostsProvider.java
@@ -1,88 +1,99 @@
-package org.apache.maven.wagon.providers.ssh.knownhost;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Set;
-
-import org.codehaus.plexus.util.FileUtils;
-
-/**
- * Provides known hosts from a file
- *
- * @author Juan F. Codagnone
- * @since Sep 12, 2005
- *
- * @plexus.component role="org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider"
- * role-hint="file"
- * instantiation-strategy="per-lookup"
- */
-public class FileKnownHostsProvider
- extends StreamKnownHostsProvider
-{
- private final File file;
-
- /**
- * Creates the FileKnownHostsProvider.
- *
- * @param file the file that holds the known hosts, in the openssh format
- * @throws IOException
- */
- public FileKnownHostsProvider( File file )
- throws IOException
- {
- super( file.exists() ? (InputStream) new FileInputStream( file ) : new ByteArrayInputStream( "".getBytes() ) );
- this.file = file;
- }
-
- /**
- * Creates a FileKnownHostsProvider using as file openssh knwon_host
- *
- * @throws IOException
- * @see #FileKnownHostsProvider(File)
- */
- public FileKnownHostsProvider()
- throws IOException
- {
- this( new File( System.getProperty( "user.home" ), ".ssh/known_hosts" ) );
- }
-
- public void storeKnownHosts( String contents )
- throws IOException
- {
- Set<KnownHostEntry> hosts = this.loadKnownHosts( contents );
-
- if ( ! this.knownHosts.equals( hosts ) )
- {
- file.getParentFile().mkdirs();
- FileUtils.fileWrite( file.getAbsolutePath(), contents );
- this.knownHosts = hosts;
- }
- }
-
- public File getFile()
- {
- return file;
- }
-}
+package org.apache.maven.wagon.providers.ssh.knownhost;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Set;
+
+import org.codehaus.plexus.util.FileUtils;
+
+/**
+ * Provides known hosts from a file
+ *
+ * @author Juan F. Codagnone
+ * @since Sep 12, 2005
+ *
+ * @plexus.component role="org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider"
+ * role-hint="file"
+ * instantiation-strategy="per-lookup"
+ */
+public class FileKnownHostsProvider
+ extends StreamKnownHostsProvider
+{
+ private final File file;
+
+ /**
+ * Creates the FileKnownHostsProvider.
+ *
+ * @param file the file that holds the known hosts, in the openssh format
+ * @throws IOException
+ */
+ public FileKnownHostsProvider( File file )
+ throws IOException
+ {
+ super( file.exists() ? (InputStream) new FileInputStream( file ) : new ByteArrayInputStream( "".getBytes() ) );
+ this.file = file;
+ }
+
+ /**
+ * Creates a FileKnownHostsProvider using as file openssh knwon_host
+ *
+ * @throws IOException
+ * @see #FileKnownHostsProvider(File)
+ */
+ public FileKnownHostsProvider()
+ throws IOException
+ {
+ this( new File( System.getProperty( "user.home" ), ".ssh/known_hosts" ) );
+ }
+
+ public void storeKnownHosts( String contents )
+ throws IOException
+ {
+ Set<KnownHostEntry> hosts = this.loadKnownHosts( contents );
+
+ if ( ! this.knownHosts.equals( hosts ) )
+ {
+ file.getParentFile().mkdirs();
+ FileUtils.fileWrite( file.getAbsolutePath(), contents );
+ this.knownHosts = hosts;
+ }
+ }
+
+ public void addKnownHost( KnownHostEntry knownHostEntry )
+ throws IOException
+ {
+ if ( !this.knownHosts.contains( knownHostEntry ) )
+ {
+ String knownHost = knownHostEntry.getHostName() + " " + knownHostEntry.getKeyType() + " "
+ + knownHostEntry.getKeyValue() + "\n";
+ FileUtils.fileAppend( file.getAbsolutePath(), knownHost );
+ }
+ }
+
+ public File getFile()
+ {
+ return file;
+ }
+}
diff --git a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/KnownHostChangedException.java b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/KnownHostChangedException.java
index f334992..b913236 100644
--- a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/KnownHostChangedException.java
+++ b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/KnownHostChangedException.java
@@ -1,34 +1,34 @@
-package org.apache.maven.wagon.providers.ssh.knownhost;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.authentication.AuthenticationException;
-
-/**
- * Exception related to known_host check failures.
- */
-public class KnownHostChangedException
- extends AuthenticationException
-{
- public KnownHostChangedException( String host, Throwable cause )
- {
- super( "The host key was different to that in the known_hosts configuration for host: " + host, cause );
- }
-}
+package org.apache.maven.wagon.providers.ssh.knownhost;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.authentication.AuthenticationException;
+
+/**
+ * Exception related to known_host check failures.
+ */
+public class KnownHostChangedException
+ extends AuthenticationException
+{
+ public KnownHostChangedException( String host, Throwable cause )
+ {
+ super( "The host key was different to that in the known_hosts configuration for host: " + host, cause );
+ }
+}
diff --git a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/KnownHostEntry.java b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/KnownHostEntry.java
index 35df9a7..302f695 100644
--- a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/KnownHostEntry.java
+++ b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/KnownHostEntry.java
@@ -1,141 +1,141 @@
-package org.apache.maven.wagon.providers.ssh.knownhost;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- *
- */
-public class KnownHostEntry
-{
-
- private String hostName;
-
- private String keyType;
-
- private String keyValue;
-
- public KnownHostEntry()
- {
- }
-
- public KnownHostEntry( String hostName, String keyType, String keyValue )
- {
- this.hostName = hostName;
- this.keyType = keyType;
- this.keyValue = keyValue;
- }
-
- public String getHostName()
- {
- return hostName;
- }
-
- public void setHostName( String hostName )
- {
- this.hostName = hostName;
- }
-
- public String getKeyType()
- {
- return keyType;
- }
-
- public void setKeyType( String keyType )
- {
- this.keyType = keyType;
- }
-
- public String getKeyValue()
- {
- return keyValue;
- }
-
- public void setKeyValue( String keyValue )
- {
- this.keyValue = keyValue;
- }
-
- public int hashCode()
- {
- final int prime = 31;
- int result = 1;
- result = prime * result + ( ( hostName == null ) ? 0 : hostName.hashCode() );
- result = prime * result + ( ( keyType == null ) ? 0 : keyType.hashCode() );
- result = prime * result + ( ( keyValue == null ) ? 0 : keyValue.hashCode() );
- return result;
- }
-
- public boolean equals( Object obj )
- {
- if ( this == obj )
- {
- return true;
- }
-
- if ( obj == null )
- {
- return false;
- }
-
- if ( getClass() != obj.getClass() )
- {
- return false;
- }
-
- KnownHostEntry other = (KnownHostEntry) obj;
- if ( hostName == null )
- {
- if ( other.hostName != null )
- {
- return false;
- }
- }
- else if ( !hostName.equals( other.hostName ) )
- {
- return false;
- }
-
- if ( keyType == null )
- {
- if ( other.keyType != null )
- {
- return false;
- }
- }
- else if ( !keyType.equals( other.keyType ) )
- {
- return false;
- }
-
- if ( keyValue == null )
- {
- if ( other.keyValue != null )
- {
- return false;
- }
- }
- else if ( !keyValue.equals( other.keyValue ) )
- {
- return false;
- }
- return true;
- }
-
-}
+package org.apache.maven.wagon.providers.ssh.knownhost;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ *
+ */
+public class KnownHostEntry
+{
+
+ private String hostName;
+
+ private String keyType;
+
+ private String keyValue;
+
+ public KnownHostEntry()
+ {
+ }
+
+ public KnownHostEntry( String hostName, String keyType, String keyValue )
+ {
+ this.hostName = hostName;
+ this.keyType = keyType;
+ this.keyValue = keyValue;
+ }
+
+ public String getHostName()
+ {
+ return hostName;
+ }
+
+ public void setHostName( String hostName )
+ {
+ this.hostName = hostName;
+ }
+
+ public String getKeyType()
+ {
+ return keyType;
+ }
+
+ public void setKeyType( String keyType )
+ {
+ this.keyType = keyType;
+ }
+
+ public String getKeyValue()
+ {
+ return keyValue;
+ }
+
+ public void setKeyValue( String keyValue )
+ {
+ this.keyValue = keyValue;
+ }
+
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ( ( hostName == null ) ? 0 : hostName.hashCode() );
+ result = prime * result + ( ( keyType == null ) ? 0 : keyType.hashCode() );
+ result = prime * result + ( ( keyValue == null ) ? 0 : keyValue.hashCode() );
+ return result;
+ }
+
+ public boolean equals( Object obj )
+ {
+ if ( this == obj )
+ {
+ return true;
+ }
+
+ if ( obj == null )
+ {
+ return false;
+ }
+
+ if ( getClass() != obj.getClass() )
+ {
+ return false;
+ }
+
+ KnownHostEntry other = (KnownHostEntry) obj;
+ if ( hostName == null )
+ {
+ if ( other.hostName != null )
+ {
+ return false;
+ }
+ }
+ else if ( !hostName.equals( other.hostName ) )
+ {
+ return false;
+ }
+
+ if ( keyType == null )
+ {
+ if ( other.keyType != null )
+ {
+ return false;
+ }
+ }
+ else if ( !keyType.equals( other.keyType ) )
+ {
+ return false;
+ }
+
+ if ( keyValue == null )
+ {
+ if ( other.keyValue != null )
+ {
+ return false;
+ }
+ }
+ else if ( !keyValue.equals( other.keyValue ) )
+ {
+ return false;
+ }
+ return true;
+ }
+
+}
diff --git a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/KnownHostsProvider.java b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/KnownHostsProvider.java
index 85ce9aa..4dda97e 100644
--- a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/KnownHostsProvider.java
+++ b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/KnownHostsProvider.java
@@ -1,42 +1,45 @@
-package org.apache.maven.wagon.providers.ssh.knownhost;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-
-/**
- * Provides a way to add Known Hosts fingerprints to the JSch transport
- *
- * @author Juan F. Codagnone
- * @since Sep 12, 2005
- */
-public interface KnownHostsProvider
-{
- String ROLE = KnownHostsProvider.class.getName();
-
- void storeKnownHosts( String contents )
- throws IOException;
-
- void setHostKeyChecking( String hostKeyChecking );
-
- String getHostKeyChecking();
-
- String getContents();
-}
+package org.apache.maven.wagon.providers.ssh.knownhost;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.IOException;
+
+/**
+ * Provides a way to add Known Hosts fingerprints to the JSch transport
+ *
+ * @author Juan F. Codagnone
+ * @since Sep 12, 2005
+ */
+public interface KnownHostsProvider
+{
+ String ROLE = KnownHostsProvider.class.getName();
+
+ void storeKnownHosts( String contents )
+ throws IOException;
+
+ void addKnownHost( KnownHostEntry knownHost )
+ throws IOException;
+
+ void setHostKeyChecking( String hostKeyChecking );
+
+ String getHostKeyChecking();
+
+ String getContents();
+}
diff --git a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/NullKnownHostProvider.java b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/NullKnownHostProvider.java
index e3a3fc4..28653c0 100644
--- a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/NullKnownHostProvider.java
+++ b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/NullKnownHostProvider.java
@@ -1,35 +1,35 @@
-package org.apache.maven.wagon.providers.ssh.knownhost;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Dummy <code>KnownHostsProvider</code>
- *
- * @author Juan F. Codagnone
- * @since Sep 12, 2005
- *
- * @plexus.component role="org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider"
- * role-hint="null"
- * instantiation-strategy="per-lookup"
- */
-public final class NullKnownHostProvider
- extends AbstractKnownHostsProvider
-{
-}
+package org.apache.maven.wagon.providers.ssh.knownhost;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Dummy <code>KnownHostsProvider</code>
+ *
+ * @author Juan F. Codagnone
+ * @since Sep 12, 2005
+ *
+ * @plexus.component role="org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider"
+ * role-hint="null"
+ * instantiation-strategy="per-lookup"
+ */
+public final class NullKnownHostProvider
+ extends AbstractKnownHostsProvider
+{
+}
diff --git a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/SingleKnownHostProvider.java b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/SingleKnownHostProvider.java
index f7d8c91..c208b8f 100644
--- a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/SingleKnownHostProvider.java
+++ b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/SingleKnownHostProvider.java
@@ -1,46 +1,46 @@
-package org.apache.maven.wagon.providers.ssh.knownhost;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * Simple <code>KnownHostsProvider</code> with known wired values
- *
- * @plexus.component role="org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider"
- * role-hint="single"
- * instantiation-strategy="per-lookup"
- *
- * @author Juan F. Codagnone
- * @since Sep 12, 2005
- */
-public class SingleKnownHostProvider
- extends AbstractKnownHostsProvider
-{
- public SingleKnownHostProvider()
- {
- }
-
- /**
- * Creates the SingleKnownHostProvider.
- */
- public SingleKnownHostProvider( String host, String key )
- {
- this.contents = host + " ssh-rsa " + key + "\n";
- }
-}
+package org.apache.maven.wagon.providers.ssh.knownhost;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Simple <code>KnownHostsProvider</code> with known wired values
+ *
+ * @plexus.component role="org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider"
+ * role-hint="single"
+ * instantiation-strategy="per-lookup"
+ *
+ * @author Juan F. Codagnone
+ * @since Sep 12, 2005
+ */
+public class SingleKnownHostProvider
+ extends AbstractKnownHostsProvider
+{
+ public SingleKnownHostProvider()
+ {
+ }
+
+ /**
+ * Creates the SingleKnownHostProvider.
+ */
+ public SingleKnownHostProvider( String host, String key )
+ {
+ this.contents = host + " ssh-rsa " + key + "\n";
+ }
+}
diff --git a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/StreamKnownHostsProvider.java b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/StreamKnownHostsProvider.java
index 8579c85..e6c5e0e 100644
--- a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/StreamKnownHostsProvider.java
+++ b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/StreamKnownHostsProvider.java
@@ -1,86 +1,90 @@
-package org.apache.maven.wagon.providers.ssh.knownhost;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringReader;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.StringOutputStream;
-import org.codehaus.plexus.util.StringUtils;
-
-/**
- * Provides known hosts from a file
- *
- * @author Juan F. Codagnone
- * @since Sep 12, 2005
- */
-public class StreamKnownHostsProvider
- extends AbstractKnownHostsProvider
-{
-
- public StreamKnownHostsProvider( InputStream stream )
- throws IOException
- {
- try
- {
- StringOutputStream stringOutputStream = new StringOutputStream();
- IOUtil.copy( stream, stringOutputStream );
- this.contents = stringOutputStream.toString();
-
- this.knownHosts = this.loadKnownHosts( this.contents );
- }
- finally
- {
- IOUtil.close( stream );
- }
- }
-
- protected Set<KnownHostEntry> loadKnownHosts( String contents )
- throws IOException
- {
- Set<KnownHostEntry> hosts = new HashSet<KnownHostEntry>();
-
- BufferedReader br = new BufferedReader( new StringReader( contents ) );
-
- String line;
-
- do
- {
- line = br.readLine();
- if ( line != null )
- {
- String tokens[] = StringUtils.split( line );
- if ( tokens.length == 3 )
- {
- hosts.add( new KnownHostEntry( tokens[0], tokens[1], tokens[2] ) );
- }
- }
-
- }
- while ( line != null );
-
- return hosts;
- }
-}
+package org.apache.maven.wagon.providers.ssh.knownhost;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.StringOutputStream;
+import org.codehaus.plexus.util.StringUtils;
+
+/**
+ * Provides known hosts from a file
+ *
+ * @author Juan F. Codagnone
+ * @since Sep 12, 2005
+ */
+public class StreamKnownHostsProvider
+ extends AbstractKnownHostsProvider
+{
+
+ public StreamKnownHostsProvider( InputStream stream )
+ throws IOException
+ {
+ try
+ {
+ StringOutputStream stringOutputStream = new StringOutputStream();
+ IOUtil.copy( stream, stringOutputStream );
+
+ stream.close();
+ stream = null;
+
+ this.contents = stringOutputStream.toString();
+
+ this.knownHosts = this.loadKnownHosts( this.contents );
+ }
+ finally
+ {
+ IOUtil.close( stream );
+ }
+ }
+
+ protected Set<KnownHostEntry> loadKnownHosts( String contents )
+ throws IOException
+ {
+ Set<KnownHostEntry> hosts = new HashSet<KnownHostEntry>();
+
+ BufferedReader br = new BufferedReader( new StringReader( contents ) );
+
+ String line;
+
+ do
+ {
+ line = br.readLine();
+ if ( line != null )
+ {
+ String tokens[] = StringUtils.split( line );
+ if ( tokens.length == 3 )
+ {
+ hosts.add( new KnownHostEntry( tokens[0], tokens[1], tokens[2] ) );
+ }
+ }
+
+ }
+ while ( line != null );
+
+ return hosts;
+ }
+}
diff --git a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/UnknownHostException.java b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/UnknownHostException.java
index 3aaed46..bfb59bd 100644
--- a/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/UnknownHostException.java
+++ b/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/UnknownHostException.java
@@ -1,34 +1,34 @@
-package org.apache.maven.wagon.providers.ssh.knownhost;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.authentication.AuthenticationException;
-
-/**
- * Exception related to known_host check failures.
- */
-public class UnknownHostException
- extends AuthenticationException
-{
- public UnknownHostException( String host, Throwable cause )
- {
- super( "The host was not known and was not accepted by the configuration: " + host, cause );
- }
-}
+package org.apache.maven.wagon.providers.ssh.knownhost;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.authentication.AuthenticationException;
+
+/**
+ * Exception related to known_host check failures.
+ */
+public class UnknownHostException
+ extends AuthenticationException
+{
+ public UnknownHostException( String host, Throwable cause )
+ {
+ super( "The host was not known and was not accepted by the configuration: " + host, cause );
+ }
+}
diff --git a/wagon-providers/wagon-ssh-common/src/site/site.xml b/wagon-providers/wagon-ssh-common/src/site/site.xml
index 820e21b..0a79a3e 100644
--- a/wagon-providers/wagon-ssh-common/src/site/site.xml
+++ b/wagon-providers/wagon-ssh-common/src/site/site.xml
@@ -1,33 +1,33 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
- <body>
- <breadcrumbs>
- <item name="SSH Common" href="http://maven.apache.org/wagon/wagon-providers/wagon-ssh-common/index.html" />
- </breadcrumbs>
-
- <menu ref="parent"/>
- <menu ref="reports"/>
- </body>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
+ <body>
+ <breadcrumbs>
+ <item name="SSH Common" href="http://maven.apache.org/wagon/wagon-providers/wagon-ssh-common/index.html" />
+ </breadcrumbs>
+
+ <menu ref="parent"/>
+ <menu ref="reports"/>
+ </body>
</project>
\ No newline at end of file
diff --git a/wagon-providers/wagon-ssh-common/src/test/java/org/apache/maven/wagon/providers/ssh/LSParserTest.java b/wagon-providers/wagon-ssh-common/src/test/java/org/apache/maven/wagon/providers/ssh/LSParserTest.java
index 95e3289..97499c6 100644
--- a/wagon-providers/wagon-ssh-common/src/test/java/org/apache/maven/wagon/providers/ssh/LSParserTest.java
+++ b/wagon-providers/wagon-ssh-common/src/test/java/org/apache/maven/wagon/providers/ssh/LSParserTest.java
@@ -1,130 +1,130 @@
-package org.apache.maven.wagon.providers.ssh;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.TransferFailedException;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-
-public class LSParserTest
- extends TestCase
-{
- public void testParseLinux()
- throws TransferFailedException
- {
- String rawLS = "total 32\n" + "drwxr-xr-x 5 joakim joakim 4096 2006-12-11 10:30 .\n"
- + "drwxr-xr-x 14 joakim joakim 4096 2006-12-11 10:30 ..\n"
- + "-rw-r--r-- 1 joakim joakim 320 2006-12-09 18:46 .classpath\n"
- + "-rw-r--r-- 1 joakim joakim 1194 2006-12-11 09:25 pom.xml\n"
- + "-rw-r--r-- 1 joakim joakim 662 2006-12-09 18:46 .project\n"
- + "drwxr-xr-x 4 joakim joakim 4096 2006-11-21 12:26 src\n"
- + "drwxr-xr-x 4 joakim joakim 4096 2006-11-21 12:26 spaced out\n"
- + "drwxr-xr-x 7 joakim joakim 4096 2006-12-11 10:31 .svn\n"
- + "drwxr-xr-x 3 joakim joakim 4096 2006-12-11 08:39 target\n";
-
- LSParser parser = new LSParser();
- List<String> files = parser.parseFiles( rawLS );
- assertNotNull( files );
- assertEquals( 9, files.size() );
- assertTrue( files.contains( "pom.xml" ) );
- assertTrue( files.contains( "spaced out" ) );
- }
-
- public void testParseOSX() throws TransferFailedException
- {
- String rawLS = "total 32\n" + "drwxr-xr-x 5 joakim joakim 238 Dec 11 10:30 .\n"
- + "drwxr-xr-x 14 joakim joakim 518 Dec 11 10:30 ..\n"
- + "-rw-r--r-- 1 joakim joakim 320 May 9 2006 .classpath\n"
- + "-rw-r--r-- 1 joakim joakim 1194 Dec 11 09:25 pom.xml\n"
- + "-rw-r--r-- 1 joakim joakim 662 May 9 2006 .project\n"
- + "drwxr-xr-x 4 joakim joakim 204 Dec 11 12:26 src\n"
- + "drwxr-xr-x 4 joakim joakim 204 Dec 11 12:26 spaced out\n"
- + "drwxr-xr-x 7 joakim joakim 476 Dec 11 10:31 .svn\n"
- + "drwxr-xr-x 3 joakim joakim 238 Dec 11 08:39 target\n";
-
- LSParser parser = new LSParser();
- List<String> files = parser.parseFiles( rawLS );
- assertNotNull( files );
- assertEquals( 9, files.size() );
- assertTrue( files.contains( "pom.xml" ) );
- assertTrue( files.contains( "spaced out" ) );
- }
-
- public void testParseOSXFrLocale() throws TransferFailedException
- {
- String rawLS = "total 40\n" + "-rw-r--r-- 1 olamy staff 11 21 sep 00:34 .index.txt\n"
- + "-rw-r--r-- 1 olamy staff 19 21 sep 00:34 more-resources.dat\n"
- + "-rw-r--r-- 1 olamy staff 20 21 sep 00:34 test-resource b.txt\n"
- +"-rw-r--r-- 1 olamy staff 18 21 sep 00:34 test-resource.pom\n"
- + "-rw-r--r-- 1 olamy staff 18 21 sep 00:34 test-resource.txt\n";
-
- LSParser parser = new LSParser();
- List<String> files = parser.parseFiles( rawLS );
- assertNotNull( files );
- assertEquals( 5, files.size() );
- assertTrue( files.contains( "more-resources.dat" ) );
- assertTrue( files.contains( ".index.txt" ) );
- }
-
-
-
- public void testParseCygwin() throws TransferFailedException
- {
- String rawLS = "total 32\n" + "drwxr-xr-x+ 5 joakim None 0 Dec 11 10:30 .\n"
- + "drwxr-xr-x+ 14 joakim None 0 Dec 11 10:30 ..\n"
- + "-rw-r--r--+ 1 joakim None 320 May 9 2006 .classpath\n"
- + "-rw-r--r--+ 1 joakim None 1194 Dec 11 09:25 pom.xml\n"
- + "-rw-r--r--+ 1 joakim None 662 May 9 2006 .project\n"
- + "drwxr-xr-x+ 4 joakim None 0 Dec 11 12:26 src\n"
- + "drwxr-xr-x+ 4 joakim None 0 Dec 11 12:26 spaced out\n"
- + "drwxr-xr-x+ 7 joakim None 0 Dec 11 10:31 .svn\n"
- + "drwxr-xr-x+ 3 joakim None 0 Dec 11 08:39 target\n";
-
- LSParser parser = new LSParser();
- List<String> files = parser.parseFiles( rawLS );
- assertNotNull( files );
- assertEquals( 9, files.size() );
- assertTrue( files.contains( "pom.xml" ) );
- assertTrue( files.contains( "spaced out" ) );
- }
-
- /**
- * Snicoll, Jvanzyl, and Tom reported problems with wagon-ssh.getFileList().
- * Just adding a real-world example of the ls to see if it is a problem.
- * - Joakime
- */
- public void testParsePeopleApacheStaging() throws TransferFailedException
- {
- String rawLS = "total 6\n"
- + "drwxr-xr-x 3 snicoll snicoll 512 Feb 7 11:04 .\n"
- + "drwxr-xr-x 3 snicoll snicoll 512 Feb 7 11:04 ..\n"
- + "drwxr-xr-x 3 snicoll snicoll 512 Feb 7 11:04 org\n"
- + "drwxr-xr-x 3 snicoll snicoll 512 Feb 7 11:04 spaced out\n";
-
- LSParser parser = new LSParser();
- List<String> files = parser.parseFiles( rawLS );
- assertNotNull( files );
- assertEquals( 4, files.size() );
- assertTrue( files.contains( "org" ) );
- assertTrue( files.contains( "spaced out" ) );
- }
-}
+package org.apache.maven.wagon.providers.ssh;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.TransferFailedException;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+public class LSParserTest
+ extends TestCase
+{
+ public void testParseLinux()
+ throws TransferFailedException
+ {
+ String rawLS = "total 32\n" + "drwxr-xr-x 5 joakim joakim 4096 2006-12-11 10:30 .\n"
+ + "drwxr-xr-x 14 joakim joakim 4096 2006-12-11 10:30 ..\n"
+ + "-rw-r--r-- 1 joakim joakim 320 2006-12-09 18:46 .classpath\n"
+ + "-rw-r--r-- 1 joakim joakim 1194 2006-12-11 09:25 pom.xml\n"
+ + "-rw-r--r-- 1 joakim joakim 662 2006-12-09 18:46 .project\n"
+ + "drwxr-xr-x 4 joakim joakim 4096 2006-11-21 12:26 src\n"
+ + "drwxr-xr-x 4 joakim joakim 4096 2006-11-21 12:26 spaced out\n"
+ + "drwxr-xr-x 7 joakim joakim 4096 2006-12-11 10:31 .svn\n"
+ + "drwxr-xr-x 3 joakim joakim 4096 2006-12-11 08:39 target\n";
+
+ LSParser parser = new LSParser();
+ List<String> files = parser.parseFiles( rawLS );
+ assertNotNull( files );
+ assertEquals( 9, files.size() );
+ assertTrue( files.contains( "pom.xml" ) );
+ assertTrue( files.contains( "spaced out" ) );
+ }
+
+ public void testParseOSX() throws TransferFailedException
+ {
+ String rawLS = "total 32\n" + "drwxr-xr-x 5 joakim joakim 238 Dec 11 10:30 .\n"
+ + "drwxr-xr-x 14 joakim joakim 518 Dec 11 10:30 ..\n"
+ + "-rw-r--r-- 1 joakim joakim 320 May 9 2006 .classpath\n"
+ + "-rw-r--r-- 1 joakim joakim 1194 Dec 11 09:25 pom.xml\n"
+ + "-rw-r--r-- 1 joakim joakim 662 May 9 2006 .project\n"
+ + "drwxr-xr-x 4 joakim joakim 204 Dec 11 12:26 src\n"
+ + "drwxr-xr-x 4 joakim joakim 204 Dec 11 12:26 spaced out\n"
+ + "drwxr-xr-x 7 joakim joakim 476 Dec 11 10:31 .svn\n"
+ + "drwxr-xr-x 3 joakim joakim 238 Dec 11 08:39 target\n";
+
+ LSParser parser = new LSParser();
+ List<String> files = parser.parseFiles( rawLS );
+ assertNotNull( files );
+ assertEquals( 9, files.size() );
+ assertTrue( files.contains( "pom.xml" ) );
+ assertTrue( files.contains( "spaced out" ) );
+ }
+
+ public void testParseOSXFrLocale() throws TransferFailedException
+ {
+ String rawLS = "total 40\n" + "-rw-r--r-- 1 olamy staff 11 21 sep 00:34 .index.txt\n"
+ + "-rw-r--r-- 1 olamy staff 19 21 sep 00:34 more-resources.dat\n"
+ + "-rw-r--r-- 1 olamy staff 20 21 sep 00:34 test-resource b.txt\n"
+ +"-rw-r--r-- 1 olamy staff 18 21 sep 00:34 test-resource.pom\n"
+ + "-rw-r--r-- 1 olamy staff 18 21 sep 00:34 test-resource.txt\n";
+
+ LSParser parser = new LSParser();
+ List<String> files = parser.parseFiles( rawLS );
+ assertNotNull( files );
+ assertEquals( 5, files.size() );
+ assertTrue( files.contains( "more-resources.dat" ) );
+ assertTrue( files.contains( ".index.txt" ) );
+ }
+
+
+
+ public void testParseCygwin() throws TransferFailedException
+ {
+ String rawLS = "total 32\n" + "drwxr-xr-x+ 5 joakim None 0 Dec 11 10:30 .\n"
+ + "drwxr-xr-x+ 14 joakim None 0 Dec 11 10:30 ..\n"
+ + "-rw-r--r--+ 1 joakim None 320 May 9 2006 .classpath\n"
+ + "-rw-r--r--+ 1 joakim None 1194 Dec 11 09:25 pom.xml\n"
+ + "-rw-r--r--+ 1 joakim None 662 May 9 2006 .project\n"
+ + "drwxr-xr-x+ 4 joakim None 0 Dec 11 12:26 src\n"
+ + "drwxr-xr-x+ 4 joakim None 0 Dec 11 12:26 spaced out\n"
+ + "drwxr-xr-x+ 7 joakim None 0 Dec 11 10:31 .svn\n"
+ + "drwxr-xr-x+ 3 joakim None 0 Dec 11 08:39 target\n";
+
+ LSParser parser = new LSParser();
+ List<String> files = parser.parseFiles( rawLS );
+ assertNotNull( files );
+ assertEquals( 9, files.size() );
+ assertTrue( files.contains( "pom.xml" ) );
+ assertTrue( files.contains( "spaced out" ) );
+ }
+
+ /**
+ * Snicoll, Jvanzyl, and Tom reported problems with wagon-ssh.getFileList().
+ * Just adding a real-world example of the ls to see if it is a problem.
+ * - Joakime
+ */
+ public void testParsePeopleApacheStaging() throws TransferFailedException
+ {
+ String rawLS = "total 6\n"
+ + "drwxr-xr-x 3 snicoll snicoll 512 Feb 7 11:04 .\n"
+ + "drwxr-xr-x 3 snicoll snicoll 512 Feb 7 11:04 ..\n"
+ + "drwxr-xr-x 3 snicoll snicoll 512 Feb 7 11:04 org\n"
+ + "drwxr-xr-x 3 snicoll snicoll 512 Feb 7 11:04 spaced out\n";
+
+ LSParser parser = new LSParser();
+ List<String> files = parser.parseFiles( rawLS );
+ assertNotNull( files );
+ assertEquals( 4, files.size() );
+ assertTrue( files.contains( "org" ) );
+ assertTrue( files.contains( "spaced out" ) );
+ }
+}
diff --git a/wagon-providers/wagon-ssh-common/src/test/java/org/apache/maven/wagon/providers/ssh/knownhost/FileKnownHostsProviderTest.java b/wagon-providers/wagon-ssh-common/src/test/java/org/apache/maven/wagon/providers/ssh/knownhost/FileKnownHostsProviderTest.java
index 66f8fae..abb35ad 100644
--- a/wagon-providers/wagon-ssh-common/src/test/java/org/apache/maven/wagon/providers/ssh/knownhost/FileKnownHostsProviderTest.java
+++ b/wagon-providers/wagon-ssh-common/src/test/java/org/apache/maven/wagon/providers/ssh/knownhost/FileKnownHostsProviderTest.java
@@ -1,75 +1,75 @@
-package org.apache.maven.wagon.providers.ssh.knownhost;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-
-import org.codehaus.plexus.util.FileUtils;
-
-import junit.framework.TestCase;
-
-public class FileKnownHostsProviderTest
- extends TestCase
-{
- private File basedir = new File( System.getProperty( "basedir", "." ) );
-
- private File testKnownHostsFile;
-
-
- private FileKnownHostsProvider provider;
-
- public void setUp()
- throws Exception
- {
- File readonlyKnownHostFile = new File( basedir, "src/test/resources/known_hosts" );
- testKnownHostsFile = new File( basedir, "target/known_hosts" );
- testKnownHostsFile.delete();
- FileUtils.copyFile( readonlyKnownHostFile, testKnownHostsFile );
- testKnownHostsFile.setLastModified( testKnownHostsFile.lastModified() - 60 * 1000 );
-
- provider = new FileKnownHostsProvider( testKnownHostsFile );
-
- }
-
- public void testStoreKnownHostsNoChange()
- throws Exception
- {
- long timestamp = this.testKnownHostsFile.lastModified();
- //file with the same contents, but with entries swapped
- File sameKnownHostFile = new File( basedir, "src/test/resources/known_hosts_same" );
- String contents = FileUtils.fileRead( sameKnownHostFile );
-
- provider.storeKnownHosts( contents );
- assertEquals( "known_hosts file is rewritten", timestamp, testKnownHostsFile.lastModified() );
- }
-
- public void testStoreKnownHostsWithChange()
- throws Exception
- {
- long timestamp = this.testKnownHostsFile.lastModified();
- File sameKnownHostFile = new File( basedir, "src/test/resources/known_hosts_same" );
- String contents = FileUtils.fileRead( sameKnownHostFile );
- contents += "1 2 3";
-
- provider.storeKnownHosts( contents );
- assertTrue( "known_hosts file is not rewritten", timestamp != testKnownHostsFile.lastModified() );
- }
-
-}
+package org.apache.maven.wagon.providers.ssh.knownhost;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+
+import org.codehaus.plexus.util.FileUtils;
+
+import junit.framework.TestCase;
+
+public class FileKnownHostsProviderTest
+ extends TestCase
+{
+ private File basedir = new File( System.getProperty( "basedir", "." ) );
+
+ private File testKnownHostsFile;
+
+
+ private FileKnownHostsProvider provider;
+
+ public void setUp()
+ throws Exception
+ {
+ File readonlyKnownHostFile = new File( basedir, "src/test/resources/known_hosts" );
+ testKnownHostsFile = new File( basedir, "target/known_hosts" );
+ testKnownHostsFile.delete();
+ FileUtils.copyFile( readonlyKnownHostFile, testKnownHostsFile );
+ testKnownHostsFile.setLastModified( testKnownHostsFile.lastModified() - 60 * 1000 );
+
+ provider = new FileKnownHostsProvider( testKnownHostsFile );
+
+ }
+
+ public void testStoreKnownHostsNoChange()
+ throws Exception
+ {
+ long timestamp = this.testKnownHostsFile.lastModified();
+ //file with the same contents, but with entries swapped
+ File sameKnownHostFile = new File( basedir, "src/test/resources/known_hosts_same" );
+ String contents = FileUtils.fileRead( sameKnownHostFile );
+
+ provider.storeKnownHosts( contents );
+ assertEquals( "known_hosts file is rewritten", timestamp, testKnownHostsFile.lastModified() );
+ }
+
+ public void testStoreKnownHostsWithChange()
+ throws Exception
+ {
+ long timestamp = this.testKnownHostsFile.lastModified();
+ File sameKnownHostFile = new File( basedir, "src/test/resources/known_hosts_same" );
+ String contents = FileUtils.fileRead( sameKnownHostFile );
+ contents += "1 2 3";
+
+ provider.storeKnownHosts( contents );
+ assertTrue( "known_hosts file is not rewritten", timestamp != testKnownHostsFile.lastModified() );
+ }
+
+}
diff --git a/wagon-providers/wagon-ssh-common/src/test/resources/known_hosts b/wagon-providers/wagon-ssh-common/src/test/resources/known_hosts
index 94501fa..7836c74 100644
--- a/wagon-providers/wagon-ssh-common/src/test/resources/known_hosts
+++ b/wagon-providers/wagon-ssh-common/src/test/resources/known_hosts
@@ -1,2 +1,2 @@
-server,192.168.0.10 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAtnWEbH/WTZG2aAl9gX8HtMqXidzQXgluARIOijWigbvA4/3N4fnNmckXBUHR32iqHQM/ySIRhc9EVDanDy0JyKdm738PwP0DbWGqiIDTtukbju4DAtXtOx3LgIqHc0PD+cquO9Ut/68o6/GdBgN18nVOMt+8Q9Vr1VSFqfHoLEx04NI+4BbGaGKQOFU25VJ3KtM0zkoyDfu0/MDusVoFIDVb0KtfxZVEDRmEFnySpFHOBdSdODsunftYccCNTNdsh+58jSqChUUlP3B0bTykm7o52CrXCMWCsLzH6dDkN7GUQwLvjPG04gedeZg6tEN8vTInRmHQrp0TTW7JGNjXgw==
-192.168.0.11 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAtnWEbH/WTZG2aAl9gX8HtMqXidzQXgluARIOijWigbvA4/3N4fnNmckXBUHR32iqHQM/ySIRhc9EVDanDy0JyKdm738PwP0DbWGqiIDTtukbju4DAtXtOx3LgIqHc0PD+cquO9Ut/68o6/GdBgN18nVOMt+8Q9Vr1VSFqfHoLEx04NI+4BbGaGKQOFU25VJ3KtM0zkoyDfu0/MDusVoFIDVb0KtfxZVEDRmEFnySpFHOBdSdODsunftYccCNTNdsh+58jSqChUUlP3B0bTykm7o52CrXCMWCsLzH6dDkN7GUQwLvjPG04gedeZg6tEN8vTInRmHQrp0TTW7JGNjXgw==
+server,192.168.0.10 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAtnWEbH/WTZG2aAl9gX8HtMqXidzQXgluARIOijWigbvA4/3N4fnNmckXBUHR32iqHQM/ySIRhc9EVDanDy0JyKdm738PwP0DbWGqiIDTtukbju4DAtXtOx3LgIqHc0PD+cquO9Ut/68o6/GdBgN18nVOMt+8Q9Vr1VSFqfHoLEx04NI+4BbGaGKQOFU25VJ3KtM0zkoyDfu0/MDusVoFIDVb0KtfxZVEDRmEFnySpFHOBdSdODsunftYccCNTNdsh+58jSqChUUlP3B0bTykm7o52CrXCMWCsLzH6dDkN7GUQwLvjPG04gedeZg6tEN8vTInRmHQrp0TTW7JGNjXgw==
+192.168.0.11 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAtnWEbH/WTZG2aAl9gX8HtMqXidzQXgluARIOijWigbvA4/3N4fnNmckXBUHR32iqHQM/ySIRhc9EVDanDy0JyKdm738PwP0DbWGqiIDTtukbju4DAtXtOx3LgIqHc0PD+cquO9Ut/68o6/GdBgN18nVOMt+8Q9Vr1VSFqfHoLEx04NI+4BbGaGKQOFU25VJ3KtM0zkoyDfu0/MDusVoFIDVb0KtfxZVEDRmEFnySpFHOBdSdODsunftYccCNTNdsh+58jSqChUUlP3B0bTykm7o52CrXCMWCsLzH6dDkN7GUQwLvjPG04gedeZg6tEN8vTInRmHQrp0TTW7JGNjXgw==
diff --git a/wagon-providers/wagon-ssh-common/src/test/resources/known_hosts_same b/wagon-providers/wagon-ssh-common/src/test/resources/known_hosts_same
index 8eec884..50cc602 100644
--- a/wagon-providers/wagon-ssh-common/src/test/resources/known_hosts_same
+++ b/wagon-providers/wagon-ssh-common/src/test/resources/known_hosts_same
@@ -1,2 +1,2 @@
-192.168.0.11 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAtnWEbH/WTZG2aAl9gX8HtMqXidzQXgluARIOijWigbvA4/3N4fnNmckXBUHR32iqHQM/ySIRhc9EVDanDy0JyKdm738PwP0DbWGqiIDTtukbju4DAtXtOx3LgIqHc0PD+cquO9Ut/68o6/GdBgN18nVOMt+8Q9Vr1VSFqfHoLEx04NI+4BbGaGKQOFU25VJ3KtM0zkoyDfu0/MDusVoFIDVb0KtfxZVEDRmEFnySpFHOBdSdODsunftYccCNTNdsh+58jSqChUUlP3B0bTykm7o52CrXCMWCsLzH6dDkN7GUQwLvjPG04gedeZg6tEN8vTInRmHQrp0TTW7JGNjXgw==
-server,192.168.0.10 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAtnWEbH/WTZG2aAl9gX8HtMqXidzQXgluARIOijWigbvA4/3N4fnNmckXBUHR32iqHQM/ySIRhc9EVDanDy0JyKdm738PwP0DbWGqiIDTtukbju4DAtXtOx3LgIqHc0PD+cquO9Ut/68o6/GdBgN18nVOMt+8Q9Vr1VSFqfHoLEx04NI+4BbGaGKQOFU25VJ3KtM0zkoyDfu0/MDusVoFIDVb0KtfxZVEDRmEFnySpFHOBdSdODsunftYccCNTNdsh+58jSqChUUlP3B0bTykm7o52CrXCMWCsLzH6dDkN7GUQwLvjPG04gedeZg6tEN8vTInRmHQrp0TTW7JGNjXgw==
+192.168.0.11 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAtnWEbH/WTZG2aAl9gX8HtMqXidzQXgluARIOijWigbvA4/3N4fnNmckXBUHR32iqHQM/ySIRhc9EVDanDy0JyKdm738PwP0DbWGqiIDTtukbju4DAtXtOx3LgIqHc0PD+cquO9Ut/68o6/GdBgN18nVOMt+8Q9Vr1VSFqfHoLEx04NI+4BbGaGKQOFU25VJ3KtM0zkoyDfu0/MDusVoFIDVb0KtfxZVEDRmEFnySpFHOBdSdODsunftYccCNTNdsh+58jSqChUUlP3B0bTykm7o52CrXCMWCsLzH6dDkN7GUQwLvjPG04gedeZg6tEN8vTInRmHQrp0TTW7JGNjXgw==
+server,192.168.0.10 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAtnWEbH/WTZG2aAl9gX8HtMqXidzQXgluARIOijWigbvA4/3N4fnNmckXBUHR32iqHQM/ySIRhc9EVDanDy0JyKdm738PwP0DbWGqiIDTtukbju4DAtXtOx3LgIqHc0PD+cquO9Ut/68o6/GdBgN18nVOMt+8Q9Vr1VSFqfHoLEx04NI+4BbGaGKQOFU25VJ3KtM0zkoyDfu0/MDusVoFIDVb0KtfxZVEDRmEFnySpFHOBdSdODsunftYccCNTNdsh+58jSqChUUlP3B0bTykm7o52CrXCMWCsLzH6dDkN7GUQwLvjPG04gedeZg6tEN8vTInRmHQrp0TTW7JGNjXgw==
diff --git a/wagon-providers/wagon-ssh-external/pom.xml b/wagon-providers/wagon-ssh-external/pom.xml
index 09ee42a..b8db4d1 100644
--- a/wagon-providers/wagon-ssh-external/pom.xml
+++ b/wagon-providers/wagon-ssh-external/pom.xml
@@ -1,135 +1,119 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-providers</artifactId>
- <version>2.10</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>wagon-ssh-external</artifactId>
- <name>Apache Maven Wagon :: Providers :: SSH External Provider</name>
- <description>
- Wagon provider that gets and puts artifacts using SSH protocol with a preinstalled SSH client
- </description>
-
- <properties>
- <sshd.stopImmediatly>false</sshd.stopImmediatly>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-ssh-common</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-ssh-common-test</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sshd</groupId>
- <artifactId>sshd-core</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>bouncycastle</groupId>
- <artifactId>bcprov-jdk15</artifactId>
- <version>140</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- <version>2.0.1</version>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-
- <profiles>
- <profile>
- <id>no-ssh-tests</id>
- <activation>
- <property>
- <name>!ssh-tests</name>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <!-- Tests that require an ssh server on localhost -->
- <excludes>
- <exclude>**/SshCommandExecutorTest.*</exclude>
- <exclude>**/Scp*Test.*</exclude>
- <exclude>**/EmbeddedScp*WagonWithKeyTest.*</exclude>
- </excludes>
- <systemPropertyVariables>
- <java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
- <test.user>olamy</test.user>
- <sshd.stopImmediatly>${sshd.stopImmediatly}</sshd.stopImmediatly>
- </systemPropertyVariables>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>ssh-embedded</id>
- <activation>
- <property>
- <name>ssh-embedded</name>
- <value>true</value>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <!-- Tests that require an ssh server on localhost -->
- <excludes>
- <exclude>**/SshCommandExecutorTest.*</exclude>
- <exclude>**/Scp*Test.*</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-providers</artifactId>
+ <version>2.12</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>wagon-ssh-external</artifactId>
+ <name>Apache Maven Wagon :: Providers :: SSH External Provider</name>
+ <description>
+ Wagon provider that gets and puts artifacts using SSH protocol with a preinstalled SSH client
+ </description>
+
+ <properties>
+ <sshd.stopImmediatly>false</sshd.stopImmediatly>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-ssh-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-ssh-common-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>no-ssh-tests</id>
+ <activation>
+ <property>
+ <name>!ssh-tests</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!-- Tests that require an ssh server on localhost -->
+ <excludes>
+ <exclude>**/SshCommandExecutorTest.*</exclude>
+ <exclude>**/Scp*Test.*</exclude>
+ <exclude>**/EmbeddedScp*WagonWithKeyTest.*</exclude>
+ </excludes>
+ <systemPropertyVariables>
+ <java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
+ <test.user>olamy</test.user>
+ <sshd.stopImmediatly>${sshd.stopImmediatly}</sshd.stopImmediatly>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>ssh-embedded</id>
+ <activation>
+ <property>
+ <name>ssh-embedded</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!-- Tests that require an ssh server on localhost -->
+ <excludes>
+ <exclude>**/SshCommandExecutorTest.*</exclude>
+ <exclude>**/Scp*Test.*</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
diff --git a/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalCommandExecutor.java b/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalCommandExecutor.java
index 3fb9595..8ee1880 100644
--- a/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalCommandExecutor.java
+++ b/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalCommandExecutor.java
@@ -1,43 +1,43 @@
-package org.apache.maven.wagon.providers.ssh.external;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * ScpExternalCommandExecutor - bridge class for plexus:descriptor
- *
- * @author <a href="mailto:joakim at erdfelt.com">Joakim Erdfelt</a>
- *
- *
- * @todo is this even needed anymore?
- *
- * @plexus.component role="org.apache.maven.wagon.CommandExecutor"
- * role-hint="scpexe"
- * instantiation-strategy="per-lookup"
- */
-public class ScpExternalCommandExecutor
- extends ScpExternalWagon
-{
-
- public ScpExternalCommandExecutor()
- {
- super();
- }
-
-}
+package org.apache.maven.wagon.providers.ssh.external;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * ScpExternalCommandExecutor - bridge class for plexus:descriptor
+ *
+ * @author <a href="mailto:joakim at erdfelt.com">Joakim Erdfelt</a>
+ *
+ *
+ * @todo is this even needed anymore?
+ *
+ * @plexus.component role="org.apache.maven.wagon.CommandExecutor"
+ * role-hint="scpexe"
+ * instantiation-strategy="per-lookup"
+ */
+public class ScpExternalCommandExecutor
+ extends ScpExternalWagon
+{
+
+ public ScpExternalCommandExecutor()
+ {
+ super();
+ }
+
+}
diff --git a/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagon.java b/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagon.java
index e6aadfa..b2dc1da 100644
--- a/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagon.java
+++ b/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagon.java
@@ -1,520 +1,520 @@
-package org.apache.maven.wagon.providers.ssh.external;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.AbstractWagon;
-import org.apache.maven.wagon.CommandExecutionException;
-import org.apache.maven.wagon.CommandExecutor;
-import org.apache.maven.wagon.PathUtils;
-import org.apache.maven.wagon.PermissionModeUtils;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
-import org.apache.maven.wagon.Streams;
-import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.WagonConstants;
-import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
-import org.apache.maven.wagon.authorization.AuthorizationException;
-import org.apache.maven.wagon.events.TransferEvent;
-import org.apache.maven.wagon.providers.ssh.ScpHelper;
-import org.apache.maven.wagon.repository.RepositoryPermissions;
-import org.apache.maven.wagon.resource.Resource;
-import org.codehaus.plexus.util.StringUtils;
-import org.codehaus.plexus.util.cli.CommandLineException;
-import org.codehaus.plexus.util.cli.CommandLineUtils;
-import org.codehaus.plexus.util.cli.Commandline;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.util.List;
-import java.util.Locale;
-
-/**
- * SCP deployer using "external" scp program. To allow for
- * ssh-agent type behavior, until we can construct a Java SSH Agent and interface for JSch.
- *
- * @author <a href="mailto:brett at apache.org">Brett Porter</a>
- * @todo [BP] add compression flag
- * @plexus.component role="org.apache.maven.wagon.Wagon"
- * role-hint="scpexe"
- * instantiation-strategy="per-lookup"
- */
-public class ScpExternalWagon
- extends AbstractWagon
- implements CommandExecutor
-{
- /**
- * The external SCP command to use - default is <code>scp</code>.
- *
- * @component.configuration default="scp"
- */
- private String scpExecutable = "scp";
-
- /**
- * The external SSH command to use - default is <code>ssh</code>.
- *
- * @component.configuration default="ssh"
- */
- private String sshExecutable = "ssh";
-
- /**
- * Arguments to pass to the SCP command.
- *
- * @component.configuration
- */
- private String scpArgs;
-
- /**
- * Arguments to pass to the SSH command.
- *
- * @component.configuration
- */
- private String sshArgs;
-
- private ScpHelper sshTool = new ScpHelper( this );
-
- private static final int SSH_FATAL_EXIT_CODE = 255;
-
- // ----------------------------------------------------------------------
- //
- // ----------------------------------------------------------------------
-
- protected void openConnectionInternal()
- throws AuthenticationException
- {
- if ( authenticationInfo == null )
- {
- authenticationInfo = new AuthenticationInfo();
- }
- }
-
- public void closeConnection()
- {
- // nothing to disconnect
- }
-
- public boolean getIfNewer( String resourceName, File destination, long timestamp )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- fireSessionDebug( "getIfNewer in SCP wagon is not supported - performing an unconditional get" );
- get( resourceName, destination );
- return true;
- }
-
- /**
- * @return The hostname of the remote server prefixed with the username, which comes either from the repository URL
- * or from the authenticationInfo.
- */
- private String buildRemoteHost()
- {
- String username = this.getRepository().getUsername();
- if ( username == null )
- {
- username = authenticationInfo.getUserName();
- }
-
- if ( username == null )
- {
- return getRepository().getHost();
- }
- else
- {
- return username + "@" + getRepository().getHost();
- }
- }
-
- public void executeCommand( String command )
- throws CommandExecutionException
- {
- fireTransferDebug( "Executing command: " + command );
-
- executeCommand( command, false );
- }
-
- public Streams executeCommand( String command, boolean ignoreFailures )
- throws CommandExecutionException
- {
- boolean putty = isPuTTY();
-
- File privateKey;
- try
- {
- privateKey = ScpHelper.getPrivateKey( authenticationInfo );
- }
- catch ( FileNotFoundException e )
- {
- throw new CommandExecutionException( e.getMessage(), e );
- }
- Commandline cl = createBaseCommandLine( putty, sshExecutable, privateKey );
-
- int port =
- repository.getPort() == WagonConstants.UNKNOWN_PORT ? ScpHelper.DEFAULT_SSH_PORT : repository.getPort();
- if ( port != ScpHelper.DEFAULT_SSH_PORT )
- {
- if ( putty )
- {
- cl.createArg().setLine( "-P " + port );
- }
- else
- {
- cl.createArg().setLine( "-p " + port );
- }
- }
-
- if ( sshArgs != null )
- {
- cl.createArg().setLine( sshArgs );
- }
-
- String remoteHost = this.buildRemoteHost();
-
- cl.createArg().setValue( remoteHost );
-
- cl.createArg().setValue( command );
-
- fireSessionDebug( "Executing command: " + cl.toString() );
-
- try
- {
- CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer();
- CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
- int exitCode = CommandLineUtils.executeCommandLine( cl, out, err );
- Streams streams = new Streams();
- streams.setOut( out.getOutput() );
- streams.setErr( err.getOutput() );
- fireSessionDebug( streams.getOut() );
- fireSessionDebug( streams.getErr() );
- if ( exitCode != 0 )
- {
- if ( !ignoreFailures || exitCode == SSH_FATAL_EXIT_CODE )
- {
- throw new CommandExecutionException( "Exit code " + exitCode + " - " + err.getOutput() );
- }
- }
- return streams;
- }
- catch ( CommandLineException e )
- {
- throw new CommandExecutionException( "Error executing command line", e );
- }
- }
-
- protected boolean isPuTTY()
- {
- return sshExecutable.toLowerCase( Locale.ENGLISH ).contains( "plink" );
- }
-
- private Commandline createBaseCommandLine( boolean putty, String executable, File privateKey )
- {
- Commandline cl = new Commandline();
-
- cl.setExecutable( executable );
-
- if ( privateKey != null )
- {
- cl.createArg().setValue( "-i" );
- cl.createArg().setFile( privateKey );
- }
-
- String password = authenticationInfo.getPassword();
- if ( putty && password != null )
- {
- cl.createArg().setValue( "-pw" );
- cl.createArg().setValue( password );
- }
-
- // should check interactive flag, but scpexe never works in interactive mode right now due to i/o streams
- if ( putty )
- {
- cl.createArg().setValue( "-batch" );
- }
- else
- {
- cl.createArg().setValue( "-o" );
- cl.createArg().setValue( "BatchMode yes" );
- }
- return cl;
- }
-
-
- private void executeScpCommand( Resource resource, File localFile, boolean put )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- boolean putty = isPuTTYSCP();
-
- File privateKey;
- try
- {
- privateKey = ScpHelper.getPrivateKey( authenticationInfo );
- }
- catch ( FileNotFoundException e )
- {
- fireSessionConnectionRefused();
-
- throw new AuthorizationException( e.getMessage() );
- }
- Commandline cl = createBaseCommandLine( putty, scpExecutable, privateKey );
-
- cl.setWorkingDirectory( localFile.getParentFile().getAbsolutePath() );
-
- int port =
- repository.getPort() == WagonConstants.UNKNOWN_PORT ? ScpHelper.DEFAULT_SSH_PORT : repository.getPort();
- if ( port != ScpHelper.DEFAULT_SSH_PORT )
- {
- cl.createArg().setLine( "-P " + port );
- }
-
- if ( scpArgs != null )
- {
- cl.createArg().setLine( scpArgs );
- }
-
- String resourceName = normalizeResource( resource );
- String remoteFile = getRepository().getBasedir() + "/" + resourceName;
-
- remoteFile = StringUtils.replace( remoteFile, " ", "\\ " );
-
- String qualifiedRemoteFile = this.buildRemoteHost() + ":" + remoteFile;
- if ( put )
- {
- cl.createArg().setValue( localFile.getName() );
- cl.createArg().setValue( qualifiedRemoteFile );
- }
- else
- {
- cl.createArg().setValue( qualifiedRemoteFile );
- cl.createArg().setValue( localFile.getName() );
- }
-
- fireSessionDebug( "Executing command: " + cl.toString() );
-
- try
- {
- CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
- int exitCode = CommandLineUtils.executeCommandLine( cl, null, err );
- if ( exitCode != 0 )
- {
- if ( !put
- && err.getOutput().trim().toLowerCase( Locale.ENGLISH ).contains( "no such file or directory" ) )
- {
- throw new ResourceDoesNotExistException( err.getOutput() );
- }
- else
- {
- TransferFailedException e =
- new TransferFailedException( "Exit code: " + exitCode + " - " + err.getOutput() );
-
- fireTransferError( resource, e, put ? TransferEvent.REQUEST_PUT : TransferEvent.REQUEST_GET );
-
- throw e;
- }
- }
- }
- catch ( CommandLineException e )
- {
- fireTransferError( resource, e, put ? TransferEvent.REQUEST_PUT : TransferEvent.REQUEST_GET );
-
- throw new TransferFailedException( "Error executing command line", e );
- }
- }
-
- boolean isPuTTYSCP()
- {
- return scpExecutable.toLowerCase( Locale.ENGLISH ).contains( "pscp" );
- }
-
- private String normalizeResource( Resource resource )
- {
- return StringUtils.replace( resource.getName(), "\\", "/" );
- }
-
- public void put( File source, String destination )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- Resource resource = new Resource( destination );
-
- firePutInitiated( resource, source );
-
- if ( !source.exists() )
- {
- throw new ResourceDoesNotExistException( "Specified source file does not exist: " + source );
- }
-
- String basedir = getRepository().getBasedir();
-
- String resourceName = StringUtils.replace( destination, "\\", "/" );
-
- String dir = PathUtils.dirname( resourceName );
-
- dir = StringUtils.replace( dir, "\\", "/" );
-
- String umaskCmd = null;
- if ( getRepository().getPermissions() != null )
- {
- String dirPerms = getRepository().getPermissions().getDirectoryMode();
-
- if ( dirPerms != null )
- {
- umaskCmd = "umask " + PermissionModeUtils.getUserMaskFor( dirPerms );
- }
- }
-
- String mkdirCmd = "mkdir -p " + basedir + "/" + dir + "\n";
-
- if ( umaskCmd != null )
- {
- mkdirCmd = umaskCmd + "; " + mkdirCmd;
- }
-
- try
- {
- executeCommand( mkdirCmd );
- }
- catch ( CommandExecutionException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
-
- throw new TransferFailedException( "Error executing command for transfer", e );
- }
-
- resource.setContentLength( source.length() );
-
- resource.setLastModified( source.lastModified() );
-
- firePutStarted( resource, source );
-
- executeScpCommand( resource, source, true );
-
- postProcessListeners( resource, source, TransferEvent.REQUEST_PUT );
-
- try
- {
- RepositoryPermissions permissions = getRepository().getPermissions();
-
- if ( permissions != null && permissions.getGroup() != null )
- {
- executeCommand( "chgrp -f " + permissions.getGroup() + " " + basedir + "/" + resourceName + "\n",
- true );
- }
-
- if ( permissions != null && permissions.getFileMode() != null )
- {
- executeCommand( "chmod -f " + permissions.getFileMode() + " " + basedir + "/" + resourceName + "\n",
- true );
- }
- }
- catch ( CommandExecutionException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
-
- throw new TransferFailedException( "Error executing command for transfer", e );
- }
- firePutCompleted( resource, source );
- }
-
- public void get( String resourceName, File destination )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- String path = StringUtils.replace( resourceName, "\\", "/" );
-
- Resource resource = new Resource( path );
-
- fireGetInitiated( resource, destination );
-
- createParentDirectories( destination );
-
- fireGetStarted( resource, destination );
-
- executeScpCommand( resource, destination, false );
-
- postProcessListeners( resource, destination, TransferEvent.REQUEST_GET );
-
- fireGetCompleted( resource, destination );
- }
-
- //
- // these parameters are user specific, so should not be read from the repository itself.
- // They can be configured by plexus, or directly on the instantiated object.
- // Alternatively, we may later accept a generic parameters argument to connect, or some other configure(Properties)
- // method on a Wagon.
- //
-
- public List<String> getFileList( String destinationDirectory )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- return sshTool.getFileList( destinationDirectory, repository );
- }
-
- public void putDirectory( File sourceDirectory, String destinationDirectory )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- sshTool.putDirectory( this, sourceDirectory, destinationDirectory );
- }
-
- public boolean resourceExists( String resourceName )
- throws TransferFailedException, AuthorizationException
- {
- return sshTool.resourceExists( resourceName, repository );
- }
-
- public boolean supportsDirectoryCopy()
- {
- return true;
- }
-
- public String getScpExecutable()
- {
- return scpExecutable;
- }
-
- public void setScpExecutable( String scpExecutable )
- {
- this.scpExecutable = scpExecutable;
- }
-
- public String getSshExecutable()
- {
- return sshExecutable;
- }
-
- public void setSshExecutable( String sshExecutable )
- {
- this.sshExecutable = sshExecutable;
- }
-
- public String getScpArgs()
- {
- return scpArgs;
- }
-
- public void setScpArgs( String scpArgs )
- {
- this.scpArgs = scpArgs;
- }
-
- public String getSshArgs()
- {
- return sshArgs;
- }
-
- public void setSshArgs( String sshArgs )
- {
- this.sshArgs = sshArgs;
- }
-}
+package org.apache.maven.wagon.providers.ssh.external;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.AbstractWagon;
+import org.apache.maven.wagon.CommandExecutionException;
+import org.apache.maven.wagon.CommandExecutor;
+import org.apache.maven.wagon.PathUtils;
+import org.apache.maven.wagon.PermissionModeUtils;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.Streams;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.WagonConstants;
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.providers.ssh.ScpHelper;
+import org.apache.maven.wagon.repository.RepositoryPermissions;
+import org.apache.maven.wagon.resource.Resource;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
+import org.codehaus.plexus.util.cli.Commandline;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.List;
+import java.util.Locale;
+
+/**
+ * SCP deployer using "external" scp program. To allow for
+ * ssh-agent type behavior, until we can construct a Java SSH Agent and interface for JSch.
+ *
+ * @author <a href="mailto:brett at apache.org">Brett Porter</a>
+ * @todo [BP] add compression flag
+ * @plexus.component role="org.apache.maven.wagon.Wagon"
+ * role-hint="scpexe"
+ * instantiation-strategy="per-lookup"
+ */
+public class ScpExternalWagon
+ extends AbstractWagon
+ implements CommandExecutor
+{
+ /**
+ * The external SCP command to use - default is <code>scp</code>.
+ *
+ * @component.configuration default="scp"
+ */
+ private String scpExecutable = "scp";
+
+ /**
+ * The external SSH command to use - default is <code>ssh</code>.
+ *
+ * @component.configuration default="ssh"
+ */
+ private String sshExecutable = "ssh";
+
+ /**
+ * Arguments to pass to the SCP command.
+ *
+ * @component.configuration
+ */
+ private String scpArgs;
+
+ /**
+ * Arguments to pass to the SSH command.
+ *
+ * @component.configuration
+ */
+ private String sshArgs;
+
+ private ScpHelper sshTool = new ScpHelper( this );
+
+ private static final int SSH_FATAL_EXIT_CODE = 255;
+
+ // ----------------------------------------------------------------------
+ //
+ // ----------------------------------------------------------------------
+
+ protected void openConnectionInternal()
+ throws AuthenticationException
+ {
+ if ( authenticationInfo == null )
+ {
+ authenticationInfo = new AuthenticationInfo();
+ }
+ }
+
+ public void closeConnection()
+ {
+ // nothing to disconnect
+ }
+
+ public boolean getIfNewer( String resourceName, File destination, long timestamp )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ fireSessionDebug( "getIfNewer in SCP wagon is not supported - performing an unconditional get" );
+ get( resourceName, destination );
+ return true;
+ }
+
+ /**
+ * @return The hostname of the remote server prefixed with the username, which comes either from the repository URL
+ * or from the authenticationInfo.
+ */
+ private String buildRemoteHost()
+ {
+ String username = this.getRepository().getUsername();
+ if ( username == null )
+ {
+ username = authenticationInfo.getUserName();
+ }
+
+ if ( username == null )
+ {
+ return getRepository().getHost();
+ }
+ else
+ {
+ return username + "@" + getRepository().getHost();
+ }
+ }
+
+ public void executeCommand( String command )
+ throws CommandExecutionException
+ {
+ fireTransferDebug( "Executing command: " + command );
+
+ executeCommand( command, false );
+ }
+
+ public Streams executeCommand( String command, boolean ignoreFailures )
+ throws CommandExecutionException
+ {
+ boolean putty = isPuTTY();
+
+ File privateKey;
+ try
+ {
+ privateKey = ScpHelper.getPrivateKey( authenticationInfo );
+ }
+ catch ( FileNotFoundException e )
+ {
+ throw new CommandExecutionException( e.getMessage(), e );
+ }
+ Commandline cl = createBaseCommandLine( putty, sshExecutable, privateKey );
+
+ int port =
+ repository.getPort() == WagonConstants.UNKNOWN_PORT ? ScpHelper.DEFAULT_SSH_PORT : repository.getPort();
+ if ( port != ScpHelper.DEFAULT_SSH_PORT )
+ {
+ if ( putty )
+ {
+ cl.createArg().setLine( "-P " + port );
+ }
+ else
+ {
+ cl.createArg().setLine( "-p " + port );
+ }
+ }
+
+ if ( sshArgs != null )
+ {
+ cl.createArg().setLine( sshArgs );
+ }
+
+ String remoteHost = this.buildRemoteHost();
+
+ cl.createArg().setValue( remoteHost );
+
+ cl.createArg().setValue( command );
+
+ fireSessionDebug( "Executing command: " + cl.toString() );
+
+ try
+ {
+ CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer();
+ CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
+ int exitCode = CommandLineUtils.executeCommandLine( cl, out, err );
+ Streams streams = new Streams();
+ streams.setOut( out.getOutput() );
+ streams.setErr( err.getOutput() );
+ fireSessionDebug( streams.getOut() );
+ fireSessionDebug( streams.getErr() );
+ if ( exitCode != 0 )
+ {
+ if ( !ignoreFailures || exitCode == SSH_FATAL_EXIT_CODE )
+ {
+ throw new CommandExecutionException( "Exit code " + exitCode + " - " + err.getOutput() );
+ }
+ }
+ return streams;
+ }
+ catch ( CommandLineException e )
+ {
+ throw new CommandExecutionException( "Error executing command line", e );
+ }
+ }
+
+ protected boolean isPuTTY()
+ {
+ return sshExecutable.toLowerCase( Locale.ENGLISH ).contains( "plink" );
+ }
+
+ private Commandline createBaseCommandLine( boolean putty, String executable, File privateKey )
+ {
+ Commandline cl = new Commandline();
+
+ cl.setExecutable( executable );
+
+ if ( privateKey != null )
+ {
+ cl.createArg().setValue( "-i" );
+ cl.createArg().setFile( privateKey );
+ }
+
+ String password = authenticationInfo.getPassword();
+ if ( putty && password != null )
+ {
+ cl.createArg().setValue( "-pw" );
+ cl.createArg().setValue( password );
+ }
+
+ // should check interactive flag, but scpexe never works in interactive mode right now due to i/o streams
+ if ( putty )
+ {
+ cl.createArg().setValue( "-batch" );
+ }
+ else
+ {
+ cl.createArg().setValue( "-o" );
+ cl.createArg().setValue( "BatchMode yes" );
+ }
+ return cl;
+ }
+
+
+ private void executeScpCommand( Resource resource, File localFile, boolean put )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ boolean putty = isPuTTYSCP();
+
+ File privateKey;
+ try
+ {
+ privateKey = ScpHelper.getPrivateKey( authenticationInfo );
+ }
+ catch ( FileNotFoundException e )
+ {
+ fireSessionConnectionRefused();
+
+ throw new AuthorizationException( e.getMessage() );
+ }
+ Commandline cl = createBaseCommandLine( putty, scpExecutable, privateKey );
+
+ cl.setWorkingDirectory( localFile.getParentFile().getAbsolutePath() );
+
+ int port =
+ repository.getPort() == WagonConstants.UNKNOWN_PORT ? ScpHelper.DEFAULT_SSH_PORT : repository.getPort();
+ if ( port != ScpHelper.DEFAULT_SSH_PORT )
+ {
+ cl.createArg().setLine( "-P " + port );
+ }
+
+ if ( scpArgs != null )
+ {
+ cl.createArg().setLine( scpArgs );
+ }
+
+ String resourceName = normalizeResource( resource );
+ String remoteFile = getRepository().getBasedir() + "/" + resourceName;
+
+ remoteFile = StringUtils.replace( remoteFile, " ", "\\ " );
+
+ String qualifiedRemoteFile = this.buildRemoteHost() + ":" + remoteFile;
+ if ( put )
+ {
+ cl.createArg().setValue( localFile.getName() );
+ cl.createArg().setValue( qualifiedRemoteFile );
+ }
+ else
+ {
+ cl.createArg().setValue( qualifiedRemoteFile );
+ cl.createArg().setValue( localFile.getName() );
+ }
+
+ fireSessionDebug( "Executing command: " + cl.toString() );
+
+ try
+ {
+ CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
+ int exitCode = CommandLineUtils.executeCommandLine( cl, null, err );
+ if ( exitCode != 0 )
+ {
+ if ( !put
+ && err.getOutput().trim().toLowerCase( Locale.ENGLISH ).contains( "no such file or directory" ) )
+ {
+ throw new ResourceDoesNotExistException( err.getOutput() );
+ }
+ else
+ {
+ TransferFailedException e =
+ new TransferFailedException( "Exit code: " + exitCode + " - " + err.getOutput() );
+
+ fireTransferError( resource, e, put ? TransferEvent.REQUEST_PUT : TransferEvent.REQUEST_GET );
+
+ throw e;
+ }
+ }
+ }
+ catch ( CommandLineException e )
+ {
+ fireTransferError( resource, e, put ? TransferEvent.REQUEST_PUT : TransferEvent.REQUEST_GET );
+
+ throw new TransferFailedException( "Error executing command line", e );
+ }
+ }
+
+ boolean isPuTTYSCP()
+ {
+ return scpExecutable.toLowerCase( Locale.ENGLISH ).contains( "pscp" );
+ }
+
+ private String normalizeResource( Resource resource )
+ {
+ return StringUtils.replace( resource.getName(), "\\", "/" );
+ }
+
+ public void put( File source, String destination )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ Resource resource = new Resource( destination );
+
+ firePutInitiated( resource, source );
+
+ if ( !source.exists() )
+ {
+ throw new ResourceDoesNotExistException( "Specified source file does not exist: " + source );
+ }
+
+ String basedir = getRepository().getBasedir();
+
+ String resourceName = StringUtils.replace( destination, "\\", "/" );
+
+ String dir = PathUtils.dirname( resourceName );
+
+ dir = StringUtils.replace( dir, "\\", "/" );
+
+ String umaskCmd = null;
+ if ( getRepository().getPermissions() != null )
+ {
+ String dirPerms = getRepository().getPermissions().getDirectoryMode();
+
+ if ( dirPerms != null )
+ {
+ umaskCmd = "umask " + PermissionModeUtils.getUserMaskFor( dirPerms );
+ }
+ }
+
+ String mkdirCmd = "mkdir -p " + basedir + "/" + dir + "\n";
+
+ if ( umaskCmd != null )
+ {
+ mkdirCmd = umaskCmd + "; " + mkdirCmd;
+ }
+
+ try
+ {
+ executeCommand( mkdirCmd );
+ }
+ catch ( CommandExecutionException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
+ throw new TransferFailedException( "Error executing command for transfer", e );
+ }
+
+ resource.setContentLength( source.length() );
+
+ resource.setLastModified( source.lastModified() );
+
+ firePutStarted( resource, source );
+
+ executeScpCommand( resource, source, true );
+
+ postProcessListeners( resource, source, TransferEvent.REQUEST_PUT );
+
+ try
+ {
+ RepositoryPermissions permissions = getRepository().getPermissions();
+
+ if ( permissions != null && permissions.getGroup() != null )
+ {
+ executeCommand( "chgrp -f " + permissions.getGroup() + " " + basedir + "/" + resourceName + "\n",
+ true );
+ }
+
+ if ( permissions != null && permissions.getFileMode() != null )
+ {
+ executeCommand( "chmod -f " + permissions.getFileMode() + " " + basedir + "/" + resourceName + "\n",
+ true );
+ }
+ }
+ catch ( CommandExecutionException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
+ throw new TransferFailedException( "Error executing command for transfer", e );
+ }
+ firePutCompleted( resource, source );
+ }
+
+ public void get( String resourceName, File destination )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ String path = StringUtils.replace( resourceName, "\\", "/" );
+
+ Resource resource = new Resource( path );
+
+ fireGetInitiated( resource, destination );
+
+ createParentDirectories( destination );
+
+ fireGetStarted( resource, destination );
+
+ executeScpCommand( resource, destination, false );
+
+ postProcessListeners( resource, destination, TransferEvent.REQUEST_GET );
+
+ fireGetCompleted( resource, destination );
+ }
+
+ //
+ // these parameters are user specific, so should not be read from the repository itself.
+ // They can be configured by plexus, or directly on the instantiated object.
+ // Alternatively, we may later accept a generic parameters argument to connect, or some other configure(Properties)
+ // method on a Wagon.
+ //
+
+ public List<String> getFileList( String destinationDirectory )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ return sshTool.getFileList( destinationDirectory, repository );
+ }
+
+ public void putDirectory( File sourceDirectory, String destinationDirectory )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ sshTool.putDirectory( this, sourceDirectory, destinationDirectory );
+ }
+
+ public boolean resourceExists( String resourceName )
+ throws TransferFailedException, AuthorizationException
+ {
+ return sshTool.resourceExists( resourceName, repository );
+ }
+
+ public boolean supportsDirectoryCopy()
+ {
+ return true;
+ }
+
+ public String getScpExecutable()
+ {
+ return scpExecutable;
+ }
+
+ public void setScpExecutable( String scpExecutable )
+ {
+ this.scpExecutable = scpExecutable;
+ }
+
+ public String getSshExecutable()
+ {
+ return sshExecutable;
+ }
+
+ public void setSshExecutable( String sshExecutable )
+ {
+ this.sshExecutable = sshExecutable;
+ }
+
+ public String getScpArgs()
+ {
+ return scpArgs;
+ }
+
+ public void setScpArgs( String scpArgs )
+ {
+ this.scpArgs = scpArgs;
+ }
+
+ public String getSshArgs()
+ {
+ return sshArgs;
+ }
+
+ public void setSshArgs( String sshArgs )
+ {
+ this.sshArgs = sshArgs;
+ }
+}
diff --git a/wagon-providers/wagon-ssh-external/src/site/apt/index.apt b/wagon-providers/wagon-ssh-external/src/site/apt/index.apt
index 1e37e6e..f401ccb 100644
--- a/wagon-providers/wagon-ssh-external/src/site/apt/index.apt
+++ b/wagon-providers/wagon-ssh-external/src/site/apt/index.apt
@@ -1,41 +1,41 @@
- ------
- Maven Wagon SSH External
- ------
- Carlos Sanchez
- ------
- 2006-04-16
- ------
-
- ~~ Licensed to the Apache Software Foundation (ASF) under one
- ~~ or more contributor license agreements. See the NOTICE file
- ~~ distributed with this work for additional information
- ~~ regarding copyright ownership. The ASF licenses this file
- ~~ to you under the Apache License, Version 2.0 (the
- ~~ "License"); you may not use this file except in compliance
- ~~ with the License. You may obtain a copy of the License at
- ~~
- ~~ http://www.apache.org/licenses/LICENSE-2.0
- ~~
- ~~ Unless required by applicable law or agreed to in writing,
- ~~ software distributed under the License is distributed on an
- ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~~ KIND, either express or implied. See the License for the
- ~~ specific language governing permissions and limitations
- ~~ under the License.
-
- ~~ NOTE: For help with the syntax of this file, see:
- ~~ http://maven.apache.org/doxia/references/apt-format.html
-
-Maven Wagon SSH External
-
- This component is an implementation of Wagon provider for SSH servers access.
-
- It enables Maven to deploy artifacts and sites to SSH servers.
- it uses an external SSH program that has to be already installed in the system.
-
- Getting files from SSH servers is not fully tested.
-
-
-Features
-
- * Deploy files and directories to SSH servers
+ ------
+ Maven Wagon SSH External
+ ------
+ Carlos Sanchez
+ ------
+ 2006-04-16
+ ------
+
+ ~~ Licensed to the Apache Software Foundation (ASF) under one
+ ~~ or more contributor license agreements. See the NOTICE file
+ ~~ distributed with this work for additional information
+ ~~ regarding copyright ownership. The ASF licenses this file
+ ~~ to you under the Apache License, Version 2.0 (the
+ ~~ "License"); you may not use this file except in compliance
+ ~~ with the License. You may obtain a copy of the License at
+ ~~
+ ~~ http://www.apache.org/licenses/LICENSE-2.0
+ ~~
+ ~~ Unless required by applicable law or agreed to in writing,
+ ~~ software distributed under the License is distributed on an
+ ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~~ KIND, either express or implied. See the License for the
+ ~~ specific language governing permissions and limitations
+ ~~ under the License.
+
+ ~~ NOTE: For help with the syntax of this file, see:
+ ~~ http://maven.apache.org/doxia/references/apt-format.html
+
+Maven Wagon SSH External
+
+ This component is an implementation of Wagon provider for SSH servers access.
+
+ It enables Maven to deploy artifacts and sites to SSH servers.
+ it uses an external SSH program that has to be already installed in the system.
+
+ Getting files from SSH servers is not fully tested.
+
+
+Features
+
+ * Deploy files and directories to SSH servers
diff --git a/wagon-providers/wagon-ssh-external/src/site/site.xml b/wagon-providers/wagon-ssh-external/src/site/site.xml
index f729045..55bfc95 100644
--- a/wagon-providers/wagon-ssh-external/src/site/site.xml
+++ b/wagon-providers/wagon-ssh-external/src/site/site.xml
@@ -1,33 +1,33 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
- <body>
- <breadcrumbs>
- <item name="SSH External" href="http://maven.apache.org/wagon/wagon-providers/wagon-ssh-external/index.html" />
- </breadcrumbs>
-
- <menu ref="parent"/>
- <menu ref="reports"/>
- </body>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
+ <body>
+ <breadcrumbs>
+ <item name="SSH External" href="http://maven.apache.org/wagon/wagon-providers/wagon-ssh-external/index.html" />
+ </breadcrumbs>
+
+ <menu ref="parent"/>
+ <menu ref="reports"/>
+ </body>
</project>
\ No newline at end of file
diff --git a/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/EmbeddedScpExternalWagonWithKeyTest.java b/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/EmbeddedScpExternalWagonWithKeyTest.java
index 5c21ad3..065e921 100644
--- a/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/EmbeddedScpExternalWagonWithKeyTest.java
+++ b/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/EmbeddedScpExternalWagonWithKeyTest.java
@@ -1,113 +1,113 @@
-package org.apache.maven.wagon.providers.ssh.external;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.io.FileUtils;
-import org.apache.maven.wagon.Streams;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
-import org.apache.maven.wagon.providers.ssh.AbstractEmbeddedScpWagonWithKeyTest;
-import org.codehaus.plexus.util.cli.CommandLineUtils;
-import org.codehaus.plexus.util.cli.Commandline;
-
-import java.io.File;
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class EmbeddedScpExternalWagonWithKeyTest
- extends AbstractEmbeddedScpWagonWithKeyTest
-{
-
-
- @Override
- protected Wagon getWagon()
- throws Exception
- {
- ScpExternalWagon scpWagon = (ScpExternalWagon) super.getWagon();
- scpWagon.setInteractive( false );
- File dummyKnowHostsFile = new File( "target/dummy_knowhost" );
- if ( dummyKnowHostsFile.exists() )
- {
- dummyKnowHostsFile.delete();
- }
- scpWagon.setScpArgs(
- "-o StrictHostKeyChecking=no -o UserKnownHostsFile=" + dummyKnowHostsFile.getCanonicalPath() );
- scpWagon.setSshArgs(
- "-o StrictHostKeyChecking=no -o UserKnownHostsFile=" + dummyKnowHostsFile.getCanonicalPath() );
- dummyKnowHostsFile.deleteOnExit();
- return scpWagon;
- }
-
-
- protected String getProtocol()
- {
- return "scpexe";
- }
-
-
- protected AuthenticationInfo getAuthInfo()
- {
- try
- {
- AuthenticationInfo authInfo = super.getAuthInfo();
- // user : guest/guest123 - passphrase : toto01
- authInfo.setUserName( "guest" );
- File sshKeysTarget = new File( "target/ssh-keys" );
- FileUtils.copyDirectory( new File( "src/test/ssh-keys" ), sshKeysTarget );
- // ssh keys need to 700 permissions
- // to prevent WARNING: UNPROTECTED PRIVATE KEY FILE!
- Commandline commandline = new Commandline( "chmod" );
- commandline.createArg().setValue( "-R" );
- commandline.createArg().setValue( "700" );
- commandline.createArg().setValue( sshKeysTarget.getCanonicalPath() );
- CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer();
- CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
- int exitCode = CommandLineUtils.executeCommandLine( commandline, out, err );
- Streams streams = new Streams();
- streams.setOut( out.getOutput() );
- streams.setErr( err.getOutput() );
- if ( exitCode != 0 )
- {
- throw new RuntimeException(
- "fail to chmod exit code " + exitCode + ", error" + streams.getErr() + ", out "
- + streams.getOut() );
- }
-
- authInfo.setPrivateKey( new File( sshKeysTarget, "id_rsa" ).getCanonicalPath() );
-
- return authInfo;
- }
- catch ( Exception e )
- {
- throw new RuntimeException( e.getMessage(), e );
-
- }
- }
-
- public void testFailedGetToStream()
- throws Exception
- {
- // ignore this test as it need a stream wagon
- }
-
-
-}
+package org.apache.maven.wagon.providers.ssh.external;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.io.FileUtils;
+import org.apache.maven.wagon.Streams;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.providers.ssh.AbstractEmbeddedScpWagonWithKeyTest;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
+import org.codehaus.plexus.util.cli.Commandline;
+
+import java.io.File;
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class EmbeddedScpExternalWagonWithKeyTest
+ extends AbstractEmbeddedScpWagonWithKeyTest
+{
+
+
+ @Override
+ protected Wagon getWagon()
+ throws Exception
+ {
+ ScpExternalWagon scpWagon = (ScpExternalWagon) super.getWagon();
+ scpWagon.setInteractive( false );
+ File dummyKnowHostsFile = new File( "target/dummy_knowhost" );
+ if ( dummyKnowHostsFile.exists() )
+ {
+ dummyKnowHostsFile.delete();
+ }
+ scpWagon.setScpArgs(
+ "-o StrictHostKeyChecking=no -o UserKnownHostsFile=" + dummyKnowHostsFile.getCanonicalPath() );
+ scpWagon.setSshArgs(
+ "-o StrictHostKeyChecking=no -o UserKnownHostsFile=" + dummyKnowHostsFile.getCanonicalPath() );
+ dummyKnowHostsFile.deleteOnExit();
+ return scpWagon;
+ }
+
+
+ protected String getProtocol()
+ {
+ return "scpexe";
+ }
+
+
+ protected AuthenticationInfo getAuthInfo()
+ {
+ try
+ {
+ AuthenticationInfo authInfo = super.getAuthInfo();
+ // user : guest/guest123 - passphrase : toto01
+ authInfo.setUserName( "guest" );
+ File sshKeysTarget = new File( "target/ssh-keys" );
+ FileUtils.copyDirectory( new File( "src/test/ssh-keys" ), sshKeysTarget );
+ // ssh keys need to 700 permissions
+ // to prevent WARNING: UNPROTECTED PRIVATE KEY FILE!
+ Commandline commandline = new Commandline( "chmod" );
+ commandline.createArg().setValue( "-R" );
+ commandline.createArg().setValue( "700" );
+ commandline.createArg().setValue( sshKeysTarget.getCanonicalPath() );
+ CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer();
+ CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
+ int exitCode = CommandLineUtils.executeCommandLine( commandline, out, err );
+ Streams streams = new Streams();
+ streams.setOut( out.getOutput() );
+ streams.setErr( err.getOutput() );
+ if ( exitCode != 0 )
+ {
+ throw new RuntimeException(
+ "fail to chmod exit code " + exitCode + ", error" + streams.getErr() + ", out "
+ + streams.getOut() );
+ }
+
+ authInfo.setPrivateKey( new File( sshKeysTarget, "id_rsa" ).getCanonicalPath() );
+
+ return authInfo;
+ }
+ catch ( Exception e )
+ {
+ throw new RuntimeException( e.getMessage(), e );
+
+ }
+ }
+
+ public void testFailedGetToStream()
+ throws Exception
+ {
+ // ignore this test as it need a stream wagon
+ }
+
+
+}
diff --git a/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagonTest.java b/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagonTest.java
index 41b5ab1..fc111a9 100644
--- a/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagonTest.java
+++ b/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagonTest.java
@@ -1,117 +1,117 @@
-package org.apache.maven.wagon.providers.ssh.external;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.WagonConstants;
-import org.apache.maven.wagon.WagonTestCase;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
-import org.apache.maven.wagon.providers.ssh.TestData;
-import org.apache.maven.wagon.repository.Repository;
-import org.apache.maven.wagon.resource.Resource;
-
-import java.io.File;
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class ScpExternalWagonTest
- extends WagonTestCase
-{
- protected int getExpectedContentLengthOnGet( int expectedSize )
- {
- return WagonConstants.UNKNOWN_LENGTH;
- }
-
- protected boolean supportsGetIfNewer()
- {
- return false;
- }
-
- protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
- {
- return 0;
- }
-
- protected String getProtocol()
- {
- return "scpexe";
- }
-
- @Override
- protected int getTestRepositoryPort()
- {
- return 0; // not used
- }
-
-
- public String getTestRepositoryUrl()
- {
- return TestData.getTestRepositoryUrl( getTestRepositoryPort() );
- }
-
- protected AuthenticationInfo getAuthInfo()
- {
- AuthenticationInfo authInfo = new AuthenticationInfo();
-
- String userName = TestData.getUserName();
-
- authInfo.setUserName( userName );
-
- File privateKey = TestData.getPrivateKey();
-
- if ( privateKey.exists() )
- {
- authInfo.setPrivateKey( privateKey.getAbsolutePath() );
-
- authInfo.setPassphrase( "" );
- }
-
- return authInfo;
- }
-
- public void testIsPuTTY()
- throws Exception
- {
- ScpExternalWagon wagon = (ScpExternalWagon) getWagon();
-
- wagon.setSshExecutable( "c:\\program files\\PuTTY\\plink.exe" );
- assertTrue( wagon.isPuTTY() );
- wagon.setSshExecutable( "plink" );
- assertTrue( wagon.isPuTTY() );
- wagon.setSshExecutable( "PLINK" );
- assertTrue( wagon.isPuTTY() );
- wagon.setSshExecutable( "PlInK" );
- assertTrue( wagon.isPuTTY() );
- wagon.setSshExecutable( "ssh" );
- assertFalse( wagon.isPuTTY() );
-
- wagon.setScpExecutable( "c:\\program files\\PuTTY\\pscp.exe" );
- assertTrue( wagon.isPuTTYSCP() );
- wagon.setScpExecutable( "pscp" );
- assertTrue( wagon.isPuTTYSCP() );
- wagon.setScpExecutable( "PSCP" );
- assertTrue( wagon.isPuTTYSCP() );
- wagon.setScpExecutable( "PsCp" );
- assertTrue( wagon.isPuTTYSCP() );
- wagon.setScpExecutable( "scp" );
- assertFalse( wagon.isPuTTYSCP() );
- }
-}
+package org.apache.maven.wagon.providers.ssh.external;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.WagonConstants;
+import org.apache.maven.wagon.WagonTestCase;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.providers.ssh.TestData;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.resource.Resource;
+
+import java.io.File;
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class ScpExternalWagonTest
+ extends WagonTestCase
+{
+ protected int getExpectedContentLengthOnGet( int expectedSize )
+ {
+ return WagonConstants.UNKNOWN_LENGTH;
+ }
+
+ protected boolean supportsGetIfNewer()
+ {
+ return false;
+ }
+
+ protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
+ {
+ return 0;
+ }
+
+ protected String getProtocol()
+ {
+ return "scpexe";
+ }
+
+ @Override
+ protected int getTestRepositoryPort()
+ {
+ return 0; // not used
+ }
+
+
+ public String getTestRepositoryUrl()
+ {
+ return TestData.getTestRepositoryUrl( getTestRepositoryPort() );
+ }
+
+ protected AuthenticationInfo getAuthInfo()
+ {
+ AuthenticationInfo authInfo = new AuthenticationInfo();
+
+ String userName = TestData.getUserName();
+
+ authInfo.setUserName( userName );
+
+ File privateKey = TestData.getPrivateKey();
+
+ if ( privateKey.exists() )
+ {
+ authInfo.setPrivateKey( privateKey.getAbsolutePath() );
+
+ authInfo.setPassphrase( "" );
+ }
+
+ return authInfo;
+ }
+
+ public void testIsPuTTY()
+ throws Exception
+ {
+ ScpExternalWagon wagon = (ScpExternalWagon) getWagon();
+
+ wagon.setSshExecutable( "c:\\program files\\PuTTY\\plink.exe" );
+ assertTrue( wagon.isPuTTY() );
+ wagon.setSshExecutable( "plink" );
+ assertTrue( wagon.isPuTTY() );
+ wagon.setSshExecutable( "PLINK" );
+ assertTrue( wagon.isPuTTY() );
+ wagon.setSshExecutable( "PlInK" );
+ assertTrue( wagon.isPuTTY() );
+ wagon.setSshExecutable( "ssh" );
+ assertFalse( wagon.isPuTTY() );
+
+ wagon.setScpExecutable( "c:\\program files\\PuTTY\\pscp.exe" );
+ assertTrue( wagon.isPuTTYSCP() );
+ wagon.setScpExecutable( "pscp" );
+ assertTrue( wagon.isPuTTYSCP() );
+ wagon.setScpExecutable( "PSCP" );
+ assertTrue( wagon.isPuTTYSCP() );
+ wagon.setScpExecutable( "PsCp" );
+ assertTrue( wagon.isPuTTYSCP() );
+ wagon.setScpExecutable( "scp" );
+ assertFalse( wagon.isPuTTYSCP() );
+ }
+}
diff --git a/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/ScpWagonWithSshPrivateKeySearchTest.java b/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/ScpWagonWithSshPrivateKeySearchTest.java
index 8ee5635..dc4c5c4 100644
--- a/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/ScpWagonWithSshPrivateKeySearchTest.java
+++ b/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/ScpWagonWithSshPrivateKeySearchTest.java
@@ -1,81 +1,81 @@
-package org.apache.maven.wagon.providers.ssh.external;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.WagonConstants;
-import org.apache.maven.wagon.WagonTestCase;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
-import org.apache.maven.wagon.providers.ssh.TestData;
-import org.apache.maven.wagon.repository.Repository;
-import org.apache.maven.wagon.resource.Resource;
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class ScpWagonWithSshPrivateKeySearchTest
- extends WagonTestCase
-{
- protected boolean supportsGetIfNewer()
- {
- return false;
- }
-
- protected int getExpectedContentLengthOnGet( int expectedSize )
- {
- return WagonConstants.UNKNOWN_LENGTH;
- }
-
- protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
- {
- return 0;
- }
-
- protected String getProtocol()
- {
- return "scpexe";
- }
-
- @Override
- protected int getTestRepositoryPort()
- {
- return 0; // not used
- }
-
-
- public String getTestRepositoryUrl()
- {
- return TestData.getTestRepositoryUrl( getTestRepositoryPort() );
- }
-
-
- protected AuthenticationInfo getAuthInfo()
- {
- AuthenticationInfo authInfo = super.getAuthInfo();
-
- authInfo.setUserName( TestData.getUserName() );
-
- authInfo.setPassphrase( "" );
-
- return authInfo;
- }
-
-
-}
+package org.apache.maven.wagon.providers.ssh.external;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.WagonConstants;
+import org.apache.maven.wagon.WagonTestCase;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.providers.ssh.TestData;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.resource.Resource;
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class ScpWagonWithSshPrivateKeySearchTest
+ extends WagonTestCase
+{
+ protected boolean supportsGetIfNewer()
+ {
+ return false;
+ }
+
+ protected int getExpectedContentLengthOnGet( int expectedSize )
+ {
+ return WagonConstants.UNKNOWN_LENGTH;
+ }
+
+ protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
+ {
+ return 0;
+ }
+
+ protected String getProtocol()
+ {
+ return "scpexe";
+ }
+
+ @Override
+ protected int getTestRepositoryPort()
+ {
+ return 0; // not used
+ }
+
+
+ public String getTestRepositoryUrl()
+ {
+ return TestData.getTestRepositoryUrl( getTestRepositoryPort() );
+ }
+
+
+ protected AuthenticationInfo getAuthInfo()
+ {
+ AuthenticationInfo authInfo = super.getAuthInfo();
+
+ authInfo.setUserName( TestData.getUserName() );
+
+ authInfo.setPassphrase( "" );
+
+ return authInfo;
+ }
+
+
+}
diff --git a/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/SshCommandExecutorTest.java b/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/SshCommandExecutorTest.java
index 0d34719..c405240 100644
--- a/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/SshCommandExecutorTest.java
+++ b/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/SshCommandExecutorTest.java
@@ -1,39 +1,39 @@
-package org.apache.maven.wagon.providers.ssh.external;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.CommandExecutorTestCase;
-import org.apache.maven.wagon.repository.Repository;
-
-/**
- * Test the command executor.
- *
- * @author <a href="mailto:brett at apache.org">Brett Porter</a>
- *
- */
-public class SshCommandExecutorTest
- extends CommandExecutorTestCase
-{
-
- protected Repository getTestRepository()
- {
- return new Repository( "test", "scpexe://localhost/" );
- }
-}
+package org.apache.maven.wagon.providers.ssh.external;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.CommandExecutorTestCase;
+import org.apache.maven.wagon.repository.Repository;
+
+/**
+ * Test the command executor.
+ *
+ * @author <a href="mailto:brett at apache.org">Brett Porter</a>
+ *
+ */
+public class SshCommandExecutorTest
+ extends CommandExecutorTestCase
+{
+
+ protected Repository getTestRepository()
+ {
+ return new Repository( "test", "scpexe://localhost/" );
+ }
+}
diff --git a/wagon-providers/wagon-ssh-external/src/test/resources/log4j.xml b/wagon-providers/wagon-ssh-external/src/test/resources/log4j.xml
index 824015b..8746354 100644
--- a/wagon-providers/wagon-ssh-external/src/test/resources/log4j.xml
+++ b/wagon-providers/wagon-ssh-external/src/test/resources/log4j.xml
@@ -1,41 +1,41 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
-
- <appender name="console" class="org.apache.log4j.ConsoleAppender">
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d [%t] %-5p %c %x - %m%n"/>
- </layout>
- </appender>
- <logger name="org.apache.sshd.server">
- <level value="INFO"/>
- </logger>
-
-
-
- <root>
- <priority value ="info" />
- <appender-ref ref="console" />
- </root>
-
-</log4j:configuration>
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d [%t] %-5p %c %x - %m%n"/>
+ </layout>
+ </appender>
+ <logger name="org.apache.sshd.server">
+ <level value="INFO"/>
+ </logger>
+
+
+
+ <root>
+ <priority value ="info" />
+ <appender-ref ref="console" />
+ </root>
+
+</log4j:configuration>
diff --git a/wagon-providers/wagon-ssh/pom.xml b/wagon-providers/wagon-ssh/pom.xml
index 0737d1d..a2c13ca 100644
--- a/wagon-providers/wagon-ssh/pom.xml
+++ b/wagon-providers/wagon-ssh/pom.xml
@@ -1,180 +1,182 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-providers</artifactId>
- <version>2.10</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>wagon-ssh</artifactId>
- <name>Apache Maven Wagon :: Providers :: SSH Provider</name>
-
- <properties>
- <sshd.stopImmediatly>false</sshd.stopImmediatly>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>com.jcraft</groupId>
- <artifactId>jsch</artifactId>
- <version>0.1.50</version>
- </dependency>
- <dependency>
- <groupId>com.jcraft</groupId>
- <artifactId>jsch.agentproxy.connector-factory</artifactId>
- <version>0.0.6</version>
- </dependency>
- <dependency>
- <groupId>com.jcraft</groupId>
- <artifactId>jsch.agentproxy.jsch</artifactId>
- <version>0.0.6</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-ssh-common</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-ssh-common-test</artifactId>
- <scope>test</scope>
- </dependency>
-
-
- <dependency>
- <groupId>org.apache.sshd</groupId>
- <artifactId>sshd-core</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>bouncycastle</groupId>
- <artifactId>bcprov-jdk15</artifactId>
- <version>140</version>
- <scope>test</scope>
- </dependency>
-
- </dependencies>
-
- <profiles>
- <profile>
- <id>no-ssh-tests</id>
- <activation>
- <property>
- <name>!ssh-tests</name>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <!-- Tests that currently doesn't work with embedded ssh server -->
- <excludes>
- <exclude>**/SftpWagonTest.*</exclude>
- <exclude>**/SshCommandExecutorTest.*</exclude>
- <exclude>**/KnownHostsProviderTest.*</exclude>
- <exclude>**/ScpWagon*Test.*</exclude>
- <exclude>**/Embedded*Test.*</exclude>
- </excludes>
- <systemPropertyVariables>
- <java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
- <test.user>olamy</test.user>
- <sshd.stopImmediatly>${sshd.stopImmediatly}</sshd.stopImmediatly>
- </systemPropertyVariables>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>windauze</id>
- <activation>
- <os>
- <family>windows</family>
- </os>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <!-- Tests that currently doesn't work with embedded ssh server and embedded as won't work on a windauze env -->
- <excludes>
- <exclude>**/SftpWagonTest.*</exclude>
- <exclude>**/SshCommandExecutorTest.*</exclude>
- <exclude>**/KnownHostsProviderTest.*</exclude>
- <exclude>**/ScpWagon*Test.*</exclude>
- <exclude>**/Embedded*Test.*</exclude>
- </excludes>
- <systemPropertyVariables>
- <java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
- <test.user>olamy</test.user>
- </systemPropertyVariables>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- <profile>
- <id>ssh-embedded</id>
- <activation>
- <property>
- <name>ssh-embedded</name>
- <value>true</value>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <!-- Tests that currently doesn't work with embedded ssh server -->
- <excludes>
- <exclude>**/SftpWagonTest.*</exclude>
- <exclude>**/SshCommandExecutorTest.*</exclude>
- <exclude>**/KnownHostsProviderTest.*</exclude>
- <exclude>**/ScpWagon*Test.*</exclude>
- </excludes>
- <systemPropertyVariables>
- <java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
- <test.user>olamy</test.user>
- <sshd.stopImmediatly>${sshd.stopImmediatly}</sshd.stopImmediatly>
- </systemPropertyVariables>
- </configuration>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-providers</artifactId>
+ <version>2.12</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>wagon-ssh</artifactId>
+ <name>Apache Maven Wagon :: Providers :: SSH Provider</name>
+
+ <properties>
+ <sshd.stopImmediatly>false</sshd.stopImmediatly>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>com.jcraft</groupId>
+ <artifactId>jsch</artifactId>
+ <version>0.1.54</version>
+ </dependency>
+ <dependency>
+ <groupId>com.jcraft</groupId>
+ <artifactId>jsch.agentproxy.connector-factory</artifactId>
+ <version>0.0.9</version>
+ </dependency>
+ <dependency>
+ <groupId>com.jcraft</groupId>
+ <artifactId>jsch.agentproxy.jsch</artifactId>
+ <version>0.0.9</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-interactivity-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-ssh-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-ssh-common-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty.aggregate</groupId>
+ <artifactId>jetty-all</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>no-ssh-tests</id>
+ <activation>
+ <property>
+ <name>!ssh-tests</name>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!-- Tests that currently doesn't work with embedded ssh server -->
+ <excludes>
+ <exclude>**/SftpWagonTest.*</exclude>
+ <exclude>**/SshCommandExecutorTest.*</exclude>
+ <exclude>**/KnownHostsProviderTest.*</exclude>
+ <exclude>**/ScpWagon*Test.*</exclude>
+ <exclude>**/Embedded*Test.*</exclude>
+ </excludes>
+ <systemPropertyVariables>
+ <java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
+ <test.user>olamy</test.user>
+ <sshd.stopImmediatly>${sshd.stopImmediatly}</sshd.stopImmediatly>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>windauze</id>
+ <activation>
+ <os>
+ <family>windows</family>
+ </os>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!-- Tests that currently doesn't work with embedded ssh server and embedded as won't work on a windauze env -->
+ <excludes>
+ <exclude>**/SftpWagonTest.*</exclude>
+ <exclude>**/SshCommandExecutorTest.*</exclude>
+ <exclude>**/KnownHostsProviderTest.*</exclude>
+ <exclude>**/ScpWagon*Test.*</exclude>
+ <exclude>**/Embedded*Test.*</exclude>
+ </excludes>
+ <systemPropertyVariables>
+ <java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
+ <test.user>olamy</test.user>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>ssh-embedded</id>
+ <activation>
+ <property>
+ <name>ssh-embedded</name>
+ <value>true</value>
+ </property>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <!-- Tests that currently doesn't work with embedded ssh server -->
+ <excludes>
+ <exclude>**/SftpWagonTest.*</exclude>
+ <exclude>**/SshCommandExecutorTest.*</exclude>
+ <exclude>**/KnownHostsProviderTest.*</exclude>
+ <exclude>**/ScpWagon*Test.*</exclude>
+ </excludes>
+ <systemPropertyVariables>
+ <java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
+ <test.user>olamy</test.user>
+ <sshd.stopImmediatly>${sshd.stopImmediatly}</sshd.stopImmediatly>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
diff --git a/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/AbstractJschWagon.java b/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/AbstractJschWagon.java
index 9ae7625..9d384b5 100644
--- a/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/AbstractJschWagon.java
+++ b/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/AbstractJschWagon.java
@@ -1,427 +1,481 @@
-package org.apache.maven.wagon.providers.ssh.jsch;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.List;
-import java.util.Properties;
-
-import org.apache.maven.wagon.CommandExecutionException;
-import org.apache.maven.wagon.CommandExecutor;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
-import org.apache.maven.wagon.StreamWagon;
-import org.apache.maven.wagon.Streams;
-import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.WagonConstants;
-import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
-import org.apache.maven.wagon.authorization.AuthorizationException;
-import org.apache.maven.wagon.events.TransferEvent;
-import org.apache.maven.wagon.providers.ssh.CommandExecutorStreamProcessor;
-import org.apache.maven.wagon.providers.ssh.ScpHelper;
-import org.apache.maven.wagon.providers.ssh.SshWagon;
-import org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo;
-import org.apache.maven.wagon.providers.ssh.interactive.NullInteractiveUserInfo;
-import org.apache.maven.wagon.providers.ssh.jsch.interactive.UserInfoUIKeyboardInteractiveProxy;
-import org.apache.maven.wagon.providers.ssh.knownhost.KnownHostChangedException;
-import org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider;
-import org.apache.maven.wagon.providers.ssh.knownhost.UnknownHostException;
-import org.apache.maven.wagon.proxy.ProxyInfo;
-import org.apache.maven.wagon.resource.Resource;
-import org.codehaus.plexus.util.IOUtil;
-import org.codehaus.plexus.util.StringInputStream;
-
-import com.jcraft.jsch.agentproxy.AgentProxyException;
-import com.jcraft.jsch.agentproxy.Connector;
-import com.jcraft.jsch.agentproxy.ConnectorFactory;
-import com.jcraft.jsch.agentproxy.RemoteIdentityRepository;
-import com.jcraft.jsch.ChannelExec;
-import com.jcraft.jsch.HostKey;
-import com.jcraft.jsch.HostKeyRepository;
-import com.jcraft.jsch.IdentityRepository;
-import com.jcraft.jsch.JSch;
-import com.jcraft.jsch.JSchException;
-import com.jcraft.jsch.Proxy;
-import com.jcraft.jsch.ProxyHTTP;
-import com.jcraft.jsch.ProxySOCKS5;
-import com.jcraft.jsch.Session;
-import com.jcraft.jsch.UIKeyboardInteractive;
-import com.jcraft.jsch.UserInfo;
-
-/**
- * AbstractJschWagon
- */
-public abstract class AbstractJschWagon
- extends StreamWagon
- implements SshWagon, CommandExecutor
-{
- protected ScpHelper sshTool = new ScpHelper( this );
-
- protected Session session;
-
- /**
- * @plexus.requirement role-hint="file"
- */
- private volatile KnownHostsProvider knownHostsProvider;
-
- /**
- * @plexus.requirement
- */
- private volatile InteractiveUserInfo interactiveUserInfo;
-
- /**
- * @plexus.requirement
- */
- private volatile UIKeyboardInteractive uIKeyboardInteractive;
-
- private static final int SOCKS5_PROXY_PORT = 1080;
-
- protected static final String EXEC_CHANNEL = "exec";
-
- public void openConnectionInternal()
- throws AuthenticationException
- {
- if ( authenticationInfo == null )
- {
- authenticationInfo = new AuthenticationInfo();
- }
-
- if ( !interactive )
- {
- uIKeyboardInteractive = null;
- setInteractiveUserInfo( new NullInteractiveUserInfo() );
- }
-
- JSch sch = new JSch();
-
- File privateKey;
- try
- {
- privateKey = ScpHelper.getPrivateKey( authenticationInfo );
- }
- catch ( FileNotFoundException e )
- {
- throw new AuthenticationException( e.getMessage() );
- }
-
- //can only pick one method of authentication
- if ( privateKey != null && privateKey.exists() )
- {
- fireSessionDebug( "Using private key: " + privateKey );
- try
- {
- sch.addIdentity( privateKey.getAbsolutePath(), authenticationInfo.getPassphrase() );
- }
- catch ( JSchException e )
- {
- throw new AuthenticationException( "Cannot connect. Reason: " + e.getMessage(), e );
- }
- }
- else
- {
- try
- {
- Connector connector = ConnectorFactory.getDefault().createConnector();
- if ( connector != null )
- {
- IdentityRepository repo = new RemoteIdentityRepository( connector );
- sch.setIdentityRepository( repo );
- }
- }
- catch ( AgentProxyException e )
- {
- fireSessionDebug( "Unable to connect to agent: " + e.toString() );
- }
-
- }
-
- String host = getRepository().getHost();
- int port =
- repository.getPort() == WagonConstants.UNKNOWN_PORT ? ScpHelper.DEFAULT_SSH_PORT : repository.getPort();
- try
- {
- String userName = authenticationInfo.getUserName();
- if ( userName == null )
- {
- userName = System.getProperty( "user.name" );
- }
- session = sch.getSession( userName, host, port );
- session.setTimeout( getTimeout() );
- }
- catch ( JSchException e )
- {
- throw new AuthenticationException( "Cannot connect. Reason: " + e.getMessage(), e );
- }
-
- Proxy proxy = null;
- ProxyInfo proxyInfo = getProxyInfo( ProxyInfo.PROXY_SOCKS5, getRepository().getHost() );
- if ( proxyInfo != null && proxyInfo.getHost() != null )
- {
- proxy = new ProxySOCKS5( proxyInfo.getHost(), proxyInfo.getPort() );
- ( (ProxySOCKS5) proxy ).setUserPasswd( proxyInfo.getUserName(), proxyInfo.getPassword() );
- }
- else
- {
- proxyInfo = getProxyInfo( ProxyInfo.PROXY_HTTP, getRepository().getHost() );
- if ( proxyInfo != null && proxyInfo.getHost() != null )
- {
- proxy = new ProxyHTTP( proxyInfo.getHost(), proxyInfo.getPort() );
- ( (ProxyHTTP) proxy ).setUserPasswd( proxyInfo.getUserName(), proxyInfo.getPassword() );
- }
- else
- {
- // Backwards compatibility
- proxyInfo = getProxyInfo( getRepository().getProtocol(), getRepository().getHost() );
- if ( proxyInfo != null && proxyInfo.getHost() != null )
- {
- // if port == 1080 we will use SOCKS5 Proxy, otherwise will use HTTP Proxy
- if ( proxyInfo.getPort() == SOCKS5_PROXY_PORT )
- {
- proxy = new ProxySOCKS5( proxyInfo.getHost(), proxyInfo.getPort() );
- ( (ProxySOCKS5) proxy ).setUserPasswd( proxyInfo.getUserName(), proxyInfo.getPassword() );
- }
- else
- {
- proxy = new ProxyHTTP( proxyInfo.getHost(), proxyInfo.getPort() );
- ( (ProxyHTTP) proxy ).setUserPasswd( proxyInfo.getUserName(), proxyInfo.getPassword() );
- }
- }
- }
- }
- session.setProxy( proxy );
-
- // username and password will be given via UserInfo interface.
- UserInfo ui = new WagonUserInfo( authenticationInfo, getInteractiveUserInfo() );
-
- if ( uIKeyboardInteractive != null )
- {
- ui = new UserInfoUIKeyboardInteractiveProxy( ui, uIKeyboardInteractive );
- }
-
- Properties config = new Properties();
- if ( getKnownHostsProvider() != null )
- {
- try
- {
- String contents = getKnownHostsProvider().getContents();
- if ( contents != null )
- {
- sch.setKnownHosts( new StringInputStream( contents ) );
- }
- }
- catch ( JSchException e )
- {
- // continue without known_hosts
- }
- config.setProperty( "StrictHostKeyChecking", getKnownHostsProvider().getHostKeyChecking() );
- }
-
- if ( authenticationInfo.getPassword() != null )
- {
- config.setProperty( "PreferredAuthentications", "gssapi-with-mic,publickey,password,keyboard-interactive" );
- }
-
- config.setProperty( "BatchMode", interactive ? "no" : "yes" );
-
- session.setConfig( config );
-
- session.setUserInfo( ui );
-
- StringWriter stringWriter = new StringWriter();
- try
- {
- session.connect();
-
- if ( getKnownHostsProvider() != null )
- {
- PrintWriter w = new PrintWriter( stringWriter );
-
- HostKeyRepository hkr = sch.getHostKeyRepository();
- HostKey[] keys = hkr.getHostKey();
-
- for ( int i = 0; keys != null && i < keys.length; i++ )
- {
- HostKey key = keys[i];
- w.println( key.getHost() + " " + key.getType() + " " + key.getKey() );
- }
- }
- }
- catch ( JSchException e )
- {
- if ( e.getMessage().startsWith( "UnknownHostKey:" ) || e.getMessage().startsWith( "reject HostKey:" ) )
- {
- throw new UnknownHostException( host, e );
- }
- else if ( e.getMessage().contains( "HostKey has been changed" ) )
- {
- throw new KnownHostChangedException( host, e );
- }
- else
- {
- throw new AuthenticationException( "Cannot connect. Reason: " + e.getMessage(), e );
- }
- }
-
- try
- {
- getKnownHostsProvider().storeKnownHosts( stringWriter.toString() );
- }
- catch ( IOException e )
- {
- closeConnection();
-
- throw new AuthenticationException(
- "Connection aborted - failed to write to known_hosts. Reason: " + e.getMessage(), e );
- }
- }
-
- public void closeConnection()
- {
- if ( session != null )
- {
- session.disconnect();
- session = null;
- }
- }
-
- public Streams executeCommand( String command, boolean ignoreFailures )
- throws CommandExecutionException
- {
- ChannelExec channel = null;
- BufferedReader stdoutReader = null;
- BufferedReader stderrReader = null;
- try
- {
- channel = (ChannelExec) session.openChannel( EXEC_CHANNEL );
-
- channel.setCommand( command + "\n" );
-
- InputStream stdout = channel.getInputStream();
- InputStream stderr = channel.getErrStream();
-
- channel.connect();
-
- stdoutReader = new BufferedReader( new InputStreamReader( stdout ) );
- stderrReader = new BufferedReader( new InputStreamReader( stderr ) );
-
- Streams streams = CommandExecutorStreamProcessor.processStreams( stderrReader, stdoutReader );
-
- if ( streams.getErr().length() > 0 && !ignoreFailures )
- {
- int exitCode = channel.getExitStatus();
- throw new CommandExecutionException( "Exit code: " + exitCode + " - " + streams.getErr() );
- }
-
- return streams;
- }
- catch ( IOException e )
- {
- throw new CommandExecutionException( "Cannot execute remote command: " + command, e );
- }
- catch ( JSchException e )
- {
- throw new CommandExecutionException( "Cannot execute remote command: " + command, e );
- }
- finally
- {
- IOUtil.close( stdoutReader );
- IOUtil.close( stderrReader );
- if ( channel != null )
- {
- channel.disconnect();
- }
- }
- }
-
- protected void handleGetException( Resource resource, Exception e )
- throws TransferFailedException
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_GET );
-
- String msg =
- "Error occurred while downloading '" + resource + "' from the remote repository:" + getRepository() + ": "
- + e.getMessage();
-
- throw new TransferFailedException( msg, e );
- }
-
- public List<String> getFileList( String destinationDirectory )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- return sshTool.getFileList( destinationDirectory, repository );
- }
-
- public void putDirectory( File sourceDirectory, String destinationDirectory )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- sshTool.putDirectory( this, sourceDirectory, destinationDirectory );
- }
-
- public boolean resourceExists( String resourceName )
- throws TransferFailedException, AuthorizationException
- {
- return sshTool.resourceExists( resourceName, repository );
- }
-
- public boolean supportsDirectoryCopy()
- {
- return true;
- }
-
- public void executeCommand( String command )
- throws CommandExecutionException
- {
- fireTransferDebug( "Executing command: " + command );
-
- executeCommand( command, false );
- }
-
- public InteractiveUserInfo getInteractiveUserInfo()
- {
- return this.interactiveUserInfo;
- }
-
- public KnownHostsProvider getKnownHostsProvider()
- {
- return this.knownHostsProvider;
- }
-
- public void setInteractiveUserInfo( InteractiveUserInfo interactiveUserInfo )
- {
- this.interactiveUserInfo = interactiveUserInfo;
- }
-
- public void setKnownHostsProvider( KnownHostsProvider knownHostsProvider )
- {
- this.knownHostsProvider = knownHostsProvider;
- }
-
- public void setUIKeyboardInteractive( UIKeyboardInteractive uIKeyboardInteractive )
- {
- this.uIKeyboardInteractive = uIKeyboardInteractive;
- }
-}
+package org.apache.maven.wagon.providers.ssh.jsch;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.maven.wagon.CommandExecutionException;
+import org.apache.maven.wagon.CommandExecutor;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.StreamWagon;
+import org.apache.maven.wagon.Streams;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.WagonConstants;
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.providers.ssh.CommandExecutorStreamProcessor;
+import org.apache.maven.wagon.providers.ssh.ScpHelper;
+import org.apache.maven.wagon.providers.ssh.SshWagon;
+import org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo;
+import org.apache.maven.wagon.providers.ssh.interactive.NullInteractiveUserInfo;
+import org.apache.maven.wagon.providers.ssh.jsch.interactive.UserInfoUIKeyboardInteractiveProxy;
+import org.apache.maven.wagon.providers.ssh.knownhost.KnownHostChangedException;
+import org.apache.maven.wagon.providers.ssh.knownhost.KnownHostEntry;
+import org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider;
+import org.apache.maven.wagon.providers.ssh.knownhost.UnknownHostException;
+import org.apache.maven.wagon.proxy.ProxyInfo;
+import org.apache.maven.wagon.resource.Resource;
+import org.codehaus.plexus.util.IOUtil;
+
+import com.jcraft.jsch.ChannelExec;
+import com.jcraft.jsch.HostKey;
+import com.jcraft.jsch.HostKeyRepository;
+import com.jcraft.jsch.IdentityRepository;
+import com.jcraft.jsch.JSch;
+import com.jcraft.jsch.JSchException;
+import com.jcraft.jsch.Proxy;
+import com.jcraft.jsch.ProxyHTTP;
+import com.jcraft.jsch.ProxySOCKS5;
+import com.jcraft.jsch.Session;
+import com.jcraft.jsch.UIKeyboardInteractive;
+import com.jcraft.jsch.UserInfo;
+import com.jcraft.jsch.agentproxy.AgentProxyException;
+import com.jcraft.jsch.agentproxy.Connector;
+import com.jcraft.jsch.agentproxy.ConnectorFactory;
+import com.jcraft.jsch.agentproxy.RemoteIdentityRepository;
+
+/**
+ * AbstractJschWagon
+ */
+public abstract class AbstractJschWagon
+ extends StreamWagon
+ implements SshWagon, CommandExecutor
+{
+ protected ScpHelper sshTool = new ScpHelper( this );
+
+ protected Session session;
+
+ private String strictHostKeyChecking;
+
+ /**
+ * @plexus.requirement role-hint="file"
+ */
+ private volatile KnownHostsProvider knownHostsProvider;
+
+ /**
+ * @plexus.requirement
+ */
+ private volatile InteractiveUserInfo interactiveUserInfo;
+
+ /**
+ * @plexus.configuration default-value="gssapi-with-mic,publickey,password,keyboard-interactive"
+ */
+ private volatile String preferredAuthentications;
+
+ /**
+ * @plexus.requirement
+ */
+ private volatile UIKeyboardInteractive uIKeyboardInteractive;
+
+ private static final int SOCKS5_PROXY_PORT = 1080;
+
+ protected static final String EXEC_CHANNEL = "exec";
+
+ public void openConnectionInternal()
+ throws AuthenticationException
+ {
+ if ( authenticationInfo == null )
+ {
+ authenticationInfo = new AuthenticationInfo();
+ }
+
+ if ( !interactive )
+ {
+ uIKeyboardInteractive = null;
+ setInteractiveUserInfo( new NullInteractiveUserInfo() );
+ }
+
+ JSch sch = new JSch();
+
+ File privateKey;
+ try
+ {
+ privateKey = ScpHelper.getPrivateKey( authenticationInfo );
+ }
+ catch ( FileNotFoundException e )
+ {
+ throw new AuthenticationException( e.getMessage() );
+ }
+
+ //can only pick one method of authentication
+ if ( privateKey != null && privateKey.exists() )
+ {
+ fireSessionDebug( "Using private key: " + privateKey );
+ try
+ {
+ sch.addIdentity( privateKey.getAbsolutePath(), authenticationInfo.getPassphrase() );
+ }
+ catch ( JSchException e )
+ {
+ throw new AuthenticationException( "Cannot connect. Reason: " + e.getMessage(), e );
+ }
+ }
+ else
+ {
+ try
+ {
+ Connector connector = ConnectorFactory.getDefault().createConnector();
+ if ( connector != null )
+ {
+ IdentityRepository repo = new RemoteIdentityRepository( connector );
+ sch.setIdentityRepository( repo );
+ }
+ }
+ catch ( AgentProxyException e )
+ {
+ fireSessionDebug( "Unable to connect to agent: " + e.toString() );
+ }
+
+ }
+
+ String host = getRepository().getHost();
+ int port =
+ repository.getPort() == WagonConstants.UNKNOWN_PORT ? ScpHelper.DEFAULT_SSH_PORT : repository.getPort();
+ try
+ {
+ String userName = authenticationInfo.getUserName();
+ if ( userName == null )
+ {
+ userName = System.getProperty( "user.name" );
+ }
+ session = sch.getSession( userName, host, port );
+ session.setTimeout( getTimeout() );
+ }
+ catch ( JSchException e )
+ {
+ throw new AuthenticationException( "Cannot connect. Reason: " + e.getMessage(), e );
+ }
+
+ Proxy proxy = null;
+ ProxyInfo proxyInfo = getProxyInfo( ProxyInfo.PROXY_SOCKS5, getRepository().getHost() );
+ if ( proxyInfo != null && proxyInfo.getHost() != null )
+ {
+ proxy = new ProxySOCKS5( proxyInfo.getHost(), proxyInfo.getPort() );
+ ( (ProxySOCKS5) proxy ).setUserPasswd( proxyInfo.getUserName(), proxyInfo.getPassword() );
+ }
+ else
+ {
+ proxyInfo = getProxyInfo( ProxyInfo.PROXY_HTTP, getRepository().getHost() );
+ if ( proxyInfo != null && proxyInfo.getHost() != null )
+ {
+ proxy = new ProxyHTTP( proxyInfo.getHost(), proxyInfo.getPort() );
+ ( (ProxyHTTP) proxy ).setUserPasswd( proxyInfo.getUserName(), proxyInfo.getPassword() );
+ }
+ else
+ {
+ // Backwards compatibility
+ proxyInfo = getProxyInfo( getRepository().getProtocol(), getRepository().getHost() );
+ if ( proxyInfo != null && proxyInfo.getHost() != null )
+ {
+ // if port == 1080 we will use SOCKS5 Proxy, otherwise will use HTTP Proxy
+ if ( proxyInfo.getPort() == SOCKS5_PROXY_PORT )
+ {
+ proxy = new ProxySOCKS5( proxyInfo.getHost(), proxyInfo.getPort() );
+ ( (ProxySOCKS5) proxy ).setUserPasswd( proxyInfo.getUserName(), proxyInfo.getPassword() );
+ }
+ else
+ {
+ proxy = new ProxyHTTP( proxyInfo.getHost(), proxyInfo.getPort() );
+ ( (ProxyHTTP) proxy ).setUserPasswd( proxyInfo.getUserName(), proxyInfo.getPassword() );
+ }
+ }
+ }
+ }
+ session.setProxy( proxy );
+
+ // username and password will be given via UserInfo interface.
+ UserInfo ui = new WagonUserInfo( authenticationInfo, getInteractiveUserInfo() );
+
+ if ( uIKeyboardInteractive != null )
+ {
+ ui = new UserInfoUIKeyboardInteractiveProxy( ui, uIKeyboardInteractive );
+ }
+
+ Properties config = new Properties();
+ if ( getKnownHostsProvider() != null )
+ {
+ try
+ {
+ String contents = getKnownHostsProvider().getContents();
+ if ( contents != null )
+ {
+ sch.setKnownHosts( new ByteArrayInputStream( contents.getBytes() ) );
+ }
+ }
+ catch ( JSchException e )
+ {
+ // continue without known_hosts
+ }
+ if ( strictHostKeyChecking == null )
+ {
+ strictHostKeyChecking = getKnownHostsProvider().getHostKeyChecking();
+ }
+ config.setProperty( "StrictHostKeyChecking", strictHostKeyChecking );
+ }
+
+ if ( authenticationInfo.getPassword() != null )
+ {
+ config.setProperty( "PreferredAuthentications", preferredAuthentications );
+ }
+
+ config.setProperty( "BatchMode", interactive ? "no" : "yes" );
+
+ session.setConfig( config );
+
+ session.setUserInfo( ui );
+
+ try
+ {
+ session.connect();
+ }
+ catch ( JSchException e )
+ {
+ if ( e.getMessage().startsWith( "UnknownHostKey:" ) || e.getMessage().startsWith( "reject HostKey:" ) )
+ {
+ throw new UnknownHostException( host, e );
+ }
+ else if ( e.getMessage().contains( "HostKey has been changed" ) )
+ {
+ throw new KnownHostChangedException( host, e );
+ }
+ else
+ {
+ throw new AuthenticationException( "Cannot connect. Reason: " + e.getMessage(), e );
+ }
+ }
+
+ if ( getKnownHostsProvider() != null )
+ {
+ HostKeyRepository hkr = sch.getHostKeyRepository();
+
+ HostKey[] hk = hkr.getHostKey( host, null );
+ try
+ {
+ if ( hk != null )
+ {
+ for ( HostKey hostKey : hk )
+ {
+ KnownHostEntry knownHostEntry = new KnownHostEntry( hostKey.getHost(), hostKey.getType(),
+ hostKey.getKey() );
+ getKnownHostsProvider().addKnownHost( knownHostEntry );
+ }
+ }
+ }
+ catch ( IOException e )
+ {
+ closeConnection();
+
+ throw new AuthenticationException(
+ "Connection aborted - failed to write to known_hosts. Reason: " + e.getMessage(), e );
+ }
+ }
+ }
+
+ public void closeConnection()
+ {
+ if ( session != null )
+ {
+ session.disconnect();
+ session = null;
+ }
+ }
+
+ public Streams executeCommand( String command, boolean ignoreStdErr, boolean ignoreNoneZeroExitCode )
+ throws CommandExecutionException
+ {
+ ChannelExec channel = null;
+ BufferedReader stdoutReader = null;
+ BufferedReader stderrReader = null;
+ Streams streams = null;
+ try
+ {
+ channel = (ChannelExec) session.openChannel( EXEC_CHANNEL );
+
+ fireSessionDebug( "Executing: " + command );
+ channel.setCommand( command + "\n" );
+
+ stdoutReader = new BufferedReader( new InputStreamReader( channel.getInputStream() ) );
+ stderrReader = new BufferedReader( new InputStreamReader( channel.getErrStream() ) );
+
+ channel.connect();
+
+ streams = CommandExecutorStreamProcessor.processStreams( stderrReader, stdoutReader );
+
+ stdoutReader.close();
+ stdoutReader = null;
+
+ stderrReader.close();
+ stderrReader = null;
+
+ int exitCode = channel.getExitStatus();
+
+ if ( streams.getErr().length() > 0 && !ignoreStdErr )
+ {
+ throw new CommandExecutionException( "Exit code: " + exitCode + " - " + streams.getErr() );
+ }
+
+ if ( exitCode != 0 && !ignoreNoneZeroExitCode )
+ {
+ throw new CommandExecutionException( "Exit code: " + exitCode + " - " + streams.getErr() );
+ }
+
+ return streams;
+ }
+ catch ( IOException e )
+ {
+ throw new CommandExecutionException( "Cannot execute remote command: " + command, e );
+ }
+ catch ( JSchException e )
+ {
+ throw new CommandExecutionException( "Cannot execute remote command: " + command, e );
+ }
+ finally
+ {
+ if ( streams != null )
+ {
+ fireSessionDebug( "Stdout results:" + streams.getOut() );
+ fireSessionDebug( "Stderr results:" + streams.getErr() );
+ }
+
+ IOUtil.close( stdoutReader );
+ IOUtil.close( stderrReader );
+ if ( channel != null )
+ {
+ channel.disconnect();
+ }
+ }
+ }
+
+ protected void handleGetException( Resource resource, Exception e )
+ throws TransferFailedException
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+
+ String msg =
+ "Error occurred while downloading '" + resource + "' from the remote repository:" + getRepository() + ": "
+ + e.getMessage();
+
+ throw new TransferFailedException( msg, e );
+ }
+
+ public List<String> getFileList( String destinationDirectory )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ return sshTool.getFileList( destinationDirectory, repository );
+ }
+
+ public void putDirectory( File sourceDirectory, String destinationDirectory )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ sshTool.putDirectory( this, sourceDirectory, destinationDirectory );
+ }
+
+ public boolean resourceExists( String resourceName )
+ throws TransferFailedException, AuthorizationException
+ {
+ return sshTool.resourceExists( resourceName, repository );
+ }
+
+ public boolean supportsDirectoryCopy()
+ {
+ return true;
+ }
+
+ public void executeCommand( String command )
+ throws CommandExecutionException
+ {
+ fireTransferDebug( "Executing command: " + command );
+
+ executeCommand( command, false );
+ }
+
+ public Streams executeCommand( String command, boolean ignoreFailures )
+ throws CommandExecutionException
+ {
+ fireTransferDebug( "Executing command: " + command );
+
+ //backward compatible with wagon 2.10
+ return executeCommand( command, ignoreFailures, ignoreFailures );
+ }
+
+ public InteractiveUserInfo getInteractiveUserInfo()
+ {
+ return this.interactiveUserInfo;
+ }
+
+ public KnownHostsProvider getKnownHostsProvider()
+ {
+ return this.knownHostsProvider;
+ }
+
+ public void setInteractiveUserInfo( InteractiveUserInfo interactiveUserInfo )
+ {
+ this.interactiveUserInfo = interactiveUserInfo;
+ }
+
+ public void setKnownHostsProvider( KnownHostsProvider knownHostsProvider )
+ {
+ this.knownHostsProvider = knownHostsProvider;
+ }
+
+ public void setUIKeyboardInteractive( UIKeyboardInteractive uIKeyboardInteractive )
+ {
+ this.uIKeyboardInteractive = uIKeyboardInteractive;
+ }
+
+ public String getPreferredAuthentications()
+ {
+ return preferredAuthentications;
+ }
+
+ public void setPreferredAuthentications( String preferredAuthentications )
+ {
+ this.preferredAuthentications = preferredAuthentications;
+ }
+
+ public String getStrictHostKeyChecking()
+ {
+ return strictHostKeyChecking;
+ }
+
+ public void setStrictHostKeyChecking( String strictHostKeyChecking )
+ {
+ this.strictHostKeyChecking = strictHostKeyChecking;
+ }
+}
diff --git a/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpCommandExecutor.java b/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpCommandExecutor.java
index 0f14468..738a42b 100644
--- a/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpCommandExecutor.java
+++ b/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpCommandExecutor.java
@@ -1,41 +1,41 @@
-package org.apache.maven.wagon.providers.ssh.jsch;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- * ScpCommandExecutor - bridge class for plexus:descriptor
- *
- * @author <a href="mailto:joakim at erdfelt.com">Joakim Erdfelt</a>
- *
- *
- * @todo is this even needed anymore?
- *
- * @plexus.component role="org.apache.maven.wagon.CommandExecutor"
- * role-hint="scp"
- * instantiation-strategy="per-lookup"
- */
-public class ScpCommandExecutor
- extends ScpWagon
-{
- public ScpCommandExecutor()
- {
- super();
- }
-}
+package org.apache.maven.wagon.providers.ssh.jsch;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * ScpCommandExecutor - bridge class for plexus:descriptor
+ *
+ * @author <a href="mailto:joakim at erdfelt.com">Joakim Erdfelt</a>
+ *
+ *
+ * @todo is this even needed anymore?
+ *
+ * @plexus.component role="org.apache.maven.wagon.CommandExecutor"
+ * role-hint="scp"
+ * instantiation-strategy="per-lookup"
+ */
+public class ScpCommandExecutor
+ extends ScpWagon
+{
+ public ScpCommandExecutor()
+ {
+ super();
+ }
+}
diff --git a/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java b/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java
index be69880..39ceedb 100644
--- a/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java
+++ b/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.java
@@ -1,452 +1,452 @@
-package org.apache.maven.wagon.providers.ssh.jsch;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.jcraft.jsch.ChannelExec;
-import com.jcraft.jsch.JSchException;
-import org.apache.maven.wagon.CommandExecutionException;
-import org.apache.maven.wagon.InputData;
-import org.apache.maven.wagon.OutputData;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
-import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.events.TransferEvent;
-import org.apache.maven.wagon.providers.ssh.ScpHelper;
-import org.apache.maven.wagon.repository.RepositoryPermissions;
-import org.apache.maven.wagon.resource.Resource;
-
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * SCP protocol wagon.
- * <p/>
- * Note that this implementation is <i>not</i> thread-safe, and multiple channels can not be used on the session at
- * the same time.
- * <p/>
- * See <a href="http://blogs.sun.com/janp/entry/how_the_scp_protocol_works">
- * http://blogs.sun.com/janp/entry/how_the_scp_protocol_works</a>
- * for information on how the SCP protocol works.
- *
- *
- * @todo [BP] add compression flag
- * @plexus.component role="org.apache.maven.wagon.Wagon"
- * role-hint="scp"
- * instantiation-strategy="per-lookup"
- */
-public class ScpWagon
- extends AbstractJschWagon
-{
- private static final char COPY_START_CHAR = 'C';
-
- private static final char ACK_SEPARATOR = ' ';
-
- private static final String END_OF_FILES_MSG = "E\n";
-
- private static final int LINE_BUFFER_SIZE = 8192;
-
- private static final byte LF = '\n';
-
- private ChannelExec channel;
-
- private InputStream channelInputStream;
-
- private OutputStream channelOutputStream;
-
- private void setFileGroup( RepositoryPermissions permissions, String basedir, Resource resource )
- throws CommandExecutionException
- {
- if ( permissions != null && permissions.getGroup() != null )
- {
- //executeCommand( "chgrp -f " + permissions.getGroup() + " " + getPath( basedir, resource.getName() ) );
- executeCommand( "chgrp -f " + permissions.getGroup() + " \"" + getPath( basedir, resource.getName() )
- + "\"" );
- }
- }
-
- protected void cleanupPutTransfer( Resource resource )
- {
- if ( channel != null )
- {
- channel.disconnect();
- channel = null;
- }
- }
-
- protected void finishPutTransfer( Resource resource, InputStream input, OutputStream output )
- throws TransferFailedException
- {
- try
- {
- sendEom( output );
-
- checkAck( channelInputStream );
-
- // This came from SCPClient in Ganymede SSH2. It is sent after all files.
- output.write( END_OF_FILES_MSG.getBytes() );
- output.flush();
- }
- catch ( IOException e )
- {
- handleIOException( resource, e );
- }
-
- String basedir = getRepository().getBasedir();
- try
- {
- setFileGroup( getRepository().getPermissions(), basedir, resource );
- }
- catch ( CommandExecutionException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
-
- throw new TransferFailedException( e.getMessage(), e );
- }
- }
-
- private void checkAck( InputStream in )
- throws IOException
- {
- int code = in.read();
- if ( code == -1 )
- {
- throw new IOException( "Unexpected end of data" );
- }
- else if ( code == 1 )
- {
- String line = readLine( in );
-
- throw new IOException( "SCP terminated with error: '" + line + "'" );
- }
- else if ( code == 2 )
- {
- throw new IOException( "SCP terminated with error (code: " + code + ")" );
- }
- else if ( code != 0 )
- {
- throw new IOException( "SCP terminated with unknown error code" );
- }
- }
-
- protected void finishGetTransfer( Resource resource, InputStream input, OutputStream output )
- throws TransferFailedException
- {
- try
- {
- checkAck( input );
-
- sendEom( channelOutputStream );
- }
- catch ( IOException e )
- {
- handleGetException( resource, e );
- }
- }
-
- protected void cleanupGetTransfer( Resource resource )
- {
- if ( channel != null )
- {
- channel.disconnect();
- }
- }
-
- @Deprecated
- protected void getTransfer( Resource resource, OutputStream output, InputStream input, boolean closeInput,
- int maxSize )
- throws TransferFailedException
- {
- super.getTransfer( resource, output, input, closeInput, (int) resource.getContentLength() );
- }
-
- protected void getTransfer( Resource resource, OutputStream output, InputStream input, boolean closeInput,
- long maxSize )
- throws TransferFailedException
- {
- super.getTransfer( resource, output, input, closeInput, resource.getContentLength() );
- }
-
- protected String readLine( InputStream in )
- throws IOException
- {
- StringBuilder sb = new StringBuilder();
-
- while ( true )
- {
- if ( sb.length() > LINE_BUFFER_SIZE )
- {
- throw new IOException( "Remote server sent a too long line" );
- }
-
- int c = in.read();
-
- if ( c < 0 )
- {
- throw new IOException( "Remote connection terminated unexpectedly." );
- }
-
- if ( c == LF )
- {
- break;
- }
-
- sb.append( (char) c );
- }
- return sb.toString();
- }
-
- protected static void sendEom( OutputStream out )
- throws IOException
- {
- out.write( 0 );
-
- out.flush();
- }
-
- public void fillInputData( InputData inputData )
- throws TransferFailedException, ResourceDoesNotExistException
- {
- Resource resource = inputData.getResource();
-
- String path = getPath( getRepository().getBasedir(), resource.getName() );
- //String cmd = "scp -p -f " + path;
- String cmd = "scp -p -f \"" + path + "\"";
-
- fireTransferDebug( "Executing command: " + cmd );
-
- try
- {
- channel = (ChannelExec) session.openChannel( EXEC_CHANNEL );
-
- channel.setCommand( cmd );
-
- // get I/O streams for remote scp
- channelOutputStream = channel.getOutputStream();
-
- InputStream in = channel.getInputStream();
- inputData.setInputStream( in );
-
- channel.connect();
-
- sendEom( channelOutputStream );
-
- int exitCode = in.read();
-
- if ( exitCode == 'T' )
- {
- String line = readLine( in );
-
- String[] times = line.split( " " );
-
- resource.setLastModified( Long.valueOf( times[0] ).longValue() * 1000 );
-
- sendEom( channelOutputStream );
-
- exitCode = in.read();
- }
-
- String line = readLine( in );
-
- if ( exitCode != COPY_START_CHAR )
- {
- if ( exitCode == 1 && ( line.contains( "No such file or directory" )
- || line.indexOf( "no such file or directory" ) != 1 ) )
- {
- throw new ResourceDoesNotExistException( line );
- }
- else
- {
- throw new IOException( "Exit code: " + exitCode + " - " + line );
- }
- }
-
- if ( line == null )
- {
- throw new EOFException( "Unexpected end of data" );
- }
-
- String perms = line.substring( 0, 4 );
- fireTransferDebug( "Remote file permissions: " + perms );
-
- if ( line.charAt( 4 ) != ACK_SEPARATOR && line.charAt( 5 ) != ACK_SEPARATOR )
- {
- throw new IOException( "Invalid transfer header: " + line );
- }
-
- int index = line.indexOf( ACK_SEPARATOR, 5 );
- if ( index < 0 )
- {
- throw new IOException( "Invalid transfer header: " + line );
- }
-
- int filesize = Integer.valueOf( line.substring( 5, index ) ).intValue();
- fireTransferDebug( "Remote file size: " + filesize );
-
- resource.setContentLength( filesize );
-
- String filename = line.substring( index + 1 );
- fireTransferDebug( "Remote filename: " + filename );
-
- sendEom( channelOutputStream );
- }
- catch ( JSchException e )
- {
- handleGetException( resource, e );
- }
- catch ( IOException e )
- {
- handleGetException( resource, e );
- }
- }
-
- public void fillOutputData( OutputData outputData )
- throws TransferFailedException
- {
- Resource resource = outputData.getResource();
-
- String basedir = getRepository().getBasedir();
-
- String path = getPath( basedir, resource.getName() );
-
- String dir = ScpHelper.getResourceDirectory( resource.getName() );
-
- try
- {
- sshTool.createRemoteDirectories( getPath( basedir, dir ), getRepository().getPermissions() );
- }
- catch ( CommandExecutionException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
-
- throw new TransferFailedException( e.getMessage(), e );
- }
-
- String octalMode = getOctalMode( getRepository().getPermissions() );
-
- // exec 'scp -p -t rfile' remotely
- String command = "scp";
- if ( octalMode != null )
- {
- command += " -p";
- }
- command += " -t \"" + path + "\"";
-
- fireTransferDebug( "Executing command: " + command );
-
- String resourceName = resource.getName();
-
- OutputStream out = null;
- try
- {
- channel = (ChannelExec) session.openChannel( EXEC_CHANNEL );
-
- channel.setCommand( command );
-
- // get I/O streams for remote scp
- out = channel.getOutputStream();
- outputData.setOutputStream( out );
-
- channelInputStream = channel.getInputStream();
-
- channel.connect();
-
- checkAck( channelInputStream );
-
- // send "C0644 filesize filename", where filename should not include '/'
- long filesize = resource.getContentLength();
-
- String mode = octalMode == null ? "0644" : octalMode;
- command = "C" + mode + " " + filesize + " ";
-
- if ( resourceName.lastIndexOf( ScpHelper.PATH_SEPARATOR ) > 0 )
- {
- command += resourceName.substring( resourceName.lastIndexOf( ScpHelper.PATH_SEPARATOR ) + 1 );
- }
- else
- {
- command += resourceName;
- }
-
- command += "\n";
-
- out.write( command.getBytes() );
-
- out.flush();
-
- checkAck( channelInputStream );
- }
- catch ( JSchException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
-
- String msg = "Error occurred while deploying '" + resourceName + "' to remote repository: "
- + getRepository().getUrl() + ": " + e.getMessage();
-
- throw new TransferFailedException( msg, e );
- }
- catch ( IOException e )
- {
- handleIOException( resource, e );
- }
- }
-
- private void handleIOException( Resource resource, IOException e )
- throws TransferFailedException
- {
- if ( e.getMessage().contains( "set mode: Operation not permitted" ) )
- {
- fireTransferDebug( e.getMessage() );
- }
- else
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
-
- String msg = "Error occurred while deploying '" + resource.getName() + "' to remote repository: "
- + getRepository().getUrl() + ": " + e.getMessage();
-
- throw new TransferFailedException( msg, e );
- }
- }
-
- public String getOctalMode( RepositoryPermissions permissions )
- {
- String mode = null;
- if ( permissions != null && permissions.getFileMode() != null )
- {
- if ( permissions.getFileMode().matches( "[0-9]{3,4}" ) )
- {
- mode = permissions.getFileMode();
-
- if ( mode.length() == 3 )
- {
- mode = "0" + mode;
- }
- }
- else
- {
- // TODO: calculate?
- // TODO: as warning
- fireSessionDebug( "Not using non-octal permissions: " + permissions.getFileMode() );
- }
- }
- return mode;
- }
-}
+package org.apache.maven.wagon.providers.ssh.jsch;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.jcraft.jsch.ChannelExec;
+import com.jcraft.jsch.JSchException;
+import org.apache.maven.wagon.CommandExecutionException;
+import org.apache.maven.wagon.InputData;
+import org.apache.maven.wagon.OutputData;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.providers.ssh.ScpHelper;
+import org.apache.maven.wagon.repository.RepositoryPermissions;
+import org.apache.maven.wagon.resource.Resource;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * SCP protocol wagon.
+ * <p/>
+ * Note that this implementation is <i>not</i> thread-safe, and multiple channels can not be used on the session at
+ * the same time.
+ * <p/>
+ * See <a href="http://blogs.sun.com/janp/entry/how_the_scp_protocol_works">
+ * http://blogs.sun.com/janp/entry/how_the_scp_protocol_works</a>
+ * for information on how the SCP protocol works.
+ *
+ *
+ * @todo [BP] add compression flag
+ * @plexus.component role="org.apache.maven.wagon.Wagon"
+ * role-hint="scp"
+ * instantiation-strategy="per-lookup"
+ */
+public class ScpWagon
+ extends AbstractJschWagon
+{
+ private static final char COPY_START_CHAR = 'C';
+
+ private static final char ACK_SEPARATOR = ' ';
+
+ private static final String END_OF_FILES_MSG = "E\n";
+
+ private static final int LINE_BUFFER_SIZE = 8192;
+
+ private static final byte LF = '\n';
+
+ private ChannelExec channel;
+
+ private InputStream channelInputStream;
+
+ private OutputStream channelOutputStream;
+
+ private void setFileGroup( RepositoryPermissions permissions, String basedir, Resource resource )
+ throws CommandExecutionException
+ {
+ if ( permissions != null && permissions.getGroup() != null )
+ {
+ //executeCommand( "chgrp -f " + permissions.getGroup() + " " + getPath( basedir, resource.getName() ) );
+ executeCommand( "chgrp -f " + permissions.getGroup() + " \"" + getPath( basedir, resource.getName() )
+ + "\"" );
+ }
+ }
+
+ protected void cleanupPutTransfer( Resource resource )
+ {
+ if ( channel != null )
+ {
+ channel.disconnect();
+ channel = null;
+ }
+ }
+
+ protected void finishPutTransfer( Resource resource, InputStream input, OutputStream output )
+ throws TransferFailedException
+ {
+ try
+ {
+ sendEom( output );
+
+ checkAck( channelInputStream );
+
+ // This came from SCPClient in Ganymede SSH2. It is sent after all files.
+ output.write( END_OF_FILES_MSG.getBytes() );
+ output.flush();
+ }
+ catch ( IOException e )
+ {
+ handleIOException( resource, e );
+ }
+
+ String basedir = getRepository().getBasedir();
+ try
+ {
+ setFileGroup( getRepository().getPermissions(), basedir, resource );
+ }
+ catch ( CommandExecutionException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
+ throw new TransferFailedException( e.getMessage(), e );
+ }
+ }
+
+ private void checkAck( InputStream in )
+ throws IOException
+ {
+ int code = in.read();
+ if ( code == -1 )
+ {
+ throw new IOException( "Unexpected end of data" );
+ }
+ else if ( code == 1 )
+ {
+ String line = readLine( in );
+
+ throw new IOException( "SCP terminated with error: '" + line + "'" );
+ }
+ else if ( code == 2 )
+ {
+ throw new IOException( "SCP terminated with error (code: " + code + ")" );
+ }
+ else if ( code != 0 )
+ {
+ throw new IOException( "SCP terminated with unknown error code" );
+ }
+ }
+
+ protected void finishGetTransfer( Resource resource, InputStream input, OutputStream output )
+ throws TransferFailedException
+ {
+ try
+ {
+ checkAck( input );
+
+ sendEom( channelOutputStream );
+ }
+ catch ( IOException e )
+ {
+ handleGetException( resource, e );
+ }
+ }
+
+ protected void cleanupGetTransfer( Resource resource )
+ {
+ if ( channel != null )
+ {
+ channel.disconnect();
+ }
+ }
+
+ @Deprecated
+ protected void getTransfer( Resource resource, OutputStream output, InputStream input, boolean closeInput,
+ int maxSize )
+ throws TransferFailedException
+ {
+ super.getTransfer( resource, output, input, closeInput, (int) resource.getContentLength() );
+ }
+
+ protected void getTransfer( Resource resource, OutputStream output, InputStream input, boolean closeInput,
+ long maxSize )
+ throws TransferFailedException
+ {
+ super.getTransfer( resource, output, input, closeInput, resource.getContentLength() );
+ }
+
+ protected String readLine( InputStream in )
+ throws IOException
+ {
+ StringBuilder sb = new StringBuilder();
+
+ while ( true )
+ {
+ if ( sb.length() > LINE_BUFFER_SIZE )
+ {
+ throw new IOException( "Remote server sent a too long line" );
+ }
+
+ int c = in.read();
+
+ if ( c < 0 )
+ {
+ throw new IOException( "Remote connection terminated unexpectedly." );
+ }
+
+ if ( c == LF )
+ {
+ break;
+ }
+
+ sb.append( (char) c );
+ }
+ return sb.toString();
+ }
+
+ protected static void sendEom( OutputStream out )
+ throws IOException
+ {
+ out.write( 0 );
+
+ out.flush();
+ }
+
+ public void fillInputData( InputData inputData )
+ throws TransferFailedException, ResourceDoesNotExistException
+ {
+ Resource resource = inputData.getResource();
+
+ String path = getPath( getRepository().getBasedir(), resource.getName() );
+ //String cmd = "scp -p -f " + path;
+ String cmd = "scp -p -f \"" + path + "\"";
+
+ fireTransferDebug( "Executing command: " + cmd );
+
+ try
+ {
+ channel = (ChannelExec) session.openChannel( EXEC_CHANNEL );
+
+ channel.setCommand( cmd );
+
+ // get I/O streams for remote scp
+ channelOutputStream = channel.getOutputStream();
+
+ InputStream in = channel.getInputStream();
+ inputData.setInputStream( in );
+
+ channel.connect();
+
+ sendEom( channelOutputStream );
+
+ int exitCode = in.read();
+
+ if ( exitCode == 'T' )
+ {
+ String line = readLine( in );
+
+ String[] times = line.split( " " );
+
+ resource.setLastModified( Long.valueOf( times[0] ).longValue() * 1000 );
+
+ sendEom( channelOutputStream );
+
+ exitCode = in.read();
+ }
+
+ String line = readLine( in );
+
+ if ( exitCode != COPY_START_CHAR )
+ {
+ if ( exitCode == 1 && ( line.contains( "No such file or directory" )
+ || line.indexOf( "no such file or directory" ) != 1 ) )
+ {
+ throw new ResourceDoesNotExistException( line );
+ }
+ else
+ {
+ throw new IOException( "Exit code: " + exitCode + " - " + line );
+ }
+ }
+
+ if ( line == null )
+ {
+ throw new EOFException( "Unexpected end of data" );
+ }
+
+ String perms = line.substring( 0, 4 );
+ fireTransferDebug( "Remote file permissions: " + perms );
+
+ if ( line.charAt( 4 ) != ACK_SEPARATOR && line.charAt( 5 ) != ACK_SEPARATOR )
+ {
+ throw new IOException( "Invalid transfer header: " + line );
+ }
+
+ int index = line.indexOf( ACK_SEPARATOR, 5 );
+ if ( index < 0 )
+ {
+ throw new IOException( "Invalid transfer header: " + line );
+ }
+
+ long filesize = Long.parseLong( line.substring( 5, index ) );
+ fireTransferDebug( "Remote file size: " + filesize );
+
+ resource.setContentLength( filesize );
+
+ String filename = line.substring( index + 1 );
+ fireTransferDebug( "Remote filename: " + filename );
+
+ sendEom( channelOutputStream );
+ }
+ catch ( JSchException e )
+ {
+ handleGetException( resource, e );
+ }
+ catch ( IOException e )
+ {
+ handleGetException( resource, e );
+ }
+ }
+
+ public void fillOutputData( OutputData outputData )
+ throws TransferFailedException
+ {
+ Resource resource = outputData.getResource();
+
+ String basedir = getRepository().getBasedir();
+
+ String path = getPath( basedir, resource.getName() );
+
+ String dir = ScpHelper.getResourceDirectory( resource.getName() );
+
+ try
+ {
+ sshTool.createRemoteDirectories( getPath( basedir, dir ), getRepository().getPermissions() );
+ }
+ catch ( CommandExecutionException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
+ throw new TransferFailedException( e.getMessage(), e );
+ }
+
+ String octalMode = getOctalMode( getRepository().getPermissions() );
+
+ // exec 'scp -p -t rfile' remotely
+ String command = "scp";
+ if ( octalMode != null )
+ {
+ command += " -p";
+ }
+ command += " -t \"" + path + "\"";
+
+ fireTransferDebug( "Executing command: " + command );
+
+ String resourceName = resource.getName();
+
+ OutputStream out = null;
+ try
+ {
+ channel = (ChannelExec) session.openChannel( EXEC_CHANNEL );
+
+ channel.setCommand( command );
+
+ // get I/O streams for remote scp
+ out = channel.getOutputStream();
+ outputData.setOutputStream( out );
+
+ channelInputStream = channel.getInputStream();
+
+ channel.connect();
+
+ checkAck( channelInputStream );
+
+ // send "C0644 filesize filename", where filename should not include '/'
+ long filesize = resource.getContentLength();
+
+ String mode = octalMode == null ? "0644" : octalMode;
+ command = "C" + mode + " " + filesize + " ";
+
+ if ( resourceName.lastIndexOf( ScpHelper.PATH_SEPARATOR ) > 0 )
+ {
+ command += resourceName.substring( resourceName.lastIndexOf( ScpHelper.PATH_SEPARATOR ) + 1 );
+ }
+ else
+ {
+ command += resourceName;
+ }
+
+ command += "\n";
+
+ out.write( command.getBytes() );
+
+ out.flush();
+
+ checkAck( channelInputStream );
+ }
+ catch ( JSchException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
+ String msg = "Error occurred while deploying '" + resourceName + "' to remote repository: "
+ + getRepository().getUrl() + ": " + e.getMessage();
+
+ throw new TransferFailedException( msg, e );
+ }
+ catch ( IOException e )
+ {
+ handleIOException( resource, e );
+ }
+ }
+
+ private void handleIOException( Resource resource, IOException e )
+ throws TransferFailedException
+ {
+ if ( e.getMessage().contains( "set mode: Operation not permitted" ) )
+ {
+ fireTransferDebug( e.getMessage() );
+ }
+ else
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
+ String msg = "Error occurred while deploying '" + resource.getName() + "' to remote repository: "
+ + getRepository().getUrl() + ": " + e.getMessage();
+
+ throw new TransferFailedException( msg, e );
+ }
+ }
+
+ public String getOctalMode( RepositoryPermissions permissions )
+ {
+ String mode = null;
+ if ( permissions != null && permissions.getFileMode() != null )
+ {
+ if ( permissions.getFileMode().matches( "[0-9]{3,4}" ) )
+ {
+ mode = permissions.getFileMode();
+
+ if ( mode.length() == 3 )
+ {
+ mode = "0" + mode;
+ }
+ }
+ else
+ {
+ // TODO: calculate?
+ // TODO: as warning
+ fireSessionDebug( "Not using non-octal permissions: " + permissions.getFileMode() );
+ }
+ }
+ return mode;
+ }
+}
diff --git a/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/SftpWagon.java b/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/SftpWagon.java
index 06d952a..d92906c 100644
--- a/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/SftpWagon.java
+++ b/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/SftpWagon.java
@@ -1,569 +1,569 @@
-package org.apache.maven.wagon.providers.ssh.jsch;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.maven.wagon.InputData;
-import org.apache.maven.wagon.OutputData;
-import org.apache.maven.wagon.PathUtils;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
-import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.authorization.AuthorizationException;
-import org.apache.maven.wagon.events.TransferEvent;
-import org.apache.maven.wagon.providers.ssh.ScpHelper;
-import org.apache.maven.wagon.repository.RepositoryPermissions;
-import org.apache.maven.wagon.resource.Resource;
-
-import com.jcraft.jsch.ChannelSftp;
-import com.jcraft.jsch.JSchException;
-import com.jcraft.jsch.SftpATTRS;
-import com.jcraft.jsch.SftpException;
-
-/**
- * SFTP protocol wagon.
- *
- * @author <a href="mailto:brett at apache.org">Brett Porter</a>
- *
- * @todo [BP] add compression flag
- * @todo see if SftpProgressMonitor allows us to do streaming (without it, we can't do checksums as the input stream is lost)
- *
- * @plexus.component role="org.apache.maven.wagon.Wagon"
- * role-hint="sftp"
- * instantiation-strategy="per-lookup"
- */
-public class SftpWagon
- extends AbstractJschWagon
-{
- private static final String SFTP_CHANNEL = "sftp";
-
- private static final int S_IFDIR = 0x4000;
-
- private static final long MILLIS_PER_SEC = 1000L;
-
- private ChannelSftp channel;
-
- public void closeConnection()
- {
- if ( channel != null )
- {
- channel.disconnect();
- }
- super.closeConnection();
- }
-
- public void openConnectionInternal()
- throws AuthenticationException
- {
- super.openConnectionInternal();
-
- try
- {
- channel = (ChannelSftp) session.openChannel( SFTP_CHANNEL );
-
- channel.connect();
- }
- catch ( JSchException e )
- {
- throw new AuthenticationException( "Error connecting to remote repository: " + getRepository().getUrl(),
- e );
- }
- }
-
- private void returnToParentDirectory( Resource resource )
- {
- try
- {
- String dir = ScpHelper.getResourceDirectory( resource.getName() );
- String[] dirs = PathUtils.dirnames( dir );
- for ( String d : dirs )
- {
- channel.cd( ".." );
- }
- }
- catch ( SftpException e )
- {
- fireTransferDebug( "Error returning to parent directory: " + e.getMessage() );
- }
- }
-
- private void putFile( File source, Resource resource, RepositoryPermissions permissions )
- throws SftpException, TransferFailedException
- {
- resource.setContentLength( source.length() );
-
- resource.setLastModified( source.lastModified() );
-
- String filename = ScpHelper.getResourceFilename( resource.getName() );
-
- firePutStarted( resource, source );
-
- channel.put( source.getAbsolutePath(), filename );
-
- postProcessListeners( resource, source, TransferEvent.REQUEST_PUT );
-
- if ( permissions != null && permissions.getGroup() != null )
- {
- setGroup( filename, permissions );
- }
-
- if ( permissions != null && permissions.getFileMode() != null )
- {
- setFileMode( filename, permissions );
- }
-
- firePutCompleted( resource, source );
- }
-
- private void setGroup( String filename, RepositoryPermissions permissions )
- {
- try
- {
- int group = Integer.valueOf( permissions.getGroup() ).intValue();
- channel.chgrp( group, filename );
- }
- catch ( NumberFormatException e )
- {
- // TODO: warning level
- fireTransferDebug( "Not setting group: must be a numerical GID for SFTP" );
- }
- catch ( SftpException e )
- {
- fireTransferDebug( "Not setting group: " + e.getMessage() );
- }
- }
-
- private void setFileMode( String filename, RepositoryPermissions permissions )
- {
- try
- {
- int mode = getOctalMode( permissions.getFileMode() );
- channel.chmod( mode, filename );
- }
- catch ( NumberFormatException e )
- {
- // TODO: warning level
- fireTransferDebug( "Not setting mode: must be a numerical mode for SFTP" );
- }
- catch ( SftpException e )
- {
- fireTransferDebug( "Not setting mode: " + e.getMessage() );
- }
- }
-
- private void mkdirs( String resourceName, int mode )
- throws SftpException, TransferFailedException
- {
- String[] dirs = PathUtils.dirnames( resourceName );
- for ( String dir : dirs )
- {
- mkdir( dir, mode );
-
- channel.cd( dir );
- }
- }
-
- private void mkdir( String dir, int mode )
- throws TransferFailedException, SftpException
- {
- try
- {
- SftpATTRS attrs = channel.stat( dir );
- if ( ( attrs.getPermissions() & S_IFDIR ) == 0 )
- {
- throw new TransferFailedException( "Remote path is not a directory: " + dir );
- }
- }
- catch ( SftpException e )
- {
- // doesn't exist, make it and try again
- channel.mkdir( dir );
- if ( mode != -1 )
- {
- try
- {
- channel.chmod( mode, dir );
- }
- catch ( SftpException e1 )
- {
- // for some extrange reason we recive this exception,
- // even when chmod success
- }
- }
- }
- }
-
- private SftpATTRS changeToRepositoryDirectory( String dir, String filename )
- throws ResourceDoesNotExistException, SftpException
- {
- // This must be called first to ensure that if the file doesn't exist it throws an exception
- SftpATTRS attrs;
- try
- {
- channel.cd( repository.getBasedir() );
-
- if ( dir.length() > 0 )
- {
- channel.cd( dir );
- }
-
- if ( filename.length() == 0 )
- {
- filename = ".";
- }
-
- attrs = channel.stat( filename );
- }
- catch ( SftpException e )
- {
- if ( e.toString().trim().endsWith( "No such file" ) )
- {
- throw new ResourceDoesNotExistException( e.toString(), e );
- }
- else if ( e.toString().trim().contains( "Can't change directory" ) )
- {
- throw new ResourceDoesNotExistException( e.toString(), e );
- }
- else
- {
- throw e;
- }
- }
- return attrs;
- }
-
- public void putDirectory( File sourceDirectory, String destinationDirectory )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- final RepositoryPermissions permissions = repository.getPermissions();
-
- try
- {
- channel.cd( "/" );
-
- String basedir = getRepository().getBasedir();
- int directoryMode = getDirectoryMode( permissions );
-
- mkdirs( basedir + "/", directoryMode );
-
- fireTransferDebug( "Recursively uploading directory " + sourceDirectory.getAbsolutePath() + " as "
- + destinationDirectory );
-
- mkdirs( destinationDirectory, directoryMode );
- ftpRecursivePut( sourceDirectory, null, ScpHelper.getResourceFilename( destinationDirectory ),
- directoryMode );
- }
- catch ( SftpException e )
- {
- String msg =
- "Error occurred while deploying '" + sourceDirectory.getAbsolutePath() + "' " + "to remote repository: "
- + getRepository().getUrl() + ": " + e.getMessage();
-
- throw new TransferFailedException( msg, e );
- }
- }
-
- private void ftpRecursivePut( File sourceFile, String prefix, String fileName, int directoryMode )
- throws TransferFailedException, SftpException
- {
- final RepositoryPermissions permissions = repository.getPermissions();
-
- if ( sourceFile.isDirectory() )
- {
- // ScpHelper.getResourceFilename( destinationDirectory ) - could return empty string
- if ( !fileName.equals( "." ) && !fileName.equals( "" ) )
- {
- prefix = getFileName( prefix, fileName );
- mkdir( fileName, directoryMode );
- channel.cd( fileName );
- }
-
- File[] files = sourceFile.listFiles();
- if ( files != null && files.length > 0 )
- {
- // Directories first, then files. Let's go deep early.
- for ( File file : files )
- {
- if ( file.isDirectory() )
- {
- ftpRecursivePut( file, prefix, file.getName(), directoryMode );
- }
- }
- for ( File file : files )
- {
- if ( !file.isDirectory() )
- {
- ftpRecursivePut( file, prefix, file.getName(), directoryMode );
- }
- }
- }
-
- channel.cd( ".." );
- }
- else
- {
- Resource resource = ScpHelper.getResource( getFileName( prefix, fileName ) );
-
- firePutInitiated( resource, sourceFile );
-
- putFile( sourceFile, resource, permissions );
- }
- }
-
- private String getFileName( String prefix, String fileName )
- {
- if ( prefix != null )
- {
- prefix = prefix + "/" + fileName;
- }
- else
- {
- prefix = fileName;
- }
- return prefix;
- }
-
- public List<String> getFileList( String destinationDirectory )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- if ( destinationDirectory.length() == 0 )
- {
- destinationDirectory = ".";
- }
-
- String filename = ScpHelper.getResourceFilename( destinationDirectory );
-
- String dir = ScpHelper.getResourceDirectory( destinationDirectory );
-
- // we already setuped the root directory. Ignore beginning /
- if ( dir.length() > 0 && dir.charAt( 0 ) == ScpHelper.PATH_SEPARATOR )
- {
- dir = dir.substring( 1 );
- }
-
- try
- {
- SftpATTRS attrs = changeToRepositoryDirectory( dir, filename );
- if ( ( attrs.getPermissions() & S_IFDIR ) == 0 )
- {
- throw new TransferFailedException( "Remote path is not a directory:" + dir );
- }
-
- @SuppressWarnings( "unchecked" )
- List<ChannelSftp.LsEntry> fileList = channel.ls( filename );
- List<String> files = new ArrayList<String>( fileList.size() );
- for ( ChannelSftp.LsEntry entry : fileList )
- {
- String name = entry.getFilename();
- if ( entry.getAttrs().isDir() )
- {
- if ( !name.equals( "." ) && !name.equals( ".." ) )
- {
- if ( !name.endsWith( "/" ) )
- {
- name += "/";
- }
- files.add( name );
- }
- }
- else
- {
- files.add( name );
- }
- }
- return files;
- }
- catch ( SftpException e )
- {
- String msg =
- "Error occurred while listing '" + destinationDirectory + "' " + "on remote repository: "
- + getRepository().getUrl() + ": " + e.getMessage();
-
- throw new TransferFailedException( msg, e );
- }
- }
-
- public boolean resourceExists( String resourceName )
- throws TransferFailedException, AuthorizationException
- {
- String filename = ScpHelper.getResourceFilename( resourceName );
-
- String dir = ScpHelper.getResourceDirectory( resourceName );
-
- // we already setuped the root directory. Ignore beginning /
- if ( dir.length() > 0 && dir.charAt( 0 ) == ScpHelper.PATH_SEPARATOR )
- {
- dir = dir.substring( 1 );
- }
-
- try
- {
- changeToRepositoryDirectory( dir, filename );
-
- return true;
- }
- catch ( ResourceDoesNotExistException e )
- {
- return false;
- }
- catch ( SftpException e )
- {
- String msg =
- "Error occurred while looking for '" + resourceName + "' " + "on remote repository: "
- + getRepository().getUrl() + ": " + e.getMessage();
-
- throw new TransferFailedException( msg, e );
- }
- }
-
- protected void cleanupGetTransfer( Resource resource )
- {
- returnToParentDirectory( resource );
- }
-
- protected void cleanupPutTransfer( Resource resource )
- {
- returnToParentDirectory( resource );
- }
-
- protected void finishPutTransfer( Resource resource, InputStream input, OutputStream output )
- throws TransferFailedException
- {
- RepositoryPermissions permissions = getRepository().getPermissions();
-
- String filename = ScpHelper.getResourceFilename( resource.getName() );
- if ( permissions != null && permissions.getGroup() != null )
- {
- setGroup( filename, permissions );
- }
-
- if ( permissions != null && permissions.getFileMode() != null )
- {
- setFileMode( filename, permissions );
- }
- }
-
- public void fillInputData( InputData inputData )
- throws TransferFailedException, ResourceDoesNotExistException
- {
- Resource resource = inputData.getResource();
-
- String filename = ScpHelper.getResourceFilename( resource.getName() );
-
- String dir = ScpHelper.getResourceDirectory( resource.getName() );
-
- // we already setuped the root directory. Ignore beginning /
- if ( dir.length() > 0 && dir.charAt( 0 ) == ScpHelper.PATH_SEPARATOR )
- {
- dir = dir.substring( 1 );
- }
-
- try
- {
- SftpATTRS attrs = changeToRepositoryDirectory( dir, filename );
-
- long lastModified = attrs.getMTime() * MILLIS_PER_SEC;
- resource.setContentLength( attrs.getSize() );
-
- resource.setLastModified( lastModified );
-
- inputData.setInputStream( channel.get( filename ) );
- }
- catch ( SftpException e )
- {
- handleGetException( resource, e );
- }
- }
-
- public void fillOutputData( OutputData outputData )
- throws TransferFailedException
- {
- int directoryMode = getDirectoryMode( getRepository().getPermissions() );
-
- Resource resource = outputData.getResource();
-
- try
- {
- channel.cd( "/" );
-
- String basedir = getRepository().getBasedir();
- mkdirs( basedir + "/", directoryMode );
-
- mkdirs( resource.getName(), directoryMode );
-
- String filename = ScpHelper.getResourceFilename( resource.getName() );
- outputData.setOutputStream( channel.put( filename ) );
- }
- catch ( TransferFailedException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
-
- throw e;
- }
- catch ( SftpException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
-
- String msg =
- "Error occurred while deploying '" + resource.getName() + "' " + "to remote repository: "
- + getRepository().getUrl() + ": " + e.getMessage();
-
- throw new TransferFailedException( msg, e );
- }
- }
-
- /**
- * @param permissions repository's permissions
- * @return the directory mode for the repository or <code>-1</code> if it
- * wasn't set
- */
- public int getDirectoryMode( RepositoryPermissions permissions )
- {
- int ret = -1;
-
- if ( permissions != null )
- {
- ret = getOctalMode( permissions.getDirectoryMode() );
- }
-
- return ret;
- }
-
- public int getOctalMode( String mode )
- {
- int ret;
- try
- {
- ret = Integer.valueOf( mode, 8 ).intValue();
- }
- catch ( NumberFormatException e )
- {
- // TODO: warning level
- fireTransferDebug( "the file mode must be a numerical mode for SFTP" );
- ret = -1;
- }
- return ret;
- }
-}
+package org.apache.maven.wagon.providers.ssh.jsch;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.wagon.InputData;
+import org.apache.maven.wagon.OutputData;
+import org.apache.maven.wagon.PathUtils;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.providers.ssh.ScpHelper;
+import org.apache.maven.wagon.repository.RepositoryPermissions;
+import org.apache.maven.wagon.resource.Resource;
+
+import com.jcraft.jsch.ChannelSftp;
+import com.jcraft.jsch.JSchException;
+import com.jcraft.jsch.SftpATTRS;
+import com.jcraft.jsch.SftpException;
+
+/**
+ * SFTP protocol wagon.
+ *
+ * @author <a href="mailto:brett at apache.org">Brett Porter</a>
+ *
+ * @todo [BP] add compression flag
+ * @todo see if SftpProgressMonitor allows us to do streaming (without it, we can't do checksums as the input stream is lost)
+ *
+ * @plexus.component role="org.apache.maven.wagon.Wagon"
+ * role-hint="sftp"
+ * instantiation-strategy="per-lookup"
+ */
+public class SftpWagon
+ extends AbstractJschWagon
+{
+ private static final String SFTP_CHANNEL = "sftp";
+
+ private static final int S_IFDIR = 0x4000;
+
+ private static final long MILLIS_PER_SEC = 1000L;
+
+ private ChannelSftp channel;
+
+ public void closeConnection()
+ {
+ if ( channel != null )
+ {
+ channel.disconnect();
+ }
+ super.closeConnection();
+ }
+
+ public void openConnectionInternal()
+ throws AuthenticationException
+ {
+ super.openConnectionInternal();
+
+ try
+ {
+ channel = (ChannelSftp) session.openChannel( SFTP_CHANNEL );
+
+ channel.connect();
+ }
+ catch ( JSchException e )
+ {
+ throw new AuthenticationException( "Error connecting to remote repository: " + getRepository().getUrl(),
+ e );
+ }
+ }
+
+ private void returnToParentDirectory( Resource resource )
+ {
+ try
+ {
+ String dir = ScpHelper.getResourceDirectory( resource.getName() );
+ String[] dirs = PathUtils.dirnames( dir );
+ for ( String d : dirs )
+ {
+ channel.cd( ".." );
+ }
+ }
+ catch ( SftpException e )
+ {
+ fireTransferDebug( "Error returning to parent directory: " + e.getMessage() );
+ }
+ }
+
+ private void putFile( File source, Resource resource, RepositoryPermissions permissions )
+ throws SftpException, TransferFailedException
+ {
+ resource.setContentLength( source.length() );
+
+ resource.setLastModified( source.lastModified() );
+
+ String filename = ScpHelper.getResourceFilename( resource.getName() );
+
+ firePutStarted( resource, source );
+
+ channel.put( source.getAbsolutePath(), filename );
+
+ postProcessListeners( resource, source, TransferEvent.REQUEST_PUT );
+
+ if ( permissions != null && permissions.getGroup() != null )
+ {
+ setGroup( filename, permissions );
+ }
+
+ if ( permissions != null && permissions.getFileMode() != null )
+ {
+ setFileMode( filename, permissions );
+ }
+
+ firePutCompleted( resource, source );
+ }
+
+ private void setGroup( String filename, RepositoryPermissions permissions )
+ {
+ try
+ {
+ int group = Integer.valueOf( permissions.getGroup() ).intValue();
+ channel.chgrp( group, filename );
+ }
+ catch ( NumberFormatException e )
+ {
+ // TODO: warning level
+ fireTransferDebug( "Not setting group: must be a numerical GID for SFTP" );
+ }
+ catch ( SftpException e )
+ {
+ fireTransferDebug( "Not setting group: " + e.getMessage() );
+ }
+ }
+
+ private void setFileMode( String filename, RepositoryPermissions permissions )
+ {
+ try
+ {
+ int mode = getOctalMode( permissions.getFileMode() );
+ channel.chmod( mode, filename );
+ }
+ catch ( NumberFormatException e )
+ {
+ // TODO: warning level
+ fireTransferDebug( "Not setting mode: must be a numerical mode for SFTP" );
+ }
+ catch ( SftpException e )
+ {
+ fireTransferDebug( "Not setting mode: " + e.getMessage() );
+ }
+ }
+
+ private void mkdirs( String resourceName, int mode )
+ throws SftpException, TransferFailedException
+ {
+ String[] dirs = PathUtils.dirnames( resourceName );
+ for ( String dir : dirs )
+ {
+ mkdir( dir, mode );
+
+ channel.cd( dir );
+ }
+ }
+
+ private void mkdir( String dir, int mode )
+ throws TransferFailedException, SftpException
+ {
+ try
+ {
+ SftpATTRS attrs = channel.stat( dir );
+ if ( ( attrs.getPermissions() & S_IFDIR ) == 0 )
+ {
+ throw new TransferFailedException( "Remote path is not a directory: " + dir );
+ }
+ }
+ catch ( SftpException e )
+ {
+ // doesn't exist, make it and try again
+ channel.mkdir( dir );
+ if ( mode != -1 )
+ {
+ try
+ {
+ channel.chmod( mode, dir );
+ }
+ catch ( SftpException e1 )
+ {
+ // for some extrange reason we recive this exception,
+ // even when chmod success
+ }
+ }
+ }
+ }
+
+ private SftpATTRS changeToRepositoryDirectory( String dir, String filename )
+ throws ResourceDoesNotExistException, SftpException
+ {
+ // This must be called first to ensure that if the file doesn't exist it throws an exception
+ SftpATTRS attrs;
+ try
+ {
+ channel.cd( repository.getBasedir() );
+
+ if ( dir.length() > 0 )
+ {
+ channel.cd( dir );
+ }
+
+ if ( filename.length() == 0 )
+ {
+ filename = ".";
+ }
+
+ attrs = channel.stat( filename );
+ }
+ catch ( SftpException e )
+ {
+ if ( e.toString().trim().endsWith( "No such file" ) )
+ {
+ throw new ResourceDoesNotExistException( e.toString(), e );
+ }
+ else if ( e.toString().trim().contains( "Can't change directory" ) )
+ {
+ throw new ResourceDoesNotExistException( e.toString(), e );
+ }
+ else
+ {
+ throw e;
+ }
+ }
+ return attrs;
+ }
+
+ public void putDirectory( File sourceDirectory, String destinationDirectory )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ final RepositoryPermissions permissions = repository.getPermissions();
+
+ try
+ {
+ channel.cd( "/" );
+
+ String basedir = getRepository().getBasedir();
+ int directoryMode = getDirectoryMode( permissions );
+
+ mkdirs( basedir + "/", directoryMode );
+
+ fireTransferDebug( "Recursively uploading directory " + sourceDirectory.getAbsolutePath() + " as "
+ + destinationDirectory );
+
+ mkdirs( destinationDirectory, directoryMode );
+ ftpRecursivePut( sourceDirectory, null, ScpHelper.getResourceFilename( destinationDirectory ),
+ directoryMode );
+ }
+ catch ( SftpException e )
+ {
+ String msg =
+ "Error occurred while deploying '" + sourceDirectory.getAbsolutePath() + "' " + "to remote repository: "
+ + getRepository().getUrl() + ": " + e.getMessage();
+
+ throw new TransferFailedException( msg, e );
+ }
+ }
+
+ private void ftpRecursivePut( File sourceFile, String prefix, String fileName, int directoryMode )
+ throws TransferFailedException, SftpException
+ {
+ final RepositoryPermissions permissions = repository.getPermissions();
+
+ if ( sourceFile.isDirectory() )
+ {
+ // ScpHelper.getResourceFilename( destinationDirectory ) - could return empty string
+ if ( !fileName.equals( "." ) && !fileName.equals( "" ) )
+ {
+ prefix = getFileName( prefix, fileName );
+ mkdir( fileName, directoryMode );
+ channel.cd( fileName );
+ }
+
+ File[] files = sourceFile.listFiles();
+ if ( files != null && files.length > 0 )
+ {
+ // Directories first, then files. Let's go deep early.
+ for ( File file : files )
+ {
+ if ( file.isDirectory() )
+ {
+ ftpRecursivePut( file, prefix, file.getName(), directoryMode );
+ }
+ }
+ for ( File file : files )
+ {
+ if ( !file.isDirectory() )
+ {
+ ftpRecursivePut( file, prefix, file.getName(), directoryMode );
+ }
+ }
+ }
+
+ channel.cd( ".." );
+ }
+ else
+ {
+ Resource resource = ScpHelper.getResource( getFileName( prefix, fileName ) );
+
+ firePutInitiated( resource, sourceFile );
+
+ putFile( sourceFile, resource, permissions );
+ }
+ }
+
+ private String getFileName( String prefix, String fileName )
+ {
+ if ( prefix != null )
+ {
+ prefix = prefix + "/" + fileName;
+ }
+ else
+ {
+ prefix = fileName;
+ }
+ return prefix;
+ }
+
+ public List<String> getFileList( String destinationDirectory )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ if ( destinationDirectory.length() == 0 )
+ {
+ destinationDirectory = ".";
+ }
+
+ String filename = ScpHelper.getResourceFilename( destinationDirectory );
+
+ String dir = ScpHelper.getResourceDirectory( destinationDirectory );
+
+ // we already setuped the root directory. Ignore beginning /
+ if ( dir.length() > 0 && dir.charAt( 0 ) == ScpHelper.PATH_SEPARATOR )
+ {
+ dir = dir.substring( 1 );
+ }
+
+ try
+ {
+ SftpATTRS attrs = changeToRepositoryDirectory( dir, filename );
+ if ( ( attrs.getPermissions() & S_IFDIR ) == 0 )
+ {
+ throw new TransferFailedException( "Remote path is not a directory:" + dir );
+ }
+
+ @SuppressWarnings( "unchecked" )
+ List<ChannelSftp.LsEntry> fileList = channel.ls( filename );
+ List<String> files = new ArrayList<String>( fileList.size() );
+ for ( ChannelSftp.LsEntry entry : fileList )
+ {
+ String name = entry.getFilename();
+ if ( entry.getAttrs().isDir() )
+ {
+ if ( !name.equals( "." ) && !name.equals( ".." ) )
+ {
+ if ( !name.endsWith( "/" ) )
+ {
+ name += "/";
+ }
+ files.add( name );
+ }
+ }
+ else
+ {
+ files.add( name );
+ }
+ }
+ return files;
+ }
+ catch ( SftpException e )
+ {
+ String msg =
+ "Error occurred while listing '" + destinationDirectory + "' " + "on remote repository: "
+ + getRepository().getUrl() + ": " + e.getMessage();
+
+ throw new TransferFailedException( msg, e );
+ }
+ }
+
+ public boolean resourceExists( String resourceName )
+ throws TransferFailedException, AuthorizationException
+ {
+ String filename = ScpHelper.getResourceFilename( resourceName );
+
+ String dir = ScpHelper.getResourceDirectory( resourceName );
+
+ // we already setuped the root directory. Ignore beginning /
+ if ( dir.length() > 0 && dir.charAt( 0 ) == ScpHelper.PATH_SEPARATOR )
+ {
+ dir = dir.substring( 1 );
+ }
+
+ try
+ {
+ changeToRepositoryDirectory( dir, filename );
+
+ return true;
+ }
+ catch ( ResourceDoesNotExistException e )
+ {
+ return false;
+ }
+ catch ( SftpException e )
+ {
+ String msg =
+ "Error occurred while looking for '" + resourceName + "' " + "on remote repository: "
+ + getRepository().getUrl() + ": " + e.getMessage();
+
+ throw new TransferFailedException( msg, e );
+ }
+ }
+
+ protected void cleanupGetTransfer( Resource resource )
+ {
+ returnToParentDirectory( resource );
+ }
+
+ protected void cleanupPutTransfer( Resource resource )
+ {
+ returnToParentDirectory( resource );
+ }
+
+ protected void finishPutTransfer( Resource resource, InputStream input, OutputStream output )
+ throws TransferFailedException
+ {
+ RepositoryPermissions permissions = getRepository().getPermissions();
+
+ String filename = ScpHelper.getResourceFilename( resource.getName() );
+ if ( permissions != null && permissions.getGroup() != null )
+ {
+ setGroup( filename, permissions );
+ }
+
+ if ( permissions != null && permissions.getFileMode() != null )
+ {
+ setFileMode( filename, permissions );
+ }
+ }
+
+ public void fillInputData( InputData inputData )
+ throws TransferFailedException, ResourceDoesNotExistException
+ {
+ Resource resource = inputData.getResource();
+
+ String filename = ScpHelper.getResourceFilename( resource.getName() );
+
+ String dir = ScpHelper.getResourceDirectory( resource.getName() );
+
+ // we already setuped the root directory. Ignore beginning /
+ if ( dir.length() > 0 && dir.charAt( 0 ) == ScpHelper.PATH_SEPARATOR )
+ {
+ dir = dir.substring( 1 );
+ }
+
+ try
+ {
+ SftpATTRS attrs = changeToRepositoryDirectory( dir, filename );
+
+ long lastModified = attrs.getMTime() * MILLIS_PER_SEC;
+ resource.setContentLength( attrs.getSize() );
+
+ resource.setLastModified( lastModified );
+
+ inputData.setInputStream( channel.get( filename ) );
+ }
+ catch ( SftpException e )
+ {
+ handleGetException( resource, e );
+ }
+ }
+
+ public void fillOutputData( OutputData outputData )
+ throws TransferFailedException
+ {
+ int directoryMode = getDirectoryMode( getRepository().getPermissions() );
+
+ Resource resource = outputData.getResource();
+
+ try
+ {
+ channel.cd( "/" );
+
+ String basedir = getRepository().getBasedir();
+ mkdirs( basedir + "/", directoryMode );
+
+ mkdirs( resource.getName(), directoryMode );
+
+ String filename = ScpHelper.getResourceFilename( resource.getName() );
+ outputData.setOutputStream( channel.put( filename ) );
+ }
+ catch ( TransferFailedException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
+ throw e;
+ }
+ catch ( SftpException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
+ String msg =
+ "Error occurred while deploying '" + resource.getName() + "' " + "to remote repository: "
+ + getRepository().getUrl() + ": " + e.getMessage();
+
+ throw new TransferFailedException( msg, e );
+ }
+ }
+
+ /**
+ * @param permissions repository's permissions
+ * @return the directory mode for the repository or <code>-1</code> if it
+ * wasn't set
+ */
+ public int getDirectoryMode( RepositoryPermissions permissions )
+ {
+ int ret = -1;
+
+ if ( permissions != null )
+ {
+ ret = getOctalMode( permissions.getDirectoryMode() );
+ }
+
+ return ret;
+ }
+
+ public int getOctalMode( String mode )
+ {
+ int ret;
+ try
+ {
+ ret = Integer.valueOf( mode, 8 ).intValue();
+ }
+ catch ( NumberFormatException e )
+ {
+ // TODO: warning level
+ fireTransferDebug( "the file mode must be a numerical mode for SFTP" );
+ ret = -1;
+ }
+ return ret;
+ }
+}
diff --git a/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/WagonUserInfo.java b/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/WagonUserInfo.java
index 50a107b..97240a2 100644
--- a/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/WagonUserInfo.java
+++ b/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/WagonUserInfo.java
@@ -1,89 +1,89 @@
-package org.apache.maven.wagon.providers.ssh.jsch;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.jcraft.jsch.UserInfo;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
-import org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo;
-
-/**
- * WagonUserInfo
- *
- *
- */
-class WagonUserInfo
- implements UserInfo
-{
- private final InteractiveUserInfo userInfo;
-
- private String password;
-
- private String passphrase;
-
- WagonUserInfo( AuthenticationInfo authInfo, InteractiveUserInfo userInfo )
- {
- this.userInfo = userInfo;
-
- this.password = authInfo.getPassword();
-
- this.passphrase = authInfo.getPassphrase();
- }
-
- public String getPassphrase()
- {
- return passphrase;
- }
-
- public String getPassword()
- {
- return password;
- }
-
- public boolean promptPassphrase( String message )
- {
- if ( passphrase == null && userInfo != null )
- {
- passphrase = userInfo.promptPassphrase( message );
- }
- return passphrase != null;
- }
-
- public boolean promptPassword( String message )
- {
- if ( password == null && userInfo != null )
- {
- password = userInfo.promptPassword( message );
- }
- return password != null;
- }
-
- public boolean promptYesNo( String message )
- {
- return userInfo != null && userInfo.promptYesNo( message );
- }
-
- public void showMessage( String message )
- {
- if ( userInfo != null )
- {
- userInfo.showMessage( message );
- }
- }
-}
+package org.apache.maven.wagon.providers.ssh.jsch;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.jcraft.jsch.UserInfo;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo;
+
+/**
+ * WagonUserInfo
+ *
+ *
+ */
+class WagonUserInfo
+ implements UserInfo
+{
+ private final InteractiveUserInfo userInfo;
+
+ private String password;
+
+ private String passphrase;
+
+ WagonUserInfo( AuthenticationInfo authInfo, InteractiveUserInfo userInfo )
+ {
+ this.userInfo = userInfo;
+
+ this.password = authInfo.getPassword();
+
+ this.passphrase = authInfo.getPassphrase();
+ }
+
+ public String getPassphrase()
+ {
+ return passphrase;
+ }
+
+ public String getPassword()
+ {
+ return password;
+ }
+
+ public boolean promptPassphrase( String message )
+ {
+ if ( passphrase == null && userInfo != null )
+ {
+ passphrase = userInfo.promptPassphrase( message );
+ }
+ return passphrase != null;
+ }
+
+ public boolean promptPassword( String message )
+ {
+ if ( password == null && userInfo != null )
+ {
+ password = userInfo.promptPassword( message );
+ }
+ return password != null;
+ }
+
+ public boolean promptYesNo( String message )
+ {
+ return userInfo != null && userInfo.promptYesNo( message );
+ }
+
+ public void showMessage( String message )
+ {
+ if ( userInfo != null )
+ {
+ userInfo.showMessage( message );
+ }
+ }
+}
diff --git a/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/interactive/PrompterUIKeyboardInteractive.java b/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/interactive/PrompterUIKeyboardInteractive.java
index ff33fae..8ad59ca 100644
--- a/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/interactive/PrompterUIKeyboardInteractive.java
+++ b/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/interactive/PrompterUIKeyboardInteractive.java
@@ -1,94 +1,94 @@
-package org.apache.maven.wagon.providers.ssh.jsch.interactive;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.jcraft.jsch.UIKeyboardInteractive;
-import org.codehaus.plexus.components.interactivity.Prompter;
-import org.codehaus.plexus.components.interactivity.PrompterException;
-
-/**
- * UIKeyboardInteractive that use plexus-prompter.
- *
- * <code>UIKeyboardInteractive</code> are usefull when you don't use user with
- * password authentication with a server that use keyboard-interactive and
- * doesn't allow password method <code>PasswordAuthentication no</code>.
- *
- * @author <a href="mailto:juam at users.sourceforge.net">Juan F. Codagnone</a>
- * @since Sep 22, 2005
- *
- * @plexus.component role="com.jcraft.jsch.UIKeyboardInteractive"
- */
-public class PrompterUIKeyboardInteractive
- implements UIKeyboardInteractive
-{
- /**
- * @plexus.requirement role-hint="default"
- */
- private volatile Prompter prompter;
-
- public PrompterUIKeyboardInteractive()
- {
- }
-
- public PrompterUIKeyboardInteractive( Prompter promper )
- {
- this.prompter = promper;
- }
-
- /**
- * @see UIKeyboardInteractive#promptKeyboardInteractive(String,String,
- *String,String[],boolean[])
- */
- public String[] promptKeyboardInteractive( String destination, String name, String instruction, String[] prompt,
- boolean[] echo )
- {
-
- if ( prompt.length != echo.length )
- {
- // jcsh is buggy?
- throw new IllegalArgumentException( "prompt and echo size arrays are different!" );
- }
- String[] ret = new String[prompt.length];
-
- try
- {
-
- for ( int i = 0; i < ret.length; i++ )
- {
- if ( echo[i] )
- {
- ret[i] = prompter.prompt( prompt[i] );
- }
- else
- {
- ret[i] = prompter.promptForPassword( prompt[i] );
- }
- }
- }
- catch ( PrompterException e )
- {
- // TODO: log
- // the user canceled?
- ret = null;
- }
-
- return ret;
- }
-}
+package org.apache.maven.wagon.providers.ssh.jsch.interactive;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.jcraft.jsch.UIKeyboardInteractive;
+import org.codehaus.plexus.components.interactivity.Prompter;
+import org.codehaus.plexus.components.interactivity.PrompterException;
+
+/**
+ * UIKeyboardInteractive that use plexus-prompter.
+ *
+ * <code>UIKeyboardInteractive</code> are usefull when you don't use user with
+ * password authentication with a server that use keyboard-interactive and
+ * doesn't allow password method <code>PasswordAuthentication no</code>.
+ *
+ * @author <a href="mailto:juam at users.sourceforge.net">Juan F. Codagnone</a>
+ * @since Sep 22, 2005
+ *
+ * @plexus.component role="com.jcraft.jsch.UIKeyboardInteractive"
+ */
+public class PrompterUIKeyboardInteractive
+ implements UIKeyboardInteractive
+{
+ /**
+ * @plexus.requirement role-hint="default"
+ */
+ private volatile Prompter prompter;
+
+ public PrompterUIKeyboardInteractive()
+ {
+ }
+
+ public PrompterUIKeyboardInteractive( Prompter promper )
+ {
+ this.prompter = promper;
+ }
+
+ /**
+ * @see UIKeyboardInteractive#promptKeyboardInteractive(String,String,
+ *String,String[],boolean[])
+ */
+ public String[] promptKeyboardInteractive( String destination, String name, String instruction, String[] prompt,
+ boolean[] echo )
+ {
+
+ if ( prompt.length != echo.length )
+ {
+ // jcsh is buggy?
+ throw new IllegalArgumentException( "prompt and echo size arrays are different!" );
+ }
+ String[] ret = new String[prompt.length];
+
+ try
+ {
+
+ for ( int i = 0; i < ret.length; i++ )
+ {
+ if ( echo[i] )
+ {
+ ret[i] = prompter.prompt( prompt[i] );
+ }
+ else
+ {
+ ret[i] = prompter.promptForPassword( prompt[i] );
+ }
+ }
+ }
+ catch ( PrompterException e )
+ {
+ // TODO: log
+ // the user canceled?
+ ret = null;
+ }
+
+ return ret;
+ }
+}
diff --git a/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/interactive/UserInfoUIKeyboardInteractiveProxy.java b/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/interactive/UserInfoUIKeyboardInteractiveProxy.java
index d728b58..f311e3d 100644
--- a/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/interactive/UserInfoUIKeyboardInteractiveProxy.java
+++ b/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/interactive/UserInfoUIKeyboardInteractiveProxy.java
@@ -1,106 +1,106 @@
-package org.apache.maven.wagon.providers.ssh.jsch.interactive;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import com.jcraft.jsch.UIKeyboardInteractive;
-import com.jcraft.jsch.UserInfo;
-
-/**
- * A proxy that let you merge a <code>UserInfo</code> and a
- * <code>UIKeyboardInteractive</code>
- *
- * @author Juan F. Codagnone
- * @since Sep 22, 2005
- */
-public class UserInfoUIKeyboardInteractiveProxy
- implements UserInfo, UIKeyboardInteractive
-{
- private final UIKeyboardInteractive interactive;
-
- private final UserInfo userInfo;
-
- public UserInfoUIKeyboardInteractiveProxy( UserInfo userInfo, UIKeyboardInteractive interactive )
- {
- this.userInfo = userInfo;
- this.interactive = interactive;
- }
-
- /**
- * @see com.jcraft.jsch.UIKeyboardInteractive#promptKeyboardInteractive(String,String,String,String[],boolean[])
- */
- public String[] promptKeyboardInteractive( String destination, String name, String instruction, String[] prompt,
- boolean[] echo )
- {
- if ( userInfo.getPassword() != null )
- {
- prompt[0] = "Keyboard interactive required, supplied password is ignored\n" + prompt[0];
- }
- return interactive.promptKeyboardInteractive( destination, name, instruction, prompt, echo );
- }
-
- /**
- * @see com.jcraft.jsch.UserInfo#getPassphrase()
- */
- public String getPassphrase()
- {
- return userInfo.getPassphrase();
- }
-
- /**
- * @see com.jcraft.jsch.UserInfo#getPassword()
- */
- public String getPassword()
- {
- return userInfo.getPassword();
- }
-
- /**
- * @see com.jcraft.jsch.UserInfo#promptPassword(String)
- */
- public boolean promptPassword( String arg0 )
- {
- return userInfo.promptPassword( arg0 );
- }
-
- /**
- * @see com.jcraft.jsch.UserInfo#promptPassphrase(String)
- */
- public boolean promptPassphrase( String arg0 )
- {
- return userInfo.promptPassphrase( arg0 );
- }
-
- /**
- * @see com.jcraft.jsch.UserInfo#promptYesNo(String)
- */
- public boolean promptYesNo( String arg0 )
- {
- return userInfo.promptYesNo( arg0 );
- }
-
- /**
- * @see com.jcraft.jsch.UserInfo#showMessage(String)
- */
- public void showMessage( String arg0 )
- {
- userInfo.showMessage( arg0 );
- }
-
-}
+package org.apache.maven.wagon.providers.ssh.jsch.interactive;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import com.jcraft.jsch.UIKeyboardInteractive;
+import com.jcraft.jsch.UserInfo;
+
+/**
+ * A proxy that let you merge a <code>UserInfo</code> and a
+ * <code>UIKeyboardInteractive</code>
+ *
+ * @author Juan F. Codagnone
+ * @since Sep 22, 2005
+ */
+public class UserInfoUIKeyboardInteractiveProxy
+ implements UserInfo, UIKeyboardInteractive
+{
+ private final UIKeyboardInteractive interactive;
+
+ private final UserInfo userInfo;
+
+ public UserInfoUIKeyboardInteractiveProxy( UserInfo userInfo, UIKeyboardInteractive interactive )
+ {
+ this.userInfo = userInfo;
+ this.interactive = interactive;
+ }
+
+ /**
+ * @see com.jcraft.jsch.UIKeyboardInteractive#promptKeyboardInteractive(String,String,String,String[],boolean[])
+ */
+ public String[] promptKeyboardInteractive( String destination, String name, String instruction, String[] prompt,
+ boolean[] echo )
+ {
+ if ( userInfo.getPassword() != null && prompt != null && prompt.length != 0 )
+ {
+ prompt[0] = "Keyboard interactive required, supplied password is ignored\n" + prompt[0];
+ }
+ return interactive.promptKeyboardInteractive( destination, name, instruction, prompt, echo );
+ }
+
+ /**
+ * @see com.jcraft.jsch.UserInfo#getPassphrase()
+ */
+ public String getPassphrase()
+ {
+ return userInfo.getPassphrase();
+ }
+
+ /**
+ * @see com.jcraft.jsch.UserInfo#getPassword()
+ */
+ public String getPassword()
+ {
+ return userInfo.getPassword();
+ }
+
+ /**
+ * @see com.jcraft.jsch.UserInfo#promptPassword(String)
+ */
+ public boolean promptPassword( String arg0 )
+ {
+ return userInfo.promptPassword( arg0 );
+ }
+
+ /**
+ * @see com.jcraft.jsch.UserInfo#promptPassphrase(String)
+ */
+ public boolean promptPassphrase( String arg0 )
+ {
+ return userInfo.promptPassphrase( arg0 );
+ }
+
+ /**
+ * @see com.jcraft.jsch.UserInfo#promptYesNo(String)
+ */
+ public boolean promptYesNo( String arg0 )
+ {
+ return userInfo.promptYesNo( arg0 );
+ }
+
+ /**
+ * @see com.jcraft.jsch.UserInfo#showMessage(String)
+ */
+ public void showMessage( String arg0 )
+ {
+ userInfo.showMessage( arg0 );
+ }
+
+}
diff --git a/wagon-providers/wagon-ssh/src/site/apt/index.apt b/wagon-providers/wagon-ssh/src/site/apt/index.apt
index c74977a..0d818df 100644
--- a/wagon-providers/wagon-ssh/src/site/apt/index.apt
+++ b/wagon-providers/wagon-ssh/src/site/apt/index.apt
@@ -1,41 +1,41 @@
- ------
- Maven Wagon SSH
- ------
- Carlos Sanchez
- ------
- 2006-06-04
- ------
-
- ~~ Licensed to the Apache Software Foundation (ASF) under one
- ~~ or more contributor license agreements. See the NOTICE file
- ~~ distributed with this work for additional information
- ~~ regarding copyright ownership. The ASF licenses this file
- ~~ to you under the Apache License, Version 2.0 (the
- ~~ "License"); you may not use this file except in compliance
- ~~ with the License. You may obtain a copy of the License at
- ~~
- ~~ http://www.apache.org/licenses/LICENSE-2.0
- ~~
- ~~ Unless required by applicable law or agreed to in writing,
- ~~ software distributed under the License is distributed on an
- ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~~ KIND, either express or implied. See the License for the
- ~~ specific language governing permissions and limitations
- ~~ under the License.
-
- ~~ NOTE: For help with the syntax of this file, see:
- ~~ http://maven.apache.org/doxia/references/apt-format.html
-
-Maven Wagon SSH
-
- This component is an implementation of Wagon provider for SCP and SFTP access.
-
- It enables Maven to deploy artifacts and sites to SSH servers.
- It uses {{{http://www.jcraft.com/jsch/}JSch - Java Secure Channel}} as lower level layer.
-
- Getting files from SSH servers is not fully tested.
-
-
-Features
-
- * Deploy files and directories to SSH servers
+ ------
+ Maven Wagon SSH
+ ------
+ Carlos Sanchez
+ ------
+ 2006-06-04
+ ------
+
+ ~~ Licensed to the Apache Software Foundation (ASF) under one
+ ~~ or more contributor license agreements. See the NOTICE file
+ ~~ distributed with this work for additional information
+ ~~ regarding copyright ownership. The ASF licenses this file
+ ~~ to you under the Apache License, Version 2.0 (the
+ ~~ "License"); you may not use this file except in compliance
+ ~~ with the License. You may obtain a copy of the License at
+ ~~
+ ~~ http://www.apache.org/licenses/LICENSE-2.0
+ ~~
+ ~~ Unless required by applicable law or agreed to in writing,
+ ~~ software distributed under the License is distributed on an
+ ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~~ KIND, either express or implied. See the License for the
+ ~~ specific language governing permissions and limitations
+ ~~ under the License.
+
+ ~~ NOTE: For help with the syntax of this file, see:
+ ~~ http://maven.apache.org/doxia/references/apt-format.html
+
+Maven Wagon SSH
+
+ This component is an implementation of Wagon provider for SCP and SFTP access.
+
+ It enables Maven to deploy artifacts and sites to SSH servers.
+ It uses {{{http://www.jcraft.com/jsch/}JSch - Java Secure Channel}} as lower level layer.
+
+ Getting files from SSH servers is not fully tested.
+
+
+Features
+
+ * Deploy files and directories to SSH servers
diff --git a/wagon-providers/wagon-ssh/src/site/site.xml b/wagon-providers/wagon-ssh/src/site/site.xml
index 2652da8..68446ca 100644
--- a/wagon-providers/wagon-ssh/src/site/site.xml
+++ b/wagon-providers/wagon-ssh/src/site/site.xml
@@ -1,33 +1,33 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
- <body>
- <breadcrumbs>
- <item name="SSH" href="http://maven.apache.org/wagon/wagon-providers/wagon-ssh/index.html" />
- </breadcrumbs>
-
- <menu ref="parent"/>
- <menu ref="reports"/>
- </body>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
+ <body>
+ <breadcrumbs>
+ <item name="SSH" href="http://maven.apache.org/wagon/wagon-providers/wagon-ssh/index.html" />
+ </breadcrumbs>
+
+ <menu ref="parent"/>
+ <menu ref="reports"/>
+ </body>
</project>
\ No newline at end of file
diff --git a/wagon-providers/wagon-ssh/src/site/xdoc/configuration.xml b/wagon-providers/wagon-ssh/src/site/xdoc/configuration.xml
index 778cf24..251e4db 100644
--- a/wagon-providers/wagon-ssh/src/site/xdoc/configuration.xml
+++ b/wagon-providers/wagon-ssh/src/site/xdoc/configuration.xml
@@ -1,224 +1,224 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<document>
- <properties>
- <title>Wagon SSH provider configuration</title>
- <author email="michal.maczka at dimatics.com">Michal Maczka</author>
- </properties>
- <body>
- <section name="Configuration">
- <p>This wagon can be configured in some ways:
- <table>
- <tr>
- <th>What? / Interface</th>
- <th>Default Value</th>
- <th>Why?</th>
- </tr>
- <tr>
- <td>
- <a
- href="apidocs/org/apache/maven/wagon/providers/ssh/KnownHostsProvider.html">Known Hosts Provider</a>
- </td>
- <td>
- <a
- href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/FileKnownHostsProvider.html">
- FileKnownHostsProvider</a>
- with fallback to
- <a
- href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/NullKnownHostsProvider.html">
- NullKnownHostProvider</a>
- </td>
- <td>provides known hosts keys, needed to check the hosts
- identity. This is an important thing!
- <p>Some implementations:
- <ul>
- <li>
- <a
- href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/NullKnownHostsProvider.html">
- NullKnownHostProvider</a>:
- Don't provide anything
- </li>
- <li>
- <a
- href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/SingleKnownHostsProvider.html">
- SingleKnownHostProvider</a>:
- One host key can be setuped
- </li>
- <li>
- <a
- href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/FileKnownHostsProvider.html">
- FileKnownHostProvider</a>:
- Load known hosts keys from a openssh's <code>~/.ssh/known_hosts</code>
- like stream
- </li>
- <li>
- <a
- href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/StreamKnownHostsProvider.html">
- StreamKnownHostProvider</a>:
- Load known hosts keys from <code>~/.ssh/known_hosts</code> (you can
- set another location)
- </li>
-
- </ul>
- </p>
- </td>
- </tr>
- <tr>
- <td>
- <a
- href="apidocs/org/apache/maven/wagon/providers/ssh/HostCheckingEnum.html">Host Checking</a>
- </td>
- <td>Ask (type safe enum)</td>
- <td>The policy with the hosts keys:
- <ul>
- <li>
- <strong>Yes:</strong>
- Check host keys. If the incoming
- key is not available in the Known Hosts Provider
- fails
- </li>
- <li>
- <strong>Ask:</strong>
- If the incoming key is not
- available in the Known Hosts Provider it ask the user
- if the fingerprint is trusted
- </li>
- <li>
- <strong>No:</strong>
- don't check host keys at all.
- pretty unsafe!!
- </li>
-
- </ul>
- </td>
- </tr>
- <tr>
- <td>
- <a
- href="apidocs/org/apache/maven/wagon/providers/ssh/InteractiveUserInfo.html">Interactive User Info</a>
- </td>
- <td>
- <a
- href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/ConsoleInteractiveUserInfo.html">
- ConsoleInteractiveUserInfo</a>
- </td>
- <td>If the user choose
- <em>Ask</em>
- as
- <em>Host Checking</em>
- , this
- bean is used to interact with the user
- <p>Some implementations:
- <ul>
- <li>
- <a href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/NullInteractiveUserInfo.html">
- NullInteractiveUserInfo</a>
- </li>
- <li>
- <a href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/ConsoleInteractiveUserInfo.html">
- ConsoleInteractiveUserInfo</a>
- </li>
- </ul>
- </p>
-
- </td>
- </tr>
- </table>
- </p>
- </section>
- <section name="Configuration">
- <p>This wagon can be configured in some ways:
- <table>
- <tr>
- <th>What? / Interface</th>
- <th>Default Value</th>
- <th>Why?</th>
- </tr>
- <tr>
- <td><a
- href="apidocs/org/apache/maven/wagon/providers/ssh/KnownHostsProvider.html">Known Hosts Provider </a></td>
- <td><a
- href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/FileKnownHostsProvider.html">FileKnownHostsProvider</a>
- with fallback to
- <a
- href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/NullKnownHostsProvider.html">NullKnownHostProvider</a></td>
- <td>provides known hosts keys, needed to check the hosts
- identity. This is an important thing!
- <p>Some implementations:
- <ul>
- <li> <a
- href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/NullKnownHostsProvider.html">NullKnownHostProvider</a>: Don't provide anything</li>
- <li> <a
- href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/SingleKnownHostsProvider.html">SingleKnownHostProvider</a>: One host key can be setuped</li>
- <li> <a
- href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/FileKnownHostsProvider.html">FileKnownHostProvider</a>:
- Load known hosts keys from a openssh's <code>~/.ssh/known_hosts</code>
- like stream</li>
- <li> <a
- href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/StreamKnownHostsProvider.html">StreamKnownHostProvider</a>:
- Load known hosts keys from <code>~/.ssh/known_hosts</code> (you can
- set another location)</li>
-
- </ul>
- </p>
- </td>
- </tr>
- <tr>
- <td><a
- href="apidocs/org/apache/maven/wagon/providers/ssh/HostCheckingEnum.html">Host Checking</a></td>
- <td>Ask (type safe enum)</td>
- <td>The policy with the hosts keys:
- <ul>
- <li><strong>Yes:</strong> Check host keys. If the incoming
- key is not available in the Known Hosts Provider
- fails</li>
- <li><strong>Ask:</strong> If the incoming key is not
- available in the Known Hosts Provider it ask the user
- if the fingerprint is trusted</li>
- <li><strong>No:</strong> don't check host keys at all.
- pretty unsafe!!</li>
-
- </ul>
- </td>
- </tr>
- <tr>
- <td><a
- href="apidocs/org/apache/maven/wagon/providers/ssh/InteractiveUserInfo.html">Interactive User Info</a></td>
- <td><a
- href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/ConsoleInteractiveUserInfo.html">ConsoleInteractiveUserInfo</a></td>
- <td>If the user choose <em>Ask</em> as <em>Host Checking</em>, this
- bean is used to interact with the user
- <p>Some implementations:
- <ul>
- <li> <a href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/NullInteractiveUserInfo.html">NullInteractiveUserInfo</a> </li>
- <li> <a href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/ConsoleInteractiveUserInfo.html">ConsoleInteractiveUserInfo</a> </li>
- </ul>
- </p>
-
- </td>
- </tr>
-
- </table>
- <strong>TODO</strong>
- Autogenerate some of this information with a xdoclet2 plugin?
- </p>
- </section>
- </body>
-</document>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<document>
+ <properties>
+ <title>Wagon SSH provider configuration</title>
+ <author email="michal.maczka at dimatics.com">Michal Maczka</author>
+ </properties>
+ <body>
+ <section name="Configuration">
+ <p>This wagon can be configured in some ways:
+ <table>
+ <tr>
+ <th>What? / Interface</th>
+ <th>Default Value</th>
+ <th>Why?</th>
+ </tr>
+ <tr>
+ <td>
+ <a
+ href="apidocs/org/apache/maven/wagon/providers/ssh/KnownHostsProvider.html">Known Hosts Provider</a>
+ </td>
+ <td>
+ <a
+ href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/FileKnownHostsProvider.html">
+ FileKnownHostsProvider</a>
+ with fallback to
+ <a
+ href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/NullKnownHostsProvider.html">
+ NullKnownHostProvider</a>
+ </td>
+ <td>provides known hosts keys, needed to check the hosts
+ identity. This is an important thing!
+ <p>Some implementations:
+ <ul>
+ <li>
+ <a
+ href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/NullKnownHostsProvider.html">
+ NullKnownHostProvider</a>:
+ Don't provide anything
+ </li>
+ <li>
+ <a
+ href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/SingleKnownHostsProvider.html">
+ SingleKnownHostProvider</a>:
+ One host key can be setuped
+ </li>
+ <li>
+ <a
+ href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/FileKnownHostsProvider.html">
+ FileKnownHostProvider</a>:
+ Load known hosts keys from a openssh's <code>~/.ssh/known_hosts</code>
+ like stream
+ </li>
+ <li>
+ <a
+ href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/StreamKnownHostsProvider.html">
+ StreamKnownHostProvider</a>:
+ Load known hosts keys from <code>~/.ssh/known_hosts</code> (you can
+ set another location)
+ </li>
+
+ </ul>
+ </p>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <a
+ href="apidocs/org/apache/maven/wagon/providers/ssh/HostCheckingEnum.html">Host Checking</a>
+ </td>
+ <td>Ask (type safe enum)</td>
+ <td>The policy with the hosts keys:
+ <ul>
+ <li>
+ <strong>Yes:</strong>
+ Check host keys. If the incoming
+ key is not available in the Known Hosts Provider
+ fails
+ </li>
+ <li>
+ <strong>Ask:</strong>
+ If the incoming key is not
+ available in the Known Hosts Provider it ask the user
+ if the fingerprint is trusted
+ </li>
+ <li>
+ <strong>No:</strong>
+ don't check host keys at all.
+ pretty unsafe!!
+ </li>
+
+ </ul>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <a
+ href="apidocs/org/apache/maven/wagon/providers/ssh/InteractiveUserInfo.html">Interactive User Info</a>
+ </td>
+ <td>
+ <a
+ href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/ConsoleInteractiveUserInfo.html">
+ ConsoleInteractiveUserInfo</a>
+ </td>
+ <td>If the user choose
+ <em>Ask</em>
+ as
+ <em>Host Checking</em>
+ , this
+ bean is used to interact with the user
+ <p>Some implementations:
+ <ul>
+ <li>
+ <a href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/NullInteractiveUserInfo.html">
+ NullInteractiveUserInfo</a>
+ </li>
+ <li>
+ <a href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/ConsoleInteractiveUserInfo.html">
+ ConsoleInteractiveUserInfo</a>
+ </li>
+ </ul>
+ </p>
+
+ </td>
+ </tr>
+ </table>
+ </p>
+ </section>
+ <section name="Configuration">
+ <p>This wagon can be configured in some ways:
+ <table>
+ <tr>
+ <th>What? / Interface</th>
+ <th>Default Value</th>
+ <th>Why?</th>
+ </tr>
+ <tr>
+ <td><a
+ href="apidocs/org/apache/maven/wagon/providers/ssh/KnownHostsProvider.html">Known Hosts Provider </a></td>
+ <td><a
+ href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/FileKnownHostsProvider.html">FileKnownHostsProvider</a>
+ with fallback to
+ <a
+ href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/NullKnownHostsProvider.html">NullKnownHostProvider</a></td>
+ <td>provides known hosts keys, needed to check the hosts
+ identity. This is an important thing!
+ <p>Some implementations:
+ <ul>
+ <li> <a
+ href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/NullKnownHostsProvider.html">NullKnownHostProvider</a>: Don't provide anything</li>
+ <li> <a
+ href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/SingleKnownHostsProvider.html">SingleKnownHostProvider</a>: One host key can be setuped</li>
+ <li> <a
+ href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/FileKnownHostsProvider.html">FileKnownHostProvider</a>:
+ Load known hosts keys from a openssh's <code>~/.ssh/known_hosts</code>
+ like stream</li>
+ <li> <a
+ href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/StreamKnownHostsProvider.html">StreamKnownHostProvider</a>:
+ Load known hosts keys from <code>~/.ssh/known_hosts</code> (you can
+ set another location)</li>
+
+ </ul>
+ </p>
+ </td>
+ </tr>
+ <tr>
+ <td><a
+ href="apidocs/org/apache/maven/wagon/providers/ssh/HostCheckingEnum.html">Host Checking</a></td>
+ <td>Ask (type safe enum)</td>
+ <td>The policy with the hosts keys:
+ <ul>
+ <li><strong>Yes:</strong> Check host keys. If the incoming
+ key is not available in the Known Hosts Provider
+ fails</li>
+ <li><strong>Ask:</strong> If the incoming key is not
+ available in the Known Hosts Provider it ask the user
+ if the fingerprint is trusted</li>
+ <li><strong>No:</strong> don't check host keys at all.
+ pretty unsafe!!</li>
+
+ </ul>
+ </td>
+ </tr>
+ <tr>
+ <td><a
+ href="apidocs/org/apache/maven/wagon/providers/ssh/InteractiveUserInfo.html">Interactive User Info</a></td>
+ <td><a
+ href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/ConsoleInteractiveUserInfo.html">ConsoleInteractiveUserInfo</a></td>
+ <td>If the user choose <em>Ask</em> as <em>Host Checking</em>, this
+ bean is used to interact with the user
+ <p>Some implementations:
+ <ul>
+ <li> <a href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/NullInteractiveUserInfo.html">NullInteractiveUserInfo</a> </li>
+ <li> <a href="apidocs/org/apache/maven/wagon/providers/ssh/knownhost/ConsoleInteractiveUserInfo.html">ConsoleInteractiveUserInfo</a> </li>
+ </ul>
+ </p>
+
+ </td>
+ </tr>
+
+ </table>
+ <strong>TODO</strong>
+ Autogenerate some of this information with a xdoclet2 plugin?
+ </p>
+ </section>
+ </body>
+</document>
diff --git a/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/EmbeddedScpWagonTest.java b/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/EmbeddedScpWagonTest.java
index 7ff8fee..2c24fd3 100644
--- a/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/EmbeddedScpWagonTest.java
+++ b/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/EmbeddedScpWagonTest.java
@@ -1,82 +1,88 @@
-package org.apache.maven.wagon.providers.ssh.jsch;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.providers.ssh.AbstractEmbeddedScpWagonTest;
-import org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider;
-
-import java.io.IOException;
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class EmbeddedScpWagonTest
- extends AbstractEmbeddedScpWagonTest
-{
-
- @Override
- protected Wagon getWagon()
- throws Exception
- {
- ScpWagon scpWagon = (ScpWagon) super.getWagon();
- scpWagon.setInteractive( false );
- scpWagon.setKnownHostsProvider( new KnownHostsProvider()
- {
- public void storeKnownHosts( String contents )
- throws IOException
- {
-
- }
-
- public void setHostKeyChecking( String hostKeyChecking )
- {
- }
-
- public String getHostKeyChecking()
- {
- return "no";
- }
-
- public String getContents()
- {
- return null;
- }
- } );
- return scpWagon;
- }
-
-
- protected String getProtocol()
- {
- return "scp";
- }
-
-
-
- @Override
- protected boolean supportsGetIfNewer()
- {
- return false;
- }
-
-
-}
+package org.apache.maven.wagon.providers.ssh.jsch;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.providers.ssh.AbstractEmbeddedScpWagonTest;
+import org.apache.maven.wagon.providers.ssh.knownhost.KnownHostEntry;
+import org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider;
+
+import java.io.IOException;
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class EmbeddedScpWagonTest
+ extends AbstractEmbeddedScpWagonTest
+{
+
+ @Override
+ protected Wagon getWagon()
+ throws Exception
+ {
+ ScpWagon scpWagon = (ScpWagon) super.getWagon();
+ scpWagon.setInteractive( false );
+ scpWagon.setKnownHostsProvider( new KnownHostsProvider()
+ {
+ public void storeKnownHosts( String contents )
+ throws IOException
+ {
+
+ }
+
+ public void addKnownHost( KnownHostEntry knownHost )
+ throws IOException
+ {
+ }
+
+ public void setHostKeyChecking( String hostKeyChecking )
+ {
+ }
+
+ public String getHostKeyChecking()
+ {
+ return "no";
+ }
+
+ public String getContents()
+ {
+ return null;
+ }
+ } );
+ return scpWagon;
+ }
+
+
+ protected String getProtocol()
+ {
+ return "scp";
+ }
+
+
+
+ @Override
+ protected boolean supportsGetIfNewer()
+ {
+ return false;
+ }
+
+
+}
diff --git a/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/EmbeddedScpWagonWithKeyTest.java b/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/EmbeddedScpWagonWithKeyTest.java
index c46609f..1163ebf 100644
--- a/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/EmbeddedScpWagonWithKeyTest.java
+++ b/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/EmbeddedScpWagonWithKeyTest.java
@@ -1,89 +1,95 @@
-package org.apache.maven.wagon.providers.ssh.jsch;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
-import org.apache.maven.wagon.providers.ssh.AbstractEmbeddedScpWagonWithKeyTest;
-import org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class EmbeddedScpWagonWithKeyTest
- extends AbstractEmbeddedScpWagonWithKeyTest
-{
-
-
- @Override
- protected Wagon getWagon()
- throws Exception
- {
- ScpWagon scpWagon = (ScpWagon) super.getWagon();
- scpWagon.setInteractive( false );
- scpWagon.setKnownHostsProvider( new KnownHostsProvider()
- {
- public void storeKnownHosts( String contents )
- throws IOException
- {
-
- }
-
- public void setHostKeyChecking( String hostKeyChecking )
- {
- }
-
- public String getHostKeyChecking()
- {
- return "no";
- }
-
- public String getContents()
- {
- return null;
- }
- } );
- return scpWagon;
- }
-
-
- protected String getProtocol()
- {
- return "scp";
- }
-
-
- protected AuthenticationInfo getAuthInfo()
- {
- AuthenticationInfo authInfo = super.getAuthInfo();
- // user : guest/guest123 - passphrase : toto01
- authInfo.setUserName( "guest" );
- //authInfo.setPassword( TestData.getUserPassword() );
- authInfo.setPrivateKey( new File( "src/test/ssh-keys/id_rsa" ).getPath() );
-
- return authInfo;
- }
-
-
-}
+package org.apache.maven.wagon.providers.ssh.jsch;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.providers.ssh.AbstractEmbeddedScpWagonWithKeyTest;
+import org.apache.maven.wagon.providers.ssh.knownhost.KnownHostEntry;
+import org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class EmbeddedScpWagonWithKeyTest
+ extends AbstractEmbeddedScpWagonWithKeyTest
+{
+
+
+ @Override
+ protected Wagon getWagon()
+ throws Exception
+ {
+ ScpWagon scpWagon = (ScpWagon) super.getWagon();
+ scpWagon.setInteractive( false );
+ scpWagon.setKnownHostsProvider( new KnownHostsProvider()
+ {
+ public void storeKnownHosts( String contents )
+ throws IOException
+ {
+
+ }
+
+ public void addKnownHost( KnownHostEntry knownHost )
+ throws IOException
+ {
+ }
+
+ public void setHostKeyChecking( String hostKeyChecking )
+ {
+ }
+
+ public String getHostKeyChecking()
+ {
+ return "no";
+ }
+
+ public String getContents()
+ {
+ return null;
+ }
+ } );
+ return scpWagon;
+ }
+
+
+ protected String getProtocol()
+ {
+ return "scp";
+ }
+
+
+ protected AuthenticationInfo getAuthInfo()
+ {
+ AuthenticationInfo authInfo = super.getAuthInfo();
+ // user : guest/guest123 - passphrase : toto01
+ authInfo.setUserName( "guest" );
+ //authInfo.setPassword( TestData.getUserPassword() );
+ authInfo.setPrivateKey( new File( "src/test/ssh-keys/id_rsa" ).getPath() );
+
+ return authInfo;
+ }
+
+
+}
diff --git a/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/KnownHostsProviderTest.java b/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/KnownHostsProviderTest.java
index 6792862..69f3fc1 100644
--- a/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/KnownHostsProviderTest.java
+++ b/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/KnownHostsProviderTest.java
@@ -1,35 +1,35 @@
-package org.apache.maven.wagon.providers.ssh.jsch;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProviderTestCase;
-
-/**
- * Generic Unit test for <code>KnownHostsProvider</code>
- *
- * @author Juan F. Codagnone
- * @see org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider
- * @since Sep 12, 2005
- */
-public class KnownHostsProviderTest
- extends KnownHostsProviderTestCase
-{
-
-}
+package org.apache.maven.wagon.providers.ssh.jsch;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProviderTestCase;
+
+/**
+ * Generic Unit test for <code>KnownHostsProvider</code>
+ *
+ * @author Juan F. Codagnone
+ * @see org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider
+ * @since Sep 12, 2005
+ */
+public class KnownHostsProviderTest
+ extends KnownHostsProviderTestCase
+{
+
+}
diff --git a/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonTest.java b/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonTest.java
index 250c88b..d00c5a8 100644
--- a/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonTest.java
+++ b/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonTest.java
@@ -1,76 +1,76 @@
-package org.apache.maven.wagon.providers.ssh.jsch;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.StreamingWagonTestCase;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
-import org.apache.maven.wagon.providers.ssh.TestData;
-import org.apache.maven.wagon.repository.Repository;
-import org.apache.maven.wagon.resource.Resource;
-
-import java.io.File;
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class ScpWagonTest
- extends StreamingWagonTestCase
-{
-
- protected String getProtocol()
- {
- return "scp";
- }
-
- @Override
- protected int getTestRepositoryPort()
- {
- return 0; // not used
- }
-
- public String getTestRepositoryUrl()
- {
- return TestData.getTestRepositoryUrl( getTestRepositoryPort() );
- }
-
- protected AuthenticationInfo getAuthInfo()
- {
- AuthenticationInfo authInfo = super.getAuthInfo();
-
- authInfo.setUserName( TestData.getUserName() );
-
- File privateKey = TestData.getPrivateKey();
-
- if ( privateKey.exists() )
- {
- authInfo.setPrivateKey( privateKey.getAbsolutePath() );
-
- authInfo.setPassphrase( "" );
- }
-
- return authInfo;
- }
-
- protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
- {
- return new File( repository.getBasedir(), resource.getName() ).lastModified();
- }
-}
+package org.apache.maven.wagon.providers.ssh.jsch;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.StreamingWagonTestCase;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.providers.ssh.TestData;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.resource.Resource;
+
+import java.io.File;
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class ScpWagonTest
+ extends StreamingWagonTestCase
+{
+
+ protected String getProtocol()
+ {
+ return "scp";
+ }
+
+ @Override
+ protected int getTestRepositoryPort()
+ {
+ return 0; // not used
+ }
+
+ public String getTestRepositoryUrl()
+ {
+ return TestData.getTestRepositoryUrl( getTestRepositoryPort() );
+ }
+
+ protected AuthenticationInfo getAuthInfo()
+ {
+ AuthenticationInfo authInfo = super.getAuthInfo();
+
+ authInfo.setUserName( TestData.getUserName() );
+
+ File privateKey = TestData.getPrivateKey();
+
+ if ( privateKey.exists() )
+ {
+ authInfo.setPrivateKey( privateKey.getAbsolutePath() );
+
+ authInfo.setPassphrase( "" );
+ }
+
+ return authInfo;
+ }
+
+ protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
+ {
+ return new File( repository.getBasedir(), resource.getName() ).lastModified();
+ }
+}
diff --git a/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonWithProxyTest.java b/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonWithProxyTest.java
index 9d5f985..cbc11be 100644
--- a/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonWithProxyTest.java
+++ b/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonWithProxyTest.java
@@ -1,204 +1,203 @@
-package org.apache.maven.wagon.providers.ssh.jsch;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.SocketTimeoutException;
-import java.util.Random;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.proxy.ProxyInfo;
-import org.apache.maven.wagon.repository.Repository;
-import org.codehaus.plexus.PlexusTestCase;
-import org.mortbay.jetty.Handler;
-import org.mortbay.jetty.Request;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.handler.AbstractHandler;
-
-public class ScpWagonWithProxyTest
- extends PlexusTestCase
-{
- private boolean handled;
-
- public void testHttpProxy()
- throws Exception
- {
- handled = false;
- Handler handler = new AbstractHandler()
- {
- public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch )
- throws IOException, ServletException
- {
- assertEquals( "CONNECT", request.getMethod() );
-
- handled = true;
- ( (Request) request ).setHandled( true );
- }
- };
-
- Server server = new Server( 0 );
- server.setHandler( handler );
- server.start();
-
- int port = server.getConnectors()[0].getLocalPort();
- ProxyInfo proxyInfo = new ProxyInfo();
- proxyInfo.setHost( "localhost" );
- proxyInfo.setPort( port );
- proxyInfo.setType( "http" );
- proxyInfo.setNonProxyHosts( null );
-
- Wagon wagon = (Wagon) lookup( Wagon.ROLE, "scp" );
- try
- {
- wagon.connect( new Repository( "id", "scp://localhost/tmp" ), proxyInfo );
- fail();
- }
- catch ( AuthenticationException e )
- {
- assertTrue( handled );
- }
- finally
- {
- if ( server != null )
- {
- server.stop();
- }
- }
- }
-
- public void testSocksProxy()
- throws Exception
- {
- handled = false;
-
- int port = ( Math.abs( new Random().nextInt() ) % 2048 ) + 1024;
-
- SocksServer s = new SocksServer( port );
- Thread t = new Thread( s );
- t.setDaemon( true );
- t.start();
-
- ProxyInfo proxyInfo = new ProxyInfo();
- proxyInfo.setHost( "localhost" );
- proxyInfo.setPort( port );
- proxyInfo.setType( "socks_5" );
- proxyInfo.setNonProxyHosts( null );
-
- Wagon wagon = (Wagon) lookup( Wagon.ROLE, "scp" );
- try
- {
- wagon.connect( new Repository( "id", "scp://localhost/tmp" ), proxyInfo );
- fail();
- }
- catch ( AuthenticationException e )
- {
- assertTrue( handled );
- }
- finally
- {
- t.interrupt();
- }
- }
-
- private final class SocksServer
- implements Runnable
- {
-
- private final int port;
-
- private String userAgent;
-
- private SocksServer( int port )
- {
- this.port = port;
- }
-
- public void run()
- {
- ServerSocket ssock = null;
- try
- {
- try
- {
- ssock = new ServerSocket( port );
- ssock.setSoTimeout( 2000 );
- }
- catch ( IOException e )
- {
- return;
- }
-
- while ( !Thread.currentThread().isInterrupted() )
- {
- Socket sock = null;
- try
- {
- try
- {
- sock = ssock.accept();
- }
- catch ( SocketTimeoutException e )
- {
- continue;
- }
-
- handled = true;
- }
- catch ( IOException e )
- {
- }
- finally
- {
- if ( sock != null )
- {
- try
- {
- sock.close();
- }
- catch ( IOException e )
- {
- }
- }
- }
- }
- }
- finally
- {
- if ( ssock != null )
- {
- try
- {
- ssock.close();
- }
- catch ( IOException e )
- {
- }
- }
- }
- }
- }
-}
+package org.apache.maven.wagon.providers.ssh.jsch;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketTimeoutException;
+import java.util.Random;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.proxy.ProxyInfo;
+import org.apache.maven.wagon.repository.Repository;
+import org.codehaus.plexus.PlexusTestCase;
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.Request;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.handler.AbstractHandler;
+
+public class ScpWagonWithProxyTest
+ extends PlexusTestCase
+{
+ private boolean handled;
+
+ public void testHttpProxy()
+ throws Exception
+ {
+ handled = false;
+ Handler handler = new AbstractHandler()
+ {
+ public void handle( String target, Request baseRequest, HttpServletRequest request,
+ HttpServletResponse response ) throws IOException, ServletException
+ {
+ assertEquals( "CONNECT", request.getMethod() );
+
+ handled = true;
+ baseRequest.setHandled( true );
+ }
+ };
+
+ Server server = new Server( 0 );
+ server.setHandler( handler );
+ server.start();
+
+ int port = server.getConnectors()[0].getLocalPort();
+ ProxyInfo proxyInfo = new ProxyInfo();
+ proxyInfo.setHost( "localhost" );
+ proxyInfo.setPort( port );
+ proxyInfo.setType( "http" );
+ proxyInfo.setNonProxyHosts( null );
+
+ Wagon wagon = (Wagon) lookup( Wagon.ROLE, "scp" );
+ try
+ {
+ wagon.connect( new Repository( "id", "scp://localhost/tmp" ), proxyInfo );
+ fail();
+ }
+ catch ( AuthenticationException e )
+ {
+ assertTrue( handled );
+ }
+ finally
+ {
+ wagon.disconnect();
+ server.stop();
+ }
+ }
+
+ public void testSocksProxy()
+ throws Exception
+ {
+ handled = false;
+
+ int port = ( Math.abs( new Random().nextInt() ) % 2048 ) + 1024;
+
+ SocksServer s = new SocksServer( port );
+ Thread t = new Thread( s );
+ t.setDaemon( true );
+ t.start();
+
+ ProxyInfo proxyInfo = new ProxyInfo();
+ proxyInfo.setHost( "localhost" );
+ proxyInfo.setPort( port );
+ proxyInfo.setType( "socks_5" );
+ proxyInfo.setNonProxyHosts( null );
+
+ Wagon wagon = (Wagon) lookup( Wagon.ROLE, "scp" );
+ try
+ {
+ wagon.connect( new Repository( "id", "scp://localhost/tmp" ), proxyInfo );
+ fail();
+ }
+ catch ( AuthenticationException e )
+ {
+ assertTrue( handled );
+ }
+ finally
+ {
+ wagon.disconnect();
+ t.interrupt();
+ }
+ }
+
+ private final class SocksServer
+ implements Runnable
+ {
+
+ private final int port;
+
+ private String userAgent;
+
+ private SocksServer( int port )
+ {
+ this.port = port;
+ }
+
+ public void run()
+ {
+ ServerSocket ssock = null;
+ try
+ {
+ try
+ {
+ ssock = new ServerSocket( port );
+ ssock.setSoTimeout( 2000 );
+ }
+ catch ( IOException e )
+ {
+ return;
+ }
+
+ while ( !Thread.currentThread().isInterrupted() )
+ {
+ Socket sock = null;
+ try
+ {
+ try
+ {
+ sock = ssock.accept();
+ }
+ catch ( SocketTimeoutException e )
+ {
+ continue;
+ }
+
+ handled = true;
+ }
+ catch ( IOException e )
+ {
+ }
+ finally
+ {
+ if ( sock != null )
+ {
+ try
+ {
+ sock.close();
+ }
+ catch ( IOException e )
+ {
+ }
+ }
+ }
+ }
+ }
+ finally
+ {
+ if ( ssock != null )
+ {
+ try
+ {
+ ssock.close();
+ }
+ catch ( IOException e )
+ {
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonWithSshPrivateKeySearchTest.java b/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonWithSshPrivateKeySearchTest.java
index 60e1083..523df64 100644
--- a/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonWithSshPrivateKeySearchTest.java
+++ b/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonWithSshPrivateKeySearchTest.java
@@ -1,114 +1,114 @@
-package org.apache.maven.wagon.providers.ssh.jsch;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.maven.wagon.ConnectionException;
-import org.apache.maven.wagon.StreamingWagonTestCase;
-import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
-import org.apache.maven.wagon.providers.ssh.TestData;
-import org.apache.maven.wagon.repository.Repository;
-import org.apache.maven.wagon.resource.Resource;
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- *
- */
-public class ScpWagonWithSshPrivateKeySearchTest
- extends StreamingWagonTestCase
-{
- protected String getProtocol()
- {
- return "scp";
- }
-
- @Override
- protected int getTestRepositoryPort() {
- return 0; // not used
- }
-
- public String getTestRepositoryUrl()
- {
- return TestData.getTestRepositoryUrl(0);
- }
-
- protected AuthenticationInfo getAuthInfo()
- {
- AuthenticationInfo authInfo = super.getAuthInfo();
-
- authInfo.setUserName( TestData.getUserName() );
-
- authInfo.setPassphrase( "" );
-
- return authInfo;
- }
-
- protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
- {
- return new File( repository.getBasedir(), resource.getName() ).lastModified();
- }
-
- public void testMissingPrivateKey()
- throws Exception
- {
- File file = File.createTempFile( "wagon", "tmp" );
- file.delete();
-
- AuthenticationInfo authInfo = new AuthenticationInfo();
- authInfo.setPrivateKey( file.getAbsolutePath() );
-
- try
- {
- getWagon().connect( new Repository(), authInfo );
- fail();
- }
- catch ( AuthenticationException e )
- {
- assertTrue( true );
- }
- }
-
- public void testBadPrivateKey()
- throws Exception
- {
- File file = File.createTempFile( "wagon", "tmp" );
- file.deleteOnExit();
-
- AuthenticationInfo authInfo = new AuthenticationInfo();
- authInfo.setPrivateKey( file.getAbsolutePath() );
-
- try
- {
- getWagon().connect( new Repository(), authInfo );
- fail();
- }
- catch ( AuthenticationException e )
- {
- assertTrue( true );
- }
- finally
- {
- file.delete();
- }
- }
-}
+package org.apache.maven.wagon.providers.ssh.jsch;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.maven.wagon.ConnectionException;
+import org.apache.maven.wagon.StreamingWagonTestCase;
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.providers.ssh.TestData;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.resource.Resource;
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ *
+ */
+public class ScpWagonWithSshPrivateKeySearchTest
+ extends StreamingWagonTestCase
+{
+ protected String getProtocol()
+ {
+ return "scp";
+ }
+
+ @Override
+ protected int getTestRepositoryPort() {
+ return 0; // not used
+ }
+
+ public String getTestRepositoryUrl()
+ {
+ return TestData.getTestRepositoryUrl(0);
+ }
+
+ protected AuthenticationInfo getAuthInfo()
+ {
+ AuthenticationInfo authInfo = super.getAuthInfo();
+
+ authInfo.setUserName( TestData.getUserName() );
+
+ authInfo.setPassphrase( "" );
+
+ return authInfo;
+ }
+
+ protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
+ {
+ return new File( repository.getBasedir(), resource.getName() ).lastModified();
+ }
+
+ public void testMissingPrivateKey()
+ throws Exception
+ {
+ File file = File.createTempFile( "wagon", "tmp" );
+ file.delete();
+
+ AuthenticationInfo authInfo = new AuthenticationInfo();
+ authInfo.setPrivateKey( file.getAbsolutePath() );
+
+ try
+ {
+ getWagon().connect( new Repository(), authInfo );
+ fail();
+ }
+ catch ( AuthenticationException e )
+ {
+ assertTrue( true );
+ }
+ }
+
+ public void testBadPrivateKey()
+ throws Exception
+ {
+ File file = File.createTempFile( "wagon", "tmp" );
+ file.deleteOnExit();
+
+ AuthenticationInfo authInfo = new AuthenticationInfo();
+ authInfo.setPrivateKey( file.getAbsolutePath() );
+
+ try
+ {
+ getWagon().connect( new Repository(), authInfo );
+ fail();
+ }
+ catch ( AuthenticationException e )
+ {
+ assertTrue( true );
+ }
+ finally
+ {
+ file.delete();
+ }
+ }
+}
diff --git a/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/SftpWagonTest.java b/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/SftpWagonTest.java
index 154224e..bc9353a 100644
--- a/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/SftpWagonTest.java
+++ b/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/SftpWagonTest.java
@@ -1,65 +1,65 @@
-package org.apache.maven.wagon.providers.ssh.jsch;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.StreamingWagonTestCase;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
-import org.apache.maven.wagon.providers.ssh.TestData;
-import org.apache.maven.wagon.repository.Repository;
-import org.apache.maven.wagon.resource.Resource;
-
-import java.io.File;
-
-/**
- * @author <a href="mailto:brett at apache.org">Brett Porter</a>
- *
- */
-public class SftpWagonTest
- extends StreamingWagonTestCase
-{
- protected String getProtocol()
- {
- return "sftp";
- }
-
- @Override
- protected int getTestRepositoryPort() {
- return 0; // not used
- }
-
- public String getTestRepositoryUrl()
- {
- return TestData.getTestRepositoryUrl(0);
- }
-
- protected AuthenticationInfo getAuthInfo()
- {
- AuthenticationInfo authInfo = super.getAuthInfo();
-
- authInfo.setUserName( TestData.getUserName() );
-
- return authInfo;
- }
-
- protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
- {
- return new File( repository.getBasedir(), resource.getName() ).lastModified();
- }
-}
+package org.apache.maven.wagon.providers.ssh.jsch;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.StreamingWagonTestCase;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.providers.ssh.TestData;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.resource.Resource;
+
+import java.io.File;
+
+/**
+ * @author <a href="mailto:brett at apache.org">Brett Porter</a>
+ *
+ */
+public class SftpWagonTest
+ extends StreamingWagonTestCase
+{
+ protected String getProtocol()
+ {
+ return "sftp";
+ }
+
+ @Override
+ protected int getTestRepositoryPort() {
+ return 0; // not used
+ }
+
+ public String getTestRepositoryUrl()
+ {
+ return TestData.getTestRepositoryUrl(0);
+ }
+
+ protected AuthenticationInfo getAuthInfo()
+ {
+ AuthenticationInfo authInfo = super.getAuthInfo();
+
+ authInfo.setUserName( TestData.getUserName() );
+
+ return authInfo;
+ }
+
+ protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
+ {
+ return new File( repository.getBasedir(), resource.getName() ).lastModified();
+ }
+}
diff --git a/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/SshCommandExecutorTest.java b/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/SshCommandExecutorTest.java
index 27140ca..14c156f 100644
--- a/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/SshCommandExecutorTest.java
+++ b/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/SshCommandExecutorTest.java
@@ -1,39 +1,39 @@
-package org.apache.maven.wagon.providers.ssh.jsch;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.CommandExecutorTestCase;
-import org.apache.maven.wagon.repository.Repository;
-
-/**
- * Test the command executor.
- *
- * @author <a href="mailto:brett at apache.org">Brett Porter</a>
- *
- */
-public class SshCommandExecutorTest
- extends CommandExecutorTestCase
-{
-
- protected Repository getTestRepository()
- {
- return new Repository( "test", "scp://localhost/" );
- }
-}
+package org.apache.maven.wagon.providers.ssh.jsch;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.CommandExecutorTestCase;
+import org.apache.maven.wagon.repository.Repository;
+
+/**
+ * Test the command executor.
+ *
+ * @author <a href="mailto:brett at apache.org">Brett Porter</a>
+ *
+ */
+public class SshCommandExecutorTest
+ extends CommandExecutorTestCase
+{
+
+ protected Repository getTestRepository()
+ {
+ return new Repository( "test", "scp://localhost/" );
+ }
+}
diff --git a/wagon-providers/wagon-ssh/src/test/resources/log4j.xml b/wagon-providers/wagon-ssh/src/test/resources/log4j.xml
index 824015b..8746354 100644
--- a/wagon-providers/wagon-ssh/src/test/resources/log4j.xml
+++ b/wagon-providers/wagon-ssh/src/test/resources/log4j.xml
@@ -1,41 +1,41 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
-
- <appender name="console" class="org.apache.log4j.ConsoleAppender">
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d [%t] %-5p %c %x - %m%n"/>
- </layout>
- </appender>
- <logger name="org.apache.sshd.server">
- <level value="INFO"/>
- </logger>
-
-
-
- <root>
- <priority value ="info" />
- <appender-ref ref="console" />
- </root>
-
-</log4j:configuration>
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d [%t] %-5p %c %x - %m%n"/>
+ </layout>
+ </appender>
+ <logger name="org.apache.sshd.server">
+ <level value="INFO"/>
+ </logger>
+
+
+
+ <root>
+ <priority value ="info" />
+ <appender-ref ref="console" />
+ </root>
+
+</log4j:configuration>
diff --git a/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/ScpWagonTest.xml b/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/ScpWagonTest.xml
index 0550ecb..5bc1707 100644
--- a/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/ScpWagonTest.xml
+++ b/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/ScpWagonTest.xml
@@ -1,36 +1,36 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<component-set>
- <components>
- <component>
- <role>org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo</role>
- <implementation>org.apache.maven.wagon.providers.ssh.interactive.NullInteractiveUserInfo</implementation>
- <instantiation-strategy>per-lookup</instantiation-strategy>
- </component>
- <component>
- <role>org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider</role>
- <implementation>org.apache.maven.wagon.providers.ssh.knownhost.NullKnownHostProvider</implementation>
- <instantiation-strategy>per-lookup</instantiation-strategy>
- <configuration>
- <hostKeyChecking>no</hostKeyChecking>
- </configuration>
- </component>
- </components>
-</component-set>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<component-set>
+ <components>
+ <component>
+ <role>org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo</role>
+ <implementation>org.apache.maven.wagon.providers.ssh.interactive.NullInteractiveUserInfo</implementation>
+ <instantiation-strategy>per-lookup</instantiation-strategy>
+ </component>
+ <component>
+ <role>org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider</role>
+ <implementation>org.apache.maven.wagon.providers.ssh.knownhost.NullKnownHostProvider</implementation>
+ <instantiation-strategy>per-lookup</instantiation-strategy>
+ <configuration>
+ <hostKeyChecking>no</hostKeyChecking>
+ </configuration>
+ </component>
+ </components>
+</component-set>
diff --git a/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/ScpWagonWithSshPrivateKeySearchTest.xml b/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/ScpWagonWithSshPrivateKeySearchTest.xml
index 0550ecb..5bc1707 100644
--- a/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/ScpWagonWithSshPrivateKeySearchTest.xml
+++ b/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/ScpWagonWithSshPrivateKeySearchTest.xml
@@ -1,36 +1,36 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<component-set>
- <components>
- <component>
- <role>org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo</role>
- <implementation>org.apache.maven.wagon.providers.ssh.interactive.NullInteractiveUserInfo</implementation>
- <instantiation-strategy>per-lookup</instantiation-strategy>
- </component>
- <component>
- <role>org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider</role>
- <implementation>org.apache.maven.wagon.providers.ssh.knownhost.NullKnownHostProvider</implementation>
- <instantiation-strategy>per-lookup</instantiation-strategy>
- <configuration>
- <hostKeyChecking>no</hostKeyChecking>
- </configuration>
- </component>
- </components>
-</component-set>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<component-set>
+ <components>
+ <component>
+ <role>org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo</role>
+ <implementation>org.apache.maven.wagon.providers.ssh.interactive.NullInteractiveUserInfo</implementation>
+ <instantiation-strategy>per-lookup</instantiation-strategy>
+ </component>
+ <component>
+ <role>org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider</role>
+ <implementation>org.apache.maven.wagon.providers.ssh.knownhost.NullKnownHostProvider</implementation>
+ <instantiation-strategy>per-lookup</instantiation-strategy>
+ <configuration>
+ <hostKeyChecking>no</hostKeyChecking>
+ </configuration>
+ </component>
+ </components>
+</component-set>
diff --git a/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/SftpWagonTest.xml b/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/SftpWagonTest.xml
index 0550ecb..5bc1707 100644
--- a/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/SftpWagonTest.xml
+++ b/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/SftpWagonTest.xml
@@ -1,36 +1,36 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<component-set>
- <components>
- <component>
- <role>org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo</role>
- <implementation>org.apache.maven.wagon.providers.ssh.interactive.NullInteractiveUserInfo</implementation>
- <instantiation-strategy>per-lookup</instantiation-strategy>
- </component>
- <component>
- <role>org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider</role>
- <implementation>org.apache.maven.wagon.providers.ssh.knownhost.NullKnownHostProvider</implementation>
- <instantiation-strategy>per-lookup</instantiation-strategy>
- <configuration>
- <hostKeyChecking>no</hostKeyChecking>
- </configuration>
- </component>
- </components>
-</component-set>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<component-set>
+ <components>
+ <component>
+ <role>org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo</role>
+ <implementation>org.apache.maven.wagon.providers.ssh.interactive.NullInteractiveUserInfo</implementation>
+ <instantiation-strategy>per-lookup</instantiation-strategy>
+ </component>
+ <component>
+ <role>org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider</role>
+ <implementation>org.apache.maven.wagon.providers.ssh.knownhost.NullKnownHostProvider</implementation>
+ <instantiation-strategy>per-lookup</instantiation-strategy>
+ <configuration>
+ <hostKeyChecking>no</hostKeyChecking>
+ </configuration>
+ </component>
+ </components>
+</component-set>
diff --git a/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/SshCommandExecutorTest.xml b/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/SshCommandExecutorTest.xml
index 0550ecb..5bc1707 100644
--- a/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/SshCommandExecutorTest.xml
+++ b/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/SshCommandExecutorTest.xml
@@ -1,36 +1,36 @@
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<component-set>
- <components>
- <component>
- <role>org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo</role>
- <implementation>org.apache.maven.wagon.providers.ssh.interactive.NullInteractiveUserInfo</implementation>
- <instantiation-strategy>per-lookup</instantiation-strategy>
- </component>
- <component>
- <role>org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider</role>
- <implementation>org.apache.maven.wagon.providers.ssh.knownhost.NullKnownHostProvider</implementation>
- <instantiation-strategy>per-lookup</instantiation-strategy>
- <configuration>
- <hostKeyChecking>no</hostKeyChecking>
- </configuration>
- </component>
- </components>
-</component-set>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<component-set>
+ <components>
+ <component>
+ <role>org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo</role>
+ <implementation>org.apache.maven.wagon.providers.ssh.interactive.NullInteractiveUserInfo</implementation>
+ <instantiation-strategy>per-lookup</instantiation-strategy>
+ </component>
+ <component>
+ <role>org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider</role>
+ <implementation>org.apache.maven.wagon.providers.ssh.knownhost.NullKnownHostProvider</implementation>
+ <instantiation-strategy>per-lookup</instantiation-strategy>
+ <configuration>
+ <hostKeyChecking>no</hostKeyChecking>
+ </configuration>
+ </component>
+ </components>
+</component-set>
diff --git a/wagon-providers/wagon-webdav-jackrabbit/pom.xml b/wagon-providers/wagon-webdav-jackrabbit/pom.xml
index b1cade5..8744b14 100644
--- a/wagon-providers/wagon-webdav-jackrabbit/pom.xml
+++ b/wagon-providers/wagon-webdav-jackrabbit/pom.xml
@@ -1,165 +1,169 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-providers</artifactId>
- <version>2.10</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>wagon-webdav-jackrabbit</artifactId>
- <name>Apache Maven Wagon :: Providers :: WebDav Provider</name>
- <description>
- Wagon provider that gets and puts artifacts through webdav protocol
- </description>
-
- <contributors>
- <contributor>
- <name>Henry Isidro</name>
- <email>hisidro at exist.com</email>
- </contributor>
- <contributor>
- <name>James William Dumay</name>
- <email>james at atlassian.com</email>
- </contributor>
- </contributors>
-
- <dependencies>
- <dependency>
- <!-- Workaround for QDOX-148, see also MNG-3686 -->
- <groupId>${project.groupId}</groupId>
- <artifactId>wagon-http-shared</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.jackrabbit</groupId>
- <artifactId>jackrabbit-webdav</artifactId>
- <version>2.5.2</version>
- <exclusions>
- <exclusion>
- <artifactId>commons-logging</artifactId>
- <groupId>commons-logging</groupId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
- <dependency> <!-- required for commons-httpclient:commons-httpclient -->
- <groupId>org.slf4j</groupId>
- <artifactId>jcl-over-slf4j</artifactId>
- </dependency>
-
- <dependency>
- <groupId>commons-lang</groupId>
- <artifactId>commons-lang</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-io</groupId>
- <artifactId>commons-io</artifactId>
- </dependency>
-
- <dependency>
- <groupId>commons-httpclient</groupId>
- <artifactId>commons-httpclient</artifactId>
- <version>3.1</version>
- <!--
- The version of commons-logging that comes transitively has class loader
- problems. So we exclude it here and add a newer version below.
- Is replaced by org.slf4j:jcl-over-slf4j
- -->
- <exclusions>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
-
- <!-- Test dependencies -->
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-servlet_2.5_spec</artifactId>
- <version>1.2</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>it.could</groupId>
- <artifactId>webdav</artifactId>
- <version>0.4</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>biz.aQute</groupId>
- <artifactId>bnd</artifactId>
- <version>1.50.0</version>
- <scope>provided</scope>
- </dependency>
-
- </dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-component-metadata</artifactId>
- <executions>
- <execution>
- <id>generate</id>
- <goals>
- <goal>generate-metadata</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin><!-- Jackrabbit is compiled for JDK 6 -->
- <artifactId>maven-enforcer-plugin</artifactId>
- <executions>
- <execution>
- <id>enforce-bytecode-version</id>
- <goals>
- <goal>enforce</goal>
- </goals>
- <configuration>
- <rules>
- <enforceBytecodeVersion>
- <maxJdkVersion>1.6</maxJdkVersion>
- </enforceBytecodeVersion>
- </rules>
- <fail>true</fail>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-providers</artifactId>
+ <version>2.12</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>wagon-webdav-jackrabbit</artifactId>
+ <name>Apache Maven Wagon :: Providers :: WebDAV Provider</name>
+ <description>
+ Wagon provider that gets and puts artifacts through WebDAV protocol
+ </description>
+
+ <contributors>
+ <contributor>
+ <name>Henry Isidro</name>
+ <email>hisidro at exist.com</email>
+ </contributor>
+ <contributor>
+ <name>James William Dumay</name>
+ <email>james at atlassian.com</email>
+ </contributor>
+ </contributors>
+
+ <dependencies>
+ <dependency>
+ <!-- Workaround for QDOX-148, see also MNG-3686 -->
+ <groupId>${project.groupId}</groupId>
+ <artifactId>wagon-http-shared</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-webdav</artifactId>
+ <version>2.5.2</version>
+ <exclusions>
+ <exclusion>
+ <artifactId>commons-logging</artifactId>
+ <groupId>commons-logging</groupId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency> <!-- required for commons-httpclient:commons-httpclient -->
+ <groupId>org.slf4j</groupId>
+ <artifactId>jcl-over-slf4j</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>commons-httpclient</groupId>
+ <artifactId>commons-httpclient</artifactId>
+ <version>3.1</version>
+ <!--
+ The version of commons-logging that comes transitively has class loader
+ problems. So we exclude it here and add a newer version below.
+ Is replaced by org.slf4j:jcl-over-slf4j
+ -->
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <!-- Test dependencies -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty.aggregate</groupId>
+ <artifactId>jetty-all</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>it.could</groupId>
+ <artifactId>webdav</artifactId>
+ <version>0.4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>biz.aQute</groupId>
+ <artifactId>bnd</artifactId>
+ <version>1.50.0</version>
+ <scope>provided</scope>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-metadata</artifactId>
+ <executions>
+ <execution>
+ <id>generate</id>
+ <goals>
+ <goal>generate-metadata</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin><!-- Jackrabbit is compiled for JDK 6 -->
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>enforce-bytecode-version</id>
+ <goals>
+ <goal>enforce</goal>
+ </goals>
+ <configuration>
+ <rules>
+ <enforceBytecodeVersion>
+ <maxJdkVersion>1.6</maxJdkVersion>
+ </enforceBytecodeVersion>
+ </rules>
+ <fail>true</fail>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/jackrabbit/webdav/MultiStatus.java b/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/jackrabbit/webdav/MultiStatus.java
index c5c2bad..780bdc4 100644
--- a/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/jackrabbit/webdav/MultiStatus.java
+++ b/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/jackrabbit/webdav/MultiStatus.java
@@ -1,210 +1,210 @@
-package org.apache.jackrabbit.webdav;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
-import org.apache.jackrabbit.webdav.xml.DomUtil;
-import org.apache.jackrabbit.webdav.xml.ElementIterator;
-import org.apache.jackrabbit.webdav.xml.XmlSerializable;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-import java.util.Map;
-import java.util.LinkedHashMap;
-
-/**
- * MultiStatus representing the content of a multistatus response body and
- * allows to retrieve the Xml representation.
- */
-public class MultiStatus
- implements DavConstants, XmlSerializable
-{
-
- /**
- * Map collecting the responses for this multistatus, where every href must
- * only occur one single time.
- */
- private Map<String, MultiStatusResponse> responses = new LinkedHashMap<String, MultiStatusResponse>();
-
- /**
- * A general response description at the multistatus top level is used to
- * provide a general message describing the overarching nature of the response.
- * If this value is available an application may use it instead of
- * presenting the individual response descriptions contained within the
- * responses.
- */
- private String responseDescription;
-
- /**
- * Add response(s) to this multistatus, in order to build a multistatus for
- * responding to a PROPFIND request.
- *
- * @param resource The resource to add property from
- * @param propNameSet The requested property names of the PROPFIND request
- * @param propFindType
- * @param depth
- */
- public void addResourceProperties( DavResource resource, DavPropertyNameSet propNameSet, int propFindType,
- int depth )
- {
- addResponse( new MultiStatusResponse( resource, propNameSet, propFindType ) );
- if ( depth > 0 && resource.isCollection() )
- {
- DavResourceIterator iter = resource.getMembers();
- while ( iter.hasNext() )
- {
- addResourceProperties( iter.nextResource(), propNameSet, propFindType, depth - 1 );
- }
- }
- }
-
- /**
- * Add response(s) to this multistatus, in order to build a multistatus e.g.
- * in order to respond to a PROPFIND request. Please note, that in terms
- * of PROPFIND, this method would correspond to a
- * {@link DavConstants#PROPFIND_BY_PROPERTY} propfind type.
- *
- * @param resource The resource to add property from
- * @param propNameSet The requested property names of the PROPFIND request
- * @param depth
- * @see #addResourceProperties(DavResource, DavPropertyNameSet, int, int) for
- * the corresponding method that allows to specify the type explicitly.
- */
- public void addResourceProperties( DavResource resource, DavPropertyNameSet propNameSet, int depth )
- {
- addResourceProperties( resource, propNameSet, PROPFIND_BY_PROPERTY, depth );
- }
-
- /**
- * Add response(s) to this multistatus, in order to build a multistatus
- * as returned for COPY, MOVE, LOCK or DELETE requests resulting in an error
- * with a resource other than the resource identified in the Request-URI.
- *
- * @param resource
- * @param status
- * @param depth
- */
- public void addResourceStatus( DavResource resource, int status, int depth )
- {
- addResponse( new MultiStatusResponse( resource.getHref(), status ) );
- if ( depth > 0 && resource.isCollection() )
- {
- DavResourceIterator iter = resource.getMembers();
- while ( iter.hasNext() )
- {
- addResourceStatus( iter.nextResource(), status, depth - 1 );
- }
- }
- }
-
- /**
- * Add a <code>MultiStatusResponse</code> element to this <code>MultiStatus</code>
- *
- * @param response
- */
- public void addResponse( MultiStatusResponse response )
- {
- responses.put( response.getHref(), response );
- }
-
- /**
- * Returns the multistatus responses present as array.
- *
- * @return array of all {@link MultiStatusResponse responses} present in this
- * multistatus.
- */
- public MultiStatusResponse[] getResponses()
- {
- return (MultiStatusResponse[]) responses.values().toArray( new MultiStatusResponse[responses.size()] );
- }
-
- /**
- * Set the response description.
- *
- * @param responseDescription
- */
- public void setResponseDescription( String responseDescription )
- {
- this.responseDescription = responseDescription;
- }
-
- /**
- * Returns the response description.
- *
- * @return responseDescription
- */
- public String getResponseDescription()
- {
- return responseDescription;
- }
-
- /**
- * Return the Xml representation of this <code>MultiStatus</code>.
- *
- * @return Xml document
- * @param document
- */
- public Element toXml( Document document )
- {
- Element multistatus = DomUtil.createElement( document, XML_MULTISTATUS, NAMESPACE );
- for ( MultiStatusResponse response : responses.values() )
- {
- multistatus.appendChild( response.toXml( document ) );
- }
- if ( responseDescription != null )
- {
- Element respDesc =
- DomUtil.createElement( document, XML_RESPONSEDESCRIPTION, NAMESPACE, responseDescription );
- multistatus.appendChild( respDesc );
- }
- return multistatus;
- }
-
- /**
- * Build a <code>MultiStatus</code> from the specified xml element.
- *
- * @param multistatusElement
- * @return new <code>MultiStatus</code> instance.
- * @throws IllegalArgumentException if the given document is <code>null</code>
- * or does not provide the required element.
- */
- public static MultiStatus createFromXml( Element multistatusElement )
- {
- if ( !DomUtil.matches( multistatusElement, XML_MULTISTATUS, NAMESPACE ) )
- {
- throw new IllegalArgumentException( "DAV:multistatus element expected." );
- }
-
- MultiStatus multistatus = new MultiStatus();
-
- ElementIterator it = DomUtil.getChildren( multistatusElement, XML_RESPONSE, NAMESPACE );
- while ( it.hasNext() )
- {
- Element respElem = it.nextElement();
- MultiStatusResponse response = MultiStatusResponse.createFromXml( respElem );
- multistatus.addResponse( response );
- }
-
- // optional response description on the multistatus element
- multistatus.setResponseDescription( DomUtil.getChildText( multistatusElement, XML_RESPONSEDESCRIPTION,
- NAMESPACE ) );
- return multistatus;
- }
-}
+package org.apache.jackrabbit.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
+import org.apache.jackrabbit.webdav.xml.DomUtil;
+import org.apache.jackrabbit.webdav.xml.ElementIterator;
+import org.apache.jackrabbit.webdav.xml.XmlSerializable;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+import java.util.Map;
+import java.util.LinkedHashMap;
+
+/**
+ * MultiStatus representing the content of a multistatus response body and
+ * allows to retrieve the Xml representation.
+ */
+public class MultiStatus
+ implements DavConstants, XmlSerializable
+{
+
+ /**
+ * Map collecting the responses for this multistatus, where every href must
+ * only occur one single time.
+ */
+ private Map<String, MultiStatusResponse> responses = new LinkedHashMap<String, MultiStatusResponse>();
+
+ /**
+ * A general response description at the multistatus top level is used to
+ * provide a general message describing the overarching nature of the response.
+ * If this value is available an application may use it instead of
+ * presenting the individual response descriptions contained within the
+ * responses.
+ */
+ private String responseDescription;
+
+ /**
+ * Add response(s) to this multistatus, in order to build a multistatus for
+ * responding to a PROPFIND request.
+ *
+ * @param resource The resource to add property from
+ * @param propNameSet The requested property names of the PROPFIND request
+ * @param propFindType
+ * @param depth
+ */
+ public void addResourceProperties( DavResource resource, DavPropertyNameSet propNameSet, int propFindType,
+ int depth )
+ {
+ addResponse( new MultiStatusResponse( resource, propNameSet, propFindType ) );
+ if ( depth > 0 && resource.isCollection() )
+ {
+ DavResourceIterator iter = resource.getMembers();
+ while ( iter.hasNext() )
+ {
+ addResourceProperties( iter.nextResource(), propNameSet, propFindType, depth - 1 );
+ }
+ }
+ }
+
+ /**
+ * Add response(s) to this multistatus, in order to build a multistatus e.g.
+ * in order to respond to a PROPFIND request. Please note, that in terms
+ * of PROPFIND, this method would correspond to a
+ * {@link DavConstants#PROPFIND_BY_PROPERTY} propfind type.
+ *
+ * @param resource The resource to add property from
+ * @param propNameSet The requested property names of the PROPFIND request
+ * @param depth
+ * @see #addResourceProperties(DavResource, DavPropertyNameSet, int, int) for
+ * the corresponding method that allows to specify the type explicitly.
+ */
+ public void addResourceProperties( DavResource resource, DavPropertyNameSet propNameSet, int depth )
+ {
+ addResourceProperties( resource, propNameSet, PROPFIND_BY_PROPERTY, depth );
+ }
+
+ /**
+ * Add response(s) to this multistatus, in order to build a multistatus
+ * as returned for COPY, MOVE, LOCK or DELETE requests resulting in an error
+ * with a resource other than the resource identified in the Request-URI.
+ *
+ * @param resource
+ * @param status
+ * @param depth
+ */
+ public void addResourceStatus( DavResource resource, int status, int depth )
+ {
+ addResponse( new MultiStatusResponse( resource.getHref(), status ) );
+ if ( depth > 0 && resource.isCollection() )
+ {
+ DavResourceIterator iter = resource.getMembers();
+ while ( iter.hasNext() )
+ {
+ addResourceStatus( iter.nextResource(), status, depth - 1 );
+ }
+ }
+ }
+
+ /**
+ * Add a <code>MultiStatusResponse</code> element to this <code>MultiStatus</code>
+ *
+ * @param response
+ */
+ public void addResponse( MultiStatusResponse response )
+ {
+ responses.put( response.getHref(), response );
+ }
+
+ /**
+ * Returns the multistatus responses present as array.
+ *
+ * @return array of all {@link MultiStatusResponse responses} present in this
+ * multistatus.
+ */
+ public MultiStatusResponse[] getResponses()
+ {
+ return (MultiStatusResponse[]) responses.values().toArray( new MultiStatusResponse[responses.size()] );
+ }
+
+ /**
+ * Set the response description.
+ *
+ * @param responseDescription
+ */
+ public void setResponseDescription( String responseDescription )
+ {
+ this.responseDescription = responseDescription;
+ }
+
+ /**
+ * Returns the response description.
+ *
+ * @return responseDescription
+ */
+ public String getResponseDescription()
+ {
+ return responseDescription;
+ }
+
+ /**
+ * Return the Xml representation of this <code>MultiStatus</code>.
+ *
+ * @return Xml document
+ * @param document
+ */
+ public Element toXml( Document document )
+ {
+ Element multistatus = DomUtil.createElement( document, XML_MULTISTATUS, NAMESPACE );
+ for ( MultiStatusResponse response : responses.values() )
+ {
+ multistatus.appendChild( response.toXml( document ) );
+ }
+ if ( responseDescription != null )
+ {
+ Element respDesc =
+ DomUtil.createElement( document, XML_RESPONSEDESCRIPTION, NAMESPACE, responseDescription );
+ multistatus.appendChild( respDesc );
+ }
+ return multistatus;
+ }
+
+ /**
+ * Build a <code>MultiStatus</code> from the specified xml element.
+ *
+ * @param multistatusElement
+ * @return new <code>MultiStatus</code> instance.
+ * @throws IllegalArgumentException if the given document is <code>null</code>
+ * or does not provide the required element.
+ */
+ public static MultiStatus createFromXml( Element multistatusElement )
+ {
+ if ( !DomUtil.matches( multistatusElement, XML_MULTISTATUS, NAMESPACE ) )
+ {
+ throw new IllegalArgumentException( "DAV:multistatus element expected." );
+ }
+
+ MultiStatus multistatus = new MultiStatus();
+
+ ElementIterator it = DomUtil.getChildren( multistatusElement, XML_RESPONSE, NAMESPACE );
+ while ( it.hasNext() )
+ {
+ Element respElem = it.nextElement();
+ MultiStatusResponse response = MultiStatusResponse.createFromXml( respElem );
+ multistatus.addResponse( response );
+ }
+
+ // optional response description on the multistatus element
+ multistatus.setResponseDescription( DomUtil.getChildText( multistatusElement, XML_RESPONSEDESCRIPTION,
+ NAMESPACE ) );
+ return multistatus;
+ }
+}
diff --git a/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/jackrabbit/webdav/client/methods/XmlRequestEntity.java b/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/jackrabbit/webdav/client/methods/XmlRequestEntity.java
index 094e114..e595163 100644
--- a/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/jackrabbit/webdav/client/methods/XmlRequestEntity.java
+++ b/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/jackrabbit/webdav/client/methods/XmlRequestEntity.java
@@ -1,95 +1,95 @@
-package org.apache.jackrabbit.webdav.client.methods;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.commons.httpclient.methods.RequestEntity;
-import org.apache.commons.httpclient.methods.StringRequestEntity;
-import org.w3c.dom.Document;
-
-import java.io.OutputStream;
-import java.io.IOException;
-import java.io.ByteArrayOutputStream;
-
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-/**
- * <code>XmlRequestEntity</code>...
- */
-public class XmlRequestEntity
- implements RequestEntity
-{
-
- private static Logger log = LoggerFactory.getLogger( XmlRequestEntity.class );
-
- private final RequestEntity delegatee;
-
- public XmlRequestEntity( Document xmlDocument )
- throws IOException
- {
- super();
- ByteArrayOutputStream out = new ByteArrayOutputStream();
-
- try
- {
- TransformerFactory factory = TransformerFactory.newInstance();
- Transformer transformer = factory.newTransformer();
- transformer.setOutputProperty( OutputKeys.METHOD, "xml" );
- transformer.setOutputProperty( OutputKeys.ENCODING, "UTF-8" );
- transformer.setOutputProperty( OutputKeys.INDENT, "no" );
- transformer.transform( new DOMSource( xmlDocument ), new StreamResult( out ) );
- }
- catch ( TransformerException e )
- {
- log.error( "XML serialization failed", e );
- IOException exception = new IOException( "XML serialization failed" );
- exception.initCause( e );
- throw exception;
- }
-
- delegatee = new StringRequestEntity( out.toString(), "text/xml", "UTF-8" );
- }
-
- public boolean isRepeatable()
- {
- return delegatee.isRepeatable();
- }
-
- public String getContentType()
- {
- return delegatee.getContentType();
- }
-
- public void writeRequest( OutputStream out ) throws IOException
- {
- delegatee.writeRequest( out );
- }
-
- public long getContentLength()
- {
- return delegatee.getContentLength();
- }
+package org.apache.jackrabbit.webdav.client.methods;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.commons.httpclient.methods.RequestEntity;
+import org.apache.commons.httpclient.methods.StringRequestEntity;
+import org.w3c.dom.Document;
+
+import java.io.OutputStream;
+import java.io.IOException;
+import java.io.ByteArrayOutputStream;
+
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+/**
+ * <code>XmlRequestEntity</code>...
+ */
+public class XmlRequestEntity
+ implements RequestEntity
+{
+
+ private static Logger log = LoggerFactory.getLogger( XmlRequestEntity.class );
+
+ private final RequestEntity delegatee;
+
+ public XmlRequestEntity( Document xmlDocument )
+ throws IOException
+ {
+ super();
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+ try
+ {
+ TransformerFactory factory = TransformerFactory.newInstance();
+ Transformer transformer = factory.newTransformer();
+ transformer.setOutputProperty( OutputKeys.METHOD, "xml" );
+ transformer.setOutputProperty( OutputKeys.ENCODING, "UTF-8" );
+ transformer.setOutputProperty( OutputKeys.INDENT, "no" );
+ transformer.transform( new DOMSource( xmlDocument ), new StreamResult( out ) );
+ }
+ catch ( TransformerException e )
+ {
+ log.error( "XML serialization failed", e );
+ IOException exception = new IOException( "XML serialization failed" );
+ exception.initCause( e );
+ throw exception;
+ }
+
+ delegatee = new StringRequestEntity( out.toString(), "text/xml", "UTF-8" );
+ }
+
+ public boolean isRepeatable()
+ {
+ return delegatee.isRepeatable();
+ }
+
+ public String getContentType()
+ {
+ return delegatee.getContentType();
+ }
+
+ public void writeRequest( OutputStream out ) throws IOException
+ {
+ delegatee.writeRequest( out );
+ }
+
+ public long getContentLength()
+ {
+ return delegatee.getContentLength();
+ }
}
\ No newline at end of file
diff --git a/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/AbstractHttpClientWagon.java b/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/AbstractHttpClientWagon.java
index 232e19b..57729c1 100644
--- a/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/AbstractHttpClientWagon.java
+++ b/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/AbstractHttpClientWagon.java
@@ -1,821 +1,831 @@
-package org.apache.maven.wagon.providers.webdav;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.httpclient.Credentials;
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HostConfiguration;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpConnectionManager;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
-import org.apache.commons.httpclient.NTCredentials;
-import org.apache.commons.httpclient.UsernamePasswordCredentials;
-import org.apache.commons.httpclient.auth.AuthScope;
-import org.apache.commons.httpclient.cookie.CookiePolicy;
-import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.HeadMethod;
-import org.apache.commons.httpclient.methods.PutMethod;
-import org.apache.commons.httpclient.methods.RequestEntity;
-import org.apache.commons.httpclient.params.HttpMethodParams;
-import org.apache.commons.httpclient.util.DateParseException;
-import org.apache.commons.httpclient.util.DateUtil;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.maven.wagon.InputData;
-import org.apache.maven.wagon.OutputData;
-import org.apache.maven.wagon.PathUtils;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
-import org.apache.maven.wagon.StreamWagon;
-import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.authorization.AuthorizationException;
-import org.apache.maven.wagon.events.TransferEvent;
-import org.apache.maven.wagon.proxy.ProxyInfo;
-import org.apache.maven.wagon.repository.Repository;
-import org.apache.maven.wagon.resource.Resource;
-import org.apache.maven.wagon.shared.http.EncodingUtil;
-import org.codehaus.plexus.util.IOUtil;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.nio.ByteBuffer;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-import java.util.Properties;
-import java.util.TimeZone;
-import java.util.zip.GZIPInputStream;
-
-/**
- * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
- * @author <a href="mailto:james at atlassian.com">James William Dumay</a>
- */
-public abstract class AbstractHttpClientWagon
- extends StreamWagon
-{
- private final class RequestEntityImplementation
- implements RequestEntity
- {
- private final Resource resource;
-
- private final Wagon wagon;
-
- private File source;
-
- private ByteBuffer byteBuffer;
-
- private RequestEntityImplementation( final InputStream stream, final Resource resource, final Wagon wagon,
- final File source )
- throws TransferFailedException
- {
- if ( source != null )
- {
- this.source = source;
- }
- else
- {
- try
- {
- byte[] bytes = IOUtils.toByteArray( stream );
- this.byteBuffer = ByteBuffer.allocate( bytes.length );
- this.byteBuffer.put( bytes );
- }
- catch ( IOException e )
- {
- throw new TransferFailedException( e.getMessage(), e );
- }
- }
-
- this.resource = resource;
- this.wagon = wagon;
- }
-
- public long getContentLength()
- {
- return resource.getContentLength();
- }
-
- public String getContentType()
- {
- return null;
- }
-
- public boolean isRepeatable()
- {
- return true;
- }
-
- public void writeRequest( OutputStream output )
- throws IOException
- {
- byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
-
- TransferEvent transferEvent =
- new TransferEvent( wagon, resource, TransferEvent.TRANSFER_PROGRESS, TransferEvent.REQUEST_PUT );
- transferEvent.setTimestamp( System.currentTimeMillis() );
-
- InputStream fin = null;
- try
- {
- fin = this.source != null
- ? new FileInputStream( source )
- : new ByteArrayInputStream( this.byteBuffer.array() );
- int remaining = Integer.MAX_VALUE;
- while ( remaining > 0 )
- {
- int n = fin.read( buffer, 0, Math.min( buffer.length, remaining ) );
-
- if ( n == -1 )
- {
- break;
- }
-
- fireTransferProgress( transferEvent, buffer, n );
-
- output.write( buffer, 0, n );
-
- remaining -= n;
- }
- }
- finally
- {
- IOUtils.closeQuietly( fin );
- }
-
- output.flush();
- }
- }
-
- protected static final int SC_NULL = -1;
-
- protected static final TimeZone GMT_TIME_ZONE = TimeZone.getTimeZone( "GMT" );
-
- private HttpClient client;
-
- protected HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
-
- /**
- * @deprecated Use httpConfiguration instead.
- */
- private Properties httpHeaders;
-
- /**
- * @since 1.0-beta-6
- */
- private HttpConfiguration httpConfiguration;
-
- private HttpMethod getMethod;
-
- public void openConnectionInternal()
- {
- repository.setUrl( getURL( repository ) );
- client = new HttpClient( connectionManager );
-
- // WAGON-273: default the cookie-policy to browser compatible
- client.getParams().setCookiePolicy( CookiePolicy.BROWSER_COMPATIBILITY );
-
- String username = null;
- String password = null;
- String domain = null;
-
- if ( authenticationInfo != null )
- {
- username = authenticationInfo.getUserName();
-
- if ( StringUtils.contains( username, "\\" ) )
- {
- String[] domainAndUsername = username.split( "\\\\" );
- domain = domainAndUsername[0];
- username = domainAndUsername[1];
- }
-
- password = authenticationInfo.getPassword();
-
-
- }
-
- String host = getRepository().getHost();
-
- if ( StringUtils.isNotEmpty( username ) && StringUtils.isNotEmpty( password ) )
- {
- Credentials creds;
- if ( domain != null )
- {
- creds = new NTCredentials( username, password, host, domain );
- }
- else
- {
- creds = new UsernamePasswordCredentials( username, password );
- }
-
- int port = getRepository().getPort() > -1 ? getRepository().getPort() : AuthScope.ANY_PORT;
-
- AuthScope scope = new AuthScope( host, port );
- client.getState().setCredentials( scope, creds );
- }
-
- HostConfiguration hc = new HostConfiguration();
-
- ProxyInfo proxyInfo = getProxyInfo( getRepository().getProtocol(), getRepository().getHost() );
- if ( proxyInfo != null )
- {
- String proxyUsername = proxyInfo.getUserName();
- String proxyPassword = proxyInfo.getPassword();
- String proxyHost = proxyInfo.getHost();
- int proxyPort = proxyInfo.getPort();
- String proxyNtlmHost = proxyInfo.getNtlmHost();
- String proxyNtlmDomain = proxyInfo.getNtlmDomain();
- if ( proxyHost != null )
- {
- hc.setProxy( proxyHost, proxyPort );
-
- if ( proxyUsername != null && proxyPassword != null )
- {
- Credentials creds;
- if ( proxyNtlmHost != null || proxyNtlmDomain != null )
- {
- creds = new NTCredentials( proxyUsername, proxyPassword, proxyNtlmHost, proxyNtlmDomain );
- }
- else
- {
- creds = new UsernamePasswordCredentials( proxyUsername, proxyPassword );
- }
-
- int port = proxyInfo.getPort() > -1 ? proxyInfo.getPort() : AuthScope.ANY_PORT;
-
- AuthScope scope = new AuthScope( proxyHost, port );
- client.getState().setProxyCredentials( scope, creds );
- }
- }
- }
-
- hc.setHost( host );
-
- //start a session with the webserver
- client.setHostConfiguration( hc );
- }
-
- public void closeConnection()
- {
- if ( connectionManager instanceof MultiThreadedHttpConnectionManager )
- {
- ( (MultiThreadedHttpConnectionManager) connectionManager ).shutdown();
- }
- }
-
- public void put( File source, String resourceName )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- Resource resource = new Resource( resourceName );
-
- firePutInitiated( resource, source );
-
- resource.setContentLength( source.length() );
-
- resource.setLastModified( source.lastModified() );
-
- put( null, resource, source );
- }
-
- public void putFromStream( final InputStream stream, String destination, long contentLength, long lastModified )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- Resource resource = new Resource( destination );
-
- firePutInitiated( resource, null );
-
- resource.setContentLength( contentLength );
-
- resource.setLastModified( lastModified );
-
- put( stream, resource, null );
- }
-
- private void put( final InputStream stream, Resource resource, File source )
- throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
- {
- RequestEntityImplementation requestEntityImplementation =
- new RequestEntityImplementation( stream, resource, this, source );
-
- put( resource, source, requestEntityImplementation, buildUrl( resource ) );
-
- }
-
- /**
- * Builds a complete URL string from the repository URL and the relative path of the resource passed.
- *
- * @param resource the resource to extract the relative path from.
- * @return the complete URL
- */
- private String buildUrl( Resource resource )
- {
- return EncodingUtil.encodeURLToString( getRepository().getUrl(), resource.getName() );
- }
-
- private void put( Resource resource, File source, RequestEntityImplementation requestEntityImplementation,
- String url )
- throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
- {
- // preemptive true for put
- client.getParams().setAuthenticationPreemptive( true );
-
- //Parent directories need to be created before posting
- try
- {
- mkdirs( PathUtils.dirname( resource.getName() ) );
- }
- catch ( IOException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_GET );
- }
-
- PutMethod putMethod = new PutMethod( url );
-
- firePutStarted( resource, source );
-
- try
- {
- putMethod.setRequestEntity( requestEntityImplementation );
-
- int statusCode;
- try
- {
- statusCode = execute( putMethod );
-
- }
- catch ( IOException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
-
- throw new TransferFailedException( e.getMessage(), e );
- }
-
- fireTransferDebug( url + " - Status code: " + statusCode );
-
- // Check that we didn't run out of retries.
- // CHECKSTYLE_OFF: AvoidNestedBlocks
- switch ( statusCode )
- {
- // Success Codes
- case HttpStatus.SC_OK: // 200
- case HttpStatus.SC_CREATED: // 201
- case HttpStatus.SC_ACCEPTED: // 202
- case HttpStatus.SC_NO_CONTENT: // 204
- break;
-
- // handle all redirect even if http specs says
- // " the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user"
- case HttpStatus.SC_MOVED_PERMANENTLY: // 301
- case HttpStatus.SC_MOVED_TEMPORARILY: // 302
- case HttpStatus.SC_SEE_OTHER: // 303
- String relocatedUrl = calculateRelocatedUrl( putMethod );
- fireTransferDebug( "relocate to " + relocatedUrl );
- put( resource, source, requestEntityImplementation, relocatedUrl );
- return;
-
- case SC_NULL:
- {
- TransferFailedException e = new TransferFailedException( "Failed to transfer file: " + url );
- fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
- throw e;
- }
-
- case HttpStatus.SC_FORBIDDEN:
- fireSessionConnectionRefused();
- throw new AuthorizationException( "Access denied to: " + url );
-
- case HttpStatus.SC_NOT_FOUND:
- throw new ResourceDoesNotExistException( "File: " + url + " does not exist" );
-
- //add more entries here
- default:
- {
- TransferFailedException e = new TransferFailedException(
- "Failed to transfer file: " + url + ". Return code is: " + statusCode );
- fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
- throw e;
- }
- }
- // CHECKSTYLE_ON: AvoidNestedBlocks
-
- firePutCompleted( resource, source );
- }
- finally
- {
- putMethod.releaseConnection();
- }
- }
-
- protected String calculateRelocatedUrl( EntityEnclosingMethod method )
- {
- Header locationHeader = method.getResponseHeader( "Location" );
- String locationField = locationHeader.getValue();
- // is it a relative Location or a full ?
- return locationField.startsWith( "http" ) ? locationField : getURL( getRepository() ) + '/' + locationField;
- }
-
- protected void mkdirs( String dirname )
- throws IOException
- {
- // do nothing as default.
- }
-
- public boolean resourceExists( String resourceName )
- throws TransferFailedException, AuthorizationException
- {
- StringBuilder url = new StringBuilder( getRepository().getUrl() );
- if ( !url.toString().endsWith( "/" ) )
- {
- url.append( '/' );
- }
- url.append( resourceName );
- HeadMethod headMethod = new HeadMethod( url.toString() );
-
- int statusCode;
- try
- {
- statusCode = execute( headMethod );
- }
- catch ( IOException e )
- {
- throw new TransferFailedException( e.getMessage(), e );
- }
- try
- {
- switch ( statusCode )
- {
- case HttpStatus.SC_OK:
- return true;
-
- case HttpStatus.SC_NOT_MODIFIED:
- return true;
-
- case SC_NULL:
- throw new TransferFailedException( "Failed to transfer file: " + url );
-
- case HttpStatus.SC_FORBIDDEN:
- throw new AuthorizationException( "Access denied to: " + url );
-
- case HttpStatus.SC_UNAUTHORIZED:
- throw new AuthorizationException( "Not authorized." );
-
- case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
- throw new AuthorizationException( "Not authorized by proxy." );
-
- case HttpStatus.SC_NOT_FOUND:
- return false;
-
- //add more entries here
- default:
- throw new TransferFailedException(
- "Failed to transfer file: " + url + ". Return code is: " + statusCode );
- }
- }
- finally
- {
- headMethod.releaseConnection();
- }
- }
-
- protected int execute( HttpMethod httpMethod )
- throws IOException
- {
- int statusCode;
-
- setParameters( httpMethod );
- setHeaders( httpMethod );
-
- statusCode = client.executeMethod( httpMethod );
- return statusCode;
- }
-
- protected void setParameters( HttpMethod method )
- {
- HttpMethodConfiguration config =
- httpConfiguration == null ? null : httpConfiguration.getMethodConfiguration( method );
- if ( config != null )
- {
- HttpMethodParams params = config.asMethodParams( method.getParams() );
- if ( params != null )
- {
- method.setParams( params );
- }
- }
-
- if ( config == null || config.getConnectionTimeout() == HttpMethodConfiguration.DEFAULT_CONNECTION_TIMEOUT )
- {
- method.getParams().setSoTimeout( getTimeout() );
- }
- }
-
- protected void setHeaders( HttpMethod method )
- {
- HttpMethodConfiguration config =
- httpConfiguration == null ? null : httpConfiguration.getMethodConfiguration( method );
- if ( config == null || config.isUseDefaultHeaders() )
- {
- // TODO: merge with the other headers and have some better defaults, unify with lightweight headers
- method.addRequestHeader( "Cache-control", "no-cache" );
- method.addRequestHeader( "Cache-store", "no-store" );
- method.addRequestHeader( "Pragma", "no-cache" );
- method.addRequestHeader( "Expires", "0" );
- method.addRequestHeader( "Accept-Encoding", "gzip" );
- method.addRequestHeader( "User-Agent", DEFAULT_USER_AGENT );
- }
-
- if ( httpHeaders != null )
- {
- for ( Object header : httpHeaders.keySet() )
- {
- if ( "User-Agent".equals( header ) )
- {
- method.setRequestHeader( (String) header, httpHeaders.getProperty( (String) header ) );
- }
- else
- {
- method.addRequestHeader( (String) header, httpHeaders.getProperty( (String) header ) );
- }
- }
- }
-
- Header[] headers = config == null ? null : config.asRequestHeaders();
- if ( headers != null )
- {
- for ( Header header : headers )
- {
- method.addRequestHeader( header );
- }
- }
- }
-
- private static final String DEFAULT_USER_AGENT = getDefaultUserAgent();
-
- private static String getDefaultUserAgent()
- {
- Properties props = new Properties();
-
- InputStream is = AbstractHttpClientWagon.class.getResourceAsStream(
- "/META-INF/maven/org.apache.maven.wagon/wagon-webdav-jackrabbit/pom.properties" );
- if ( is != null )
- {
- try
- {
- props.load( is );
- }
- catch ( IOException ignore )
- {
- // ignore
- }
- finally
- {
- IOUtil.close( is );
- }
- }
-
- String ver = props.getProperty( "version", "unknown-version" );
- return "Apache-Maven-Wagon/" + ver + " (Java " + System.getProperty( "java.version" ) + "; ";
- }
-
- /**
- * getUrl
- * Implementors can override this to remove unwanted parts of the url such as role-hints
- *
- * @param repository
- * @return
- */
- protected String getURL( Repository repository )
- {
- return repository.getUrl();
- }
-
- protected HttpClient getClient()
- {
- return client;
- }
-
- public void setConnectionManager( HttpConnectionManager connectionManager )
- {
- this.connectionManager = connectionManager;
- }
-
- public Properties getHttpHeaders()
- {
- return httpHeaders;
- }
-
- public void setHttpHeaders( Properties httpHeaders )
- {
- this.httpHeaders = httpHeaders;
- }
-
- public HttpConfiguration getHttpConfiguration()
- {
- return httpConfiguration;
- }
-
- public void setHttpConfiguration( HttpConfiguration httpConfiguration )
- {
- this.httpConfiguration = httpConfiguration;
- }
-
- public void fillInputData( InputData inputData )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- Resource resource = inputData.getResource();
-
- StringBuilder url = new StringBuilder( getRepository().getUrl() );
- if ( !url.toString().endsWith( "/" ) )
- {
- url.append( '/' );
- }
- url.append( resource.getName() );
-
- getMethod = new GetMethod( url.toString() );
-
- long timestamp = resource.getLastModified();
- if ( timestamp > 0 )
- {
- SimpleDateFormat fmt = new SimpleDateFormat( "EEE, dd-MMM-yy HH:mm:ss zzz", Locale.US );
- fmt.setTimeZone( GMT_TIME_ZONE );
- Header hdr = new Header( "If-Modified-Since", fmt.format( new Date( timestamp ) ) );
- fireTransferDebug( "sending ==> " + hdr + "(" + timestamp + ")" );
- getMethod.addRequestHeader( hdr );
- }
-
- int statusCode;
- try
- {
- statusCode = execute( getMethod );
- }
- catch ( IOException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_GET );
-
- throw new TransferFailedException( e.getMessage(), e );
- }
-
- fireTransferDebug( url + " - Status code: " + statusCode );
-
- // TODO [BP]: according to httpclient docs, really should swallow the output on error. verify if that is
- // required
- // CHECKSTYLE_OFF: AvoidNestedBlocks
- switch ( statusCode )
- {
- case HttpStatus.SC_OK:
- break;
-
- case HttpStatus.SC_NOT_MODIFIED:
- // return, leaving last modified set to original value so getIfNewer should return unmodified
- return;
-
- case SC_NULL:
- {
- TransferFailedException e = new TransferFailedException( "Failed to transfer file: " + url );
- fireTransferError( resource, e, TransferEvent.REQUEST_GET );
- throw e;
- }
-
- case HttpStatus.SC_FORBIDDEN:
- fireSessionConnectionRefused();
- throw new AuthorizationException( "Access denied to: " + url );
-
- case HttpStatus.SC_UNAUTHORIZED:
- fireSessionConnectionRefused();
- throw new AuthorizationException( "Not authorized." );
-
- case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
- fireSessionConnectionRefused();
- throw new AuthorizationException( "Not authorized by proxy." );
-
- case HttpStatus.SC_NOT_FOUND:
- throw new ResourceDoesNotExistException( "File: " + url + " does not exist" );
-
- // add more entries here
- default:
- {
- cleanupGetTransfer( resource );
- TransferFailedException e = new TransferFailedException(
- "Failed to transfer file: " + url + ". Return code is: " + statusCode );
- fireTransferError( resource, e, TransferEvent.REQUEST_GET );
- throw e;
- }
- }
- // CHECKSTYLE_ON: AvoidNestedBlocks
-
- InputStream is = null;
-
- Header contentLengthHeader = getMethod.getResponseHeader( "Content-Length" );
-
- if ( contentLengthHeader != null )
- {
- try
- {
- long contentLength = Integer.valueOf( contentLengthHeader.getValue() ).intValue();
-
- resource.setContentLength( contentLength );
- }
- catch ( NumberFormatException e )
- {
- fireTransferDebug(
- "error parsing content length header '" + contentLengthHeader.getValue() + "' " + e );
- }
- }
-
- Header lastModifiedHeader = getMethod.getResponseHeader( "Last-Modified" );
-
- long lastModified = 0;
-
- if ( lastModifiedHeader != null )
- {
- try
- {
- lastModified = DateUtil.parseDate( lastModifiedHeader.getValue() ).getTime();
-
- resource.setLastModified( lastModified );
- }
- catch ( DateParseException e )
- {
- fireTransferDebug( "Unable to parse last modified header" );
- }
-
- fireTransferDebug( "last-modified = " + lastModifiedHeader.getValue() + " (" + lastModified + ")" );
- }
-
- Header contentEncoding = getMethod.getResponseHeader( "Content-Encoding" );
- boolean isGZipped = contentEncoding != null && "gzip".equalsIgnoreCase( contentEncoding.getValue() );
-
- try
- {
- is = getMethod.getResponseBodyAsStream();
- if ( isGZipped )
- {
- is = new GZIPInputStream( is );
- }
- }
- catch ( IOException e )
- {
- fireTransferError( resource, e, TransferEvent.REQUEST_GET );
-
- String msg =
- "Error occurred while retrieving from remote repository:" + getRepository() + ": " + e.getMessage();
-
- throw new TransferFailedException( msg, e );
- }
-
- inputData.setInputStream( is );
- }
-
- protected void cleanupGetTransfer( Resource resource )
- {
- if ( getMethod != null )
- {
- getMethod.releaseConnection();
- }
- }
-
- @Override
- public void putFromStream( InputStream stream, String destination )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- putFromStream( stream, destination, -1, -1 );
- }
-
- @Override
- protected void putFromStream( InputStream stream, Resource resource )
- throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
- {
- putFromStream( stream, resource.getName(), -1, -1 );
- }
-
- @Override
- public void fillOutputData( OutputData outputData )
- throws TransferFailedException
- {
- // no needed in this implementation but throw an Exception if used
- throw new IllegalStateException( "this wagon http client must not use fillOutputData" );
- }
-}
+package org.apache.maven.wagon.providers.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.httpclient.Credentials;
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HostConfiguration;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpConnectionManager;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+import org.apache.commons.httpclient.NTCredentials;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.auth.AuthScope;
+import org.apache.commons.httpclient.cookie.CookiePolicy;
+import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.HeadMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.httpclient.methods.RequestEntity;
+import org.apache.commons.httpclient.params.HttpMethodParams;
+import org.apache.commons.httpclient.util.DateParseException;
+import org.apache.commons.httpclient.util.DateUtil;
+import org.apache.commons.io.IOUtils;
+import org.apache.maven.wagon.InputData;
+import org.apache.maven.wagon.OutputData;
+import org.apache.maven.wagon.PathUtils;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.StreamWagon;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.events.TransferEvent;
+import org.apache.maven.wagon.proxy.ProxyInfo;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.resource.Resource;
+import org.apache.maven.wagon.shared.http.EncodingUtil;
+import org.codehaus.plexus.util.IOUtil;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+import java.util.Properties;
+import java.util.TimeZone;
+import java.util.zip.GZIPInputStream;
+
+/**
+ * @author <a href="michal.maczka at dimatics.com">Michal Maczka</a>
+ * @author <a href="mailto:james at atlassian.com">James William Dumay</a>
+ */
+public abstract class AbstractHttpClientWagon
+ extends StreamWagon
+{
+ private final class RequestEntityImplementation
+ implements RequestEntity
+ {
+ private final Resource resource;
+
+ private final Wagon wagon;
+
+ private File source;
+
+ private ByteBuffer byteBuffer;
+
+ private RequestEntityImplementation( final InputStream stream, final Resource resource, final Wagon wagon,
+ final File source )
+ throws TransferFailedException
+ {
+ if ( source != null )
+ {
+ this.source = source;
+ }
+ else
+ {
+ try
+ {
+ byte[] bytes = IOUtils.toByteArray( stream );
+ this.byteBuffer = ByteBuffer.allocate( bytes.length );
+ this.byteBuffer.put( bytes );
+ stream.close();
+ }
+ catch ( IOException e )
+ {
+ throw new TransferFailedException( e.getMessage(), e );
+ }
+ finally
+ {
+ IOUtils.closeQuietly( stream );
+ }
+ }
+
+ this.resource = resource;
+ this.wagon = wagon;
+ }
+
+ public long getContentLength()
+ {
+ return resource.getContentLength();
+ }
+
+ public String getContentType()
+ {
+ return null;
+ }
+
+ public boolean isRepeatable()
+ {
+ return true;
+ }
+
+ public void writeRequest( OutputStream output )
+ throws IOException
+ {
+ byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];
+
+ TransferEvent transferEvent =
+ new TransferEvent( wagon, resource, TransferEvent.TRANSFER_PROGRESS, TransferEvent.REQUEST_PUT );
+ transferEvent.setTimestamp( System.currentTimeMillis() );
+
+ InputStream fin = null;
+ try
+ {
+ fin = this.source != null
+ ? new FileInputStream( source )
+ : new ByteArrayInputStream( this.byteBuffer.array() );
+ int remaining = Integer.MAX_VALUE;
+ while ( remaining > 0 )
+ {
+ int n = fin.read( buffer, 0, Math.min( buffer.length, remaining ) );
+
+ if ( n == -1 )
+ {
+ break;
+ }
+
+ fireTransferProgress( transferEvent, buffer, n );
+
+ output.write( buffer, 0, n );
+
+ remaining -= n;
+ }
+
+ fin.close();
+ fin = null;
+ }
+ finally
+ {
+ IOUtils.closeQuietly( fin );
+ }
+
+ output.flush();
+ }
+ }
+
+ protected static final int SC_NULL = -1;
+
+ protected static final TimeZone GMT_TIME_ZONE = TimeZone.getTimeZone( "GMT" );
+
+ private HttpClient client;
+
+ protected HttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager();
+
+ /**
+ * @deprecated Use httpConfiguration instead.
+ */
+ private Properties httpHeaders;
+
+ /**
+ * @since 1.0-beta-6
+ */
+ private HttpConfiguration httpConfiguration;
+
+ private HttpMethod getMethod;
+
+ public void openConnectionInternal()
+ {
+ repository.setUrl( getURL( repository ) );
+ client = new HttpClient( connectionManager );
+
+ // WAGON-273: default the cookie-policy to browser compatible
+ client.getParams().setCookiePolicy( CookiePolicy.BROWSER_COMPATIBILITY );
+
+ String username = null;
+ String password = null;
+ String domain = null;
+
+ if ( authenticationInfo != null )
+ {
+ username = authenticationInfo.getUserName();
+
+ if ( username != null && username.contains( "\\" ) )
+ {
+ String[] domainAndUsername = username.split( "\\\\" );
+ domain = domainAndUsername[0];
+ username = domainAndUsername[1];
+ }
+
+ password = authenticationInfo.getPassword();
+
+
+ }
+
+ String host = getRepository().getHost();
+
+ if ( !( username == null || username.length() == 0 )
+ && !( password == null || password.length() == 0 ) )
+ {
+ Credentials creds;
+ if ( domain != null )
+ {
+ creds = new NTCredentials( username, password, host, domain );
+ }
+ else
+ {
+ creds = new UsernamePasswordCredentials( username, password );
+ }
+
+ int port = getRepository().getPort() > -1 ? getRepository().getPort() : AuthScope.ANY_PORT;
+
+ AuthScope scope = new AuthScope( host, port );
+ client.getState().setCredentials( scope, creds );
+ }
+
+ HostConfiguration hc = new HostConfiguration();
+
+ ProxyInfo proxyInfo = getProxyInfo( getRepository().getProtocol(), getRepository().getHost() );
+ if ( proxyInfo != null )
+ {
+ String proxyUsername = proxyInfo.getUserName();
+ String proxyPassword = proxyInfo.getPassword();
+ String proxyHost = proxyInfo.getHost();
+ int proxyPort = proxyInfo.getPort();
+ String proxyNtlmHost = proxyInfo.getNtlmHost();
+ String proxyNtlmDomain = proxyInfo.getNtlmDomain();
+ if ( proxyHost != null )
+ {
+ hc.setProxy( proxyHost, proxyPort );
+
+ if ( proxyUsername != null && proxyPassword != null )
+ {
+ Credentials creds;
+ if ( proxyNtlmHost != null || proxyNtlmDomain != null )
+ {
+ creds = new NTCredentials( proxyUsername, proxyPassword, proxyNtlmHost, proxyNtlmDomain );
+ }
+ else
+ {
+ creds = new UsernamePasswordCredentials( proxyUsername, proxyPassword );
+ }
+
+ int port = proxyInfo.getPort() > -1 ? proxyInfo.getPort() : AuthScope.ANY_PORT;
+
+ AuthScope scope = new AuthScope( proxyHost, port );
+ client.getState().setProxyCredentials( scope, creds );
+ }
+ }
+ }
+
+ hc.setHost( host );
+
+ //start a session with the webserver
+ client.setHostConfiguration( hc );
+ }
+
+ public void closeConnection()
+ {
+ if ( connectionManager instanceof MultiThreadedHttpConnectionManager )
+ {
+ ( (MultiThreadedHttpConnectionManager) connectionManager ).shutdown();
+ }
+ }
+
+ public void put( File source, String resourceName )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ Resource resource = new Resource( resourceName );
+
+ firePutInitiated( resource, source );
+
+ resource.setContentLength( source.length() );
+
+ resource.setLastModified( source.lastModified() );
+
+ put( null, resource, source );
+ }
+
+ public void putFromStream( final InputStream stream, String destination, long contentLength, long lastModified )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ Resource resource = new Resource( destination );
+
+ firePutInitiated( resource, null );
+
+ resource.setContentLength( contentLength );
+
+ resource.setLastModified( lastModified );
+
+ put( stream, resource, null );
+ }
+
+ private void put( final InputStream stream, Resource resource, File source )
+ throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
+ {
+ RequestEntityImplementation requestEntityImplementation =
+ new RequestEntityImplementation( stream, resource, this, source );
+
+ put( resource, source, requestEntityImplementation, buildUrl( resource ) );
+
+ }
+
+ /**
+ * Builds a complete URL string from the repository URL and the relative path of the resource passed.
+ *
+ * @param resource the resource to extract the relative path from.
+ * @return the complete URL
+ */
+ private String buildUrl( Resource resource )
+ {
+ return EncodingUtil.encodeURLToString( getRepository().getUrl(), resource.getName() );
+ }
+
+ private void put( Resource resource, File source, RequestEntityImplementation requestEntityImplementation,
+ String url )
+ throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
+ {
+ // preemptive true for put
+ client.getParams().setAuthenticationPreemptive( true );
+
+ //Parent directories need to be created before posting
+ try
+ {
+ mkdirs( PathUtils.dirname( resource.getName() ) );
+ }
+ catch ( IOException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+ }
+
+ PutMethod putMethod = new PutMethod( url );
+
+ firePutStarted( resource, source );
+
+ try
+ {
+ putMethod.setRequestEntity( requestEntityImplementation );
+
+ int statusCode;
+ try
+ {
+ statusCode = execute( putMethod );
+
+ }
+ catch ( IOException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+
+ throw new TransferFailedException( e.getMessage(), e );
+ }
+
+ fireTransferDebug( url + " - Status code: " + statusCode );
+
+ // Check that we didn't run out of retries.
+ // CHECKSTYLE_OFF: AvoidNestedBlocks
+ switch ( statusCode )
+ {
+ // Success Codes
+ case HttpStatus.SC_OK: // 200
+ case HttpStatus.SC_CREATED: // 201
+ case HttpStatus.SC_ACCEPTED: // 202
+ case HttpStatus.SC_NO_CONTENT: // 204
+ break;
+
+ // handle all redirect even if http specs says
+ // " the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user"
+ case HttpStatus.SC_MOVED_PERMANENTLY: // 301
+ case HttpStatus.SC_MOVED_TEMPORARILY: // 302
+ case HttpStatus.SC_SEE_OTHER: // 303
+ String relocatedUrl = calculateRelocatedUrl( putMethod );
+ fireTransferDebug( "relocate to " + relocatedUrl );
+ put( resource, source, requestEntityImplementation, relocatedUrl );
+ return;
+
+ case SC_NULL:
+ {
+ TransferFailedException e = new TransferFailedException( "Failed to transfer file: " + url );
+ fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+ throw e;
+ }
+
+ case HttpStatus.SC_FORBIDDEN:
+ fireSessionConnectionRefused();
+ throw new AuthorizationException( "Access denied to: " + url );
+
+ case HttpStatus.SC_NOT_FOUND:
+ throw new ResourceDoesNotExistException( "File: " + url + " does not exist" );
+
+ //add more entries here
+ default:
+ {
+ TransferFailedException e = new TransferFailedException(
+ "Failed to transfer file: " + url + ". Return code is: " + statusCode );
+ fireTransferError( resource, e, TransferEvent.REQUEST_PUT );
+ throw e;
+ }
+ }
+ // CHECKSTYLE_ON: AvoidNestedBlocks
+
+ firePutCompleted( resource, source );
+ }
+ finally
+ {
+ putMethod.releaseConnection();
+ }
+ }
+
+ protected String calculateRelocatedUrl( EntityEnclosingMethod method )
+ {
+ Header locationHeader = method.getResponseHeader( "Location" );
+ String locationField = locationHeader.getValue();
+ // is it a relative Location or a full ?
+ return locationField.startsWith( "http" ) ? locationField : getURL( getRepository() ) + '/' + locationField;
+ }
+
+ protected void mkdirs( String dirname )
+ throws IOException
+ {
+ // do nothing as default.
+ }
+
+ public boolean resourceExists( String resourceName )
+ throws TransferFailedException, AuthorizationException
+ {
+ StringBuilder url = new StringBuilder( getRepository().getUrl() );
+ if ( !url.toString().endsWith( "/" ) )
+ {
+ url.append( '/' );
+ }
+ url.append( resourceName );
+ HeadMethod headMethod = new HeadMethod( url.toString() );
+
+ int statusCode;
+ try
+ {
+ statusCode = execute( headMethod );
+ }
+ catch ( IOException e )
+ {
+ throw new TransferFailedException( e.getMessage(), e );
+ }
+ try
+ {
+ switch ( statusCode )
+ {
+ case HttpStatus.SC_OK:
+ return true;
+
+ case HttpStatus.SC_NOT_MODIFIED:
+ return true;
+
+ case SC_NULL:
+ throw new TransferFailedException( "Failed to transfer file: " + url );
+
+ case HttpStatus.SC_FORBIDDEN:
+ throw new AuthorizationException( "Access denied to: " + url );
+
+ case HttpStatus.SC_UNAUTHORIZED:
+ throw new AuthorizationException( "Not authorized." );
+
+ case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
+ throw new AuthorizationException( "Not authorized by proxy." );
+
+ case HttpStatus.SC_NOT_FOUND:
+ return false;
+
+ //add more entries here
+ default:
+ throw new TransferFailedException(
+ "Failed to transfer file: " + url + ". Return code is: " + statusCode );
+ }
+ }
+ finally
+ {
+ headMethod.releaseConnection();
+ }
+ }
+
+ protected int execute( HttpMethod httpMethod )
+ throws IOException
+ {
+ int statusCode;
+
+ setParameters( httpMethod );
+ setHeaders( httpMethod );
+
+ statusCode = client.executeMethod( httpMethod );
+ return statusCode;
+ }
+
+ protected void setParameters( HttpMethod method )
+ {
+ HttpMethodConfiguration config =
+ httpConfiguration == null ? null : httpConfiguration.getMethodConfiguration( method );
+ if ( config != null )
+ {
+ HttpMethodParams params = config.asMethodParams( method.getParams() );
+ if ( params != null )
+ {
+ method.setParams( params );
+ }
+ }
+
+ if ( config == null || config.getConnectionTimeout() == HttpMethodConfiguration.DEFAULT_CONNECTION_TIMEOUT )
+ {
+ method.getParams().setSoTimeout( getTimeout() );
+ }
+ }
+
+ protected void setHeaders( HttpMethod method )
+ {
+ HttpMethodConfiguration config =
+ httpConfiguration == null ? null : httpConfiguration.getMethodConfiguration( method );
+ if ( config == null || config.isUseDefaultHeaders() )
+ {
+ // TODO: merge with the other headers and have some better defaults, unify with lightweight headers
+ method.addRequestHeader( "Cache-control", "no-cache" );
+ method.addRequestHeader( "Cache-store", "no-store" );
+ method.addRequestHeader( "Pragma", "no-cache" );
+ method.addRequestHeader( "Expires", "0" );
+ method.addRequestHeader( "Accept-Encoding", "gzip" );
+ method.addRequestHeader( "User-Agent", DEFAULT_USER_AGENT );
+ }
+
+ if ( httpHeaders != null )
+ {
+ for ( Object header : httpHeaders.keySet() )
+ {
+ if ( "User-Agent".equals( header ) )
+ {
+ method.setRequestHeader( (String) header, httpHeaders.getProperty( (String) header ) );
+ }
+ else
+ {
+ method.addRequestHeader( (String) header, httpHeaders.getProperty( (String) header ) );
+ }
+ }
+ }
+
+ Header[] headers = config == null ? null : config.asRequestHeaders();
+ if ( headers != null )
+ {
+ for ( Header header : headers )
+ {
+ method.addRequestHeader( header );
+ }
+ }
+ }
+
+ private static final String DEFAULT_USER_AGENT = getDefaultUserAgent();
+
+ private static String getDefaultUserAgent()
+ {
+ Properties props = new Properties();
+
+ InputStream is = AbstractHttpClientWagon.class.getResourceAsStream(
+ "/META-INF/maven/org.apache.maven.wagon/wagon-webdav-jackrabbit/pom.properties" );
+ if ( is != null )
+ {
+ try
+ {
+ props.load( is );
+ is.close();
+ is = null;
+ }
+ catch ( IOException ignore )
+ {
+ // ignore
+ }
+ finally
+ {
+ IOUtil.close( is );
+ }
+ }
+
+ String ver = props.getProperty( "version", "unknown-version" );
+ return "Apache-Maven-Wagon/" + ver + " (Java " + System.getProperty( "java.version" ) + "; ";
+ }
+
+ /**
+ * getUrl
+ * Implementors can override this to remove unwanted parts of the url such as role-hints
+ *
+ * @param repository
+ * @return
+ */
+ protected String getURL( Repository repository )
+ {
+ return repository.getUrl();
+ }
+
+ protected HttpClient getClient()
+ {
+ return client;
+ }
+
+ public void setConnectionManager( HttpConnectionManager connectionManager )
+ {
+ this.connectionManager = connectionManager;
+ }
+
+ public Properties getHttpHeaders()
+ {
+ return httpHeaders;
+ }
+
+ public void setHttpHeaders( Properties httpHeaders )
+ {
+ this.httpHeaders = httpHeaders;
+ }
+
+ public HttpConfiguration getHttpConfiguration()
+ {
+ return httpConfiguration;
+ }
+
+ public void setHttpConfiguration( HttpConfiguration httpConfiguration )
+ {
+ this.httpConfiguration = httpConfiguration;
+ }
+
+ public void fillInputData( InputData inputData )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ Resource resource = inputData.getResource();
+
+ StringBuilder url = new StringBuilder( getRepository().getUrl() );
+ if ( !url.toString().endsWith( "/" ) )
+ {
+ url.append( '/' );
+ }
+ url.append( resource.getName() );
+
+ getMethod = new GetMethod( url.toString() );
+
+ long timestamp = resource.getLastModified();
+ if ( timestamp > 0 )
+ {
+ SimpleDateFormat fmt = new SimpleDateFormat( "EEE, dd-MMM-yy HH:mm:ss zzz", Locale.US );
+ fmt.setTimeZone( GMT_TIME_ZONE );
+ Header hdr = new Header( "If-Modified-Since", fmt.format( new Date( timestamp ) ) );
+ fireTransferDebug( "sending ==> " + hdr + "(" + timestamp + ")" );
+ getMethod.addRequestHeader( hdr );
+ }
+
+ int statusCode;
+ try
+ {
+ statusCode = execute( getMethod );
+ }
+ catch ( IOException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+
+ throw new TransferFailedException( e.getMessage(), e );
+ }
+
+ fireTransferDebug( url + " - Status code: " + statusCode );
+
+ // TODO [BP]: according to httpclient docs, really should swallow the output on error. verify if that is
+ // required
+ // CHECKSTYLE_OFF: AvoidNestedBlocks
+ switch ( statusCode )
+ {
+ case HttpStatus.SC_OK:
+ break;
+
+ case HttpStatus.SC_NOT_MODIFIED:
+ // return, leaving last modified set to original value so getIfNewer should return unmodified
+ return;
+
+ case SC_NULL:
+ {
+ TransferFailedException e = new TransferFailedException( "Failed to transfer file: " + url );
+ fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+ throw e;
+ }
+
+ case HttpStatus.SC_FORBIDDEN:
+ fireSessionConnectionRefused();
+ throw new AuthorizationException( "Access denied to: " + url );
+
+ case HttpStatus.SC_UNAUTHORIZED:
+ fireSessionConnectionRefused();
+ throw new AuthorizationException( "Not authorized." );
+
+ case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED:
+ fireSessionConnectionRefused();
+ throw new AuthorizationException( "Not authorized by proxy." );
+
+ case HttpStatus.SC_NOT_FOUND:
+ throw new ResourceDoesNotExistException( "File: " + url + " does not exist" );
+
+ // add more entries here
+ default:
+ {
+ cleanupGetTransfer( resource );
+ TransferFailedException e = new TransferFailedException(
+ "Failed to transfer file: " + url + ". Return code is: " + statusCode );
+ fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+ throw e;
+ }
+ }
+ // CHECKSTYLE_ON: AvoidNestedBlocks
+
+ InputStream is = null;
+
+ Header contentLengthHeader = getMethod.getResponseHeader( "Content-Length" );
+
+ if ( contentLengthHeader != null )
+ {
+ try
+ {
+ long contentLength = Integer.valueOf( contentLengthHeader.getValue() ).intValue();
+
+ resource.setContentLength( contentLength );
+ }
+ catch ( NumberFormatException e )
+ {
+ fireTransferDebug(
+ "error parsing content length header '" + contentLengthHeader.getValue() + "' " + e );
+ }
+ }
+
+ Header lastModifiedHeader = getMethod.getResponseHeader( "Last-Modified" );
+
+ long lastModified = 0;
+
+ if ( lastModifiedHeader != null )
+ {
+ try
+ {
+ lastModified = DateUtil.parseDate( lastModifiedHeader.getValue() ).getTime();
+
+ resource.setLastModified( lastModified );
+ }
+ catch ( DateParseException e )
+ {
+ fireTransferDebug( "Unable to parse last modified header" );
+ }
+
+ fireTransferDebug( "last-modified = " + lastModifiedHeader.getValue() + " (" + lastModified + ")" );
+ }
+
+ Header contentEncoding = getMethod.getResponseHeader( "Content-Encoding" );
+ boolean isGZipped = contentEncoding != null && "gzip".equalsIgnoreCase( contentEncoding.getValue() );
+
+ try
+ {
+ is = getMethod.getResponseBodyAsStream();
+ if ( isGZipped )
+ {
+ is = new GZIPInputStream( is );
+ }
+ }
+ catch ( IOException e )
+ {
+ fireTransferError( resource, e, TransferEvent.REQUEST_GET );
+
+ String msg =
+ "Error occurred while retrieving from remote repository:" + getRepository() + ": " + e.getMessage();
+
+ throw new TransferFailedException( msg, e );
+ }
+
+ inputData.setInputStream( is );
+ }
+
+ protected void cleanupGetTransfer( Resource resource )
+ {
+ if ( getMethod != null )
+ {
+ getMethod.releaseConnection();
+ }
+ }
+
+ @Override
+ public void putFromStream( InputStream stream, String destination )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ putFromStream( stream, destination, -1, -1 );
+ }
+
+ @Override
+ protected void putFromStream( InputStream stream, Resource resource )
+ throws TransferFailedException, AuthorizationException, ResourceDoesNotExistException
+ {
+ putFromStream( stream, resource.getName(), -1, -1 );
+ }
+
+ @Override
+ public void fillOutputData( OutputData outputData )
+ throws TransferFailedException
+ {
+ // no needed in this implementation but throw an Exception if used
+ throw new IllegalStateException( "this wagon http client must not use fillOutputData" );
+ }
+}
diff --git a/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/HttpConfiguration.java b/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/HttpConfiguration.java
index c00b73a..83ec2f8 100644
--- a/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/HttpConfiguration.java
+++ b/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/HttpConfiguration.java
@@ -1,107 +1,107 @@
-package org.apache.maven.wagon.providers.webdav;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.HeadMethod;
-import org.apache.commons.httpclient.methods.PutMethod;
-import org.apache.commons.httpclient.params.HttpClientParams;
-
-/**
- *
- */
-public class HttpConfiguration
-{
-
- private static final HttpMethodConfiguration DEFAULT_PUT =
- new HttpMethodConfiguration().addParam( HttpClientParams.USE_EXPECT_CONTINUE, "%b,true" );
-
- private HttpMethodConfiguration all;
-
- private HttpMethodConfiguration get;
-
- private HttpMethodConfiguration put;
-
- private HttpMethodConfiguration head;
-
- public HttpMethodConfiguration getAll()
- {
- return all;
- }
-
- public HttpConfiguration setAll( HttpMethodConfiguration all )
- {
- this.all = all;
- return this;
- }
-
- public HttpMethodConfiguration getGet()
- {
- return get;
- }
-
- public HttpConfiguration setGet( HttpMethodConfiguration get )
- {
- this.get = get;
- return this;
- }
-
- public HttpMethodConfiguration getPut()
- {
- return put;
- }
-
- public HttpConfiguration setPut( HttpMethodConfiguration put )
- {
- this.put = put;
- return this;
- }
-
- public HttpMethodConfiguration getHead()
- {
- return head;
- }
-
- public HttpConfiguration setHead( HttpMethodConfiguration head )
- {
- this.head = head;
- return this;
- }
-
- public HttpMethodConfiguration getMethodConfiguration( HttpMethod method )
- {
- if ( method instanceof GetMethod )
- {
- return HttpMethodConfiguration.merge( all, get );
- }
- else if ( method instanceof PutMethod )
- {
- return HttpMethodConfiguration.merge( DEFAULT_PUT, all, put );
- }
- else if ( method instanceof HeadMethod )
- {
- return HttpMethodConfiguration.merge( all, head );
- }
-
- return all;
- }
-
-}
+package org.apache.maven.wagon.providers.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.HeadMethod;
+import org.apache.commons.httpclient.methods.PutMethod;
+import org.apache.commons.httpclient.params.HttpClientParams;
+
+/**
+ *
+ */
+public class HttpConfiguration
+{
+
+ private static final HttpMethodConfiguration DEFAULT_PUT =
+ new HttpMethodConfiguration().addParam( HttpClientParams.USE_EXPECT_CONTINUE, "%b,true" );
+
+ private HttpMethodConfiguration all;
+
+ private HttpMethodConfiguration get;
+
+ private HttpMethodConfiguration put;
+
+ private HttpMethodConfiguration head;
+
+ public HttpMethodConfiguration getAll()
+ {
+ return all;
+ }
+
+ public HttpConfiguration setAll( HttpMethodConfiguration all )
+ {
+ this.all = all;
+ return this;
+ }
+
+ public HttpMethodConfiguration getGet()
+ {
+ return get;
+ }
+
+ public HttpConfiguration setGet( HttpMethodConfiguration get )
+ {
+ this.get = get;
+ return this;
+ }
+
+ public HttpMethodConfiguration getPut()
+ {
+ return put;
+ }
+
+ public HttpConfiguration setPut( HttpMethodConfiguration put )
+ {
+ this.put = put;
+ return this;
+ }
+
+ public HttpMethodConfiguration getHead()
+ {
+ return head;
+ }
+
+ public HttpConfiguration setHead( HttpMethodConfiguration head )
+ {
+ this.head = head;
+ return this;
+ }
+
+ public HttpMethodConfiguration getMethodConfiguration( HttpMethod method )
+ {
+ if ( method instanceof GetMethod )
+ {
+ return HttpMethodConfiguration.merge( all, get );
+ }
+ else if ( method instanceof PutMethod )
+ {
+ return HttpMethodConfiguration.merge( DEFAULT_PUT, all, put );
+ }
+ else if ( method instanceof HeadMethod )
+ {
+ return HttpMethodConfiguration.merge( all, head );
+ }
+
+ return all;
+ }
+
+}
diff --git a/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/HttpMethodConfiguration.java b/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/HttpMethodConfiguration.java
index b1dccab..8896889 100644
--- a/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/HttpMethodConfiguration.java
+++ b/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/HttpMethodConfiguration.java
@@ -1,319 +1,319 @@
-package org.apache.maven.wagon.providers.webdav;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.params.HttpMethodParams;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- *
- */
-public class HttpMethodConfiguration
-{
-
- public static final int DEFAULT_CONNECTION_TIMEOUT = 60000;
-
- private static final String COERCE_PATTERN = "%(\\w+),(.+)";
-
- private Boolean useDefaultHeaders;
-
- private Properties headers = new Properties();
-
- private Properties params = new Properties();
-
- private int connectionTimeout = DEFAULT_CONNECTION_TIMEOUT;
-
- public boolean isUseDefaultHeaders()
- {
- return useDefaultHeaders == null ? true : useDefaultHeaders.booleanValue();
- }
-
- public HttpMethodConfiguration setUseDefaultHeaders( boolean useDefaultHeaders )
- {
- this.useDefaultHeaders = Boolean.valueOf( useDefaultHeaders );
- return this;
- }
-
- public Boolean getUseDefaultHeaders()
- {
- return useDefaultHeaders;
- }
-
- public HttpMethodConfiguration addHeader( String header, String value )
- {
- headers.setProperty( header, value );
- return this;
- }
-
- public Properties getHeaders()
- {
- return headers;
- }
-
- public HttpMethodConfiguration setHeaders( Properties headers )
- {
- this.headers = headers;
- return this;
- }
-
- public HttpMethodConfiguration addParam( String param, String value )
- {
- params.setProperty( param, value );
- return this;
- }
-
- public Properties getParams()
- {
- return params;
- }
-
- public HttpMethodConfiguration setParams( Properties params )
- {
- this.params = params;
- return this;
- }
-
- public int getConnectionTimeout()
- {
- return connectionTimeout;
- }
-
- public HttpMethodConfiguration setConnectionTimeout( int connectionTimeout )
- {
- this.connectionTimeout = connectionTimeout;
- return this;
- }
-
- public HttpMethodParams asMethodParams( HttpMethodParams defaults )
- {
- if ( !hasParams() )
- {
- return null;
- }
-
- HttpMethodParams p = new HttpMethodParams();
- p.setDefaults( defaults );
-
- fillParams( p );
-
- return p;
- }
-
- private boolean hasParams()
- {
- if ( connectionTimeout < 1 && params == null )
- {
- return false;
- }
-
- return true;
- }
-
- private void fillParams( HttpMethodParams p )
- {
- if ( !hasParams() )
- {
- return;
- }
-
- if ( connectionTimeout > 0 )
- {
- p.setSoTimeout( connectionTimeout );
- }
-
- if ( params != null )
- {
- Pattern coercePattern = Pattern.compile( COERCE_PATTERN );
-
- for ( Map.Entry<Object, Object> entry : params.entrySet() )
- {
- String key = (String) entry.getKey();
- String value = (String) entry.getValue();
-
- Matcher matcher = coercePattern.matcher( value );
- if ( matcher.matches() )
- {
- char type = matcher.group( 1 ).charAt( 0 );
- value = matcher.group( 2 );
-
- // CHECKSTYLE_OFF: AvoidNestedBlocks
- switch ( type )
- {
- case 'i':
- p.setIntParameter( key, Integer.parseInt( value ) );
- break;
-
- case 'd':
- p.setDoubleParameter( key, Double.parseDouble( value ) );
- break;
-
- case 'l':
- p.setLongParameter( key, Long.parseLong( value ) );
- break;
-
- case 'b':
- p.setBooleanParameter( key, Boolean.valueOf( value ).booleanValue() );
- break;
-
- case 'c':
- {
- String[] entries = value.split( "," );
- List<String> collection = new ArrayList<String>();
- for ( String e : entries )
- {
- collection.add( e.trim() );
- }
-
- p.setParameter( key, collection );
- break;
- }
- case 'm':
- {
- String[] entries = value.split( "," );
-
- Map<String, String> map = new LinkedHashMap<String, String>();
- for ( String e : entries )
- {
- int idx = e.indexOf( "=>" );
- if ( idx < 1 )
- {
- break;
- }
-
- String mapKey = e.substring( 0, idx );
- String mapVal = e.substring( idx + 1, e.length() );
- map.put( mapKey.trim(), mapVal.trim() );
- }
-
- p.setParameter( key, map );
- break;
- }
- default:
- }
- // CHECKSTYLE_ON: AvoidNestedBlocks
- }
- else
- {
- p.setParameter( key, value );
- }
- }
- }
- }
-
- public Header[] asRequestHeaders()
- {
- if ( headers == null )
- {
- return new Header[0];
- }
-
- Header[] result = new Header[headers.size()];
-
- int index = 0;
- for ( Map.Entry<Object, Object> entry : headers.entrySet() )
- {
- String key = (String) entry.getKey();
- String value = (String) entry.getValue();
-
- Header header = new Header( key, value );
- result[index++] = header;
- }
-
- return result;
- }
-
- private HttpMethodConfiguration copy()
- {
- HttpMethodConfiguration copy = new HttpMethodConfiguration();
-
- copy.setConnectionTimeout( getConnectionTimeout() );
- if ( getHeaders() != null )
- {
- copy.setHeaders( getHeaders() );
- }
-
- if ( getParams() != null )
- {
- copy.setParams( getParams() );
- }
-
- copy.setUseDefaultHeaders( isUseDefaultHeaders() );
-
- return copy;
- }
-
- public static HttpMethodConfiguration merge( HttpMethodConfiguration defaults, HttpMethodConfiguration base,
- HttpMethodConfiguration local )
- {
- HttpMethodConfiguration result = merge( defaults, base );
- return merge( result, local );
- }
-
- public static HttpMethodConfiguration merge( HttpMethodConfiguration base, HttpMethodConfiguration local )
- {
- if ( base == null && local == null )
- {
- return null;
- }
- else if ( base == null )
- {
- return local;
- }
- else if ( local == null )
- {
- return base;
- }
- else
- {
- HttpMethodConfiguration result = base.copy();
-
- if ( local.getConnectionTimeout() != DEFAULT_CONNECTION_TIMEOUT )
- {
- result.setConnectionTimeout( local.getConnectionTimeout() );
- }
-
- if ( local.getHeaders() != null )
- {
- result.getHeaders().putAll( local.getHeaders() );
- }
-
- if ( local.getParams() != null )
- {
- result.getParams().putAll( local.getParams() );
- }
-
- if ( local.getUseDefaultHeaders() != null )
- {
- result.setUseDefaultHeaders( local.isUseDefaultHeaders() );
- }
-
- return result;
- }
- }
-
-}
+package org.apache.maven.wagon.providers.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.params.HttpMethodParams;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ *
+ */
+public class HttpMethodConfiguration
+{
+
+ public static final int DEFAULT_CONNECTION_TIMEOUT = 60000;
+
+ private static final String COERCE_PATTERN = "%(\\w+),(.+)";
+
+ private Boolean useDefaultHeaders;
+
+ private Properties headers = new Properties();
+
+ private Properties params = new Properties();
+
+ private int connectionTimeout = DEFAULT_CONNECTION_TIMEOUT;
+
+ public boolean isUseDefaultHeaders()
+ {
+ return useDefaultHeaders == null ? true : useDefaultHeaders.booleanValue();
+ }
+
+ public HttpMethodConfiguration setUseDefaultHeaders( boolean useDefaultHeaders )
+ {
+ this.useDefaultHeaders = Boolean.valueOf( useDefaultHeaders );
+ return this;
+ }
+
+ public Boolean getUseDefaultHeaders()
+ {
+ return useDefaultHeaders;
+ }
+
+ public HttpMethodConfiguration addHeader( String header, String value )
+ {
+ headers.setProperty( header, value );
+ return this;
+ }
+
+ public Properties getHeaders()
+ {
+ return headers;
+ }
+
+ public HttpMethodConfiguration setHeaders( Properties headers )
+ {
+ this.headers = headers;
+ return this;
+ }
+
+ public HttpMethodConfiguration addParam( String param, String value )
+ {
+ params.setProperty( param, value );
+ return this;
+ }
+
+ public Properties getParams()
+ {
+ return params;
+ }
+
+ public HttpMethodConfiguration setParams( Properties params )
+ {
+ this.params = params;
+ return this;
+ }
+
+ public int getConnectionTimeout()
+ {
+ return connectionTimeout;
+ }
+
+ public HttpMethodConfiguration setConnectionTimeout( int connectionTimeout )
+ {
+ this.connectionTimeout = connectionTimeout;
+ return this;
+ }
+
+ public HttpMethodParams asMethodParams( HttpMethodParams defaults )
+ {
+ if ( !hasParams() )
+ {
+ return null;
+ }
+
+ HttpMethodParams p = new HttpMethodParams();
+ p.setDefaults( defaults );
+
+ fillParams( p );
+
+ return p;
+ }
+
+ private boolean hasParams()
+ {
+ if ( connectionTimeout < 1 && params == null )
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ private void fillParams( HttpMethodParams p )
+ {
+ if ( !hasParams() )
+ {
+ return;
+ }
+
+ if ( connectionTimeout > 0 )
+ {
+ p.setSoTimeout( connectionTimeout );
+ }
+
+ if ( params != null )
+ {
+ Pattern coercePattern = Pattern.compile( COERCE_PATTERN );
+
+ for ( Map.Entry<Object, Object> entry : params.entrySet() )
+ {
+ String key = (String) entry.getKey();
+ String value = (String) entry.getValue();
+
+ Matcher matcher = coercePattern.matcher( value );
+ if ( matcher.matches() )
+ {
+ char type = matcher.group( 1 ).charAt( 0 );
+ value = matcher.group( 2 );
+
+ // CHECKSTYLE_OFF: AvoidNestedBlocks
+ switch ( type )
+ {
+ case 'i':
+ p.setIntParameter( key, Integer.parseInt( value ) );
+ break;
+
+ case 'd':
+ p.setDoubleParameter( key, Double.parseDouble( value ) );
+ break;
+
+ case 'l':
+ p.setLongParameter( key, Long.parseLong( value ) );
+ break;
+
+ case 'b':
+ p.setBooleanParameter( key, Boolean.valueOf( value ).booleanValue() );
+ break;
+
+ case 'c':
+ {
+ String[] entries = value.split( "," );
+ List<String> collection = new ArrayList<String>();
+ for ( String e : entries )
+ {
+ collection.add( e.trim() );
+ }
+
+ p.setParameter( key, collection );
+ break;
+ }
+ case 'm':
+ {
+ String[] entries = value.split( "," );
+
+ Map<String, String> map = new LinkedHashMap<String, String>();
+ for ( String e : entries )
+ {
+ int idx = e.indexOf( "=>" );
+ if ( idx < 1 )
+ {
+ break;
+ }
+
+ String mapKey = e.substring( 0, idx );
+ String mapVal = e.substring( idx + 1, e.length() );
+ map.put( mapKey.trim(), mapVal.trim() );
+ }
+
+ p.setParameter( key, map );
+ break;
+ }
+ default:
+ }
+ // CHECKSTYLE_ON: AvoidNestedBlocks
+ }
+ else
+ {
+ p.setParameter( key, value );
+ }
+ }
+ }
+ }
+
+ public Header[] asRequestHeaders()
+ {
+ if ( headers == null )
+ {
+ return new Header[0];
+ }
+
+ Header[] result = new Header[headers.size()];
+
+ int index = 0;
+ for ( Map.Entry<Object, Object> entry : headers.entrySet() )
+ {
+ String key = (String) entry.getKey();
+ String value = (String) entry.getValue();
+
+ Header header = new Header( key, value );
+ result[index++] = header;
+ }
+
+ return result;
+ }
+
+ private HttpMethodConfiguration copy()
+ {
+ HttpMethodConfiguration copy = new HttpMethodConfiguration();
+
+ copy.setConnectionTimeout( getConnectionTimeout() );
+ if ( getHeaders() != null )
+ {
+ copy.setHeaders( getHeaders() );
+ }
+
+ if ( getParams() != null )
+ {
+ copy.setParams( getParams() );
+ }
+
+ copy.setUseDefaultHeaders( isUseDefaultHeaders() );
+
+ return copy;
+ }
+
+ public static HttpMethodConfiguration merge( HttpMethodConfiguration defaults, HttpMethodConfiguration base,
+ HttpMethodConfiguration local )
+ {
+ HttpMethodConfiguration result = merge( defaults, base );
+ return merge( result, local );
+ }
+
+ public static HttpMethodConfiguration merge( HttpMethodConfiguration base, HttpMethodConfiguration local )
+ {
+ if ( base == null && local == null )
+ {
+ return null;
+ }
+ else if ( base == null )
+ {
+ return local;
+ }
+ else if ( local == null )
+ {
+ return base;
+ }
+ else
+ {
+ HttpMethodConfiguration result = base.copy();
+
+ if ( local.getConnectionTimeout() != DEFAULT_CONNECTION_TIMEOUT )
+ {
+ result.setConnectionTimeout( local.getConnectionTimeout() );
+ }
+
+ if ( local.getHeaders() != null )
+ {
+ result.getHeaders().putAll( local.getHeaders() );
+ }
+
+ if ( local.getParams() != null )
+ {
+ result.getParams().putAll( local.getParams() );
+ }
+
+ if ( local.getUseDefaultHeaders() != null )
+ {
+ result.setUseDefaultHeaders( local.isUseDefaultHeaders() );
+ }
+
+ return result;
+ }
+ }
+
+}
diff --git a/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/PathNavigator.java b/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/PathNavigator.java
index a03be54..21bc614 100644
--- a/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/PathNavigator.java
+++ b/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/PathNavigator.java
@@ -1,73 +1,73 @@
-package org.apache.maven.wagon.providers.webdav;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.codehaus.plexus.util.StringUtils;
-
-import java.util.List;
-import java.util.Arrays;
-
-/**
- * @author <a href="mailto:james at atlassian.com">James William Dumay</a>
- */
-public class PathNavigator
-{
- private final List<String> list;
-
- private int currentPosition;
-
- public PathNavigator( String path )
- {
- list = Arrays.asList( StringUtils.split( path, "/" ) );
- currentPosition = list.size();
- }
-
- public String getPath()
- {
- List<String> currentPathList = list.subList( 0, currentPosition );
- StringBuilder sb = new StringBuilder();
- for ( String path : currentPathList )
- {
- sb.append( path );
- sb.append( '/' );
- }
- return sb.toString();
- }
-
- public boolean backward()
- {
- if ( currentPosition == 0 )
- {
- return false;
- }
- currentPosition--;
- return true;
- }
-
- public boolean forward()
- {
- if ( currentPosition + 1 > list.size() )
- {
- return false;
- }
- currentPosition++;
- return true;
- }
-}
+package org.apache.maven.wagon.providers.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.codehaus.plexus.util.StringUtils;
+
+import java.util.List;
+import java.util.Arrays;
+
+/**
+ * @author <a href="mailto:james at atlassian.com">James William Dumay</a>
+ */
+public class PathNavigator
+{
+ private final List<String> list;
+
+ private int currentPosition;
+
+ public PathNavigator( String path )
+ {
+ list = Arrays.asList( StringUtils.split( path, "/" ) );
+ currentPosition = list.size();
+ }
+
+ public String getPath()
+ {
+ List<String> currentPathList = list.subList( 0, currentPosition );
+ StringBuilder sb = new StringBuilder();
+ for ( String path : currentPathList )
+ {
+ sb.append( path );
+ sb.append( '/' );
+ }
+ return sb.toString();
+ }
+
+ public boolean backward()
+ {
+ if ( currentPosition == 0 )
+ {
+ return false;
+ }
+ currentPosition--;
+ return true;
+ }
+
+ public boolean forward()
+ {
+ if ( currentPosition + 1 > list.size() )
+ {
+ return false;
+ }
+ currentPosition++;
+ return true;
+ }
+}
diff --git a/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java b/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java
index 4cf8bda..6bf421b 100644
--- a/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java
+++ b/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.java
@@ -1,343 +1,343 @@
-package org.apache.maven.wagon.providers.webdav;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.jackrabbit.webdav.DavConstants;
-import org.apache.jackrabbit.webdav.DavException;
-import org.apache.jackrabbit.webdav.MultiStatus;
-import org.apache.jackrabbit.webdav.MultiStatusResponse;
-import org.apache.jackrabbit.webdav.client.methods.MkColMethod;
-import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
-import org.apache.jackrabbit.webdav.property.DavProperty;
-import org.apache.jackrabbit.webdav.property.DavPropertyName;
-import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
-import org.apache.jackrabbit.webdav.property.DavPropertySet;
-import org.apache.maven.wagon.PathUtils;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
-import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.WagonConstants;
-import org.apache.maven.wagon.authorization.AuthorizationException;
-import org.apache.maven.wagon.repository.Repository;
-import org.codehaus.plexus.util.FileUtils;
-import org.codehaus.plexus.util.StringUtils;
-import org.w3c.dom.Node;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * <p>WebDavWagon</p>
- * <p/>
- * <p>Allows using a webdav remote repository for downloads and deployments</p>
- *
- * @author <a href="mailto:hisidro at exist.com">Henry Isidro</a>
- * @author <a href="mailto:joakime at apache.org">Joakim Erdfelt</a>
- * @author <a href="mailto:carlos at apache.org">Carlos Sanchez</a>
- * @author <a href="mailto:james at atlassian.com">James William Dumay</a>
- * @plexus.component role="org.apache.maven.wagon.Wagon"
- * role-hint="dav"
- * instantiation-strategy="per-lookup"
- */
-public class WebDavWagon
- extends AbstractHttpClientWagon
-{
- protected static final String CONTINUE_ON_FAILURE_PROPERTY = "wagon.webdav.continueOnFailure";
-
- private final boolean continueOnFailure = Boolean.getBoolean( CONTINUE_ON_FAILURE_PROPERTY );
-
- /**
- * Defines the protocol mapping to use.
- * <p/>
- * First string is the user definition way to define a webdav url,
- * the second string is the internal representation of that url.
- * <p/>
- * NOTE: The order of the mapping becomes the search order.
- */
- private static final String[][] PROTOCOL_MAP =
- new String[][]{ { "dav:http://", "http://" }, /* maven 2.0.x url string format. (violates URI spec) */
- { "dav:https://", "https://" }, /* maven 2.0.x url string format. (violates URI spec) */
- { "dav+http://", "http://" }, /* URI spec compliant (protocol+transport) */
- { "dav+https://", "https://" }, /* URI spec compliant (protocol+transport) */
- { "dav://", "http://" }, /* URI spec compliant (protocol only) */
- { "davs://", "https://" } /* URI spec compliant (protocol only) */ };
-
- /**
- * This wagon supports directory copying
- *
- * @return <code>true</code> always
- */
- public boolean supportsDirectoryCopy()
- {
- return true;
- }
-
- /**
- * Create directories in server as needed.
- * They are created one at a time until the whole path exists.
- *
- * @param dir path to be created in server from repository basedir
- * @throws IOException
- * @throws TransferFailedException
- */
- protected void mkdirs( String dir )
- throws IOException
- {
- Repository repository = getRepository();
- String basedir = repository.getBasedir();
-
- String baseUrl = repository.getProtocol() + "://" + repository.getHost();
- if ( repository.getPort() != WagonConstants.UNKNOWN_PORT )
- {
- baseUrl += ":" + repository.getPort();
- }
-
- // create relative path that will always have a leading and trailing slash
- String relpath = FileUtils.normalize( getPath( basedir, dir ) + "/" );
-
- PathNavigator navigator = new PathNavigator( relpath );
-
- // traverse backwards until we hit a directory that already exists (OK/NOT_ALLOWED), or that we were able to
- // create (CREATED), or until we get to the top of the path
- int status = SC_NULL;
- do
- {
- String url = baseUrl + "/" + navigator.getPath();
- status = doMkCol( url );
- if ( status == HttpStatus.SC_OK || status == HttpStatus.SC_CREATED
- || status == HttpStatus.SC_METHOD_NOT_ALLOWED )
- {
- break;
- }
- }
- while ( navigator.backward() );
-
- // traverse forward creating missing directories
- while ( navigator.forward() )
- {
- String url = baseUrl + "/" + navigator.getPath();
- status = doMkCol( url );
- if ( status != HttpStatus.SC_OK && status != HttpStatus.SC_CREATED )
- {
- throw new IOException( "Unable to create collection: " + url + "; status code = " + status );
- }
- }
- }
-
- private int doMkCol( String url )
- throws IOException
- {
- MkColMethod method = null;
- try
- {
- method = new MkColMethod( url );
- return execute( method );
- }
- finally
- {
- if ( method != null )
- {
- method.releaseConnection();
- }
- }
- }
-
- /**
- * Copy a directory from local system to remote webdav server
- *
- * @param sourceDirectory the local directory
- * @param destinationDirectory the remote destination
- * @throws TransferFailedException
- * @throws ResourceDoesNotExistException
- * @throws AuthorizationException
- */
- public void putDirectory( File sourceDirectory, String destinationDirectory )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- for ( File file : sourceDirectory.listFiles() )
- {
- if ( file.isDirectory() )
- {
- putDirectory( file, destinationDirectory + "/" + file.getName() );
- }
- else
- {
- String target = destinationDirectory + "/" + file.getName();
-
- put( file, target );
- }
- }
- }
-
- private boolean isDirectory( String url )
- throws IOException, DavException
- {
- DavPropertyNameSet nameSet = new DavPropertyNameSet();
- nameSet.add( DavPropertyName.create( DavConstants.PROPERTY_RESOURCETYPE ) );
-
- PropFindMethod method = null;
- try
- {
- method = new PropFindMethod( url, nameSet, DavConstants.DEPTH_0 );
- execute( method );
- if ( method.succeeded() )
- {
- MultiStatus multiStatus = method.getResponseBodyAsMultiStatus();
- MultiStatusResponse response = multiStatus.getResponses()[0];
- DavPropertySet propertySet = response.getProperties( HttpStatus.SC_OK );
- DavProperty<?> property = propertySet.get( DavConstants.PROPERTY_RESOURCETYPE );
- if ( property != null )
- {
- Node node = (Node) property.getValue();
- return node.getLocalName().equals( DavConstants.XML_COLLECTION );
- }
- }
- return false;
- }
- finally
- {
- if ( method != null )
- {
- method.releaseConnection();
- }
- }
- }
-
- public List<String> getFileList( String destinationDirectory )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- String repositoryUrl = repository.getUrl();
- String url = repositoryUrl + ( repositoryUrl.endsWith( "/" ) ? "" : "/" ) + destinationDirectory;
-
- PropFindMethod method = null;
- try
- {
- if ( isDirectory( url ) )
- {
- DavPropertyNameSet nameSet = new DavPropertyNameSet();
- nameSet.add( DavPropertyName.create( DavConstants.PROPERTY_DISPLAYNAME ) );
-
- method = new PropFindMethod( url, nameSet, DavConstants.DEPTH_1 );
- int status = execute( method );
- if ( method.succeeded() )
- {
- ArrayList<String> dirs = new ArrayList<String>();
- MultiStatus multiStatus = method.getResponseBodyAsMultiStatus();
-
- for ( int i = 0; i < multiStatus.getResponses().length; i++ )
- {
-
- MultiStatusResponse response = multiStatus.getResponses()[i];
-
- String entryUrl = response.getHref();
- String fileName = PathUtils.filename( URLDecoder.decode( entryUrl ) );
- if ( entryUrl.endsWith( "/" ) )
- {
- if ( i == 0 )
- {
- // by design jackrabbit webdav sticks parent directory as the first entry
- // so we need to ignore this entry
- // http://www.nabble.com/Extra-entry-in-get-file-list-with-jackrabbit-webdav-td21262786.html
- // http://www.webdav.org/specs/rfc4918.html#rfc.section.9.1
- continue;
- }
-
- //extract "dir/" part of "path.to.dir/"
- fileName = PathUtils.filename( PathUtils.dirname( URLDecoder.decode( entryUrl ) ) ) + "/";
- }
-
- if ( !StringUtils.isEmpty( fileName ) )
- {
- dirs.add( fileName );
- }
- }
- return dirs;
- }
-
- if ( status == HttpStatus.SC_NOT_FOUND )
- {
- throw new ResourceDoesNotExistException( "Destination directory does not exist: " + url );
- }
- }
- }
- catch ( DavException e )
- {
- throw new TransferFailedException( e.getMessage(), e );
- }
- catch ( IOException e )
- {
- throw new TransferFailedException( e.getMessage(), e );
- }
- finally
- {
- if ( method != null )
- {
- method.releaseConnection();
- }
- }
- throw new ResourceDoesNotExistException(
- "Destination path exists but is not a " + "WebDAV collection (directory): " + url );
- }
-
- public String getURL( Repository repository )
- {
- String url = repository.getUrl();
-
- // Process mappings first.
- for ( String[] entry : PROTOCOL_MAP )
- {
- String protocol = entry[0];
- if ( url.startsWith( protocol ) )
- {
- return entry[1] + url.substring( protocol.length() );
- }
- }
-
- // No mapping trigger? then just return as-is.
- return url;
- }
-
-
- public void put( File source, String resourceName )
- throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- try
- {
- super.put( source, resourceName );
- }
- catch ( TransferFailedException e )
- {
- if ( continueOnFailure )
- {
- // TODO use a logging mechanism here or a fireTransferWarning
- System.out.println(
- "WARN: Skip unable to transfer '" + resourceName + "' from '" + source.getPath() + "' due to "
- + e.getMessage() );
- }
- else
- {
- throw e;
- }
- }
- }
-}
+package org.apache.maven.wagon.providers.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.MultiStatus;
+import org.apache.jackrabbit.webdav.MultiStatusResponse;
+import org.apache.jackrabbit.webdav.client.methods.MkColMethod;
+import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
+import org.apache.jackrabbit.webdav.property.DavProperty;
+import org.apache.jackrabbit.webdav.property.DavPropertyName;
+import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
+import org.apache.jackrabbit.webdav.property.DavPropertySet;
+import org.apache.maven.wagon.PathUtils;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.WagonConstants;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.repository.Repository;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.StringUtils;
+import org.w3c.dom.Node;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>WebDavWagon</p>
+ * <p/>
+ * <p>Allows using a WebDAV remote repository for downloads and deployments</p>
+ *
+ * @author <a href="mailto:hisidro at exist.com">Henry Isidro</a>
+ * @author <a href="mailto:joakime at apache.org">Joakim Erdfelt</a>
+ * @author <a href="mailto:carlos at apache.org">Carlos Sanchez</a>
+ * @author <a href="mailto:james at atlassian.com">James William Dumay</a>
+ * @plexus.component role="org.apache.maven.wagon.Wagon"
+ * role-hint="dav"
+ * instantiation-strategy="per-lookup"
+ */
+public class WebDavWagon
+ extends AbstractHttpClientWagon
+{
+ protected static final String CONTINUE_ON_FAILURE_PROPERTY = "wagon.webdav.continueOnFailure";
+
+ private final boolean continueOnFailure = Boolean.getBoolean( CONTINUE_ON_FAILURE_PROPERTY );
+
+ /**
+ * Defines the protocol mapping to use.
+ * <p/>
+ * First string is the user definition way to define a WebDAV url,
+ * the second string is the internal representation of that url.
+ * <p/>
+ * NOTE: The order of the mapping becomes the search order.
+ */
+ private static final String[][] PROTOCOL_MAP =
+ new String[][]{ { "dav:http://", "http://" }, /* maven 2.0.x url string format. (violates URI spec) */
+ { "dav:https://", "https://" }, /* maven 2.0.x url string format. (violates URI spec) */
+ { "dav+http://", "http://" }, /* URI spec compliant (protocol+transport) */
+ { "dav+https://", "https://" }, /* URI spec compliant (protocol+transport) */
+ { "dav://", "http://" }, /* URI spec compliant (protocol only) */
+ { "davs://", "https://" } /* URI spec compliant (protocol only) */ };
+
+ /**
+ * This wagon supports directory copying
+ *
+ * @return <code>true</code> always
+ */
+ public boolean supportsDirectoryCopy()
+ {
+ return true;
+ }
+
+ /**
+ * Create directories in server as needed.
+ * They are created one at a time until the whole path exists.
+ *
+ * @param dir path to be created in server from repository basedir
+ * @throws IOException
+ * @throws TransferFailedException
+ */
+ protected void mkdirs( String dir )
+ throws IOException
+ {
+ Repository repository = getRepository();
+ String basedir = repository.getBasedir();
+
+ String baseUrl = repository.getProtocol() + "://" + repository.getHost();
+ if ( repository.getPort() != WagonConstants.UNKNOWN_PORT )
+ {
+ baseUrl += ":" + repository.getPort();
+ }
+
+ // create relative path that will always have a leading and trailing slash
+ String relpath = FileUtils.normalize( getPath( basedir, dir ) + "/" );
+
+ PathNavigator navigator = new PathNavigator( relpath );
+
+ // traverse backwards until we hit a directory that already exists (OK/NOT_ALLOWED), or that we were able to
+ // create (CREATED), or until we get to the top of the path
+ int status = SC_NULL;
+ do
+ {
+ String url = baseUrl + "/" + navigator.getPath();
+ status = doMkCol( url );
+ if ( status == HttpStatus.SC_OK || status == HttpStatus.SC_CREATED
+ || status == HttpStatus.SC_METHOD_NOT_ALLOWED )
+ {
+ break;
+ }
+ }
+ while ( navigator.backward() );
+
+ // traverse forward creating missing directories
+ while ( navigator.forward() )
+ {
+ String url = baseUrl + "/" + navigator.getPath();
+ status = doMkCol( url );
+ if ( status != HttpStatus.SC_OK && status != HttpStatus.SC_CREATED )
+ {
+ throw new IOException( "Unable to create collection: " + url + "; status code = " + status );
+ }
+ }
+ }
+
+ private int doMkCol( String url )
+ throws IOException
+ {
+ MkColMethod method = null;
+ try
+ {
+ method = new MkColMethod( url );
+ return execute( method );
+ }
+ finally
+ {
+ if ( method != null )
+ {
+ method.releaseConnection();
+ }
+ }
+ }
+
+ /**
+ * Copy a directory from local system to remote WebDAV server
+ *
+ * @param sourceDirectory the local directory
+ * @param destinationDirectory the remote destination
+ * @throws TransferFailedException
+ * @throws ResourceDoesNotExistException
+ * @throws AuthorizationException
+ */
+ public void putDirectory( File sourceDirectory, String destinationDirectory )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ for ( File file : sourceDirectory.listFiles() )
+ {
+ if ( file.isDirectory() )
+ {
+ putDirectory( file, destinationDirectory + "/" + file.getName() );
+ }
+ else
+ {
+ String target = destinationDirectory + "/" + file.getName();
+
+ put( file, target );
+ }
+ }
+ }
+
+ private boolean isDirectory( String url )
+ throws IOException, DavException
+ {
+ DavPropertyNameSet nameSet = new DavPropertyNameSet();
+ nameSet.add( DavPropertyName.create( DavConstants.PROPERTY_RESOURCETYPE ) );
+
+ PropFindMethod method = null;
+ try
+ {
+ method = new PropFindMethod( url, nameSet, DavConstants.DEPTH_0 );
+ execute( method );
+ if ( method.succeeded() )
+ {
+ MultiStatus multiStatus = method.getResponseBodyAsMultiStatus();
+ MultiStatusResponse response = multiStatus.getResponses()[0];
+ DavPropertySet propertySet = response.getProperties( HttpStatus.SC_OK );
+ DavProperty<?> property = propertySet.get( DavConstants.PROPERTY_RESOURCETYPE );
+ if ( property != null )
+ {
+ Node node = (Node) property.getValue();
+ return node.getLocalName().equals( DavConstants.XML_COLLECTION );
+ }
+ }
+ return false;
+ }
+ finally
+ {
+ if ( method != null )
+ {
+ method.releaseConnection();
+ }
+ }
+ }
+
+ public List<String> getFileList( String destinationDirectory )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ String repositoryUrl = repository.getUrl();
+ String url = repositoryUrl + ( repositoryUrl.endsWith( "/" ) ? "" : "/" ) + destinationDirectory;
+
+ PropFindMethod method = null;
+ try
+ {
+ if ( isDirectory( url ) )
+ {
+ DavPropertyNameSet nameSet = new DavPropertyNameSet();
+ nameSet.add( DavPropertyName.create( DavConstants.PROPERTY_DISPLAYNAME ) );
+
+ method = new PropFindMethod( url, nameSet, DavConstants.DEPTH_1 );
+ int status = execute( method );
+ if ( method.succeeded() )
+ {
+ ArrayList<String> dirs = new ArrayList<String>();
+ MultiStatus multiStatus = method.getResponseBodyAsMultiStatus();
+
+ for ( int i = 0; i < multiStatus.getResponses().length; i++ )
+ {
+
+ MultiStatusResponse response = multiStatus.getResponses()[i];
+
+ String entryUrl = response.getHref();
+ String fileName = PathUtils.filename( URLDecoder.decode( entryUrl ) );
+ if ( entryUrl.endsWith( "/" ) )
+ {
+ if ( i == 0 )
+ {
+ // by design jackrabbit WebDAV sticks parent directory as the first entry
+ // so we need to ignore this entry
+ // http://www.nabble.com/Extra-entry-in-get-file-list-with-jackrabbit-webdav-td21262786.html
+ // http://www.webdav.org/specs/rfc4918.html#rfc.section.9.1
+ continue;
+ }
+
+ //extract "dir/" part of "path.to.dir/"
+ fileName = PathUtils.filename( PathUtils.dirname( URLDecoder.decode( entryUrl ) ) ) + "/";
+ }
+
+ if ( !StringUtils.isEmpty( fileName ) )
+ {
+ dirs.add( fileName );
+ }
+ }
+ return dirs;
+ }
+
+ if ( status == HttpStatus.SC_NOT_FOUND )
+ {
+ throw new ResourceDoesNotExistException( "Destination directory does not exist: " + url );
+ }
+ }
+ }
+ catch ( DavException e )
+ {
+ throw new TransferFailedException( e.getMessage(), e );
+ }
+ catch ( IOException e )
+ {
+ throw new TransferFailedException( e.getMessage(), e );
+ }
+ finally
+ {
+ if ( method != null )
+ {
+ method.releaseConnection();
+ }
+ }
+ throw new ResourceDoesNotExistException(
+ "Destination path exists but is not a " + "WebDAV collection (directory): " + url );
+ }
+
+ public String getURL( Repository repository )
+ {
+ String url = repository.getUrl();
+
+ // Process mappings first.
+ for ( String[] entry : PROTOCOL_MAP )
+ {
+ String protocol = entry[0];
+ if ( url.startsWith( protocol ) )
+ {
+ return entry[1] + url.substring( protocol.length() );
+ }
+ }
+
+ // No mapping trigger? then just return as-is.
+ return url;
+ }
+
+
+ public void put( File source, String resourceName )
+ throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ try
+ {
+ super.put( source, resourceName );
+ }
+ catch ( TransferFailedException e )
+ {
+ if ( continueOnFailure )
+ {
+ // TODO use a logging mechanism here or a fireTransferWarning
+ System.out.println(
+ "WARN: Skip unable to transfer '" + resourceName + "' from '" + source.getPath() + "' due to "
+ + e.getMessage() );
+ }
+ else
+ {
+ throw e;
+ }
+ }
+ }
+}
diff --git a/wagon-providers/wagon-webdav-jackrabbit/src/main/resources/META-INF/plexus/default-bindings.xml b/wagon-providers/wagon-webdav-jackrabbit/src/main/resources/META-INF/plexus/default-bindings.xml
index 9328e67..775c733 100644
--- a/wagon-providers/wagon-webdav-jackrabbit/src/main/resources/META-INF/plexus/default-bindings.xml
+++ b/wagon-providers/wagon-webdav-jackrabbit/src/main/resources/META-INF/plexus/default-bindings.xml
@@ -1,63 +1,63 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<component-set>
- <components>
- <component>
- <role>org.apache.maven.wagon.Wagon</role>
- <role-hint>dav</role-hint>
- <implementation>org.apache.maven.wagon.providers.webdav.WebDavWagon</implementation>
- <instantiation-strategy>per-lookup</instantiation-strategy>
- <description><p>WebDavWagon</p>
-<p/>
-<p>Allows using a webdav remote repository for downloads and deployments</p></description>
- <isolated-realm>false</isolated-realm>
- </component>
- <component>
- <role>org.apache.maven.wagon.Wagon</role>
- <role-hint>davs</role-hint>
- <implementation>org.apache.maven.wagon.providers.webdav.WebDavWagon</implementation>
- <instantiation-strategy>per-lookup</instantiation-strategy>
- <description><p>WebDavWagon</p>
-<p/>
-<p>Allows using a webdav remote repository for downloads and deployments</p></description>
- <isolated-realm>false</isolated-realm>
- </component>
- <component>
- <role>org.apache.maven.wagon.Wagon</role>
- <role-hint>dav+http</role-hint>
- <implementation>org.apache.maven.wagon.providers.webdav.WebDavWagon</implementation>
- <instantiation-strategy>per-lookup</instantiation-strategy>
- <description><p>WebDavWagon</p>
-<p/>
-<p>Allows using a webdav remote repository for downloads and deployments</p></description>
- <isolated-realm>false</isolated-realm>
- </component>
- <component>
- <role>org.apache.maven.wagon.Wagon</role>
- <role-hint>dav+https</role-hint>
- <implementation>org.apache.maven.wagon.providers.webdav.WebDavWagon</implementation>
- <instantiation-strategy>per-lookup</instantiation-strategy>
- <description><p>WebDavWagon</p>
-<p/>
-<p>Allows using a webdav remote repository for downloads and deployments</p></description>
- <isolated-realm>false</isolated-realm>
- </component>
- </components>
-</component-set>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<component-set>
+ <components>
+ <component>
+ <role>org.apache.maven.wagon.Wagon</role>
+ <role-hint>dav</role-hint>
+ <implementation>org.apache.maven.wagon.providers.webdav.WebDavWagon</implementation>
+ <instantiation-strategy>per-lookup</instantiation-strategy>
+ <description><p>WebDavWagon</p>
+<p/>
+<p>Allows using a WebDAV remote repository for downloads and deployments</p></description>
+ <isolated-realm>false</isolated-realm>
+ </component>
+ <component>
+ <role>org.apache.maven.wagon.Wagon</role>
+ <role-hint>davs</role-hint>
+ <implementation>org.apache.maven.wagon.providers.webdav.WebDavWagon</implementation>
+ <instantiation-strategy>per-lookup</instantiation-strategy>
+ <description><p>WebDavWagon</p>
+<p/>
+<p>Allows using a WebDAV remote repository for downloads and deployments</p></description>
+ <isolated-realm>false</isolated-realm>
+ </component>
+ <component>
+ <role>org.apache.maven.wagon.Wagon</role>
+ <role-hint>dav+http</role-hint>
+ <implementation>org.apache.maven.wagon.providers.webdav.WebDavWagon</implementation>
+ <instantiation-strategy>per-lookup</instantiation-strategy>
+ <description><p>WebDavWagon</p>
+<p/>
+<p>Allows using a WebDAV remote repository for downloads and deployments</p></description>
+ <isolated-realm>false</isolated-realm>
+ </component>
+ <component>
+ <role>org.apache.maven.wagon.Wagon</role>
+ <role-hint>dav+https</role-hint>
+ <implementation>org.apache.maven.wagon.providers.webdav.WebDavWagon</implementation>
+ <instantiation-strategy>per-lookup</instantiation-strategy>
+ <description><p>WebDavWagon</p>
+<p/>
+<p>Allows using a webdav remote repository for downloads and deployments</p></description>
+ <isolated-realm>false</isolated-realm>
+ </component>
+ </components>
+</component-set>
diff --git a/wagon-providers/wagon-webdav-jackrabbit/src/site/apt/index.apt b/wagon-providers/wagon-webdav-jackrabbit/src/site/apt/index.apt
index be1ce58..c854549 100644
--- a/wagon-providers/wagon-webdav-jackrabbit/src/site/apt/index.apt
+++ b/wagon-providers/wagon-webdav-jackrabbit/src/site/apt/index.apt
@@ -1,43 +1,43 @@
- ------
- Maven Wagon WebDAV
- ------
- Carlos Sanchez
- ------
- 2012-11-19
- ------
-
- ~~ Licensed to the Apache Software Foundation (ASF) under one
- ~~ or more contributor license agreements. See the NOTICE file
- ~~ distributed with this work for additional information
- ~~ regarding copyright ownership. The ASF licenses this file
- ~~ to you under the Apache License, Version 2.0 (the
- ~~ "License"); you may not use this file except in compliance
- ~~ with the License. You may obtain a copy of the License at
- ~~
- ~~ http://www.apache.org/licenses/LICENSE-2.0
- ~~
- ~~ Unless required by applicable law or agreed to in writing,
- ~~ software distributed under the License is distributed on an
- ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~~ KIND, either express or implied. See the License for the
- ~~ specific language governing permissions and limitations
- ~~ under the License.
-
- ~~ NOTE: For help with the syntax of this file, see:
- ~~ http://maven.apache.org/doxia/references/apt-format.html
-
-Maven Wagon WebDAV
-
- This component is an implementation of Wagon provider for WebDAV server access.
- You will need to use at least Java 1.6 if you want to use this Wagon provider.
-
- It enables Maven to deploy artifacts and files to WebDAV enabled servers.
- Getting files from WebDAV servers is not fully tested.
-
-* Features
-
- * Deploy files and directories to WebDAV enabled servers
-
-* System Properties
-
- Using <<<-Dwagon.webdav.continueOnFailure=true>>> will continue deploying other files even if one fail.
+ ------
+ Maven Wagon WebDAV
+ ------
+ Carlos Sanchez
+ ------
+ 2012-11-19
+ ------
+
+ ~~ Licensed to the Apache Software Foundation (ASF) under one
+ ~~ or more contributor license agreements. See the NOTICE file
+ ~~ distributed with this work for additional information
+ ~~ regarding copyright ownership. The ASF licenses this file
+ ~~ to you under the Apache License, Version 2.0 (the
+ ~~ "License"); you may not use this file except in compliance
+ ~~ with the License. You may obtain a copy of the License at
+ ~~
+ ~~ http://www.apache.org/licenses/LICENSE-2.0
+ ~~
+ ~~ Unless required by applicable law or agreed to in writing,
+ ~~ software distributed under the License is distributed on an
+ ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~~ KIND, either express or implied. See the License for the
+ ~~ specific language governing permissions and limitations
+ ~~ under the License.
+
+ ~~ NOTE: For help with the syntax of this file, see:
+ ~~ http://maven.apache.org/doxia/references/apt-format.html
+
+Maven Wagon WebDAV
+
+ This component is an implementation of Wagon provider for WebDAV server access.
+ You will need to use at least Java 1.6 if you want to use this Wagon provider.
+
+ It enables Maven to deploy artifacts and files to WebDAV enabled servers.
+ Getting files from WebDAV servers is not fully tested.
+
+* Features
+
+ * Deploy files and directories to WebDAV enabled servers
+
+* System Properties
+
+ Using <<<-Dwagon.webdav.continueOnFailure=true>>> will continue deploying other files even if one fail.
diff --git a/wagon-providers/wagon-webdav-jackrabbit/src/site/site.xml b/wagon-providers/wagon-webdav-jackrabbit/src/site/site.xml
index 4c91fd0..e15ed92 100644
--- a/wagon-providers/wagon-webdav-jackrabbit/src/site/site.xml
+++ b/wagon-providers/wagon-webdav-jackrabbit/src/site/site.xml
@@ -1,33 +1,33 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
- <body>
- <breadcrumbs>
- <item name="WEBDAV Jackrabbit" href="http://maven.apache.org/wagon/wagon-providers/wagon-webdav-jackrabbit/index.html" />
- </breadcrumbs>
-
- <menu ref="parent"/>
- <menu ref="reports"/>
- </body>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
+ <body>
+ <breadcrumbs>
+ <item name="WebDAV Jackrabbit" href="http://maven.apache.org/wagon/wagon-providers/wagon-webdav-jackrabbit/index.html" />
+ </breadcrumbs>
+
+ <menu ref="parent"/>
+ <menu ref="reports"/>
+ </body>
</project>
\ No newline at end of file
diff --git a/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/HttpClientWagonTest.java b/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/HttpClientWagonTest.java
index 652a7ec..b72f32f 100644
--- a/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/HttpClientWagonTest.java
+++ b/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/HttpClientWagonTest.java
@@ -1,242 +1,242 @@
-package org.apache.maven.wagon.providers.webdav;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-import org.apache.commons.httpclient.Credentials;
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.NTCredentials;
-import org.apache.commons.httpclient.auth.AuthScope;
-import org.apache.commons.httpclient.methods.HeadMethod;
-import org.apache.commons.httpclient.params.HttpClientParams;
-import org.apache.commons.httpclient.params.HttpMethodParams;
-import org.apache.maven.wagon.ConnectionException;
-import org.apache.maven.wagon.OutputData;
-import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
-import org.apache.maven.wagon.proxy.ProxyInfo;
-import org.apache.maven.wagon.repository.Repository;
-
-public class HttpClientWagonTest
- extends TestCase
-{
-
- public void testSetPreemptiveAuthParamViaConfig()
- {
- HttpMethodConfiguration methodConfig = new HttpMethodConfiguration();
- methodConfig.addParam( HttpClientParams.PREEMPTIVE_AUTHENTICATION, "%b,true" );
-
- HttpConfiguration config = new HttpConfiguration();
- config.setAll( methodConfig );
-
- TestWagon wagon = new TestWagon();
- wagon.setHttpConfiguration( config );
-
- HeadMethod method = new HeadMethod();
- wagon.setParameters( method );
-
- HttpMethodParams params = method.getParams();
- assertNotNull( params );
- assertTrue( params.isParameterTrue( HttpClientParams.PREEMPTIVE_AUTHENTICATION ) );
- }
-
- public void testSetMaxRedirectsParamViaConfig()
- {
- HttpMethodConfiguration methodConfig = new HttpMethodConfiguration();
- int maxRedirects = 2;
- methodConfig.addParam( HttpClientParams.MAX_REDIRECTS, "%i," + maxRedirects );
-
- HttpConfiguration config = new HttpConfiguration();
- config.setAll( methodConfig );
-
- TestWagon wagon = new TestWagon();
- wagon.setHttpConfiguration( config );
-
- HeadMethod method = new HeadMethod();
- wagon.setParameters( method );
-
- HttpMethodParams params = method.getParams();
- assertNotNull( params );
- assertEquals( maxRedirects, params.getIntParameter( HttpClientParams.MAX_REDIRECTS, -1 ) );
- }
-
- public void testDefaultHeadersUsedByDefault()
- {
- HttpConfiguration config = new HttpConfiguration();
- config.setAll( new HttpMethodConfiguration() );
-
- TestWagon wagon = new TestWagon();
- wagon.setHttpConfiguration( config );
-
- HeadMethod method = new HeadMethod();
- wagon.setHeaders( method );
-
- // these are the default headers.
- // method.addRequestHeader( "Cache-control", "no-cache" );
- // method.addRequestHeader( "Cache-store", "no-store" );
- // method.addRequestHeader( "Pragma", "no-cache" );
- // method.addRequestHeader( "Expires", "0" );
- // method.addRequestHeader( "Accept-Encoding", "gzip" );
-
- Header header = method.getRequestHeader( "Cache-control" );
- assertNotNull( header );
- assertEquals( "no-cache", header.getValue() );
-
- header = method.getRequestHeader( "Cache-store" );
- assertNotNull( header );
- assertEquals( "no-store", header.getValue() );
-
- header = method.getRequestHeader( "Pragma" );
- assertNotNull( header );
- assertEquals( "no-cache", header.getValue() );
-
- header = method.getRequestHeader( "Expires" );
- assertNotNull( header );
- assertEquals( "0", header.getValue() );
-
- header = method.getRequestHeader( "Accept-Encoding" );
- assertNotNull( header );
- assertEquals( "gzip", header.getValue() );
-
- header = method.getRequestHeader( "User-Agent" );
- assertNotNull( header );
- // during test-phase /META-INF/maven/org.apache.maven.wagon/*/pom.properties hasn't been created yet
- assertTrue( header.getValue().startsWith( "Apache-Maven-Wagon/unknown-version (Java " ) );
- }
-
- public void testTurnOffDefaultHeaders()
- {
- HttpConfiguration config = new HttpConfiguration();
- config.setAll( new HttpMethodConfiguration().setUseDefaultHeaders( false ) );
-
- TestWagon wagon = new TestWagon();
- wagon.setHttpConfiguration( config );
-
- HeadMethod method = new HeadMethod();
- wagon.setHeaders( method );
-
- // these are the default headers.
- // method.addRequestHeader( "Cache-control", "no-cache" );
- // method.addRequestHeader( "Cache-store", "no-store" );
- // method.addRequestHeader( "Pragma", "no-cache" );
- // method.addRequestHeader( "Expires", "0" );
- // method.addRequestHeader( "Accept-Encoding", "gzip" );
-
- Header header = method.getRequestHeader( "Cache-control" );
- assertNull( header );
-
- header = method.getRequestHeader( "Cache-store" );
- assertNull( header );
-
- header = method.getRequestHeader( "Pragma" );
- assertNull( header );
-
- header = method.getRequestHeader( "Expires" );
- assertNull( header );
-
- header = method.getRequestHeader( "Accept-Encoding" );
- assertNull( header );
- }
-
- public void testNTCredentialsWithUsernameNull()
- throws AuthenticationException, ConnectionException
- {
- TestWagon wagon = new TestWagon();
-
- Repository repository = new Repository( "mockRepoId", "mockRepoURL" );
- wagon.connect( repository );
-
- wagon.openConnection();
-
- assertNull( wagon.getAuthenticationInfo().getUserName() );
- assertNull( wagon.getAuthenticationInfo().getPassword() );
-
- assertFalse( wagon.getClient().getState().getCredentials( new AuthScope( null, 0 ) ) instanceof NTCredentials );
- }
-
- public void testNTCredentialsNoNTDomain()
- throws AuthenticationException, ConnectionException
- {
- TestWagon wagon = new TestWagon();
-
- AuthenticationInfo authenticationInfo = new AuthenticationInfo();
- String myUsernameNoNTDomain = "myUserNameNoNTDomain";
- authenticationInfo.setUserName( myUsernameNoNTDomain );
-
- String myPassword = "myPassword";
- authenticationInfo.setPassword( myPassword );
-
- Repository repository = new Repository( "mockRepoId", "mockRepoURL" );
-
- wagon.connect( repository, authenticationInfo, (ProxyInfo) null );
-
- wagon.openConnection();
-
- assertEquals( myUsernameNoNTDomain, wagon.getAuthenticationInfo().getUserName() );
- assertEquals( myPassword, wagon.getAuthenticationInfo().getPassword() );
-
- assertFalse( wagon.getClient().getState().getCredentials( new AuthScope( null, 0 ) ) instanceof NTCredentials );
- }
-
- public void testNTCredentialsWithNTDomain()
- throws AuthenticationException, ConnectionException
- {
- TestWagon wagon = new TestWagon();
-
- AuthenticationInfo authenticationInfo = new AuthenticationInfo();
- String myNTDomain = "myNTDomain";
- String myUsername = "myUsername";
- String myNTDomainAndUser = myNTDomain + "\\" + myUsername;
- authenticationInfo.setUserName( myNTDomainAndUser );
-
- String myPassword = "myPassword";
- authenticationInfo.setPassword( myPassword );
-
- Repository repository = new Repository( "mockRepoId", "mockRepoURL" );
-
- wagon.connect( repository, authenticationInfo, (ProxyInfo) null );
-
- wagon.openConnection();
-
- assertEquals( myNTDomainAndUser, wagon.getAuthenticationInfo().getUserName() );
- assertEquals( myPassword, wagon.getAuthenticationInfo().getPassword() );
-
- Credentials credentials = wagon.getClient().getState().getCredentials( new AuthScope( null, 0 ) );
- assertTrue( credentials instanceof NTCredentials );
-
- NTCredentials ntCredentials = (NTCredentials) credentials;
- assertEquals( myNTDomain, ntCredentials.getDomain() );
- assertEquals( myUsername, ntCredentials.getUserName() );
- assertEquals( myPassword, ntCredentials.getPassword() );
- }
-
- private static final class TestWagon
- extends AbstractHttpClientWagon
- {
- @Override
- public void fillOutputData( OutputData outputData )
- throws TransferFailedException
- {
-
- }
- }
-
-}
+package org.apache.maven.wagon.providers.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+import org.apache.commons.httpclient.Credentials;
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.NTCredentials;
+import org.apache.commons.httpclient.auth.AuthScope;
+import org.apache.commons.httpclient.methods.HeadMethod;
+import org.apache.commons.httpclient.params.HttpClientParams;
+import org.apache.commons.httpclient.params.HttpMethodParams;
+import org.apache.maven.wagon.ConnectionException;
+import org.apache.maven.wagon.OutputData;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.proxy.ProxyInfo;
+import org.apache.maven.wagon.repository.Repository;
+
+public class HttpClientWagonTest
+ extends TestCase
+{
+
+ public void testSetPreemptiveAuthParamViaConfig()
+ {
+ HttpMethodConfiguration methodConfig = new HttpMethodConfiguration();
+ methodConfig.addParam( HttpClientParams.PREEMPTIVE_AUTHENTICATION, "%b,true" );
+
+ HttpConfiguration config = new HttpConfiguration();
+ config.setAll( methodConfig );
+
+ TestWagon wagon = new TestWagon();
+ wagon.setHttpConfiguration( config );
+
+ HeadMethod method = new HeadMethod();
+ wagon.setParameters( method );
+
+ HttpMethodParams params = method.getParams();
+ assertNotNull( params );
+ assertTrue( params.isParameterTrue( HttpClientParams.PREEMPTIVE_AUTHENTICATION ) );
+ }
+
+ public void testSetMaxRedirectsParamViaConfig()
+ {
+ HttpMethodConfiguration methodConfig = new HttpMethodConfiguration();
+ int maxRedirects = 2;
+ methodConfig.addParam( HttpClientParams.MAX_REDIRECTS, "%i," + maxRedirects );
+
+ HttpConfiguration config = new HttpConfiguration();
+ config.setAll( methodConfig );
+
+ TestWagon wagon = new TestWagon();
+ wagon.setHttpConfiguration( config );
+
+ HeadMethod method = new HeadMethod();
+ wagon.setParameters( method );
+
+ HttpMethodParams params = method.getParams();
+ assertNotNull( params );
+ assertEquals( maxRedirects, params.getIntParameter( HttpClientParams.MAX_REDIRECTS, -1 ) );
+ }
+
+ public void testDefaultHeadersUsedByDefault()
+ {
+ HttpConfiguration config = new HttpConfiguration();
+ config.setAll( new HttpMethodConfiguration() );
+
+ TestWagon wagon = new TestWagon();
+ wagon.setHttpConfiguration( config );
+
+ HeadMethod method = new HeadMethod();
+ wagon.setHeaders( method );
+
+ // these are the default headers.
+ // method.addRequestHeader( "Cache-control", "no-cache" );
+ // method.addRequestHeader( "Cache-store", "no-store" );
+ // method.addRequestHeader( "Pragma", "no-cache" );
+ // method.addRequestHeader( "Expires", "0" );
+ // method.addRequestHeader( "Accept-Encoding", "gzip" );
+
+ Header header = method.getRequestHeader( "Cache-control" );
+ assertNotNull( header );
+ assertEquals( "no-cache", header.getValue() );
+
+ header = method.getRequestHeader( "Cache-store" );
+ assertNotNull( header );
+ assertEquals( "no-store", header.getValue() );
+
+ header = method.getRequestHeader( "Pragma" );
+ assertNotNull( header );
+ assertEquals( "no-cache", header.getValue() );
+
+ header = method.getRequestHeader( "Expires" );
+ assertNotNull( header );
+ assertEquals( "0", header.getValue() );
+
+ header = method.getRequestHeader( "Accept-Encoding" );
+ assertNotNull( header );
+ assertEquals( "gzip", header.getValue() );
+
+ header = method.getRequestHeader( "User-Agent" );
+ assertNotNull( header );
+ // during test-phase /META-INF/maven/org.apache.maven.wagon/*/pom.properties hasn't been created yet
+ assertTrue( header.getValue().startsWith( "Apache-Maven-Wagon/unknown-version (Java " ) );
+ }
+
+ public void testTurnOffDefaultHeaders()
+ {
+ HttpConfiguration config = new HttpConfiguration();
+ config.setAll( new HttpMethodConfiguration().setUseDefaultHeaders( false ) );
+
+ TestWagon wagon = new TestWagon();
+ wagon.setHttpConfiguration( config );
+
+ HeadMethod method = new HeadMethod();
+ wagon.setHeaders( method );
+
+ // these are the default headers.
+ // method.addRequestHeader( "Cache-control", "no-cache" );
+ // method.addRequestHeader( "Cache-store", "no-store" );
+ // method.addRequestHeader( "Pragma", "no-cache" );
+ // method.addRequestHeader( "Expires", "0" );
+ // method.addRequestHeader( "Accept-Encoding", "gzip" );
+
+ Header header = method.getRequestHeader( "Cache-control" );
+ assertNull( header );
+
+ header = method.getRequestHeader( "Cache-store" );
+ assertNull( header );
+
+ header = method.getRequestHeader( "Pragma" );
+ assertNull( header );
+
+ header = method.getRequestHeader( "Expires" );
+ assertNull( header );
+
+ header = method.getRequestHeader( "Accept-Encoding" );
+ assertNull( header );
+ }
+
+ public void testNTCredentialsWithUsernameNull()
+ throws AuthenticationException, ConnectionException
+ {
+ TestWagon wagon = new TestWagon();
+
+ Repository repository = new Repository( "mockRepoId", "mockRepoURL" );
+ wagon.connect( repository );
+
+ wagon.openConnection();
+
+ assertNull( wagon.getAuthenticationInfo().getUserName() );
+ assertNull( wagon.getAuthenticationInfo().getPassword() );
+
+ assertFalse( wagon.getClient().getState().getCredentials( new AuthScope( null, 0 ) ) instanceof NTCredentials );
+ }
+
+ public void testNTCredentialsNoNTDomain()
+ throws AuthenticationException, ConnectionException
+ {
+ TestWagon wagon = new TestWagon();
+
+ AuthenticationInfo authenticationInfo = new AuthenticationInfo();
+ String myUsernameNoNTDomain = "myUserNameNoNTDomain";
+ authenticationInfo.setUserName( myUsernameNoNTDomain );
+
+ String myPassword = "myPassword";
+ authenticationInfo.setPassword( myPassword );
+
+ Repository repository = new Repository( "mockRepoId", "mockRepoURL" );
+
+ wagon.connect( repository, authenticationInfo, (ProxyInfo) null );
+
+ wagon.openConnection();
+
+ assertEquals( myUsernameNoNTDomain, wagon.getAuthenticationInfo().getUserName() );
+ assertEquals( myPassword, wagon.getAuthenticationInfo().getPassword() );
+
+ assertFalse( wagon.getClient().getState().getCredentials( new AuthScope( null, 0 ) ) instanceof NTCredentials );
+ }
+
+ public void testNTCredentialsWithNTDomain()
+ throws AuthenticationException, ConnectionException
+ {
+ TestWagon wagon = new TestWagon();
+
+ AuthenticationInfo authenticationInfo = new AuthenticationInfo();
+ String myNTDomain = "myNTDomain";
+ String myUsername = "myUsername";
+ String myNTDomainAndUser = myNTDomain + "\\" + myUsername;
+ authenticationInfo.setUserName( myNTDomainAndUser );
+
+ String myPassword = "myPassword";
+ authenticationInfo.setPassword( myPassword );
+
+ Repository repository = new Repository( "mockRepoId", "mockRepoURL" );
+
+ wagon.connect( repository, authenticationInfo, (ProxyInfo) null );
+
+ wagon.openConnection();
+
+ assertEquals( myNTDomainAndUser, wagon.getAuthenticationInfo().getUserName() );
+ assertEquals( myPassword, wagon.getAuthenticationInfo().getPassword() );
+
+ Credentials credentials = wagon.getClient().getState().getCredentials( new AuthScope( null, 0 ) );
+ assertTrue( credentials instanceof NTCredentials );
+
+ NTCredentials ntCredentials = (NTCredentials) credentials;
+ assertEquals( myNTDomain, ntCredentials.getDomain() );
+ assertEquals( myUsername, ntCredentials.getUserName() );
+ assertEquals( myPassword, ntCredentials.getPassword() );
+ }
+
+ private static final class TestWagon
+ extends AbstractHttpClientWagon
+ {
+ @Override
+ public void fillOutputData( OutputData outputData )
+ throws TransferFailedException
+ {
+
+ }
+ }
+
+}
diff --git a/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/PathNavigatorTest.java b/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/PathNavigatorTest.java
index 95c0b79..09cab80 100644
--- a/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/PathNavigatorTest.java
+++ b/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/PathNavigatorTest.java
@@ -1,63 +1,63 @@
-package org.apache.maven.wagon.providers.webdav;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-
-/**
- * @author <a href="mailto:james at atlassian.com">James William Dumay</a>
- */
-public class PathNavigatorTest extends TestCase
-{
- private static final String TEST_PATH = "foo/bar/baz";
-
- public void testBackAndForward()
- {
- PathNavigator navigator = new PathNavigator( TEST_PATH );
-
- assertEquals( "foo/bar/baz/", navigator.getPath() );
-
- // Nav backward
- assertTrue( navigator.backward() );
- assertEquals( "foo/bar/", navigator.getPath() );
-
- assertTrue( navigator.backward() );
- assertEquals( "foo/", navigator.getPath() );
-
- assertTrue( navigator.backward() );
- assertEquals( "", navigator.getPath() );
-
- assertFalse( navigator.backward() );
- assertEquals( "", navigator.getPath() );
-
- // Nav forward
- assertTrue( navigator.forward() );
- assertEquals( "foo/", navigator.getPath() );
-
- assertTrue( navigator.forward() );
- assertEquals( "foo/bar/", navigator.getPath() );
-
- assertTrue( navigator.forward() );
- assertEquals( "foo/bar/baz/", navigator.getPath() );
-
- assertFalse( navigator.forward() );
- assertEquals( "foo/bar/baz/", navigator.getPath() );
- }
-}
+package org.apache.maven.wagon.providers.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * @author <a href="mailto:james at atlassian.com">James William Dumay</a>
+ */
+public class PathNavigatorTest extends TestCase
+{
+ private static final String TEST_PATH = "foo/bar/baz";
+
+ public void testBackAndForward()
+ {
+ PathNavigator navigator = new PathNavigator( TEST_PATH );
+
+ assertEquals( "foo/bar/baz/", navigator.getPath() );
+
+ // Nav backward
+ assertTrue( navigator.backward() );
+ assertEquals( "foo/bar/", navigator.getPath() );
+
+ assertTrue( navigator.backward() );
+ assertEquals( "foo/", navigator.getPath() );
+
+ assertTrue( navigator.backward() );
+ assertEquals( "", navigator.getPath() );
+
+ assertFalse( navigator.backward() );
+ assertEquals( "", navigator.getPath() );
+
+ // Nav forward
+ assertTrue( navigator.forward() );
+ assertEquals( "foo/", navigator.getPath() );
+
+ assertTrue( navigator.forward() );
+ assertEquals( "foo/bar/", navigator.getPath() );
+
+ assertTrue( navigator.forward() );
+ assertEquals( "foo/bar/baz/", navigator.getPath() );
+
+ assertFalse( navigator.forward() );
+ assertEquals( "foo/bar/baz/", navigator.getPath() );
+ }
+}
diff --git a/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java b/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java
index 1bab212..8163edb 100644
--- a/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java
+++ b/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.java
@@ -1,502 +1,511 @@
-package org.apache.maven.wagon.providers.webdav;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
- * agreements. See the NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance with the License. You may obtain a
- * copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- */
-
-import it.could.webdav.DAVServlet;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
-import org.apache.maven.wagon.StreamingWagon;
-import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.http.HttpWagonTestCase;
-import org.apache.maven.wagon.repository.Repository;
-import org.apache.maven.wagon.resource.Resource;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.servlet.Context;
-import org.mortbay.jetty.servlet.ServletHolder;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.SocketTimeoutException;
-import java.util.List;
-import java.util.Properties;
-
-/*
- * WebDAV Wagon Test
- *
- * @author <a href="mailto:joakim at erdfelt.com">Joakim Erdfelt</a>
- *
- * @author <a href="mailto:carlos at apache.org">Carlos Sanchez</a>
- */
-public class WebDavWagonTest
- extends HttpWagonTestCase
-{
- protected String getTestRepositoryUrl()
- throws IOException
- {
- return getProtocol() + "://localhost:" + getTestRepositoryPort() + "/newfolder/folder2/";
- }
-
- protected String getProtocol()
- {
- return "dav";
- }
-
- protected void createContext( Server server, File repositoryDirectory )
- throws IOException
- {
- Context dav = new Context( server, "/", Context.SESSIONS );
- ServletHolder davServletHolder = new ServletHolder( new DAVServlet() );
- davServletHolder.setInitParameter( "rootPath", repositoryDirectory.getAbsolutePath() );
- davServletHolder.setInitParameter( "xmlOnly", "false" );
- dav.addServlet( davServletHolder, "/*" );
- }
-
- protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
- {
- File file = new File( getDavRepository(), resource.getName() );
- return ( file.lastModified() / 1000 ) * 1000;
- }
-
-
- private File getDavRepository()
- {
- return getTestFile( "target/test-output/http-repository/newfolder/folder2" );
- }
-
- private void assertURL( String userUrl, String expectedUrl )
- {
- Repository repo = new Repository( "test-geturl", userUrl );
- String actualUrl = ( new WebDavWagon() ).getURL( repo );
- assertEquals( "WebDavWagon.getURL(" + userUrl + ")", expectedUrl, actualUrl );
- }
-
- /**
- * Tests the maven 2.0.x way to define a webdav URL without SSL.
- */
- public void testGetURLDavHttp()
- {
- assertURL( "dav:http://localhost:" + getTestRepositoryPort() + "/dav/",
- "http://localhost:" + getTestRepositoryPort() + "/dav/" );
- }
-
- /**
- * Tests the maven 2.0.x way to define a webdav URL with SSL.
- */
- public void testGetURLDavHttps()
- {
- assertURL( "dav:https://localhost:" + getTestRepositoryPort() + "/dav/",
- "https://localhost:" + getTestRepositoryPort() + "/dav/" );
- }
-
- /**
- * Tests the URI spec way of defining a webdav URL without SSL.
- */
- public void testGetURLDavUri()
- {
- assertURL( "dav://localhost:" + getTestRepositoryPort() + "/dav/",
- "http://localhost:" + getTestRepositoryPort() + "/dav/" );
- }
-
- /**
- * Tests the URI spec way of defining a webdav URL with SSL.
- */
- public void testGetURLDavUriWithSsl()
- {
- assertURL( "davs://localhost:" + getTestRepositoryPort() + "/dav/",
- "https://localhost:" + getTestRepositoryPort() + "/dav/" );
- }
-
- /**
- * Tests the URI spec way of defining a webdav URL without SSL.
- */
- public void testGetURLDavPlusHttp()
- {
- assertURL( "dav+https://localhost:" + getTestRepositoryPort() + "/dav/",
- "https://localhost:" + getTestRepositoryPort() + "/dav/" );
- }
-
- /**
- * Tests the URI spec way of defining a webdav URL with SSL.
- */
- public void testGetURLDavPlusHttps()
- {
- assertURL( "dav+https://localhost:" + getTestRepositoryPort() + "/dav/",
- "https://localhost:" + getTestRepositoryPort() + "/dav/" );
- }
-
- public void testMkdirs()
- throws Exception
- {
- setupRepositories();
-
- setupWagonTestingFixtures();
-
- WebDavWagon wagon = (WebDavWagon) getWagon();
- wagon.connect( testRepository, getAuthInfo() );
-
- try
- {
- File dir = getRepositoryDirectory();
-
- // check basedir also doesn't exist and will need to be created
- dir = new File( dir, testRepository.getBasedir() );
- assertFalse( dir.exists() );
-
- // test leading /
- assertFalse( new File( dir, "foo" ).exists() );
- wagon.mkdirs( "/foo" );
- assertTrue( new File( dir, "foo" ).exists() );
-
- // test trailing /
- assertFalse( new File( dir, "bar" ).exists() );
- wagon.mkdirs( "bar/" );
- assertTrue( new File( dir, "bar" ).exists() );
-
- // test when already exists
- wagon.mkdirs( "bar" );
-
- // test several parts
- assertFalse( new File( dir, "1/2/3/4" ).exists() );
- wagon.mkdirs( "1/2/3/4" );
- assertTrue( new File( dir, "1/2/3/4" ).exists() );
-
- // test additional part and trailing /
- assertFalse( new File( dir, "1/2/3/4/5" ).exists() );
- wagon.mkdirs( "1/2/3/4/5/" );
- assertTrue( new File( dir, "1/2/3/4" ).exists() );
- }
- finally
- {
- wagon.disconnect();
-
- tearDownWagonTestingFixtures();
- }
- }
-
- public void testMkdirsWithNoBasedir()
- throws Exception
- {
- // WAGON-244
- setupRepositories();
-
- setupWagonTestingFixtures();
-
- // reconstruct with no basedir
- testRepository.setUrl(
- testRepository.getProtocol() + "://" + testRepository.getHost() + ":" + testRepository.getPort() );
-
- WebDavWagon wagon = (WebDavWagon) getWagon();
- wagon.connect( testRepository, getAuthInfo() );
-
- try
- {
- File dir = getRepositoryDirectory();
-
- // check basedir also doesn't exist and will need to be created
- dir = new File( dir, testRepository.getBasedir() );
- assertTrue( dir.exists() );
-
- // test leading /
- assertFalse( new File( dir, "foo" ).exists() );
- wagon.mkdirs( "/foo" );
- assertTrue( new File( dir, "foo" ).exists() );
- }
- finally
- {
- wagon.disconnect();
-
- tearDownWagonTestingFixtures();
- }
- }
-
- protected void setHttpHeaders( StreamingWagon wagon, Properties properties )
- {
- ( (WebDavWagon) wagon ).setHttpHeaders( properties );
- }
-
- /**
- * Make sure wagon webdav can detect remote directory
- *
- * @throws Exception
- */
- public void testWagonWebDavGetFileList()
- throws Exception
- {
- setupRepositories();
-
- setupWagonTestingFixtures();
-
- String dirName = "file-list";
-
- String filenames[] =
- new String[]{ "test-resource.txt", "test-resource.pom", "test-resource b.txt", "more-resources.dat" };
-
- for ( int i = 0; i < filenames.length; i++ )
- {
- putFile( dirName + "/" + filenames[i], dirName + "/" + filenames[i], filenames[i] + "\n" );
- }
-
- String dirnames[] = new String[]{ "test-dir1", "test-dir2" };
-
- for ( int i = 0; i < dirnames.length; i++ )
- {
- new File( getDavRepository(), dirName + "/" + dirnames[i] ).mkdirs();
- }
-
- Wagon wagon = getWagon();
-
- wagon.connect( testRepository, getAuthInfo() );
-
- List<String> list = wagon.getFileList( dirName );
-
- assertNotNull( "file list should not be null.", list );
- assertEquals( "file list should contain 6 items", 6, list.size() );
-
- for ( int i = 0; i < filenames.length; i++ )
- {
- assertTrue( "Filename '" + filenames[i] + "' should be in list.", list.contains( filenames[i] ) );
- }
-
- for ( int i = 0; i < dirnames.length; i++ )
- {
- assertTrue( "Directory '" + dirnames[i] + "' should be in list.", list.contains( dirnames[i] + "/" ) );
- }
-
- ///////////////////////////////////////////////////////////////////////////
- list = wagon.getFileList( "" );
- assertNotNull( "file list should not be null.", list );
- assertEquals( "file list should contain 1 items", 1, list.size() );
-
- ///////////////////////////////////////////////////////////////////////////
- list = wagon.getFileList( dirName + "/test-dir1" );
- assertNotNull( "file list should not be null.", list );
- assertEquals( "file list should contain 0 items", 0, list.size() );
-
- /////////////////////////////////////////////////////////////////////////////
- try
- {
- list = wagon.getFileList( dirName + "/test-dir-bogus" );
- fail( "Exception expected" );
- }
- catch ( ResourceDoesNotExistException e )
- {
-
- }
-
- wagon.disconnect();
-
- tearDownWagonTestingFixtures();
- }
-
-
- public void testWagonFailsOnPutFailureByDefault()
- throws Exception
- {
- setupRepositories();
-
- setupWagonTestingFixtures();
-
- File testFile = getTempFile();
-
- System.clearProperty( WebDavWagon.CONTINUE_ON_FAILURE_PROPERTY );
-
- WebDavWagon wagon = new TimeoutSimulatingWagon();
- wagon.connect( testRepository, getAuthInfo() );
-
- try
- {
- String filename = TimeoutSimulatingWagon.TIMEOUT_TRIGGER + ".txt";
-
- try
- {
- wagon.put( testFile, filename );
- fail( "Exception expected" );
- }
- catch ( TransferFailedException e )
- {
-
- }
- }
- finally
- {
- wagon.disconnect();
-
- tearDownWagonTestingFixtures();
- }
- }
-
- private File getTempFile()
- throws IOException
- {
- File inputFile = File.createTempFile( "test-resource", ".txt" );
- inputFile.deleteOnExit();
- return inputFile;
- }
-
- private static class TimeoutSimulatingWagon
- extends WebDavWagon
- {
- private static final String TIMEOUT_TRIGGER = "timeout";
-
- protected int execute( HttpMethod httpMethod )
- throws HttpException, IOException
- {
- if ( httpMethod.getPath().contains( TIMEOUT_TRIGGER ) )
- {
- throw new SocketTimeoutException( "Timeout triggered by request for '" + httpMethod.getPath() + "'" );
- }
- else
- {
- return super.execute( httpMethod );
- }
- }
- }
-
- public void testWagonContinuesOnPutFailureIfPropertySet()
- throws Exception
- {
- setupRepositories();
-
- setupWagonTestingFixtures();
-
- File testFile = getTempFile();
-
- String continueOnFailureProperty = WebDavWagon.CONTINUE_ON_FAILURE_PROPERTY;
- System.setProperty( continueOnFailureProperty, "true" );
-
- WebDavWagon wagon = new TimeoutSimulatingWagon();
- wagon.connect( testRepository, getAuthInfo() );
-
- try
- {
- String filename = TimeoutSimulatingWagon.TIMEOUT_TRIGGER + ".txt";
-
- wagon.put( testFile, filename );
- }
- finally
- {
- wagon.disconnect();
-
- System.clearProperty( continueOnFailureProperty );
-
- tearDownWagonTestingFixtures();
- }
- }
-
- @Override
- protected boolean supportPreemptiveAuthenticationPut()
- {
- return true;
- }
-
- @Override
- protected boolean supportPreemptiveAuthenticationGet()
- {
- return false;
- }
-
- @Override
- protected boolean supportProxyPreemptiveAuthentication()
- {
- return false;
- }
-
- protected void testPreemptiveAuthenticationGet( TestSecurityHandler sh, boolean preemptive )
- {
- if ( preemptive )
- {
- assertEquals( "testPreemptiveAuthenticationGet preemptive=true: expected 1 request, got "
- + sh.handlerRequestResponses, 1, sh.handlerRequestResponses.size() );
- assertEquals( 200, sh.handlerRequestResponses.get( 0 ).responseCode );
- }
- else
- {
- assertEquals( "testPreemptiveAuthenticationGet preemptive=false: expected 2 requests (401,200), got "
- + sh.handlerRequestResponses, 2, sh.handlerRequestResponses.size() );
- assertEquals( 401, sh.handlerRequestResponses.get( 0 ).responseCode );
- assertEquals( 200, sh.handlerRequestResponses.get( 1 ).responseCode );
- }
- }
-
- protected void testPreemptiveAuthenticationPut( TestSecurityHandler sh, boolean preemptive )
- {
- if ( preemptive )
- {
- assertEquals( "testPreemptiveAuthenticationPut preemptive=true: expected 2 requests (200,.), got "
- + sh.handlerRequestResponses, 2, sh.handlerRequestResponses.size() );
- assertEquals( 200, sh.handlerRequestResponses.get( 0 ).responseCode );
- }
- else
- {
- assertEquals( "testPreemptiveAuthenticationPut preemptive=false: expected 3 requests (401,200,.), got "
- + sh.handlerRequestResponses, 3, sh.handlerRequestResponses.size() );
- assertEquals( 401, sh.handlerRequestResponses.get( 0 ).responseCode );
- assertEquals( 200, sh.handlerRequestResponses.get( 1 ).responseCode );
- }
- }
-
-
- @Override
- protected void testPreemptiveAuthentication( TestSecurityHandler sh, boolean preemptive )
- {
- if ( preemptive )
- {
- assertEquals( "testPreemptiveAuthentication preemptive=false: expected 2 requests (200,.), got "
- + sh.handlerRequestResponses, 2, sh.handlerRequestResponses.size() );
- assertEquals( 200, sh.handlerRequestResponses.get( 0 ).responseCode );
- }
- else
- {
- assertEquals( "testPreemptiveAuthentication preemptive=false: expected 3 requests (401,200,200), got "
- + sh.handlerRequestResponses, 3, sh.handlerRequestResponses.size() );
- assertEquals( 401, sh.handlerRequestResponses.get( 0 ).responseCode );
- assertEquals( 200, sh.handlerRequestResponses.get( 1 ).responseCode );
- assertEquals( 200, sh.handlerRequestResponses.get( 2 ).responseCode );
-
- }
- }
-
- protected void checkRequestResponseForRedirectPutFromStreamWithFullUrl( PutHandler putHandler,
- RedirectHandler redirectHandler )
- {
- assertEquals( "found:" + putHandler.handlerRequestResponses, 1, putHandler.handlerRequestResponses.size() );
- assertEquals( "found:" + putHandler.handlerRequestResponses, 201,
- putHandler.handlerRequestResponses.get( 0 ).responseCode );
- assertEquals( "found:" + redirectHandler.handlerRequestResponses, 3,
- redirectHandler.handlerRequestResponses.size() );
- assertEquals( "found:" + redirectHandler.handlerRequestResponses, 302,
- redirectHandler.handlerRequestResponses.get( 0 ).responseCode );
- }
-
- protected void checkRequestResponseForRedirectPutFromStreamWithRelativeUrl( PutHandler putHandler,
- RedirectHandler redirectHandler )
- {
- assertEquals( "found:" + putHandler.handlerRequestResponses, 0, putHandler.handlerRequestResponses.size() );
-
- assertEquals( "found:" + redirectHandler.handlerRequestResponses, 4,
- redirectHandler.handlerRequestResponses.size() );
- assertEquals( "found:" + redirectHandler.handlerRequestResponses, 302,
- redirectHandler.handlerRequestResponses.get( 0 ).responseCode );
- assertEquals( "found:" + redirectHandler.handlerRequestResponses, 302,
- redirectHandler.handlerRequestResponses.get( 1 ).responseCode );
- assertEquals( "found:" + redirectHandler.handlerRequestResponses, 201,
- redirectHandler.handlerRequestResponses.get( 3 ).responseCode );
-
- }
-
-}
+package org.apache.maven.wagon.providers.webdav;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+import it.could.webdav.DAVServlet;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpMethod;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.StreamingWagon;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.http.HttpWagonTestCase;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.resource.Resource;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.SocketTimeoutException;
+import java.util.List;
+import java.util.Properties;
+
+import javax.servlet.http.HttpServletResponse;
+
+/*
+ * WebDAV Wagon Test
+ *
+ * @author <a href="mailto:joakim at erdfelt.com">Joakim Erdfelt</a>
+ *
+ * @author <a href="mailto:carlos at apache.org">Carlos Sanchez</a>
+ */
+public class WebDavWagonTest
+ extends HttpWagonTestCase
+{
+ protected String getTestRepositoryUrl()
+ throws IOException
+ {
+ return getProtocol() + "://localhost:" + getTestRepositoryPort() + "/newfolder/folder2/";
+ }
+
+ protected String getProtocol()
+ {
+ return "dav";
+ }
+
+ protected ServletContextHandler createContext( Server server, File repositoryDirectory )
+ throws IOException
+ {
+ ServletContextHandler dav = new ServletContextHandler( ServletContextHandler.SESSIONS );
+ ServletHolder davServletHolder = new ServletHolder( new DAVServlet() );
+ davServletHolder.setInitParameter( "rootPath", repositoryDirectory.getAbsolutePath() );
+ davServletHolder.setInitParameter( "xmlOnly", "false" );
+ dav.addServlet( davServletHolder, "/*" );
+ return dav;
+ }
+
+ protected long getExpectedLastModifiedOnGet( Repository repository, Resource resource )
+ {
+ File file = new File( getDavRepository(), resource.getName() );
+ return ( file.lastModified() / 1000L ) * 1000L;
+ }
+
+
+ private File getDavRepository()
+ {
+ return getTestFile( "target/test-output/http-repository/newfolder/folder2" );
+ }
+
+ private void assertURL( String userUrl, String expectedUrl )
+ {
+ Repository repo = new Repository( "test-geturl", userUrl );
+ String actualUrl = ( new WebDavWagon() ).getURL( repo );
+ assertEquals( "WebDavWagon.getURL(" + userUrl + ")", expectedUrl, actualUrl );
+ }
+
+ /**
+ * Tests the maven 2.0.x way to define a webdav URL without SSL.
+ */
+ public void testGetURLDavHttp()
+ {
+ assertURL( "dav:http://localhost:" + getTestRepositoryPort() + "/dav/",
+ "http://localhost:" + getTestRepositoryPort() + "/dav/" );
+ }
+
+ /**
+ * Tests the maven 2.0.x way to define a webdav URL with SSL.
+ */
+ public void testGetURLDavHttps()
+ {
+ assertURL( "dav:https://localhost:" + getTestRepositoryPort() + "/dav/",
+ "https://localhost:" + getTestRepositoryPort() + "/dav/" );
+ }
+
+ /**
+ * Tests the URI spec way of defining a webdav URL without SSL.
+ */
+ public void testGetURLDavUri()
+ {
+ assertURL( "dav://localhost:" + getTestRepositoryPort() + "/dav/",
+ "http://localhost:" + getTestRepositoryPort() + "/dav/" );
+ }
+
+ /**
+ * Tests the URI spec way of defining a webdav URL with SSL.
+ */
+ public void testGetURLDavUriWithSsl()
+ {
+ assertURL( "davs://localhost:" + getTestRepositoryPort() + "/dav/",
+ "https://localhost:" + getTestRepositoryPort() + "/dav/" );
+ }
+
+ /**
+ * Tests the URI spec way of defining a webdav URL without SSL.
+ */
+ public void testGetURLDavPlusHttp()
+ {
+ assertURL( "dav+https://localhost:" + getTestRepositoryPort() + "/dav/",
+ "https://localhost:" + getTestRepositoryPort() + "/dav/" );
+ }
+
+ /**
+ * Tests the URI spec way of defining a webdav URL with SSL.
+ */
+ public void testGetURLDavPlusHttps()
+ {
+ assertURL( "dav+https://localhost:" + getTestRepositoryPort() + "/dav/",
+ "https://localhost:" + getTestRepositoryPort() + "/dav/" );
+ }
+
+ public void testMkdirs()
+ throws Exception
+ {
+ setupRepositories();
+
+ setupWagonTestingFixtures();
+
+ WebDavWagon wagon = (WebDavWagon) getWagon();
+ wagon.connect( testRepository, getAuthInfo() );
+
+ try
+ {
+ File dir = getRepositoryDirectory();
+
+ // check basedir also doesn't exist and will need to be created
+ dir = new File( dir, testRepository.getBasedir() );
+ assertFalse( dir.exists() );
+
+ // test leading /
+ assertFalse( new File( dir, "foo" ).exists() );
+ wagon.mkdirs( "/foo" );
+ assertTrue( new File( dir, "foo" ).exists() );
+
+ // test trailing /
+ assertFalse( new File( dir, "bar" ).exists() );
+ wagon.mkdirs( "bar/" );
+ assertTrue( new File( dir, "bar" ).exists() );
+
+ // test when already exists
+ wagon.mkdirs( "bar" );
+
+ // test several parts
+ assertFalse( new File( dir, "1/2/3/4" ).exists() );
+ wagon.mkdirs( "1/2/3/4" );
+ assertTrue( new File( dir, "1/2/3/4" ).exists() );
+
+ // test additional part and trailing /
+ assertFalse( new File( dir, "1/2/3/4/5" ).exists() );
+ wagon.mkdirs( "1/2/3/4/5/" );
+ assertTrue( new File( dir, "1/2/3/4" ).exists() );
+ }
+ finally
+ {
+ wagon.disconnect();
+
+ tearDownWagonTestingFixtures();
+ }
+ }
+
+ public void testMkdirsWithNoBasedir()
+ throws Exception
+ {
+ // WAGON-244
+ setupRepositories();
+
+ setupWagonTestingFixtures();
+
+ // reconstruct with no basedir
+ testRepository.setUrl(
+ testRepository.getProtocol() + "://" + testRepository.getHost() + ":" + testRepository.getPort() );
+
+ WebDavWagon wagon = (WebDavWagon) getWagon();
+ wagon.connect( testRepository, getAuthInfo() );
+
+ try
+ {
+ File dir = getRepositoryDirectory();
+
+ // check basedir also doesn't exist and will need to be created
+ dir = new File( dir, testRepository.getBasedir() );
+ assertTrue( dir.exists() );
+
+ // test leading /
+ assertFalse( new File( dir, "foo" ).exists() );
+ wagon.mkdirs( "/foo" );
+ assertTrue( new File( dir, "foo" ).exists() );
+ }
+ finally
+ {
+ wagon.disconnect();
+
+ tearDownWagonTestingFixtures();
+ }
+ }
+
+ protected void setHttpHeaders( StreamingWagon wagon, Properties properties )
+ {
+ ( (WebDavWagon) wagon ).setHttpHeaders( properties );
+ }
+
+ /**
+ * Make sure Wagon WebDAV can detect remote directory
+ *
+ * @throws Exception
+ */
+ public void testWagonWebDavGetFileList()
+ throws Exception
+ {
+ setupRepositories();
+
+ setupWagonTestingFixtures();
+
+ String dirName = "file-list";
+
+ String filenames[] =
+ new String[]{ "test-resource.txt", "test-resource.pom", "test-resource b.txt", "more-resources.dat" };
+
+ for ( int i = 0; i < filenames.length; i++ )
+ {
+ putFile( dirName + "/" + filenames[i], dirName + "/" + filenames[i], filenames[i] + "\n" );
+ }
+
+ String dirnames[] = new String[]{ "test-dir1", "test-dir2" };
+
+ for ( int i = 0; i < dirnames.length; i++ )
+ {
+ new File( getDavRepository(), dirName + "/" + dirnames[i] ).mkdirs();
+ }
+
+ Wagon wagon = getWagon();
+
+ wagon.connect( testRepository, getAuthInfo() );
+
+ List<String> list = wagon.getFileList( dirName );
+
+ assertNotNull( "file list should not be null.", list );
+ assertEquals( "file list should contain 6 items", 6, list.size() );
+
+ for ( int i = 0; i < filenames.length; i++ )
+ {
+ assertTrue( "Filename '" + filenames[i] + "' should be in list.", list.contains( filenames[i] ) );
+ }
+
+ for ( int i = 0; i < dirnames.length; i++ )
+ {
+ assertTrue( "Directory '" + dirnames[i] + "' should be in list.", list.contains( dirnames[i] + "/" ) );
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ list = wagon.getFileList( "" );
+ assertNotNull( "file list should not be null.", list );
+ assertEquals( "file list should contain 1 items", 1, list.size() );
+
+ ///////////////////////////////////////////////////////////////////////////
+ list = wagon.getFileList( dirName + "/test-dir1" );
+ assertNotNull( "file list should not be null.", list );
+ assertEquals( "file list should contain 0 items", 0, list.size() );
+
+ /////////////////////////////////////////////////////////////////////////////
+ try
+ {
+ list = wagon.getFileList( dirName + "/test-dir-bogus" );
+ fail( "Exception expected" );
+ }
+ catch ( ResourceDoesNotExistException e )
+ {
+
+ }
+
+ wagon.disconnect();
+
+ tearDownWagonTestingFixtures();
+ }
+
+
+ public void testWagonFailsOnPutFailureByDefault()
+ throws Exception
+ {
+ setupRepositories();
+
+ setupWagonTestingFixtures();
+
+ File testFile = getTempFile();
+
+ System.clearProperty( WebDavWagon.CONTINUE_ON_FAILURE_PROPERTY );
+
+ WebDavWagon wagon = new TimeoutSimulatingWagon();
+ wagon.connect( testRepository, getAuthInfo() );
+
+ try
+ {
+ String filename = TimeoutSimulatingWagon.TIMEOUT_TRIGGER + ".txt";
+
+ try
+ {
+ wagon.put( testFile, filename );
+ fail( "Exception expected" );
+ }
+ catch ( TransferFailedException e )
+ {
+
+ }
+ }
+ finally
+ {
+ wagon.disconnect();
+
+ tearDownWagonTestingFixtures();
+ }
+ }
+
+ private File getTempFile()
+ throws IOException
+ {
+ File inputFile = File.createTempFile( "test-resource", ".txt" );
+ inputFile.deleteOnExit();
+ return inputFile;
+ }
+
+ private static class TimeoutSimulatingWagon
+ extends WebDavWagon
+ {
+ private static final String TIMEOUT_TRIGGER = "timeout";
+
+ protected int execute( HttpMethod httpMethod )
+ throws HttpException, IOException
+ {
+ if ( httpMethod.getPath().contains( TIMEOUT_TRIGGER ) )
+ {
+ throw new SocketTimeoutException( "Timeout triggered by request for '" + httpMethod.getPath() + "'" );
+ }
+ else
+ {
+ return super.execute( httpMethod );
+ }
+ }
+ }
+
+ public void testWagonContinuesOnPutFailureIfPropertySet()
+ throws Exception
+ {
+ setupRepositories();
+
+ setupWagonTestingFixtures();
+
+ File testFile = getTempFile();
+
+ String continueOnFailureProperty = WebDavWagon.CONTINUE_ON_FAILURE_PROPERTY;
+ System.setProperty( continueOnFailureProperty, "true" );
+
+ WebDavWagon wagon = new TimeoutSimulatingWagon();
+ wagon.connect( testRepository, getAuthInfo() );
+
+ try
+ {
+ String filename = TimeoutSimulatingWagon.TIMEOUT_TRIGGER + ".txt";
+
+ wagon.put( testFile, filename );
+ }
+ finally
+ {
+ wagon.disconnect();
+
+ System.clearProperty( continueOnFailureProperty );
+
+ tearDownWagonTestingFixtures();
+ }
+ }
+
+ @Override
+ protected boolean supportPreemptiveAuthenticationPut()
+ {
+ return true;
+ }
+
+ @Override
+ protected boolean supportPreemptiveAuthenticationGet()
+ {
+ return false;
+ }
+
+ @Override
+ protected boolean supportProxyPreemptiveAuthentication()
+ {
+ return false;
+ }
+
+ protected void testPreemptiveAuthenticationGet( TestSecurityHandler sh, boolean preemptive )
+ {
+ if ( preemptive )
+ {
+ assertEquals( "testPreemptiveAuthenticationGet preemptive=true: expected 1 request, got "
+ + sh.handlerRequestResponses, 1, sh.handlerRequestResponses.size() );
+ assertEquals( HttpServletResponse.SC_OK, sh.handlerRequestResponses.get( 0 ).responseCode );
+ }
+ else
+ {
+ assertEquals( "testPreemptiveAuthenticationGet preemptive=false: expected 2 requests (401,200), got "
+ + sh.handlerRequestResponses, 2, sh.handlerRequestResponses.size() );
+ assertEquals( HttpServletResponse.SC_UNAUTHORIZED, sh.handlerRequestResponses.get( 0 ).responseCode );
+ assertEquals( HttpServletResponse.SC_OK, sh.handlerRequestResponses.get( 1 ).responseCode );
+ }
+ }
+
+ protected void testPreemptiveAuthenticationPut( TestSecurityHandler sh, boolean preemptive )
+ {
+ if ( preemptive )
+ {
+ assertEquals( "testPreemptiveAuthenticationPut preemptive=true: expected 2 requests (200,201), got "
+ + sh.handlerRequestResponses, 2, sh.handlerRequestResponses.size() );
+ assertEquals( HttpServletResponse.SC_OK, sh.handlerRequestResponses.get( 0 ).responseCode );
+ assertEquals( HttpServletResponse.SC_CREATED, sh.handlerRequestResponses.get( 1 ).responseCode );
+ }
+ else
+ {
+ assertEquals( "testPreemptiveAuthenticationPut preemptive=false: expected 3 requests (401,200,201), got "
+ + sh.handlerRequestResponses, 3, sh.handlerRequestResponses.size() );
+ assertEquals( HttpServletResponse.SC_UNAUTHORIZED, sh.handlerRequestResponses.get( 0 ).responseCode );
+ assertEquals( HttpServletResponse.SC_OK, sh.handlerRequestResponses.get( 1 ).responseCode );
+ assertEquals( HttpServletResponse.SC_CREATED, sh.handlerRequestResponses.get( 2 ).responseCode );
+ }
+ }
+
+
+ /* This method cannot be reasonable used to represend GET and PUT for WebDAV, it would contain too much
+ * duplicate code. Leave as-is, but don't use it.
+ */
+ protected void testPreemptiveAuthentication( TestSecurityHandler sh, boolean preemptive )
+ {
+ if ( preemptive )
+ {
+ assertEquals( "testPreemptiveAuthentication preemptive=false: expected 2 requests (200,.), got "
+ + sh.handlerRequestResponses, 2, sh.handlerRequestResponses.size() );
+ assertEquals( HttpServletResponse.SC_OK, sh.handlerRequestResponses.get( 0 ).responseCode );
+ }
+ else
+ {
+ assertEquals( "testPreemptiveAuthentication preemptive=false: expected 3 requests (401,200,200), got "
+ + sh.handlerRequestResponses, 3, sh.handlerRequestResponses.size() );
+ assertEquals( HttpServletResponse.SC_UNAUTHORIZED, sh.handlerRequestResponses.get( 0 ).responseCode );
+ assertEquals( HttpServletResponse.SC_OK, sh.handlerRequestResponses.get( 1 ).responseCode );
+ assertEquals( HttpServletResponse.SC_OK, sh.handlerRequestResponses.get( 2 ).responseCode );
+
+ }
+ }
+
+ @Override
+ protected void checkRequestResponseForRedirectPutWithFullUrl( RedirectHandler redirectHandler,
+ PutHandler putHandler )
+ {
+ assertEquals( "found:" + putHandler.handlerRequestResponses, 1, putHandler.handlerRequestResponses.size() );
+ assertEquals( "found:" + putHandler.handlerRequestResponses, HttpServletResponse.SC_CREATED,
+ putHandler.handlerRequestResponses.get( 0 ).responseCode );
+ assertEquals( "found:" + redirectHandler.handlerRequestResponses, 3,
+ redirectHandler.handlerRequestResponses.size() );
+ assertEquals( "found:" + redirectHandler.handlerRequestResponses, HttpServletResponse.SC_SEE_OTHER,
+ redirectHandler.handlerRequestResponses.get( 0 ).responseCode );
+ }
+
+ @Override
+ protected void checkRequestResponseForRedirectPutWithRelativeUrl( RedirectHandler redirectHandler,
+ PutHandler putHandler )
+ {
+ assertEquals( "found:" + putHandler.handlerRequestResponses, 0, putHandler.handlerRequestResponses.size() );
+
+ assertEquals( "found:" + redirectHandler.handlerRequestResponses, 4,
+ redirectHandler.handlerRequestResponses.size() );
+ assertEquals( "found:" + redirectHandler.handlerRequestResponses, HttpServletResponse.SC_SEE_OTHER,
+ redirectHandler.handlerRequestResponses.get( 0 ).responseCode );
+ assertEquals( "found:" + redirectHandler.handlerRequestResponses, HttpServletResponse.SC_SEE_OTHER,
+ redirectHandler.handlerRequestResponses.get( 1 ).responseCode );
+ assertEquals( "found:" + redirectHandler.handlerRequestResponses, HttpServletResponse.SC_CREATED,
+ redirectHandler.handlerRequestResponses.get( 3 ).responseCode );
+
+ }
+
+}
diff --git a/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavsWagonTest.java b/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavsWagonTest.java
index ba18510..cb12adb 100644
--- a/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavsWagonTest.java
+++ b/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavsWagonTest.java
@@ -1,56 +1,56 @@
-package org.apache.maven.wagon.providers.webdav;
-
-import org.mortbay.jetty.Connector;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.security.SslSocketConnector;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-
-/**
- * WebDAV Wagon Test
- *
- * @author <a href="mailto:joakim at erdfelt.com">Joakim Erdfelt</a>
- * @author <a href="mailto:carlos at apache.org">Carlos Sanchez</a>
- */
-public class WebDavsWagonTest
- extends WebDavWagonTest
-{
- protected String getProtocol()
- {
- return "davs";
- }
-
- protected void addConnectors( Server server )
- {
- System.setProperty( "javax.net.ssl.trustStore",
- getTestFile( "src/test/resources/ssl/keystore" ).getAbsolutePath() );
-
- SslSocketConnector connector = new SslSocketConnector();
- connector.setPort( server.getConnectors()[0].getPort() );
- connector.setKeystore( getTestPath( "src/test/resources/ssl/keystore" ) );
- connector.setPassword( "wagonhttp" );
- connector.setKeyPassword( "wagonhttp" );
- connector.setTruststore( getTestPath( "src/test/resources/ssl/keystore" ) );
- connector.setTrustPassword( "wagonhttp" );
- server.setConnectors( new Connector[] { connector } );
- }
-
-}
+package org.apache.maven.wagon.providers.webdav;
+
+import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.ssl.SslSocketConnector;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+
+/**
+ * WebDAV Wagon Test
+ *
+ * @author <a href="mailto:joakim at erdfelt.com">Joakim Erdfelt</a>
+ * @author <a href="mailto:carlos at apache.org">Carlos Sanchez</a>
+ */
+public class WebDavsWagonTest
+ extends WebDavWagonTest
+{
+ protected String getProtocol()
+ {
+ return "davs";
+ }
+
+ protected void addConnectors( Server server )
+ {
+ System.setProperty( "javax.net.ssl.trustStore",
+ getTestFile( "src/test/resources/ssl/keystore" ).getAbsolutePath() );
+
+ SslSocketConnector connector = new SslSocketConnector();
+ connector.setPort( server.getConnectors()[0].getPort() );
+ connector.setKeystore( getTestPath( "src/test/resources/ssl/keystore" ) );
+ connector.setPassword( "wagonhttp" );
+ connector.setKeyPassword( "wagonhttp" );
+ connector.setTruststore( getTestPath( "src/test/resources/ssl/keystore" ) );
+ connector.setTrustPassword( "wagonhttp" );
+ server.setConnectors( new Connector[] { connector } );
+ }
+
+}
diff --git a/wagon-providers/wagon-webdav-jackrabbit/src/test/resources/log4j.xml b/wagon-providers/wagon-webdav-jackrabbit/src/test/resources/log4j.xml
index 7780ac8..43003c8 100644
--- a/wagon-providers/wagon-webdav-jackrabbit/src/test/resources/log4j.xml
+++ b/wagon-providers/wagon-webdav-jackrabbit/src/test/resources/log4j.xml
@@ -1,36 +1,36 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<!--
- ~ Licensed to the Apache Software Foundation (ASF) under one
- ~ or more contributor license agreements. See the NOTICE file
- ~ distributed with this work for additional information
- ~ regarding copyright ownership. The ASF licenses this file
- ~ to you under the Apache License, Version 2.0 (the
- ~ "License"); you may not use this file except in compliance
- ~ with the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing,
- ~ software distributed under the License is distributed on an
- ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- ~ KIND, either express or implied. See the License for the
- ~ specific language governing permissions and limitations
- ~ under the License.
- -->
-
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
-
- <appender name="console" class="org.apache.log4j.ConsoleAppender">
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d [%t] %-5p %c %x - %m%n"/>
- </layout>
- </appender>
-
- <root>
- <priority value ="info" />
- <appender-ref ref="console" />
- </root>
-
-</log4j:configuration>
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you under the Apache License, Version 2.0 (the
+ ~ "License"); you may not use this file except in compliance
+ ~ with the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing,
+ ~ software distributed under the License is distributed on an
+ ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ~ KIND, either express or implied. See the License for the
+ ~ specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d [%t] %-5p %c %x - %m%n"/>
+ </layout>
+ </appender>
+
+ <root>
+ <priority value ="info" />
+ <appender-ref ref="console" />
+ </root>
+
+</log4j:configuration>
diff --git a/wagon-tcks/pom.xml b/wagon-tcks/pom.xml
index 367222b..0f7f05e 100644
--- a/wagon-tcks/pom.xml
+++ b/wagon-tcks/pom.xml
@@ -1,44 +1,44 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon</artifactId>
- <version>2.10</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>wagon-tcks</artifactId>
- <packaging>pom</packaging>
- <name>Apache Maven Wagon :: Test Compatibility Kits</name>
-
- <modules>
- <module>wagon-tck-http</module>
- </modules>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-provider-api</artifactId>
- </dependency>
- </dependencies>
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon</artifactId>
+ <version>2.12</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>wagon-tcks</artifactId>
+ <packaging>pom</packaging>
+ <name>Apache Maven Wagon :: Test Compatibility Kits</name>
+
+ <modules>
+ <module>wagon-tck-http</module>
+ </modules>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-provider-api</artifactId>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/wagon-tcks/src/site/site.xml b/wagon-tcks/src/site/site.xml
index f740066..aaeb178 100644
--- a/wagon-tcks/src/site/site.xml
+++ b/wagon-tcks/src/site/site.xml
@@ -1,34 +1,34 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
- <body>
- <breadcrumbs>
- <item name="TCKs" href="http://maven.apache.org/wagon/wagon-tcks/index.html" />
- </breadcrumbs>
-
- <menu ref="parent"/>
- <menu ref="modules"/>
- <menu ref="reports"/>
- </body>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
+ <body>
+ <breadcrumbs>
+ <item name="TCKs" href="http://maven.apache.org/wagon/wagon-tcks/index.html" />
+ </breadcrumbs>
+
+ <menu ref="parent"/>
+ <menu ref="modules"/>
+ <menu ref="reports"/>
+ </body>
</project>
\ No newline at end of file
diff --git a/wagon-tcks/wagon-tck-http/pom.xml b/wagon-tcks/wagon-tck-http/pom.xml
index 584c43c..1f772e8 100644
--- a/wagon-tcks/wagon-tck-http/pom.xml
+++ b/wagon-tcks/wagon-tck-http/pom.xml
@@ -1,61 +1,77 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <parent>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-tcks</artifactId>
- <version>2.10</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
- <artifactId>wagon-tck-http</artifactId>
-
- <name>Apache Maven Wagon :: HTTP Test Compatibility Kit</name>
-
- <dependencies>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-container-default</artifactId>
- <!-- override test scope from parents -->
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- </dependency>
- <dependency>
- <groupId>org.mortbay.jetty</groupId>
- <artifactId>jetty</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-provider-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>commons-codec</groupId>
- <artifactId>commons-codec</artifactId>
- <version>1.4</version>
- </dependency>
- </dependencies>
-
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-tcks</artifactId>
+ <version>2.12</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>wagon-tck-http</artifactId>
+
+ <name>Apache Maven Wagon :: HTTP Test Compatibility Kit</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-classworlds</artifactId>
+ <version>2.2.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty.aggregate</groupId>
+ <artifactId>jetty-all</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>javax.servlet-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-provider-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-codec</groupId>
+ <artifactId>commons-codec</artifactId>
+ <version>1.4</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/wagon-tcks/wagon-tck-http/sample-tck-consumer/pom.xml b/wagon-tcks/wagon-tck-http/sample-tck-consumer/pom.xml
index 8ee8d6e..aa838c8 100644
--- a/wagon-tcks/wagon-tck-http/sample-tck-consumer/pom.xml
+++ b/wagon-tcks/wagon-tck-http/sample-tck-consumer/pom.xml
@@ -1,66 +1,66 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>sample-tck-consumer</artifactId>
- <version>1.0-SNAPSHOT</version>
-
- <name>sample-tck-consumer</name>
-
- <dependencies>
- <!-- TODO: Split this out into a sample project that shows how to use this TCK. -->
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-http-lightweight</artifactId>
- <version>1.0-beta-6</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.maven.wagon</groupId>
- <artifactId>wagon-tck-http</artifactId>
- <version>1.0-beta-7-SNAPSHOT</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>2.0.2</version>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
-
-</project>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>sample-tck-consumer</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <name>sample-tck-consumer</name>
+
+ <dependencies>
+ <!-- TODO: Split this out into a sample project that shows how to use this TCK. -->
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-http-lightweight</artifactId>
+ <version>1.0-beta-6</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-tck-http</artifactId>
+ <version>1.0-beta-7-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+</project>
diff --git a/wagon-tcks/wagon-tck-http/sample-tck-consumer/src/test/java/org/apache/maven/wagon/tck/http/consumer/TestSuite.java b/wagon-tcks/wagon-tck-http/sample-tck-consumer/src/test/java/org/apache/maven/wagon/tck/http/consumer/TestSuite.java
index 23bc227..1079fb5 100644
--- a/wagon-tcks/wagon-tck-http/sample-tck-consumer/src/test/java/org/apache/maven/wagon/tck/http/consumer/TestSuite.java
+++ b/wagon-tcks/wagon-tck-http/sample-tck-consumer/src/test/java/org/apache/maven/wagon/tck/http/consumer/TestSuite.java
@@ -1,31 +1,31 @@
-package org.apache.maven.wagon.tck.http.consumer;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.tck.http.GetWagonTests;
-import org.apache.maven.wagon.tck.http.HttpsGetWagonTests;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
- at RunWith( Suite.class )
- at Suite.SuiteClasses( { GetWagonTests.class, HttpsGetWagonTests.class } )
-public class TestSuite
-{
-}
+package org.apache.maven.wagon.tck.http.consumer;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.tck.http.GetWagonTests;
+import org.apache.maven.wagon.tck.http.HttpsGetWagonTests;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+ at RunWith( Suite.class )
+ at Suite.SuiteClasses( { GetWagonTests.class, HttpsGetWagonTests.class } )
+public class TestSuite
+{
+}
diff --git a/wagon-tcks/wagon-tck-http/sample-tck-consumer/src/test/resources/META-INF/plexus/components.xml b/wagon-tcks/wagon-tck-http/sample-tck-consumer/src/test/resources/META-INF/plexus/components.xml
index 967b370..d1c96dd 100644
--- a/wagon-tcks/wagon-tck-http/sample-tck-consumer/src/test/resources/META-INF/plexus/components.xml
+++ b/wagon-tcks/wagon-tck-http/sample-tck-consumer/src/test/resources/META-INF/plexus/components.xml
@@ -1,39 +1,39 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-<component-set>
- <!-- TODO: Split this out into a sample project that shows how to use this TCK. -->
- <components>
- <component>
- <role>org.apache.maven.wagon.tck.http.WagonTestCaseConfigurator</role>
- <implementation>org.apache.maven.wagon.tck.http.WagonTestCaseConfigurator</implementation>
- <configuration>
- <wagonHint>http</wagonHint>
- <useCaseConfigs>
- <highLatencyLowTimeout>
- <unsupported/>
- </highLatencyLowTimeout>
- <inifiniteLatencyTimeout>
- <unsupported/>
- </inifiniteLatencyTimeout>
- </useCaseConfigs>
- </configuration>
- </component>
- </components>
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<component-set>
+ <!-- TODO: Split this out into a sample project that shows how to use this TCK. -->
+ <components>
+ <component>
+ <role>org.apache.maven.wagon.tck.http.WagonTestCaseConfigurator</role>
+ <implementation>org.apache.maven.wagon.tck.http.WagonTestCaseConfigurator</implementation>
+ <configuration>
+ <wagonHint>http</wagonHint>
+ <useCaseConfigs>
+ <highLatencyLowTimeout>
+ <unsupported/>
+ </highLatencyLowTimeout>
+ <inifiniteLatencyTimeout>
+ <unsupported/>
+ </inifiniteLatencyTimeout>
+ </useCaseConfigs>
+ </configuration>
+ </component>
+ </components>
</component-set>
\ No newline at end of file
diff --git a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/Assertions.java b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/Assertions.java
index e5cf37d..319e24a 100644
--- a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/Assertions.java
+++ b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/Assertions.java
@@ -1,68 +1,70 @@
-package org.apache.maven.wagon.tck.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import static junit.framework.Assert.assertEquals;
-import static org.codehaus.plexus.util.FileUtils.fileRead;
-
-import org.codehaus.plexus.util.IOUtil;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- *
- */
-public final class Assertions
-{
-
- public static void assertFileContentsFromResource( final String resourceBase, final String resourceName,
- final File output, final String whyWouldItFail )
- throws IOException
- {
- String content = readResource( resourceBase, resourceName );
- String test = fileRead( output );
-
- assertEquals( whyWouldItFail, content, test );
- }
-
- private static String readResource( final String base, final String name )
- throws IOException
- {
- String url = base;
- if ( !url.endsWith( "/" ) && !name.startsWith( "/" ) )
- {
- url += "/";
- }
- url += name;
-
- ClassLoader cloader = Thread.currentThread().getContextClassLoader();
- InputStream stream = cloader.getResourceAsStream( url );
-
- if ( stream == null )
- {
- return null;
- }
-
- return IOUtil.toString( stream );
- }
-
-}
+package org.apache.maven.wagon.tck.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import static junit.framework.Assert.assertEquals;
+import static org.codehaus.plexus.util.FileUtils.fileRead;
+
+import org.codehaus.plexus.util.IOUtil;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ *
+ */
+public final class Assertions
+{
+
+ public static void assertFileContentsFromResource( final String resourceBase, final String resourceName,
+ final File output, final String whyWouldItFail )
+ throws IOException
+ {
+ String content = readResource( resourceBase, resourceName );
+ String test = fileRead( output );
+
+ assertEquals( whyWouldItFail, content, test );
+ }
+
+ private static String readResource( final String base, final String name )
+ throws IOException
+ {
+ String url = base;
+ if ( !url.endsWith( "/" ) && !name.startsWith( "/" ) )
+ {
+ url += "/";
+ }
+ url += name;
+
+ ClassLoader cloader = Thread.currentThread().getContextClassLoader();
+ InputStream stream = cloader.getResourceAsStream( url );
+
+ if ( stream == null )
+ {
+ return null;
+ }
+
+ final String resource = IOUtil.toString( stream );
+ stream.close();
+ return resource;
+ }
+
+}
diff --git a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/GetWagonTests.java b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/GetWagonTests.java
index 01152a0..238550f 100644
--- a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/GetWagonTests.java
+++ b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/GetWagonTests.java
@@ -1,561 +1,561 @@
-package org.apache.maven.wagon.tck.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.maven.wagon.ConnectionException;
-import org.apache.maven.wagon.ResourceDoesNotExistException;
-import org.apache.maven.wagon.StreamWagon;
-import org.apache.maven.wagon.TransferFailedException;
-import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
-import org.apache.maven.wagon.authorization.AuthorizationException;
-import org.apache.maven.wagon.proxy.ProxyInfo;
-import org.apache.maven.wagon.tck.http.fixture.ErrorCodeServlet;
-import org.apache.maven.wagon.tck.http.fixture.LatencyServlet;
-import org.apache.maven.wagon.tck.http.fixture.ProxyConnectionVerifierFilter;
-import org.apache.maven.wagon.tck.http.fixture.RedirectionServlet;
-import org.apache.maven.wagon.tck.http.fixture.ServerFixture;
-import org.apache.maven.wagon.tck.http.fixture.ServletExceptionServlet;
-import org.apache.maven.wagon.tck.http.util.ValueHolder;
-import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import javax.servlet.Servlet;
-import javax.servlet.http.HttpServletResponse;
-import java.io.File;
-import java.io.IOException;
-
-import static junit.framework.Assert.assertTrue;
-import static junit.framework.Assert.fail;
-import static org.apache.maven.wagon.tck.http.Assertions.assertFileContentsFromResource;
-
-/**
- *
- */
-public class GetWagonTests
- extends HttpWagonTests
-{
- private static final int TWO_SECONDS = 2000;
- private static final int ONE_MINUTE = 60000;
-
- @Test
- public void basic()
- throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
- TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- testSuccessfulGet( "base.txt" );
- }
-
- @Test
- @Ignore( "FIX ME!" )
- public void proxied()
- throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
- TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- getServerFixture().addFilter( "*", new ProxyConnectionVerifierFilter() );
-
- ProxyInfo info = newProxyInfo();
- if ( !initTest( null, info ) )
- {
- return;
- }
-
- File target = newTempFile();
- getWagon().get( "base.txt", target );
-
- assertFileContentsFromResource( ServerFixture.SERVER_ROOT_RESOURCE_PATH, "base.txt", target,
- "Downloaded file doesn't match original." );
- }
-
- @Test
- public void highLatencyHighTimeout()
- throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
- TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- getServerFixture().addServlet( "/slow/*", new LatencyServlet( TWO_SECONDS ) );
- testSuccessfulGet( "slow/large.txt", "large.txt" );
- }
-
- @Test
- public void highLatencyLowTimeout()
- throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
- TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- Servlet servlet = new LatencyServlet( TWO_SECONDS );
- getServerFixture().addServlet( "/slow/*", servlet );
- testSuccessfulGet( "slow/large.txt", "large.txt" );
- }
-
- @Test
- public void inifiniteLatencyTimeout()
- throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
- TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- if ( !isSupported() )
- {
- return;
- }
-
- final ValueHolder<Boolean> holder = new ValueHolder<Boolean>( false );
-
- Runnable r = new Runnable()
- {
- public void run()
- {
- Servlet servlet = new LatencyServlet( -1 );
- addNotificationTarget( servlet );
-
- getServerFixture().addServlet( "/infinite/*", servlet );
- try
- {
- if ( !initTest( null, null ) )
- {
- return;
- }
-
- if ( getWagon() instanceof StreamWagon )
- {
- LOGGER.info( "Connection timeout is: " + getWagon().getTimeout() );
- }
-
- File target = newTempFile();
- getWagon().get( "infinite/", target );
-
- fail( "Should have failed to transfer due to transaction timeout." );
- }
- catch ( ConnectionException e )
- {
- throw new IllegalStateException( e );
- }
- catch ( AuthenticationException e )
- {
- throw new IllegalStateException( e );
- }
- catch ( TransferFailedException e )
- {
- // expected
- holder.setValue( true );
- }
- catch ( ResourceDoesNotExistException e )
- {
- throw new IllegalStateException( e );
- }
- catch ( AuthorizationException e )
- {
- throw new IllegalStateException( e );
- }
- catch ( ComponentConfigurationException e )
- {
- throw new IllegalStateException( e );
- }
- catch ( IOException e )
- {
- throw new IllegalStateException( e );
- }
- }
- };
-
- Thread t = new Thread( r );
- t.start();
-
- try
- {
- LOGGER.info( "Waiting 60 seconds for wagon timeout." );
- t.join( ONE_MINUTE );
- }
- catch ( InterruptedException e )
- {
- e.printStackTrace();
- }
-
- LOGGER.info( "Interrupting thread." );
- t.interrupt();
-
- assertTrue( "TransferFailedException should have been thrown.", holder.getValue() );
- }
-
- @Test
- public void nonExistentHost()
- throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
- ResourceDoesNotExistException, AuthorizationException
- {
- // we use a invalid localhost URL since some Internet Service Providers lately
- // use funny 'search-DNS' which don't handle explicitly marked testing DNS properly.
- // According to RFC-2606 .test, .invalid TLDs etc should work, but in practice it doesn't :(
- if ( !initTest( "http://localhost:65520", null, null ) )
- {
- return;
- }
-
- File target = newTempFile();
- try
- {
- getWagon().get( "base.txt", target );
- fail( "Expected error related to host lookup failure." );
- }
- catch ( TransferFailedException e )
- {
- // expected
- }
- }
-
- @Test
- public void oneLevelPermanentMove()
- throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
- TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- getServerFixture().addServlet( "/moved.txt",
- new RedirectionServlet( HttpServletResponse.SC_MOVED_PERMANENTLY,
- "/base.txt" ) );
-
- testSuccessfulGet( "moved.txt" );
- }
-
- @Test
- public void oneLevelTemporaryMove()
- throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
- TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- getServerFixture().addServlet( "/moved.txt",
- new RedirectionServlet( HttpServletResponse.SC_MOVED_TEMPORARILY,
- "/base.txt" ) );
-
- testSuccessfulGet( "moved.txt" );
- }
-
- @Test
- public void sixLevelPermanentMove()
- throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
- TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- String myPath = "moved.txt";
- String targetPath = "/base.txt";
-
- getServerFixture().addServlet( "/" + myPath + "/*",
- new RedirectionServlet( HttpServletResponse.SC_MOVED_PERMANENTLY, myPath,
- targetPath, 6 ) );
-
- testSuccessfulGet( myPath );
- }
-
- @Test
- public void sixLevelTemporaryMove()
- throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
- TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- String myPath = "moved.txt";
- String targetPath = "/base.txt";
-
- getServerFixture().addServlet( "/" + myPath + "/*",
- new RedirectionServlet( HttpServletResponse.SC_MOVED_TEMPORARILY, myPath,
- targetPath, 6 ) );
-
- testSuccessfulGet( myPath );
- }
-
- @Test
- public void infinitePermanentMove()
- throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
- TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- String myPath = "moved.txt";
- String targetPath = "/base.txt";
-
- getServerFixture().addServlet(
- "/" + myPath,
- new RedirectionServlet( HttpServletResponse.SC_MOVED_PERMANENTLY, myPath,
- targetPath, -1 ) );
-
- try
- {
- testSuccessfulGet( myPath );
- fail( "Expected failure as a result of too many redirects." );
- }
- catch ( TransferFailedException e )
- {
- // expected
- }
- }
-
- @Test
- public void infiniteTemporaryMove()
- throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
- ResourceDoesNotExistException, AuthorizationException
- {
- String myPath = "moved.txt";
- String targetPath = "/base.txt";
-
- getServerFixture().addServlet(
- "/" + myPath,
- new RedirectionServlet( HttpServletResponse.SC_MOVED_TEMPORARILY, myPath,
- targetPath, -1 ) );
-
- try
- {
- testSuccessfulGet( myPath );
- fail( "Expected failure as a result of too many redirects." );
- }
- catch ( TransferFailedException e )
- {
- // expected
- }
- }
-
- /**
- * NOTE: This test depends on a {@link WagonTestCaseConfigurator} configuration to limit redirects to 20. In the
- * case of the Sun HTTP implementation, this is the default limit.
- */
- @Test
- @SuppressWarnings( "checkstyle:methodname" )
- public void permanentMove_TooManyRedirects_limit20()
- throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
- TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- String myPath = "moved.txt";
- String targetPath = "/base.txt";
-
- getServerFixture().addServlet(
- "/" + myPath,
- new RedirectionServlet( HttpServletResponse.SC_MOVED_PERMANENTLY, myPath,
- targetPath, -1 ) );
-
- try
- {
- testSuccessfulGet( myPath );
- fail( "Expected failure as a result of too many redirects." );
- }
- catch ( TransferFailedException e )
- {
- // expected
- }
- }
-
- /**
- * NOTE: This test depends on a {@link WagonTestCaseConfigurator} configuration to limit redirects to 20. In the
- * case of the Sun HTTP implementation, this is the default limit.
- */
- @Test
- @SuppressWarnings( "checkstyle:methodname" )
- public void temporaryMove_TooManyRedirects_limit20()
- throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
- ResourceDoesNotExistException, AuthorizationException
- {
- String myPath = "moved.txt";
- String targetPath = "/base.txt";
-
- getServerFixture().addServlet(
- "/" + myPath,
- new RedirectionServlet( HttpServletResponse.SC_MOVED_TEMPORARILY, myPath,
- targetPath, -1 ) );
-
- try
- {
- testSuccessfulGet( myPath );
- fail( "Expected failure as a result of too many redirects." );
- }
- catch ( TransferFailedException e )
- {
- // expected
- }
- }
-
- @Test
- public void missing()
- throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
- TransferFailedException, AuthorizationException
- {
- if ( !initTest( null, null ) )
- {
- return;
- }
-
- File target = newTempFile();
- try
- {
- getWagon().get( "404.txt", target );
- fail( "should have received a 404, meaning the resource doesn't exist." );
- }
- catch ( ResourceDoesNotExistException e )
- {
- // expected
- }
- }
-
- @Test
- public void error()
- throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
- AuthorizationException, ResourceDoesNotExistException
- {
- testErrorHandling( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
- }
-
- @Test
- public void proxyTimeout()
- throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
- AuthorizationException, ResourceDoesNotExistException
- {
- testErrorHandling( HttpServletResponse.SC_GATEWAY_TIMEOUT );
- }
-
- @Test
- public void forbidden()
- throws ConnectionException, ComponentConfigurationException, IOException, ResourceDoesNotExistException,
- TransferFailedException
- {
- AuthenticationInfo info = new AuthenticationInfo();
- info.setUserName( "user" );
- info.setPassword( "password" );
-
- getServerFixture().addUser( info.getUserName(), "password" );
-
- getServerFixture().addServlet( "/403.txt",
- new ErrorCodeServlet( HttpServletResponse.SC_FORBIDDEN, "Expected 403" ) );
-
- testAuthFailure( "403.txt", info );
- }
-
- @Test
- public void successfulAuthentication()
- throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
- TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- AuthenticationInfo info = new AuthenticationInfo();
- info.setUserName( "user" );
- info.setPassword( "password" );
-
- getServerFixture().addUser( info.getUserName(), info.getPassword() );
-
- if ( !initTest( info, null ) )
- {
- return;
- }
-
- File target = newTempFile();
- getWagon().get( "protected/base.txt", target );
-
- assertFileContentsFromResource( ServerFixture.SERVER_ROOT_RESOURCE_PATH, "base.txt", target,
- "Downloaded file doesn't match original." );
- }
-
- @Test
- public void unsuccessfulAuthentication()
- throws ConnectionException, ComponentConfigurationException, IOException, TransferFailedException,
- ResourceDoesNotExistException
- {
- AuthenticationInfo info = new AuthenticationInfo();
- info.setUserName( "user" );
- info.setPassword( "password" );
-
- getServerFixture().addUser( info.getUserName(), "anotherPassword" );
-
- testAuthFailure( "protected/base.txt", info );
- }
-
- protected void testAuthFailure( final String path, final AuthenticationInfo info )
- throws ConnectionException, ComponentConfigurationException, IOException, TransferFailedException,
- ResourceDoesNotExistException
- {
- boolean authFailure = false;
- try
- {
- if ( !initTest( info, null ) )
- {
- return;
- }
- }
- catch ( AuthenticationException e )
- {
- // expected
- authFailure = true;
- }
-
- File target = newTempFile();
- try
- {
- getWagon().get( path, target );
- }
- catch ( AuthorizationException e )
- {
- // expected
- authFailure = true;
- }
-
- assertTrue( "Authentication/Authorization should have failed.", authFailure );
- }
-
- protected void testSuccessfulGet( final String path )
- throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
- TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- testSuccessfulGet( path, "base.txt" );
- }
-
- protected void testSuccessfulGet( final String path, final String checkPath )
- throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
- TransferFailedException, ResourceDoesNotExistException, AuthorizationException
- {
- if ( !initTest( null, null ) )
- {
- return;
- }
-
- if ( getWagon() instanceof StreamWagon )
- {
- LOGGER.info( "Connection timeout is: " + getWagon().getTimeout() );
- }
-
- File target = newTempFile();
- getWagon().get( path, target );
-
- assertFileContentsFromResource( ServerFixture.SERVER_ROOT_RESOURCE_PATH, checkPath, target,
- "Downloaded file doesn't match original." );
- }
-
- protected void testErrorHandling( final int code )
- throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
- AuthorizationException, ResourceDoesNotExistException
- {
- if ( code == HttpServletResponse.SC_INTERNAL_SERVER_ERROR )
- {
- getServerFixture().addServlet( "/" + code + ".txt", new ServletExceptionServlet( "Expected " + code ) );
- }
- else
- {
- getServerFixture().addServlet( "/" + code + ".txt", new ErrorCodeServlet( code, "Expected " + code ) );
- }
-
- if ( !initTest( null, null ) )
- {
- return;
- }
-
- File target = newTempFile();
- try
- {
- getWagon().get( code + ".txt", target );
- fail( "should have received a " + code + " error code, meaning the resource doesn't exist." );
- }
- catch ( TransferFailedException e )
- {
- // expected
- }
- }
-}
+package org.apache.maven.wagon.tck.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.ConnectionException;
+import org.apache.maven.wagon.ResourceDoesNotExistException;
+import org.apache.maven.wagon.StreamWagon;
+import org.apache.maven.wagon.TransferFailedException;
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.authorization.AuthorizationException;
+import org.apache.maven.wagon.proxy.ProxyInfo;
+import org.apache.maven.wagon.tck.http.fixture.ErrorCodeServlet;
+import org.apache.maven.wagon.tck.http.fixture.LatencyServlet;
+import org.apache.maven.wagon.tck.http.fixture.ProxyConnectionVerifierFilter;
+import org.apache.maven.wagon.tck.http.fixture.RedirectionServlet;
+import org.apache.maven.wagon.tck.http.fixture.ServerFixture;
+import org.apache.maven.wagon.tck.http.fixture.ServletExceptionServlet;
+import org.apache.maven.wagon.tck.http.util.ValueHolder;
+import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
+import org.junit.Ignore;
+import org.junit.Test;
+
+import javax.servlet.Servlet;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.IOException;
+
+import static junit.framework.Assert.assertTrue;
+import static junit.framework.Assert.fail;
+import static org.apache.maven.wagon.tck.http.Assertions.assertFileContentsFromResource;
+
+/**
+ *
+ */
+public class GetWagonTests
+ extends HttpWagonTests
+{
+ private static final int TWO_SECONDS = 2000;
+ private static final int ONE_MINUTE = 60000;
+
+ @Test
+ public void basic()
+ throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
+ TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ testSuccessfulGet( "base.txt" );
+ }
+
+ @Test
+ @Ignore( "FIX ME!" )
+ public void proxied()
+ throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
+ TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ getServerFixture().addFilter( "*", new ProxyConnectionVerifierFilter() );
+
+ ProxyInfo info = newProxyInfo();
+ if ( !initTest( null, info ) )
+ {
+ return;
+ }
+
+ File target = newTempFile();
+ getWagon().get( "base.txt", target );
+
+ assertFileContentsFromResource( ServerFixture.SERVER_ROOT_RESOURCE_PATH, "base.txt", target,
+ "Downloaded file doesn't match original." );
+ }
+
+ @Test
+ public void highLatencyHighTimeout()
+ throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
+ TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ getServerFixture().addServlet( "/slow/*", new LatencyServlet( TWO_SECONDS ) );
+ testSuccessfulGet( "slow/large.txt", "large.txt" );
+ }
+
+ @Test
+ public void highLatencyLowTimeout()
+ throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
+ TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ Servlet servlet = new LatencyServlet( TWO_SECONDS );
+ getServerFixture().addServlet( "/slow/*", servlet );
+ testSuccessfulGet( "slow/large.txt", "large.txt" );
+ }
+
+ @Test
+ public void inifiniteLatencyTimeout()
+ throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
+ TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ if ( !isSupported() )
+ {
+ return;
+ }
+
+ final ValueHolder<Boolean> holder = new ValueHolder<Boolean>( false );
+
+ Runnable r = new Runnable()
+ {
+ public void run()
+ {
+ Servlet servlet = new LatencyServlet( -1 );
+ addNotificationTarget( servlet );
+
+ getServerFixture().addServlet( "/infinite/*", servlet );
+ try
+ {
+ if ( !initTest( null, null ) )
+ {
+ return;
+ }
+
+ if ( getWagon() instanceof StreamWagon )
+ {
+ logger.info( "Connection timeout is: " + getWagon().getTimeout() );
+ }
+
+ File target = newTempFile();
+ getWagon().get( "infinite/", target );
+
+ fail( "Should have failed to transfer due to transaction timeout." );
+ }
+ catch ( ConnectionException e )
+ {
+ throw new IllegalStateException( e );
+ }
+ catch ( AuthenticationException e )
+ {
+ throw new IllegalStateException( e );
+ }
+ catch ( TransferFailedException e )
+ {
+ // expected
+ holder.setValue( true );
+ }
+ catch ( ResourceDoesNotExistException e )
+ {
+ throw new IllegalStateException( e );
+ }
+ catch ( AuthorizationException e )
+ {
+ throw new IllegalStateException( e );
+ }
+ catch ( ComponentConfigurationException e )
+ {
+ throw new IllegalStateException( e );
+ }
+ catch ( IOException e )
+ {
+ throw new IllegalStateException( e );
+ }
+ }
+ };
+
+ Thread t = new Thread( r );
+ t.start();
+
+ try
+ {
+ logger.info( "Waiting 60 seconds for wagon timeout." );
+ t.join( ONE_MINUTE );
+ }
+ catch ( InterruptedException e )
+ {
+ e.printStackTrace();
+ }
+
+ logger.info( "Interrupting thread." );
+ t.interrupt();
+
+ assertTrue( "TransferFailedException should have been thrown.", holder.getValue() );
+ }
+
+ @Test
+ public void nonExistentHost()
+ throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
+ ResourceDoesNotExistException, AuthorizationException
+ {
+ // we use a invalid localhost URL since some Internet Service Providers lately
+ // use funny 'search-DNS' which don't handle explicitly marked testing DNS properly.
+ // According to RFC-2606 .test, .invalid TLDs etc should work, but in practice it doesn't :(
+ if ( !initTest( "http://localhost:65520", null, null ) )
+ {
+ return;
+ }
+
+ File target = newTempFile();
+ try
+ {
+ getWagon().get( "base.txt", target );
+ fail( "Expected error related to host lookup failure." );
+ }
+ catch ( TransferFailedException e )
+ {
+ // expected
+ }
+ }
+
+ @Test
+ public void oneLevelPermanentMove()
+ throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
+ TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ getServerFixture().addServlet( "/moved.txt",
+ new RedirectionServlet( HttpServletResponse.SC_MOVED_PERMANENTLY,
+ "/base.txt" ) );
+
+ testSuccessfulGet( "moved.txt" );
+ }
+
+ @Test
+ public void oneLevelTemporaryMove()
+ throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
+ TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ getServerFixture().addServlet( "/moved.txt",
+ new RedirectionServlet( HttpServletResponse.SC_MOVED_TEMPORARILY,
+ "/base.txt" ) );
+
+ testSuccessfulGet( "moved.txt" );
+ }
+
+ @Test
+ public void sixLevelPermanentMove()
+ throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
+ TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ String myPath = "moved.txt";
+ String targetPath = "/base.txt";
+
+ getServerFixture().addServlet( "/" + myPath + "/*",
+ new RedirectionServlet( HttpServletResponse.SC_MOVED_PERMANENTLY, myPath,
+ targetPath, 6 ) );
+
+ testSuccessfulGet( myPath );
+ }
+
+ @Test
+ public void sixLevelTemporaryMove()
+ throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
+ TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ String myPath = "moved.txt";
+ String targetPath = "/base.txt";
+
+ getServerFixture().addServlet( "/" + myPath + "/*",
+ new RedirectionServlet( HttpServletResponse.SC_MOVED_TEMPORARILY, myPath,
+ targetPath, 6 ) );
+
+ testSuccessfulGet( myPath );
+ }
+
+ @Test
+ public void infinitePermanentMove()
+ throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
+ TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ String myPath = "moved.txt";
+ String targetPath = "/base.txt";
+
+ getServerFixture().addServlet(
+ "/" + myPath,
+ new RedirectionServlet( HttpServletResponse.SC_MOVED_PERMANENTLY, myPath,
+ targetPath, -1 ) );
+
+ try
+ {
+ testSuccessfulGet( myPath );
+ fail( "Expected failure as a result of too many redirects." );
+ }
+ catch ( TransferFailedException e )
+ {
+ // expected
+ }
+ }
+
+ @Test
+ public void infiniteTemporaryMove()
+ throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
+ ResourceDoesNotExistException, AuthorizationException
+ {
+ String myPath = "moved.txt";
+ String targetPath = "/base.txt";
+
+ getServerFixture().addServlet(
+ "/" + myPath,
+ new RedirectionServlet( HttpServletResponse.SC_MOVED_TEMPORARILY, myPath,
+ targetPath, -1 ) );
+
+ try
+ {
+ testSuccessfulGet( myPath );
+ fail( "Expected failure as a result of too many redirects." );
+ }
+ catch ( TransferFailedException e )
+ {
+ // expected
+ }
+ }
+
+ /**
+ * NOTE: This test depends on a {@link WagonTestCaseConfigurator} configuration to limit redirects to 20. In the
+ * case of the Sun HTTP implementation, this is the default limit.
+ */
+ @Test
+ @SuppressWarnings( "checkstyle:methodname" )
+ public void permanentMove_TooManyRedirects_limit20()
+ throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
+ TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ String myPath = "moved.txt";
+ String targetPath = "/base.txt";
+
+ getServerFixture().addServlet(
+ "/" + myPath,
+ new RedirectionServlet( HttpServletResponse.SC_MOVED_PERMANENTLY, myPath,
+ targetPath, -1 ) );
+
+ try
+ {
+ testSuccessfulGet( myPath );
+ fail( "Expected failure as a result of too many redirects." );
+ }
+ catch ( TransferFailedException e )
+ {
+ // expected
+ }
+ }
+
+ /**
+ * NOTE: This test depends on a {@link WagonTestCaseConfigurator} configuration to limit redirects to 20. In the
+ * case of the Sun HTTP implementation, this is the default limit.
+ */
+ @Test
+ @SuppressWarnings( "checkstyle:methodname" )
+ public void temporaryMove_TooManyRedirects_limit20()
+ throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
+ ResourceDoesNotExistException, AuthorizationException
+ {
+ String myPath = "moved.txt";
+ String targetPath = "/base.txt";
+
+ getServerFixture().addServlet(
+ "/" + myPath,
+ new RedirectionServlet( HttpServletResponse.SC_MOVED_TEMPORARILY, myPath,
+ targetPath, -1 ) );
+
+ try
+ {
+ testSuccessfulGet( myPath );
+ fail( "Expected failure as a result of too many redirects." );
+ }
+ catch ( TransferFailedException e )
+ {
+ // expected
+ }
+ }
+
+ @Test
+ public void missing()
+ throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
+ TransferFailedException, AuthorizationException
+ {
+ if ( !initTest( null, null ) )
+ {
+ return;
+ }
+
+ File target = newTempFile();
+ try
+ {
+ getWagon().get( "404.txt", target );
+ fail( "should have received a 404, meaning the resource doesn't exist." );
+ }
+ catch ( ResourceDoesNotExistException e )
+ {
+ // expected
+ }
+ }
+
+ @Test
+ public void error()
+ throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
+ AuthorizationException, ResourceDoesNotExistException
+ {
+ testErrorHandling( HttpServletResponse.SC_INTERNAL_SERVER_ERROR );
+ }
+
+ @Test
+ public void proxyTimeout()
+ throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
+ AuthorizationException, ResourceDoesNotExistException
+ {
+ testErrorHandling( HttpServletResponse.SC_GATEWAY_TIMEOUT );
+ }
+
+ @Test
+ public void forbidden()
+ throws ConnectionException, ComponentConfigurationException, IOException, ResourceDoesNotExistException,
+ TransferFailedException
+ {
+ AuthenticationInfo info = new AuthenticationInfo();
+ info.setUserName( "user" );
+ info.setPassword( "password" );
+
+ getServerFixture().addUser( info.getUserName(), "password" );
+
+ getServerFixture().addServlet( "/403.txt",
+ new ErrorCodeServlet( HttpServletResponse.SC_FORBIDDEN, "Expected 403" ) );
+
+ testAuthFailure( "403.txt", info );
+ }
+
+ @Test
+ public void successfulAuthentication()
+ throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
+ TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ AuthenticationInfo info = new AuthenticationInfo();
+ info.setUserName( "user" );
+ info.setPassword( "password" );
+
+ getServerFixture().addUser( info.getUserName(), info.getPassword() );
+
+ if ( !initTest( info, null ) )
+ {
+ return;
+ }
+
+ File target = newTempFile();
+ getWagon().get( "protected/base.txt", target );
+
+ assertFileContentsFromResource( ServerFixture.SERVER_ROOT_RESOURCE_PATH, "base.txt", target,
+ "Downloaded file doesn't match original." );
+ }
+
+ @Test
+ public void unsuccessfulAuthentication()
+ throws ConnectionException, ComponentConfigurationException, IOException, TransferFailedException,
+ ResourceDoesNotExistException
+ {
+ AuthenticationInfo info = new AuthenticationInfo();
+ info.setUserName( "user" );
+ info.setPassword( "password" );
+
+ getServerFixture().addUser( info.getUserName(), "anotherPassword" );
+
+ testAuthFailure( "protected/base.txt", info );
+ }
+
+ protected void testAuthFailure( final String path, final AuthenticationInfo info )
+ throws ConnectionException, ComponentConfigurationException, IOException, TransferFailedException,
+ ResourceDoesNotExistException
+ {
+ boolean authFailure = false;
+ try
+ {
+ if ( !initTest( info, null ) )
+ {
+ return;
+ }
+ }
+ catch ( AuthenticationException e )
+ {
+ // expected
+ authFailure = true;
+ }
+
+ File target = newTempFile();
+ try
+ {
+ getWagon().get( path, target );
+ }
+ catch ( AuthorizationException e )
+ {
+ // expected
+ authFailure = true;
+ }
+
+ assertTrue( "Authentication/Authorization should have failed.", authFailure );
+ }
+
+ protected void testSuccessfulGet( final String path )
+ throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
+ TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ testSuccessfulGet( path, "base.txt" );
+ }
+
+ protected void testSuccessfulGet( final String path, final String checkPath )
+ throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
+ TransferFailedException, ResourceDoesNotExistException, AuthorizationException
+ {
+ if ( !initTest( null, null ) )
+ {
+ return;
+ }
+
+ if ( getWagon() instanceof StreamWagon )
+ {
+ logger.info( "Connection timeout is: " + getWagon().getTimeout() );
+ }
+
+ File target = newTempFile();
+ getWagon().get( path, target );
+
+ assertFileContentsFromResource( ServerFixture.SERVER_ROOT_RESOURCE_PATH, checkPath, target,
+ "Downloaded file doesn't match original." );
+ }
+
+ protected void testErrorHandling( final int code )
+ throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException,
+ AuthorizationException, ResourceDoesNotExistException
+ {
+ if ( code == HttpServletResponse.SC_INTERNAL_SERVER_ERROR )
+ {
+ getServerFixture().addServlet( "/" + code + ".txt", new ServletExceptionServlet( "Expected " + code ) );
+ }
+ else
+ {
+ getServerFixture().addServlet( "/" + code + ".txt", new ErrorCodeServlet( code, "Expected " + code ) );
+ }
+
+ if ( !initTest( null, null ) )
+ {
+ return;
+ }
+
+ File target = newTempFile();
+ try
+ {
+ getWagon().get( code + ".txt", target );
+ fail( "should have received a " + code + " error code, meaning the resource doesn't exist." );
+ }
+ catch ( TransferFailedException e )
+ {
+ // expected
+ }
+ }
+}
diff --git a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/HttpWagonTests.java b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/HttpWagonTests.java
index bad033c..eae4ed0 100644
--- a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/HttpWagonTests.java
+++ b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/HttpWagonTests.java
@@ -1,333 +1,337 @@
-package org.apache.maven.wagon.tck.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.log4j.Logger;
-import org.apache.maven.wagon.ConnectionException;
-import org.apache.maven.wagon.Wagon;
-import org.apache.maven.wagon.authentication.AuthenticationException;
-import org.apache.maven.wagon.authentication.AuthenticationInfo;
-import org.apache.maven.wagon.proxy.ProxyInfo;
-import org.apache.maven.wagon.repository.Repository;
-import org.apache.maven.wagon.tck.http.fixture.ServerFixture;
-import org.codehaus.plexus.DefaultPlexusContainer;
-import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
-import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
-import org.codehaus.plexus.util.FileUtils;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import static org.apache.maven.wagon.tck.http.util.TestUtil.getResource;
-
-/**
- *
- */
-public abstract class HttpWagonTests
-{
-
- private ServerFixture serverFixture;
-
- private static PlexusContainer container;
-
- private Wagon wagon;
-
- private static WagonTestCaseConfigurator configurator;
-
- private String baseUrl;
-
- private static final Set<File> TMP_FILES = new HashSet<File>();
-
- private Repository repo;
-
- private final Set<Object> notificationTargets = new HashSet<Object>();
-
- protected static final Logger LOGGER = Logger.getLogger( HttpWagonTests.class );
-
- @Before
- public void beforeEach()
- throws Exception
- {
- serverFixture = new ServerFixture( isSsl() );
- serverFixture.start();
- wagon = (Wagon) container.lookup( Wagon.ROLE, configurator.getWagonHint() );
- }
-
- @BeforeClass
- public static void beforeAll()
- throws Exception
- {
- File keystore = getResource( ServerFixture.SERVER_SSL_KEYSTORE_RESOURCE_PATH );
-
- System.setProperty( "javax.net.ssl.keyStore", keystore.getAbsolutePath() );
- System.setProperty( "javax.net.ssl.keyStorePassword", ServerFixture.SERVER_SSL_KEYSTORE_PASSWORD );
- System.setProperty( "javax.net.ssl.trustStore", keystore.getAbsolutePath() );
- System.setProperty( "javax.net.ssl.trustStorePassword", ServerFixture.SERVER_SSL_KEYSTORE_PASSWORD );
-
- container = new DefaultPlexusContainer();
- //container.initialize();
- //container.start();
-
- configurator = (WagonTestCaseConfigurator) container.lookup( WagonTestCaseConfigurator.class.getName() );
- }
-
- @After
- public void afterEach()
- {
- try
- {
- wagon.disconnect();
- }
- catch ( ConnectionException e )
- {
- e.printStackTrace();
- }
-
- for ( Object obj : notificationTargets )
- {
- synchronized ( obj )
- {
- obj.notify();
- }
- }
-
- if ( serverFixture != null )
- {
- try
- {
- serverFixture.stop();
- }
- catch ( Exception e )
- {
- e.printStackTrace();
- }
- }
-
- try
- {
- container.release( wagon );
- }
- catch ( ComponentLifecycleException e )
- {
- e.printStackTrace();
- }
- }
-
- @AfterClass
- public static void afterAll()
- {
- for ( File f : TMP_FILES )
- {
- if ( f.exists() )
- {
- try
- {
- FileUtils.forceDelete( f );
- }
- catch ( IOException e )
- {
- e.printStackTrace();
- }
- }
- }
-
- if ( container != null )
- {
- try
- {
- container.release( configurator );
- }
- catch ( ComponentLifecycleException e )
- {
- e.printStackTrace();
- }
-
- container.dispose();
- }
- }
-
- protected void addNotificationTarget( final Object target )
- {
- notificationTargets.add( target );
- }
-
- protected File newTempFile()
- throws IOException
- {
- File f = File.createTempFile( "wagon-target.", ".file" );
- f.deleteOnExit();
-
- return f;
- }
-
- protected boolean isSsl()
- {
- return false;
- }
-
- protected ProxyInfo newProxyInfo()
- {
- ProxyInfo info = new ProxyInfo();
- info.setType( isSsl() ? "https" : "http" );
- info.setHost( ServerFixture.SERVER_HOST );
- info.setPort( getPort() );
-
- return info;
- }
-
- protected boolean isSupported()
- {
- StackTraceElement[] elements = new Throwable().getStackTrace();
- String testCaseId = null;
- String lastMethodName = null;
- for ( StackTraceElement e : elements )
- {
- if ( !e.getClassName().startsWith( getClass().getPackage().getName() ) )
- {
- testCaseId = lastMethodName;
- break;
- }
- else
- {
- lastMethodName = e.getMethodName();
- }
- }
-
- if ( testCaseId == null || !configurator.isSupported( testCaseId ) )
- {
- LOGGER.error( "Cannot run test: " + testCaseId
- + ". Wagon under test does not support this test case." );
- return false;
- }
-
- return true;
- }
-
- protected boolean initTest( final AuthenticationInfo auth, final ProxyInfo proxy )
- throws ComponentConfigurationException, ConnectionException, AuthenticationException
- {
- return initTest( getBaseUrl(), auth, proxy );
- }
-
- protected boolean initTest( final String baseUrl, final AuthenticationInfo auth, final ProxyInfo proxy )
- throws ComponentConfigurationException, ConnectionException, AuthenticationException
- {
- StackTraceElement[] elements = new Throwable().getStackTrace();
- String testCaseId = null;
- String lastMethodName = null;
- for ( StackTraceElement e : elements )
- {
- if ( !e.getClassName().startsWith( getClass().getPackage().getName() ) )
- {
- testCaseId = lastMethodName;
- break;
- }
- else
- {
- lastMethodName = e.getMethodName();
- }
- }
-
- if ( testCaseId == null || !configurator.configureWagonForTest( wagon, testCaseId ) )
- {
- LOGGER.error( "Cannot run test: " + testCaseId
- + ". Wagon under test does not support this test case." );
-
- return false;
- }
-
- try
- {
- serverFixture.start();
- }
- catch ( Exception e )
- {
- throw new IllegalStateException( "Failed to start: " + e.getMessage(), e );
- }
-
- repo = new Repository( "test", baseUrl );
-
- wagon.connect( repo, auth, proxy );
-
- return true;
- }
-
- protected int getPort()
- {
- return serverFixture.getHttpPort();
- }
-
- protected int getPortPropertyValue()
- {
- return Integer.parseInt( System.getProperty( "test.port", "-1" ) );
- }
-
- protected String getBaseUrl()
- {
- if ( baseUrl == null )
- {
- StringBuilder sb = new StringBuilder();
- sb.append( isSsl() ? "https" : "http" );
- sb.append( "://" + ServerFixture.SERVER_HOST + ":" );
- sb.append( getPort() );
-
- baseUrl = sb.toString();
- }
-
- return baseUrl;
- }
-
- protected ServerFixture getServerFixture()
- {
- return serverFixture;
- }
-
- protected static PlexusContainer getContainer()
- {
- return container;
- }
-
- protected Wagon getWagon()
- {
- return wagon;
- }
-
- protected static WagonTestCaseConfigurator getConfigurator()
- {
- return configurator;
- }
-
- protected static Set<File> getTmpfiles()
- {
- return TMP_FILES;
- }
-
- protected Repository getRepo()
- {
- return repo;
- }
-
-}
+package org.apache.maven.wagon.tck.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.maven.wagon.ConnectionException;
+import org.apache.maven.wagon.Wagon;
+import org.apache.maven.wagon.authentication.AuthenticationException;
+import org.apache.maven.wagon.authentication.AuthenticationInfo;
+import org.apache.maven.wagon.proxy.ProxyInfo;
+import org.apache.maven.wagon.repository.Repository;
+import org.apache.maven.wagon.tck.http.fixture.ServerFixture;
+import org.codehaus.plexus.DefaultPlexusContainer;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
+import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
+import org.codehaus.plexus.util.FileUtils;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import static org.apache.maven.wagon.tck.http.util.TestUtil.getResource;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ */
+public abstract class HttpWagonTests
+{
+
+ private ServerFixture serverFixture;
+
+ private static PlexusContainer container;
+
+ private Wagon wagon;
+
+ private static WagonTestCaseConfigurator configurator;
+
+ private String baseUrl;
+
+ private static final Set<File> TMP_FILES = new HashSet<File>();
+
+ private Repository repo;
+
+ private final Set<Object> notificationTargets = new HashSet<Object>();
+
+ // CHECKSTYLE_OFF: ConstantName
+ protected static final Logger logger = LoggerFactory.getLogger( HttpWagonTests.class );
+ // CHECKSTYLE_ON: ConstantName
+
+ @Before
+ public void beforeEach()
+ throws Exception
+ {
+ serverFixture = new ServerFixture( isSsl() );
+ serverFixture.start();
+ wagon = (Wagon) container.lookup( Wagon.ROLE, configurator.getWagonHint() );
+ }
+
+ @BeforeClass
+ public static void beforeAll()
+ throws Exception
+ {
+ File keystore = getResource( ServerFixture.SERVER_SSL_KEYSTORE_RESOURCE_PATH );
+
+ System.setProperty( "javax.net.ssl.keyStore", keystore.getAbsolutePath() );
+ System.setProperty( "javax.net.ssl.keyStorePassword", ServerFixture.SERVER_SSL_KEYSTORE_PASSWORD );
+ System.setProperty( "javax.net.ssl.trustStore", keystore.getAbsolutePath() );
+ System.setProperty( "javax.net.ssl.trustStorePassword", ServerFixture.SERVER_SSL_KEYSTORE_PASSWORD );
+
+ container = new DefaultPlexusContainer();
+ //container.initialize();
+ //container.start();
+
+ configurator = (WagonTestCaseConfigurator) container.lookup( WagonTestCaseConfigurator.class.getName() );
+ }
+
+ @After
+ public void afterEach()
+ {
+ try
+ {
+ wagon.disconnect();
+ }
+ catch ( ConnectionException e )
+ {
+ e.printStackTrace();
+ }
+
+ for ( Object obj : notificationTargets )
+ {
+ synchronized ( obj )
+ {
+ obj.notify();
+ }
+ }
+
+ if ( serverFixture != null )
+ {
+ try
+ {
+ serverFixture.stop();
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+ try
+ {
+ container.release( wagon );
+ }
+ catch ( ComponentLifecycleException e )
+ {
+ e.printStackTrace();
+ }
+ }
+
+ @AfterClass
+ public static void afterAll()
+ {
+ for ( File f : TMP_FILES )
+ {
+ if ( f.exists() )
+ {
+ try
+ {
+ FileUtils.forceDelete( f );
+ }
+ catch ( IOException e )
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ if ( container != null )
+ {
+ try
+ {
+ container.release( configurator );
+ }
+ catch ( ComponentLifecycleException e )
+ {
+ e.printStackTrace();
+ }
+
+ container.dispose();
+ }
+ }
+
+ protected void addNotificationTarget( final Object target )
+ {
+ notificationTargets.add( target );
+ }
+
+ protected File newTempFile()
+ throws IOException
+ {
+ File f = File.createTempFile( "wagon-target.", ".file" );
+ f.deleteOnExit();
+
+ return f;
+ }
+
+ protected boolean isSsl()
+ {
+ return false;
+ }
+
+ protected ProxyInfo newProxyInfo()
+ {
+ ProxyInfo info = new ProxyInfo();
+ info.setType( isSsl() ? "https" : "http" );
+ info.setHost( ServerFixture.SERVER_HOST );
+ info.setPort( getPort() );
+
+ return info;
+ }
+
+ protected boolean isSupported()
+ {
+ StackTraceElement[] elements = new Throwable().getStackTrace();
+ String testCaseId = null;
+ String lastMethodName = null;
+ for ( StackTraceElement e : elements )
+ {
+ if ( !e.getClassName().startsWith( getClass().getPackage().getName() ) )
+ {
+ testCaseId = lastMethodName;
+ break;
+ }
+ else
+ {
+ lastMethodName = e.getMethodName();
+ }
+ }
+
+ if ( testCaseId == null || !configurator.isSupported( testCaseId ) )
+ {
+ logger.error( "Cannot run test: " + testCaseId
+ + ". Wagon under test does not support this test case." );
+ return false;
+ }
+
+ return true;
+ }
+
+ protected boolean initTest( final AuthenticationInfo auth, final ProxyInfo proxy )
+ throws ComponentConfigurationException, ConnectionException, AuthenticationException
+ {
+ return initTest( getBaseUrl(), auth, proxy );
+ }
+
+ protected boolean initTest( final String baseUrl, final AuthenticationInfo auth, final ProxyInfo proxy )
+ throws ComponentConfigurationException, ConnectionException, AuthenticationException
+ {
+ StackTraceElement[] elements = new Throwable().getStackTrace();
+ String testCaseId = null;
+ String lastMethodName = null;
+ for ( StackTraceElement e : elements )
+ {
+ if ( !e.getClassName().startsWith( getClass().getPackage().getName() ) )
+ {
+ testCaseId = lastMethodName;
+ break;
+ }
+ else
+ {
+ lastMethodName = e.getMethodName();
+ }
+ }
+
+ if ( testCaseId == null || !configurator.configureWagonForTest( wagon, testCaseId ) )
+ {
+ logger.error( "Cannot run test: " + testCaseId
+ + ". Wagon under test does not support this test case." );
+
+ return false;
+ }
+
+ try
+ {
+ serverFixture.start();
+ }
+ catch ( Exception e )
+ {
+ throw new IllegalStateException( "Failed to start: " + e.getMessage(), e );
+ }
+
+ repo = new Repository( "test", baseUrl );
+
+ wagon.connect( repo, auth, proxy );
+
+ return true;
+ }
+
+ protected int getPort()
+ {
+ return serverFixture.getHttpPort();
+ }
+
+ protected int getPortPropertyValue()
+ {
+ return Integer.parseInt( System.getProperty( "test.port", "-1" ) );
+ }
+
+ protected String getBaseUrl()
+ {
+ if ( baseUrl == null )
+ {
+ StringBuilder sb = new StringBuilder();
+ sb.append( isSsl() ? "https" : "http" );
+ sb.append( "://" + ServerFixture.SERVER_HOST + ":" );
+ sb.append( getPort() );
+
+ baseUrl = sb.toString();
+ }
+
+ return baseUrl;
+ }
+
+ protected ServerFixture getServerFixture()
+ {
+ return serverFixture;
+ }
+
+ protected static PlexusContainer getContainer()
+ {
+ return container;
+ }
+
+ protected Wagon getWagon()
+ {
+ return wagon;
+ }
+
+ protected static WagonTestCaseConfigurator getConfigurator()
+ {
+ return configurator;
+ }
+
+ protected static Set<File> getTmpfiles()
+ {
+ return TMP_FILES;
+ }
+
+ protected Repository getRepo()
+ {
+ return repo;
+ }
+
+}
diff --git a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/HttpsGetWagonTests.java b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/HttpsGetWagonTests.java
index 5fa14ee..48aa0ff 100644
--- a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/HttpsGetWagonTests.java
+++ b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/HttpsGetWagonTests.java
@@ -1,34 +1,34 @@
-package org.apache.maven.wagon.tck.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- *
- */
-public class HttpsGetWagonTests
- extends GetWagonTests
-{
- @Override
- protected boolean isSsl()
- {
- return true;
- }
-
-}
+package org.apache.maven.wagon.tck.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ *
+ */
+public class HttpsGetWagonTests
+ extends GetWagonTests
+{
+ @Override
+ protected boolean isSsl()
+ {
+ return true;
+ }
+
+}
diff --git a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/WagonTestCaseConfigurator.java b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/WagonTestCaseConfigurator.java
index 835e222..f81dc1f 100644
--- a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/WagonTestCaseConfigurator.java
+++ b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/WagonTestCaseConfigurator.java
@@ -1,137 +1,139 @@
-package org.apache.maven.wagon.tck.http;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.log4j.Logger;
-import org.apache.maven.wagon.Wagon;
-import org.codehaus.plexus.PlexusConstants;
-import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.classworlds.realm.ClassRealm;
-import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
-import org.codehaus.plexus.component.configurator.ComponentConfigurator;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
-import org.codehaus.plexus.configuration.PlexusConfiguration;
-import org.codehaus.plexus.context.Context;
-import org.codehaus.plexus.context.ContextException;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
-
-/**
- *
- */
-public class WagonTestCaseConfigurator
- implements Contextualizable
-{
- private static final String UNSUPPORTED_ELEMENT = "unsupported";
-
- private PlexusConfiguration useCaseConfigs;
-
- private ComponentConfigurator configurator;
-
- private ClassRealm realm;
-
- private String wagonHint;
-
- private static Logger logger = Logger.getLogger( WagonTestCaseConfigurator.class );
-
- public boolean isSupported( final String useCaseId )
- {
- if ( useCaseConfigs != null )
- {
- PlexusConfiguration config = useCaseConfigs.getChild( useCaseId, false );
-
- if ( config != null && config.getChild( UNSUPPORTED_ELEMENT, false ) != null )
- {
- logger.info( "Test case '" + useCaseId + "' is marked as unsupported by this wagon." );
- return false;
- }
- }
-
- return true;
- }
-
- public boolean configureWagonForTest( final Wagon wagon, final String useCaseId )
- throws ComponentConfigurationException
- {
- if ( useCaseConfigs != null )
- {
- PlexusConfiguration config = useCaseConfigs.getChild( useCaseId, false );
-
- if ( config != null )
- {
- if ( config.getChild( UNSUPPORTED_ELEMENT, false ) != null )
- {
- logger.error( "Test case '" + useCaseId + "' is marked as unsupported by this wagon." );
- return false;
- }
- else
- {
- logger.info( "Configuring wagon for test case: " + useCaseId + " with:\n\n" + config );
- configurator.configureComponent( wagon, useCaseConfigs.getChild( useCaseId, false ), realm );
- }
- }
- else
- {
- logger.info( "No wagon configuration found for test case: " + useCaseId );
- }
- }
- else
- {
- logger.info( "No test case configurations found." );
- }
-
- return true;
- }
-
- public void contextualize( final Context context )
- throws ContextException
- {
- PlexusContainer container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
- this.realm = container.getContainerRealm();
- try
- {
- configurator = (ComponentConfigurator) container.lookup( ComponentConfigurator.ROLE );
- }
- catch ( ComponentLookupException e )
- {
- throw new ContextException( "Failed to lookup component configurator: " + e.getMessage(), e );
- }
- }
-
- public PlexusConfiguration getUseCaseConfigs()
- {
- return useCaseConfigs;
- }
-
- public void setUseCaseConfigs( final PlexusConfiguration useCaseConfigs )
- {
- this.useCaseConfigs = useCaseConfigs;
- }
-
- public String getWagonHint()
- {
- return wagonHint;
- }
-
- public void setWagonHint( final String wagonHint )
- {
- this.wagonHint = wagonHint;
- }
-
-}
+package org.apache.maven.wagon.tck.http;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.wagon.Wagon;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.classworlds.realm.ClassRealm;
+import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
+import org.codehaus.plexus.component.configurator.ComponentConfigurator;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.codehaus.plexus.configuration.PlexusConfiguration;
+import org.codehaus.plexus.context.Context;
+import org.codehaus.plexus.context.ContextException;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ */
+public class WagonTestCaseConfigurator
+ implements Contextualizable
+{
+ private static final String UNSUPPORTED_ELEMENT = "unsupported";
+
+ private PlexusConfiguration useCaseConfigs;
+
+ private ComponentConfigurator configurator;
+
+ private ClassRealm realm;
+
+ private String wagonHint;
+
+ private static Logger logger = LoggerFactory.getLogger( WagonTestCaseConfigurator.class );
+
+ public boolean isSupported( final String useCaseId )
+ {
+ if ( useCaseConfigs != null )
+ {
+ PlexusConfiguration config = useCaseConfigs.getChild( useCaseId, false );
+
+ if ( config != null && config.getChild( UNSUPPORTED_ELEMENT, false ) != null )
+ {
+ logger.info( "Test case '" + useCaseId + "' is marked as unsupported by this wagon." );
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public boolean configureWagonForTest( final Wagon wagon, final String useCaseId )
+ throws ComponentConfigurationException
+ {
+ if ( useCaseConfigs != null )
+ {
+ PlexusConfiguration config = useCaseConfigs.getChild( useCaseId, false );
+
+ if ( config != null )
+ {
+ if ( config.getChild( UNSUPPORTED_ELEMENT, false ) != null )
+ {
+ logger.error( "Test case '" + useCaseId + "' is marked as unsupported by this wagon." );
+ return false;
+ }
+ else
+ {
+ logger.info( "Configuring wagon for test case: " + useCaseId + " with:\n\n" + config );
+ configurator.configureComponent( wagon, useCaseConfigs.getChild( useCaseId, false ), realm );
+ }
+ }
+ else
+ {
+ logger.info( "No wagon configuration found for test case: " + useCaseId );
+ }
+ }
+ else
+ {
+ logger.info( "No test case configurations found." );
+ }
+
+ return true;
+ }
+
+ public void contextualize( final Context context )
+ throws ContextException
+ {
+ PlexusContainer container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
+ this.realm = container.getContainerRealm();
+ try
+ {
+ configurator = (ComponentConfigurator) container.lookup( ComponentConfigurator.ROLE );
+ }
+ catch ( ComponentLookupException e )
+ {
+ throw new ContextException( "Failed to lookup component configurator: " + e.getMessage(), e );
+ }
+ }
+
+ public PlexusConfiguration getUseCaseConfigs()
+ {
+ return useCaseConfigs;
+ }
+
+ public void setUseCaseConfigs( final PlexusConfiguration useCaseConfigs )
+ {
+ this.useCaseConfigs = useCaseConfigs;
+ }
+
+ public String getWagonHint()
+ {
+ return wagonHint;
+ }
+
+ public void setWagonHint( final String wagonHint )
+ {
+ this.wagonHint = wagonHint;
+ }
+
+}
diff --git a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/AuthSnoopFilter.java b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/AuthSnoopFilter.java
index 233fe4d..083dd71 100644
--- a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/AuthSnoopFilter.java
+++ b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/AuthSnoopFilter.java
@@ -1,70 +1,72 @@
-package org.apache.maven.wagon.tck.http.fixture;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.commons.codec.binary.Base64;
-import org.apache.log4j.Logger;
-
-/**
- *
- */
-public class AuthSnoopFilter
- implements Filter
-{
- private static Logger logger = Logger.getLogger( AuthSnoopFilter.class );
-
- public void destroy()
- {
- }
-
- public void doFilter( final ServletRequest req, final ServletResponse response, final FilterChain chain )
- throws IOException, ServletException
- {
- HttpServletRequest request = (HttpServletRequest) req;
- String authHeader = request.getHeader( "Authorization" );
-
- if ( authHeader != null )
- {
- logger.info( "Authorization: " + authHeader );
- String data = authHeader.substring( "BASIC ".length() );
- String decoded = new String( Base64.decodeBase64( data ) );
- logger.info( decoded );
- String[] creds = decoded.split( ":" );
-
- logger.info( "User: " + creds[0] + "\nPassword: " + creds[1] );
- }
- }
-
- public void init( final FilterConfig filterConfig )
- throws ServletException
- {
- }
-
-}
+package org.apache.maven.wagon.tck.http.fixture;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.codec.binary.Base64;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ */
+public class AuthSnoopFilter
+ implements Filter
+{
+ private static Logger logger = LoggerFactory.getLogger( AuthSnoopFilter.class );
+
+ public void destroy()
+ {
+ }
+
+ public void doFilter( final ServletRequest req, final ServletResponse response, final FilterChain chain )
+ throws IOException, ServletException
+ {
+ HttpServletRequest request = (HttpServletRequest) req;
+ String authHeader = request.getHeader( "Authorization" );
+
+ if ( authHeader != null )
+ {
+ logger.info( "Authorization: " + authHeader );
+ String data = authHeader.substring( "BASIC ".length() );
+ String decoded = new String( Base64.decodeBase64( data ) );
+ logger.info( decoded );
+ String[] creds = decoded.split( ":" );
+
+ logger.info( "User: " + creds[0] + "\nPassword: " + creds[1] );
+ }
+ }
+
+ public void init( final FilterConfig filterConfig )
+ throws ServletException
+ {
+ }
+
+}
diff --git a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ErrorCodeServlet.java b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ErrorCodeServlet.java
index 7055c1d..583f272 100644
--- a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ErrorCodeServlet.java
+++ b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ErrorCodeServlet.java
@@ -1,55 +1,55 @@
-package org.apache.maven.wagon.tck.http.fixture;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- *
- */
-public class ErrorCodeServlet
- extends HttpServlet
-{
-
- private static final long serialVersionUID = 1L;
-
- private final int code;
-
- private final String message;
-
- public ErrorCodeServlet( final int code, final String message )
- {
- this.code = code;
- this.message = message;
- }
-
- @Override
- protected void service( final HttpServletRequest req, final HttpServletResponse resp )
- throws ServletException, IOException
- {
- resp.sendError( code, message );
- }
-
-}
+package org.apache.maven.wagon.tck.http.fixture;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ *
+ */
+public class ErrorCodeServlet
+ extends HttpServlet
+{
+
+ private static final long serialVersionUID = 1L;
+
+ private final int code;
+
+ private final String message;
+
+ public ErrorCodeServlet( final int code, final String message )
+ {
+ this.code = code;
+ this.message = message;
+ }
+
+ @Override
+ protected void service( final HttpServletRequest req, final HttpServletResponse resp )
+ throws ServletException, IOException
+ {
+ resp.sendError( code, message );
+ }
+
+}
diff --git a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/LatencyServlet.java b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/LatencyServlet.java
index 7d70075..f488aee 100644
--- a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/LatencyServlet.java
+++ b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/LatencyServlet.java
@@ -1,123 +1,128 @@
-package org.apache.maven.wagon.tck.http.fixture;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.log4j.Logger;
-import org.codehaus.plexus.util.IOUtil;
-
-/**
- *
- */
-public class LatencyServlet
- extends HttpServlet
-{
- private static Logger logger = Logger.getLogger( LatencyServlet.class );
-
- private static final long serialVersionUID = 1L;
-
- private static final int BUFFER_SIZE = 32;
-
- private final int latencyMs;
-
- public LatencyServlet( final int latencyMs )
- {
- this.latencyMs = latencyMs;
- }
-
- @Override
- protected void doGet( final HttpServletRequest req, final HttpServletResponse resp )
- throws ServletException, IOException
- {
- if ( latencyMs < 0 )
- {
- logger.info( "Starting infinite wait." );
- synchronized ( this )
- {
- try
- {
- wait();
- }
- catch ( InterruptedException e )
- {
- // ignore
- }
- }
-
- return;
- }
-
- String path = req.getPathInfo();
-
- // ignore the servlet's path here, since the servlet path is really only to provide a
- // binding for the servlet.
- String realPath = getServletContext().getRealPath( path );
- File f = new File( realPath );
-
- FileInputStream in = null;
- long total = 0;
- long start = System.currentTimeMillis();
- try
- {
- in = new FileInputStream( f );
- OutputStream out = resp.getOutputStream();
-
- logger.info( "Starting high-latency transfer. This should take about "
- + ( ( f.length() / BUFFER_SIZE * latencyMs / 1000 ) + ( latencyMs / 1000 ) ) + " seconds." );
-
- int read;
- byte[] buf = new byte[BUFFER_SIZE];
- while ( ( read = in.read( buf ) ) > -1 )
- {
- try
- {
- Thread.sleep( latencyMs );
- }
- catch ( InterruptedException e )
- {
- e.printStackTrace();
- }
-
- logger.info( "Writing bytes " + total + "-" + ( total + read - 1 ) + " of " + f.length()
- + ". Elapsed time so far: " + ( ( System.currentTimeMillis() - start ) / 1000 ) + " seconds" );
-
- out.write( buf, 0, read );
-
- total += read;
- }
- }
- finally
- {
- IOUtil.close( in );
- }
-
- logger.info( "High-latency transfer done in " + ( System.currentTimeMillis() - start ) + "ms" );
- }
-
-}
+package org.apache.maven.wagon.tck.http.fixture;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.codehaus.plexus.util.IOUtil;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ */
+public class LatencyServlet
+ extends HttpServlet
+{
+ private static Logger logger = LoggerFactory.getLogger( LatencyServlet.class );
+
+ private static final long serialVersionUID = 1L;
+
+ private static final int BUFFER_SIZE = 32;
+
+ private final int latencyMs;
+
+ public LatencyServlet( final int latencyMs )
+ {
+ this.latencyMs = latencyMs;
+ }
+
+ @Override
+ protected void doGet( final HttpServletRequest req, final HttpServletResponse resp )
+ throws ServletException, IOException
+ {
+ if ( latencyMs < 0 )
+ {
+ logger.info( "Starting infinite wait." );
+ synchronized ( this )
+ {
+ try
+ {
+ wait();
+ }
+ catch ( InterruptedException e )
+ {
+ // ignore
+ }
+ }
+
+ return;
+ }
+
+ String path = req.getPathInfo();
+
+ // ignore the servlet's path here, since the servlet path is really only to provide a
+ // binding for the servlet.
+ String realPath = getServletContext().getRealPath( path );
+ File f = new File( realPath );
+
+ FileInputStream in = null;
+ long total = 0;
+ long start = System.currentTimeMillis();
+ try
+ {
+ in = new FileInputStream( f );
+ OutputStream out = resp.getOutputStream();
+
+ logger.info( "Starting high-latency transfer. This should take about "
+ + ( ( f.length() / BUFFER_SIZE * latencyMs / 1000 ) + ( latencyMs / 1000 ) ) + " seconds." );
+
+ int read;
+ byte[] buf = new byte[BUFFER_SIZE];
+ while ( ( read = in.read( buf ) ) > -1 )
+ {
+ try
+ {
+ Thread.sleep( latencyMs );
+ }
+ catch ( InterruptedException e )
+ {
+ e.printStackTrace();
+ }
+
+ logger.info( "Writing bytes " + total + "-" + ( total + read - 1 ) + " of " + f.length()
+ + ". Elapsed time so far: " + ( ( System.currentTimeMillis() - start ) / 1000 ) + " seconds" );
+
+ out.write( buf, 0, read );
+
+ total += read;
+ }
+
+ in.close();
+ in = null;
+ }
+ finally
+ {
+ IOUtil.close( in );
+ }
+
+ logger.info( "High-latency transfer done in " + ( System.currentTimeMillis() - start ) + "ms" );
+ }
+
+}
diff --git a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ProxyAuthenticationFilter.java b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ProxyAuthenticationFilter.java
index 2da6aa4..47fcb05 100644
--- a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ProxyAuthenticationFilter.java
+++ b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ProxyAuthenticationFilter.java
@@ -1,89 +1,89 @@
-package org.apache.maven.wagon.tck.http.fixture;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.codec.binary.Base64;
-
-import java.io.IOException;
-
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- *
- */
-public class ProxyAuthenticationFilter
- implements Filter
-{
-
- private final String username;
-
- private final String password;
-
- public ProxyAuthenticationFilter( final String username, final String password )
- {
- this.username = username;
- this.password = password;
- }
-
- public void destroy()
- {
- }
-
- public void doFilter( final ServletRequest req, final ServletResponse resp, final FilterChain chain )
- throws IOException, ServletException
- {
- HttpServletRequest request = (HttpServletRequest) req;
- HttpServletResponse response = (HttpServletResponse) resp;
-
- String header = request.getHeader( "Proxy-Authorization" );
- if ( header == null )
- {
- response.setStatus( HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED );
- response.addHeader( "Proxy-Authenticate", "Basic realm=\"Squid proxy-caching web server\"" );
- return;
- }
- else
- {
- String data = header.substring( "BASIC ".length() );
- data = new String( Base64.decodeBase64( data ) );
- String[] creds = data.split( ":" );
-
- if ( !creds[0].equals( username ) || !creds[1].equals( password ) )
- {
- response.sendError( HttpServletResponse.SC_UNAUTHORIZED );
- }
- }
-
- chain.doFilter( req, resp );
- }
-
- public void init( final FilterConfig filterConfig )
- throws ServletException
- {
- }
-
-}
+package org.apache.maven.wagon.tck.http.fixture;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.commons.codec.binary.Base64;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ *
+ */
+public class ProxyAuthenticationFilter
+ implements Filter
+{
+
+ private final String username;
+
+ private final String password;
+
+ public ProxyAuthenticationFilter( final String username, final String password )
+ {
+ this.username = username;
+ this.password = password;
+ }
+
+ public void destroy()
+ {
+ }
+
+ public void doFilter( final ServletRequest req, final ServletResponse resp, final FilterChain chain )
+ throws IOException, ServletException
+ {
+ HttpServletRequest request = (HttpServletRequest) req;
+ HttpServletResponse response = (HttpServletResponse) resp;
+
+ String header = request.getHeader( "Proxy-Authorization" );
+ if ( header == null )
+ {
+ response.setStatus( HttpServletResponse.SC_PROXY_AUTHENTICATION_REQUIRED );
+ response.addHeader( "Proxy-Authenticate", "Basic realm=\"Squid proxy-caching web server\"" );
+ return;
+ }
+ else
+ {
+ String data = header.substring( "BASIC ".length() );
+ data = new String( Base64.decodeBase64( data ) );
+ String[] creds = data.split( ":" );
+
+ if ( !creds[0].equals( username ) || !creds[1].equals( password ) )
+ {
+ response.sendError( HttpServletResponse.SC_UNAUTHORIZED );
+ }
+ }
+
+ chain.doFilter( req, resp );
+ }
+
+ public void init( final FilterConfig filterConfig )
+ throws ServletException
+ {
+ }
+
+}
diff --git a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ProxyConnectionVerifierFilter.java b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ProxyConnectionVerifierFilter.java
index 0c2bc39..66ddc1f 100644
--- a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ProxyConnectionVerifierFilter.java
+++ b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ProxyConnectionVerifierFilter.java
@@ -1,81 +1,82 @@
-package org.apache.maven.wagon.tck.http.fixture;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-import java.util.Collections;
-import java.util.Enumeration;
-
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.log4j.Logger;
-
-/**
- *
- */
-public class ProxyConnectionVerifierFilter
- implements Filter
-{
- private static Logger logger = Logger.getLogger( ProxyConnectionVerifierFilter.class );
-
- public void destroy()
- {
- }
-
- @SuppressWarnings( "unchecked" )
- public void doFilter( final ServletRequest req, final ServletResponse resp, final FilterChain chain )
- throws IOException, ServletException
- {
- HttpServletRequest request = (HttpServletRequest) req;
- // HttpServletResponse response = (HttpServletResponse) resp;
-
- Enumeration<String> kEn = request.getHeaderNames();
- for ( String key : Collections.list( kEn ) )
- {
- if ( key == null )
- {
- continue;
- }
-
- Enumeration<String> vEn = request.getHeaders( key );
- if ( vEn != null )
- {
- for ( String val : Collections.list( vEn ) )
- {
- logger.info( key + ": " + val );
- }
- }
- }
-
- chain.doFilter( req, resp );
- }
-
- public void init( final FilterConfig filterConfig )
- throws ServletException
- {
- }
-
-}
+package org.apache.maven.wagon.tck.http.fixture;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.Enumeration;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ */
+public class ProxyConnectionVerifierFilter
+ implements Filter
+{
+ private static Logger logger = LoggerFactory.getLogger( ProxyConnectionVerifierFilter.class );
+
+ public void destroy()
+ {
+ }
+
+ @SuppressWarnings( "unchecked" )
+ public void doFilter( final ServletRequest req, final ServletResponse resp, final FilterChain chain )
+ throws IOException, ServletException
+ {
+ HttpServletRequest request = (HttpServletRequest) req;
+ // HttpServletResponse response = (HttpServletResponse) resp;
+
+ Enumeration<String> kEn = request.getHeaderNames();
+ for ( String key : Collections.list( kEn ) )
+ {
+ if ( key == null )
+ {
+ continue;
+ }
+
+ Enumeration<String> vEn = request.getHeaders( key );
+ if ( vEn != null )
+ {
+ for ( String val : Collections.list( vEn ) )
+ {
+ logger.info( key + ": " + val );
+ }
+ }
+ }
+
+ chain.doFilter( req, resp );
+ }
+
+ public void init( final FilterConfig filterConfig )
+ throws ServletException
+ {
+ }
+
+}
diff --git a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/RedirectionServlet.java b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/RedirectionServlet.java
index 0ff5752..b4fd750 100644
--- a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/RedirectionServlet.java
+++ b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/RedirectionServlet.java
@@ -1,96 +1,96 @@
-package org.apache.maven.wagon.tck.http.fixture;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-/**
- *
- */
-public class RedirectionServlet
- extends HttpServlet
-{
-
- private static final long serialVersionUID = 1L;
-
- private final String targetPath;
-
- private final int code;
-
- private final int maxRedirects;
-
- private int redirectCount = 0;
-
- private final String myPath;
-
- public RedirectionServlet( final int code, final String targetPath )
- {
- this.code = code;
- this.targetPath = targetPath;
- this.maxRedirects = 1;
- this.myPath = null;
- }
-
- public RedirectionServlet( final int code, final String myPath, final String targetPath, final int maxRedirects )
- {
- this.code = code;
- this.myPath = myPath;
- this.targetPath = targetPath;
- this.maxRedirects = maxRedirects;
- }
-
- public int getRedirectCount()
- {
- return redirectCount;
- }
-
- @Override
- protected void service( final HttpServletRequest req, final HttpServletResponse resp )
- throws ServletException, IOException
- {
- redirectCount++;
-
- if ( myPath == null )
- {
- resp.setStatus( code );
- resp.setHeader( "Location", targetPath );
- }
- else if ( maxRedirects < 0 )
- {
- resp.setStatus( code );
- resp.setHeader( "Location", myPath );
- }
- else if ( redirectCount <= maxRedirects )
- {
- resp.setStatus( code );
- resp.setHeader( "Location", myPath + "/" + redirectCount );
- }
- else
- {
- resp.setStatus( code );
- resp.setHeader( "Location", targetPath );
- }
- }
-
-}
+package org.apache.maven.wagon.tck.http.fixture;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+/**
+ *
+ */
+public class RedirectionServlet
+ extends HttpServlet
+{
+
+ private static final long serialVersionUID = 1L;
+
+ private final String targetPath;
+
+ private final int code;
+
+ private final int maxRedirects;
+
+ private int redirectCount = 0;
+
+ private final String myPath;
+
+ public RedirectionServlet( final int code, final String targetPath )
+ {
+ this.code = code;
+ this.targetPath = targetPath;
+ this.maxRedirects = 1;
+ this.myPath = null;
+ }
+
+ public RedirectionServlet( final int code, final String myPath, final String targetPath, final int maxRedirects )
+ {
+ this.code = code;
+ this.myPath = myPath;
+ this.targetPath = targetPath;
+ this.maxRedirects = maxRedirects;
+ }
+
+ public int getRedirectCount()
+ {
+ return redirectCount;
+ }
+
+ @Override
+ protected void service( final HttpServletRequest req, final HttpServletResponse resp )
+ throws ServletException, IOException
+ {
+ redirectCount++;
+
+ if ( myPath == null )
+ {
+ resp.setStatus( code );
+ resp.setHeader( "Location", targetPath );
+ }
+ else if ( maxRedirects < 0 )
+ {
+ resp.setStatus( code );
+ resp.setHeader( "Location", myPath );
+ }
+ else if ( redirectCount <= maxRedirects )
+ {
+ resp.setStatus( code );
+ resp.setHeader( "Location", myPath + "/" + redirectCount );
+ }
+ else
+ {
+ resp.setStatus( code );
+ resp.setHeader( "Location", targetPath );
+ }
+ }
+
+}
diff --git a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ServerFixture.java b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ServerFixture.java
index f73e7e7..96fb51b 100644
--- a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ServerFixture.java
+++ b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ServerFixture.java
@@ -1,212 +1,214 @@
-package org.apache.maven.wagon.tck.http.fixture;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.log4j.Logger;
-import org.mortbay.jetty.Connector;
-import org.mortbay.jetty.Handler;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.handler.DefaultHandler;
-import org.mortbay.jetty.handler.HandlerCollection;
-import org.mortbay.jetty.nio.SelectChannelConnector;
-import org.mortbay.jetty.security.Constraint;
-import org.mortbay.jetty.security.ConstraintMapping;
-import org.mortbay.jetty.security.HashUserRealm;
-import org.mortbay.jetty.security.SecurityHandler;
-import org.mortbay.jetty.security.SslSocketConnector;
-import org.mortbay.jetty.servlet.AbstractSessionManager;
-import org.mortbay.jetty.servlet.FilterHolder;
-import org.mortbay.jetty.servlet.FilterMapping;
-import org.mortbay.jetty.servlet.ServletHolder;
-import org.mortbay.jetty.servlet.SessionHandler;
-import org.mortbay.jetty.webapp.WebAppContext;
-
-import javax.servlet.Filter;
-import javax.servlet.Servlet;
-import java.io.File;
-import java.io.IOException;
-import java.net.URISyntaxException;
-
-import static org.apache.maven.wagon.tck.http.util.TestUtil.getResource;
-
-/**
- *
- */
-public class ServerFixture
-{
- private static Logger logger = Logger.getLogger( ServerFixture.class );
-
- public static final String SERVER_ROOT_RESOURCE_PATH = "default-server-root";
-
- // it seems that some JDKs have a problem if you use different key stores
- // so we gonna reuse the keystore which is is used in the wagon implementations already
- public static final String SERVER_SSL_KEYSTORE_RESOURCE_PATH = "ssl/keystore";
-
- public static final String SERVER_SSL_KEYSTORE_PASSWORD = "wagonhttp";
-
- public static final String SERVER_HOST = "localhost";
-
- private final Server server;
-
- private final WebAppContext webappContext;
-
- private final HashUserRealm securityRealm;
-
- private final SecurityHandler securityHandler;
-
- private int filterCount = 0;
-
- private int httpPort;
-
- public ServerFixture( final boolean ssl )
- throws URISyntaxException, IOException
- {
- server = new Server();
- if ( ssl )
- {
- SslSocketConnector connector = new SslSocketConnector();
- String keystore = getResource( SERVER_SSL_KEYSTORE_RESOURCE_PATH ).getAbsolutePath();
-
- Logger.getLogger( ServerFixture.class ).info( "TCK Keystore path: " + keystore );
- System.setProperty( "javax.net.ssl.keyStore", keystore );
- System.setProperty( "javax.net.ssl.trustStore", keystore );
-
- // connector.setHost( SERVER_HOST );
- //connector.setPort( port );
- connector.setKeystore( keystore );
- connector.setPassword( SERVER_SSL_KEYSTORE_PASSWORD );
- connector.setKeyPassword( SERVER_SSL_KEYSTORE_PASSWORD );
-
- server.addConnector( connector );
- }
- else
- {
- Connector connector = new SelectChannelConnector();
- connector.setHost( "localhost" );
- //connector.setPort( port );
- server.addConnector( connector );
- }
-
- Constraint constraint = new Constraint();
- constraint.setName( Constraint.__BASIC_AUTH );
-
- constraint.setRoles( new String[]{ "allowed" } );
- constraint.setAuthenticate( true );
-
- ConstraintMapping cm = new ConstraintMapping();
- cm.setConstraint( constraint );
- cm.setPathSpec( "/protected/*" );
-
- securityHandler = new SecurityHandler();
-
- securityRealm = new HashUserRealm( "Test Server" );
-
- securityHandler.setUserRealm( securityRealm );
- securityHandler.setConstraintMappings( new ConstraintMapping[]{ cm } );
-
- webappContext = new WebAppContext();
- webappContext.setContextPath( "/" );
-
- File base = getResource( SERVER_ROOT_RESOURCE_PATH );
- logger.info( "docroot: " + base );
- webappContext.setWar( base.getAbsolutePath() );
- webappContext.addHandler( securityHandler );
-
- SessionHandler sessionHandler = webappContext.getSessionHandler();
- ( (AbstractSessionManager) sessionHandler.getSessionManager() ).setUsingCookies( false );
-
- HandlerCollection handlers = new HandlerCollection();
- handlers.setHandlers( new Handler[]{ webappContext, new DefaultHandler() } );
-
- server.setHandler( handlers );
- }
-
- public void addFilter( final String pathSpec, final Filter filter )
- {
- String name = "filter" + filterCount++;
-
- FilterMapping fm = new FilterMapping();
- fm.setPathSpec( pathSpec );
- fm.setFilterName( name );
-
- FilterHolder fh = new FilterHolder( filter );
- fh.setName( name );
-
- webappContext.getServletHandler().addFilter( fh, fm );
- }
-
- public void addServlet( final String pathSpec, final Servlet servlet )
- {
- webappContext.getServletHandler().addServletWithMapping( new ServletHolder( servlet ), pathSpec );
- }
-
- public void addUser( final String user, final String password )
- {
- securityRealm.put( user, password );
- securityRealm.addUserToRole( user, "allowed" );
- }
-
- public Server getServer()
- {
- return server;
- }
-
- public WebAppContext getWebappContext()
- {
- return webappContext;
- }
-
- public void stop()
- throws Exception
- {
- if ( server != null )
- {
- server.stop();
- }
- }
-
- public void start()
- throws Exception
- {
- if ( server.isStarted() || server.isRunning() )
- {
- return;
- }
- server.start();
-
- int total = 0;
- while ( total < 3 * 1000 && !server.isStarted() )
- {
- server.wait( 10 );
- total += 10;
- }
-
- if ( !server.isStarted() )
- {
- throw new IllegalStateException( "Server didn't start in: " + total + "ms." );
- }
- this.httpPort = server.getConnectors()[0].getLocalPort();
- }
-
- public int getHttpPort()
- {
- return httpPort;
- }
-}
+package org.apache.maven.wagon.tck.http.fixture;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.Handler;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.handler.DefaultHandler;
+import org.eclipse.jetty.server.handler.HandlerCollection;
+import org.eclipse.jetty.server.nio.SelectChannelConnector;
+import org.eclipse.jetty.server.session.AbstractSessionManager;
+import org.eclipse.jetty.server.session.SessionHandler;
+import org.eclipse.jetty.security.ConstraintMapping;
+import org.eclipse.jetty.security.ConstraintSecurityHandler;
+import org.eclipse.jetty.security.HashLoginService;
+import org.eclipse.jetty.server.ssl.SslSocketConnector;
+import org.eclipse.jetty.servlet.FilterHolder;
+import org.eclipse.jetty.servlet.FilterMapping;
+import org.eclipse.jetty.servlet.ServletHolder;
+import org.eclipse.jetty.util.security.Constraint;
+import org.eclipse.jetty.util.security.Password;
+import org.eclipse.jetty.webapp.WebAppContext;
+
+import javax.servlet.Filter;
+import javax.servlet.Servlet;
+import java.io.File;
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+import static org.apache.maven.wagon.tck.http.util.TestUtil.getResource;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ */
+public class ServerFixture
+{
+ private static Logger logger = LoggerFactory.getLogger( ServerFixture.class );
+
+ public static final String SERVER_ROOT_RESOURCE_PATH = "default-server-root";
+
+ // it seems that some JDKs have a problem if you use different key stores
+ // so we gonna reuse the keystore which is is used in the wagon implementations already
+ public static final String SERVER_SSL_KEYSTORE_RESOURCE_PATH = "ssl/keystore";
+
+ public static final String SERVER_SSL_KEYSTORE_PASSWORD = "wagonhttp";
+
+ public static final String SERVER_HOST = "localhost";
+
+ private final Server server;
+
+ private final WebAppContext webappContext;
+
+ private final HashLoginService loginService;
+
+ private final ConstraintSecurityHandler securityHandler;
+
+ private int filterCount = 0;
+
+ private int httpPort;
+
+ public ServerFixture( final boolean ssl )
+ throws URISyntaxException, IOException
+ {
+ server = new Server();
+ if ( ssl )
+ {
+ SslSocketConnector connector = new SslSocketConnector();
+ String keystore = getResource( SERVER_SSL_KEYSTORE_RESOURCE_PATH ).getAbsolutePath();
+
+ LoggerFactory.getLogger( ServerFixture.class ).info( "TCK Keystore path: " + keystore );
+ System.setProperty( "javax.net.ssl.keyStore", keystore );
+ System.setProperty( "javax.net.ssl.trustStore", keystore );
+
+ // connector.setHost( SERVER_HOST );
+ //connector.setPort( port );
+ connector.setKeystore( keystore );
+ connector.setPassword( SERVER_SSL_KEYSTORE_PASSWORD );
+ connector.setKeyPassword( SERVER_SSL_KEYSTORE_PASSWORD );
+
+ server.addConnector( connector );
+ }
+ else
+ {
+ Connector connector = new SelectChannelConnector();
+ connector.setHost( "localhost" );
+ //connector.setPort( port );
+ server.addConnector( connector );
+ }
+
+ Constraint constraint = new Constraint();
+ constraint.setName( Constraint.__BASIC_AUTH );
+
+ constraint.setRoles( new String[]{ "allowed" } );
+ constraint.setAuthenticate( true );
+
+ ConstraintMapping cm = new ConstraintMapping();
+ cm.setConstraint( constraint );
+ cm.setPathSpec( "/protected/*" );
+
+ securityHandler = new ConstraintSecurityHandler();
+
+ loginService = new HashLoginService( "Test Server" );
+
+ securityHandler.setLoginService( loginService );
+ securityHandler.setConstraintMappings( new ConstraintMapping[]{ cm } );
+
+ webappContext = new WebAppContext();
+ webappContext.setContextPath( "/" );
+
+ File base = getResource( SERVER_ROOT_RESOURCE_PATH );
+ logger.info( "docroot: " + base );
+ webappContext.setWar( base.getAbsolutePath() );
+ webappContext.setHandler( securityHandler );
+
+ SessionHandler sessionHandler = webappContext.getSessionHandler();
+ ( (AbstractSessionManager) sessionHandler.getSessionManager() ).setUsingCookies( false );
+
+ HandlerCollection handlers = new HandlerCollection();
+ handlers.setHandlers( new Handler[]{ webappContext, new DefaultHandler() } );
+
+ server.setHandler( handlers );
+ }
+
+ public void addFilter( final String pathSpec, final Filter filter )
+ {
+ String name = "filter" + filterCount++;
+
+ FilterMapping fm = new FilterMapping();
+ fm.setPathSpec( pathSpec );
+ fm.setFilterName( name );
+
+ FilterHolder fh = new FilterHolder( filter );
+ fh.setName( name );
+
+ webappContext.getServletHandler().addFilter( fh, fm );
+ }
+
+ public void addServlet( final String pathSpec, final Servlet servlet )
+ {
+ webappContext.getServletHandler().addServletWithMapping( new ServletHolder( servlet ), pathSpec );
+ }
+
+ public void addUser( final String user, final String password )
+ {
+ loginService.putUser( user, new Password( password ), new String[] { "allowed" } );
+ }
+
+ public Server getServer()
+ {
+ return server;
+ }
+
+ public WebAppContext getWebappContext()
+ {
+ return webappContext;
+ }
+
+ public void stop()
+ throws Exception
+ {
+ if ( server != null )
+ {
+ server.stop();
+ }
+ }
+
+ public void start()
+ throws Exception
+ {
+ if ( server.isStarted() || server.isRunning() )
+ {
+ return;
+ }
+ server.start();
+
+ int total = 0;
+ while ( total < 3 * 1000 && !server.isStarted() )
+ {
+ server.wait( 10 );
+ total += 10;
+ }
+
+ if ( !server.isStarted() )
+ {
+ throw new IllegalStateException( "Server didn't start in: " + total + "ms." );
+ }
+ this.httpPort = server.getConnectors()[0].getLocalPort();
+ }
+
+ public int getHttpPort()
+ {
+ return httpPort;
+ }
+}
diff --git a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ServletExceptionServlet.java b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ServletExceptionServlet.java
index 10820ef..2dd7634 100644
--- a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ServletExceptionServlet.java
+++ b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ServletExceptionServlet.java
@@ -1,52 +1,52 @@
-package org.apache.maven.wagon.tck.http.fixture;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-/**
- *
- */
-public class ServletExceptionServlet
- extends HttpServlet
-{
-
- private static final long serialVersionUID = 1L;
-
- private final String message;
-
- public ServletExceptionServlet( final String message )
- {
- this.message = message;
- }
-
- @Override
- protected void service( final HttpServletRequest request, final HttpServletResponse response )
- throws ServletException, IOException
- {
- throw new ServletException( message );
- }
-
-}
+package org.apache.maven.wagon.tck.http.fixture;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ *
+ */
+public class ServletExceptionServlet
+ extends HttpServlet
+{
+
+ private static final long serialVersionUID = 1L;
+
+ private final String message;
+
+ public ServletExceptionServlet( final String message )
+ {
+ this.message = message;
+ }
+
+ @Override
+ protected void service( final HttpServletRequest request, final HttpServletResponse response )
+ throws ServletException, IOException
+ {
+ throw new ServletException( message );
+ }
+
+}
diff --git a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/util/TestUtil.java b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/util/TestUtil.java
index ebcf15e..df3707a 100644
--- a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/util/TestUtil.java
+++ b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/util/TestUtil.java
@@ -1,140 +1,150 @@
-package org.apache.maven.wagon.tck.http.util;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
-import org.apache.log4j.Logger;
-import org.codehaus.plexus.util.IOUtil;
-
-/**
- *
- */
-public final class TestUtil
-{
- private static final Logger LOGGER = Logger.getLogger( TestUtil.class );
-
- private static final Map<String, File> BASES = new HashMap<String, File>();
-
- private TestUtil()
- {
- }
-
- public static File getResource( final String path )
- throws URISyntaxException, IOException
- {
- URL resource = Thread.currentThread().getContextClassLoader().getResource( path );
- if ( resource == null )
- {
- throw new IllegalStateException( "Cannot find classpath resource: " + path );
- }
-
- if ( resource.getProtocol().startsWith( "jar" ) )
- {
- // File f = new File( path );
- // f = File.createTempFile( f.getName() + ".", ".tmp" );
-
- String url = resource.toExternalForm();
- int startIdx = url.lastIndexOf( ':' ) + 1;
- int endIdx = url.indexOf( "!" );
- url = url.substring( startIdx, endIdx );
-
- File base = BASES.get( url );
- if ( base == null )
- {
- File urlFile = new File( url );
-
- base = new File( "target/tck-resources/" + urlFile.getName() );
- base.getParentFile().mkdirs();
-
- LOGGER.info( "unpacking test resources in jar: " + url );
- JarFile jf = null;
- try
- {
- jf = new JarFile( urlFile );
-
- InputStream in = null;
- OutputStream out = null;
-
- for ( Enumeration<JarEntry> en = jf.entries(); en.hasMoreElements(); )
- {
- JarEntry je = en.nextElement();
- File target = new File( base, je.getName() ).getAbsoluteFile();
- if ( je.isDirectory() )
- {
- target.mkdirs();
- }
- else
- {
- target.getParentFile().mkdirs();
-
- try
- {
- in = jf.getInputStream( je );
- out = new FileOutputStream( target );
-
- IOUtil.copy( in, out );
- }
- finally
- {
- IOUtil.close( in );
- IOUtil.close( out );
- }
- }
- }
-
- BASES.put( url, base );
- }
- finally
- {
- if ( jf != null )
- {
- try
- {
- jf.close();
- }
- catch ( Exception e )
- {
- // ignore
- }
- }
- }
- }
-
- return new File( base, path );
- }
- else
- {
- return new File( resource.toURI().normalize() );
- }
- }
-
-}
+package org.apache.maven.wagon.tck.http.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+import org.codehaus.plexus.util.IOUtil;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ */
+public final class TestUtil
+{
+ // CHECKSTYLE_OFF: ConstantName
+ private static final Logger logger = LoggerFactory.getLogger( TestUtil.class );
+ // CHECKSTYLE_ON: ConstantName
+
+ private static final Map<String, File> BASES = new HashMap<String, File>();
+
+ private TestUtil()
+ {
+ }
+
+ public static File getResource( final String path )
+ throws URISyntaxException, IOException
+ {
+ URL resource = Thread.currentThread().getContextClassLoader().getResource( path );
+ if ( resource == null )
+ {
+ throw new IllegalStateException( "Cannot find classpath resource: " + path );
+ }
+
+ if ( resource.getProtocol().startsWith( "jar" ) )
+ {
+ // File f = new File( path );
+ // f = File.createTempFile( f.getName() + ".", ".tmp" );
+
+ String url = resource.toExternalForm();
+ int startIdx = url.lastIndexOf( ':' ) + 1;
+ int endIdx = url.indexOf( "!" );
+ url = url.substring( startIdx, endIdx );
+
+ File base = BASES.get( url );
+ if ( base == null )
+ {
+ File urlFile = new File( url );
+
+ base = new File( "target/tck-resources/" + urlFile.getName() );
+ base.getParentFile().mkdirs();
+
+ logger.info( "unpacking test resources in jar: " + url );
+ JarFile jf = null;
+ try
+ {
+ jf = new JarFile( urlFile );
+
+ InputStream in = null;
+ OutputStream out = null;
+
+ for ( Enumeration<JarEntry> en = jf.entries(); en.hasMoreElements(); )
+ {
+ JarEntry je = en.nextElement();
+ File target = new File( base, je.getName() ).getAbsoluteFile();
+ if ( je.isDirectory() )
+ {
+ target.mkdirs();
+ }
+ else
+ {
+ target.getParentFile().mkdirs();
+
+ try
+ {
+ in = jf.getInputStream( je );
+ out = new FileOutputStream( target );
+
+ IOUtil.copy( in, out );
+
+ out.close();
+ out = null;
+
+ in.close();
+ in = null;
+ }
+ finally
+ {
+ IOUtil.close( in );
+ IOUtil.close( out );
+ }
+ }
+ }
+
+ BASES.put( url, base );
+ }
+ finally
+ {
+ if ( jf != null )
+ {
+ try
+ {
+ jf.close();
+ }
+ catch ( Exception e )
+ {
+ // ignore
+ }
+ }
+ }
+ }
+
+ return new File( base, path );
+ }
+ else
+ {
+ return new File( resource.toURI().normalize() );
+ }
+ }
+
+}
diff --git a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/util/ValueHolder.java b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/util/ValueHolder.java
index cc303bc..5a818f9 100644
--- a/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/util/ValueHolder.java
+++ b/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/util/ValueHolder.java
@@ -1,48 +1,48 @@
-package org.apache.maven.wagon.tck.http.util;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-/**
- *
- * @param <T>
- */
-public class ValueHolder<T>
-{
- private T value;
-
- public ValueHolder()
- {
- }
-
- public ValueHolder( final T initial )
- {
- this.value = initial;
- }
-
- public void setValue( final T value )
- {
- this.value = value;
- }
-
- public T getValue()
- {
- return value;
- }
-}
+package org.apache.maven.wagon.tck.http.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ *
+ * @param <T>
+ */
+public class ValueHolder<T>
+{
+ private T value;
+
+ public ValueHolder()
+ {
+ }
+
+ public ValueHolder( final T initial )
+ {
+ this.value = initial;
+ }
+
+ public void setValue( final T value )
+ {
+ this.value = value;
+ }
+
+ public T getValue()
+ {
+ return value;
+ }
+}
diff --git a/wagon-tcks/wagon-tck-http/src/main/resources/default-server-root/large.txt b/wagon-tcks/wagon-tck-http/src/main/resources/default-server-root/large.txt
index b33aabc..fe03c89 100644
--- a/wagon-tcks/wagon-tck-http/src/main/resources/default-server-root/large.txt
+++ b/wagon-tcks/wagon-tck-http/src/main/resources/default-server-root/large.txt
@@ -1,2 +1,2 @@
-a;sldkfja;ldfkja;ldfkjas;ldfkjas;dflkjasdg;lkasjdgpaeiortjuawpoefnasd;lgknasropt;iahsdgpoasdgijn;alsdgknzsd;lgkhszdoiahjsetpoaijnsdgf;laskdnga;lsdkghjas;lktjae;toiaehwgrpoaigh;alskdgnas;ldghkast;ahiletpoaihtpoasghaposghia
-a;sldkfja;ldfkja;ldfkjas;ldfkjas;dflkjasdg;lkasjdgpaeiortjuawpoefnasd;lgknasropt;iahsdgpoasdgijn;alsdgknzsd;lgkhszdoiahjsetpoaijnsdgf;laskdnga;lsdkghjas;lktjae;toiaehwgrpoaigh;alskdgnas;ldghkast;ahiletpoaihtpoasghaposghia
+a;sldkfja;ldfkja;ldfkjas;ldfkjas;dflkjasdg;lkasjdgpaeiortjuawpoefnasd;lgknasropt;iahsdgpoasdgijn;alsdgknzsd;lgkhszdoiahjsetpoaijnsdgf;laskdnga;lsdkghjas;lktjae;toiaehwgrpoaigh;alskdgnas;ldghkast;ahiletpoaihtpoasghaposghia
+a;sldkfja;ldfkja;ldfkjas;ldfkjas;dflkjasdg;lkasjdgpaeiortjuawpoefnasd;lgknasropt;iahsdgpoasdgijn;alsdgknzsd;lgkhszdoiahjsetpoaijnsdgf;laskdnga;lsdkghjas;lktjae;toiaehwgrpoaigh;alskdgnas;ldghkast;ahiletpoaihtpoasghaposghia
diff --git a/wagon-tcks/wagon-tck-http/src/site/site.xml b/wagon-tcks/wagon-tck-http/src/site/site.xml
index ff1babb..6bd846a 100644
--- a/wagon-tcks/wagon-tck-http/src/site/site.xml
+++ b/wagon-tcks/wagon-tck-http/src/site/site.xml
@@ -1,33 +1,33 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
-Licensed to the Apache Software Foundation (ASF) under one
-or more contributor license agreements. See the NOTICE file
-distributed with this work for additional information
-regarding copyright ownership. The ASF licenses this file
-to you under the Apache License, Version 2.0 (the
-"License"); you may not use this file except in compliance
-with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing,
-software distributed under the License is distributed on an
-"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-KIND, either express or implied. See the License for the
-specific language governing permissions and limitations
-under the License.
--->
-
-<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
- <body>
- <breadcrumbs>
- <item name="HTTP" href="http://maven.apache.org/wagon/wagon-tcks/wagon-tck-consumer/index.html" />
- </breadcrumbs>
-
- <menu ref="parent"/>
- <menu ref="reports"/>
- </body>
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+<project xmlns="http://maven.apache.org/DECORATION/1.3.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/DECORATION/1.3.0 http://maven.apache.org/xsd/decoration-1.3.0.xsd">
+ <body>
+ <breadcrumbs>
+ <item name="HTTP" href="http://maven.apache.org/wagon/wagon-tcks/wagon-tck-consumer/index.html" />
+ </breadcrumbs>
+
+ <menu ref="parent"/>
+ <menu ref="reports"/>
+ </body>
</project>
\ No newline at end of file
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/wagon2.git
More information about the pkg-java-commits
mailing list