wagon-1.0.0/0000755000175000017500000000000011630374114012561 5ustar twernertwernerwagon-1.0.0/src/0000755000175000017500000000000011630374114013350 5ustar twernertwernerwagon-1.0.0/src/main/0000755000175000017500000000000011630374114014274 5ustar twernertwernerwagon-1.0.0/src/main/assembly/0000755000175000017500000000000011630374114016113 5ustar twernertwernerwagon-1.0.0/src/main/assembly/source-release.xml0000644000175000017500000000304411221776467021571 0ustar twernertwerner source-release tar.gz tar.bz2 zip ${project.basedir} / true *.log %regex[(?!.*src/).*${project.build.directory}.*] ${project.build.directory}/maven-shared-archive-resources/META-INF / DEPENDENCIES wagon-1.0.0/src/site/0000755000175000017500000000000011630374114014314 5ustar twernertwernerwagon-1.0.0/src/site/site.xml0000644000175000017500000000214011134110350015764 0ustar twernertwerner org.apache.maven.skins maven-stylus-skin 1.1 wagon-1.0.0/src/site/apt/0000755000175000017500000000000011630374114015100 5ustar twernertwernerwagon-1.0.0/src/site/apt/index.apt0000644000175000017500000000111211046407077016716 0ustar twernertwerner ------ Maven Wagon ------ Jason van Zyl ------ 2005-10-25 ------ Maven Wagon Maven Wagon is a transport abstraction that is used in Maven's artifact and repository handling code. Currently wagon has the following providers: * {{{wagon-providers/wagon-file/}File}} * {{{wagon-providers/wagon-http/}HTTP}} * {{{wagon-providers/wagon-http-lightweight/}HTTP lightweight}} * {{{wagon-providers/wagon-ftp/}FTP}} * {{{wagon-providers/wagon-ssh/}SSH/SCP}} * {{{wagon-providers/wagon-webdav-jackrabbit/}WebDAV}} * {{{wagon-providers/wagon-scm/}SCM}} (in progress) wagon-1.0.0/wagon-providers/0000755000175000017500000000000011630374114015707 5ustar twernertwernerwagon-1.0.0/wagon-providers/src/0000755000175000017500000000000011630374112016474 5ustar twernertwernerwagon-1.0.0/wagon-providers/src/site/0000755000175000017500000000000011630374112017440 5ustar twernertwernerwagon-1.0.0/wagon-providers/src/site/site.xml0000644000175000017500000000016411045135116021126 0ustar twernertwerner wagon-1.0.0/wagon-providers/wagon-ssh-external/0000755000175000017500000000000011630374112021433 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-external/src/0000755000175000017500000000000011630374112022222 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-external/src/main/0000755000175000017500000000000011630374112023146 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-external/src/main/resources/0000755000175000017500000000000011630374112025160 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-external/src/main/java/0000755000175000017500000000000011630374112024067 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-external/src/main/java/org/0000755000175000017500000000000011630374112024656 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-external/src/main/java/org/apache/0000755000175000017500000000000011630374112026077 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/0000755000175000017500000000000011630374112027205 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/0000755000175000017500000000000011630374112030320 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/0000755000175000017500000000000011630374112032335 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/ssh/0000755000175000017500000000000011630374112033132 5ustar twernertwerner././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/ssh/external/wagon-1.0.0/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/ssh/ex0000755000175000017500000000000011630374112033467 5ustar twernertwerner././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagon.javawagon-1.0.0/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/ssh/ex0000644000175000017500000004062011147347140033477 0ustar twernertwernerpackage 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 java.io.File; import java.io.FileNotFoundException; import java.util.List; import java.util.Locale; 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; /** * 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 Brett Porter * @version $Id:ScpExternalWagon.java 477260 2006-11-20 17:11:39Z brett $ * @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 scp. * * @component.configuration default="scp" */ private String scpExecutable = "scp"; /** * The external SSH command to use - default is ssh. * * @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() ); } 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.createArgument().setLine( "-P " + port ); } else { cl.createArgument().setLine( "-p " + port ); } } if ( sshArgs != null ) { cl.createArgument().setLine( sshArgs ); } String remoteHost = this.buildRemoteHost(); cl.createArgument().setValue( remoteHost ); cl.createArgument().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 ).indexOf( "plink" ) >= 0; } private Commandline createBaseCommandLine( boolean putty, String executable, File privateKey ) { Commandline cl = new Commandline(); cl.setExecutable( executable ); if ( privateKey != null ) { cl.createArgument().setValue( "-i" ); cl.createArgument().setFile( privateKey ); } String password = authenticationInfo.getPassword(); if ( putty && password != null ) { cl.createArgument().setValue( "-pw" ); cl.createArgument().setValue( password ); } // should check interactive flag, but scpexe never works in interactive mode right now due to i/o streams if ( putty ) { cl.createArgument().setValue( "-batch" ); } else { cl.createArgument().setValue( "-o" ); cl.createArgument().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.createArgument().setLine( "-P " + port ); } if ( scpArgs != null ) { cl.createArgument().setLine( scpArgs ); } String resourceName = normalizeResource( resource ); String remoteFile = getRepository().getBasedir() + "/" + resourceName; remoteFile = StringUtils.replace( remoteFile, " ", "\\ " ); String qualifiedRemoteFile = this.buildRemoteHost() + ":" + remoteFile; if ( put ) { cl.createArgument().setValue( localFile.getName() ); cl.createArgument().setValue( qualifiedRemoteFile ); } else { cl.createArgument().setValue( qualifiedRemoteFile ); cl.createArgument().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 ).indexOf( "no such file or directory" ) != -1 ) { 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 ).indexOf( "pscp" ) >= 0; } 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 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; } } ././@LongLink0000000000000000000000000000021300000000000011561 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalCommandExecutor.javawagon-1.0.0/wagon-providers/wagon-ssh-external/src/main/java/org/apache/maven/wagon/providers/ssh/ex0000644000175000017500000000261511015033162033467 0ustar twernertwernerpackage 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 Joakim Erdfelt * @version $Id: ScpExternalCommandExecutor.java 658720 2008-05-21 14:49:22Z bentmann $ * * @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(); } } wagon-1.0.0/wagon-providers/wagon-ssh-external/src/site/0000755000175000017500000000000011630374112023166 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-external/src/site/site.xml0000644000175000017500000000013211045135116024647 0ustar twernertwerner wagon-1.0.0/wagon-providers/wagon-ssh-external/src/site/apt/0000755000175000017500000000000011630374112023752 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-external/src/site/apt/index.apt0000644000175000017500000000070111045136112025561 0ustar twernertwerner ------ Maven Wagon SSH External ------ Carlos Sanchez ------ 2006-04-16 ------ Maven Wagon SSH External This project 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 wagon-1.0.0/wagon-providers/wagon-ssh-external/src/test/0000755000175000017500000000000011630374112023201 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-external/src/test/java/0000755000175000017500000000000011630374112024122 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-external/src/test/java/org/0000755000175000017500000000000011630374112024711 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-external/src/test/java/org/apache/0000755000175000017500000000000011630374112026132 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/0000755000175000017500000000000011630374112027240 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/0000755000175000017500000000000011630374112030353 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/0000755000175000017500000000000011630374112032370 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/0000755000175000017500000000000011630374112033165 5ustar twernertwerner././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/wagon-1.0.0/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/ex0000755000175000017500000000000011630374112033522 5ustar twernertwerner././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/ScpExternalWagonTest.javawagon-1.0.0/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/ex0000644000175000017500000000651211147157201033531 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: ScpExternalWagonTest.java 745719 2009-02-19 04:22:25Z brett $ */ 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"; } public String getTestRepositoryUrl() { return TestData.getTestRepositoryUrl(); } 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() ); } } ././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/SshCommandExecutorTest.javawagon-1.0.0/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/ex0000644000175000017500000000251711015033162033523 0ustar twernertwernerpackage 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 Brett Porter * @version $Id: SshCommandExecutorTest.java 658720 2008-05-21 14:49:22Z bentmann $ */ public class SshCommandExecutorTest extends CommandExecutorTestCase { protected Repository getTestRepository() { return new Repository( "test", "scpexe://localhost/" ); } } ././@LongLink0000000000000000000000000000022400000000000011563 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/external/ScpWagonWithSshPrivateKeySearchTest.javawagon-1.0.0/wagon-providers/wagon-ssh-external/src/test/java/org/apache/maven/wagon/providers/ssh/ex0000644000175000017500000000417311020715375033534 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: ScpWagonWithSshPrivateKeySearchTest.java 662345 2008-06-02 07:02:21Z brett $ */ 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"; } public String getTestRepositoryUrl() { return TestData.getTestRepositoryUrl(); } protected AuthenticationInfo getAuthInfo() { AuthenticationInfo authInfo = super.getAuthInfo(); authInfo.setUserName( TestData.getUserName() ); authInfo.setPassphrase( "" ); return authInfo; } } wagon-1.0.0/wagon-providers/wagon-ssh-external/pom.xml0000644000175000017500000000500311605164037022753 0ustar twernertwerner 4.0.0 org.apache.maven.wagon wagon-providers 1.0 ../pom.xml wagon-ssh-external Maven Wagon SSH External Provider Wagon that gets and puts artifacts using SSH protocol with a preinstalled SSH client org.codehaus.plexus plexus-utils org.apache.maven.wagon wagon-ssh-common org.apache.maven.wagon wagon-ssh-common-test test no-ssh-tests !ssh-tests maven-surefire-plugin **/SshCommandExecutorTest.* **/Scp*Test.* wagon-1.0.0/wagon-providers/wagon-ssh/0000755000175000017500000000000011630374112017613 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/0000755000175000017500000000000011630374112020402 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/main/0000755000175000017500000000000011630374112021326 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/main/resources/0000755000175000017500000000000011630374112023340 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/main/java/0000755000175000017500000000000011630374112022247 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/main/java/org/0000755000175000017500000000000011630374112023036 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/main/java/org/apache/0000755000175000017500000000000011630374112024257 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/0000755000175000017500000000000011630374112025365 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/0000755000175000017500000000000011630374112026500 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/0000755000175000017500000000000011630374112030515 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/0000755000175000017500000000000011630374112031312 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/0000755000175000017500000000000011630374112032241 5ustar twernertwerner././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/AbstractJschWagon.javawagon-1.0.0/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/Abstra0000644000175000017500000003312611053643144033410 0ustar twernertwernerpackage 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.ChannelExec; import com.jcraft.jsch.HostKey; import com.jcraft.jsch.HostKeyRepository; 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 * * @version $Id: AbstractJschWagon.java 688222 2008-08-22 23:06:12Z hboutemy $ */ public abstract class AbstractJschWagon extends StreamWagon implements SshWagon, CommandExecutor { protected ScpHelper sshTool = new ScpHelper( this ); protected Session session; /** * @plexus.requirement role-hint="file" */ private KnownHostsProvider knownHostsProvider; /** * @plexus.requirement */ private InteractiveUserInfo interactiveUserInfo; /** * @plexus.requirement */ private 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() ); } 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 ); } } 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().indexOf( "HostKey has been changed" ) >= 0 ) { 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 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; } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/interactive/wagon-1.0.0/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/intera0000755000175000017500000000000011630374112033444 5ustar twernertwerner././@LongLink0000000000000000000000000000022200000000000011561 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/interactive/UserInfoUIKeyboardInteractiveProxy.javawagon-1.0.0/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/intera0000644000175000017500000000606011016703400033442 0ustar twernertwernerpackage 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 UserInfo and a * UIKeyboardInteractive * * @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 ); } } ././@LongLink0000000000000000000000000000021500000000000011563 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/interactive/PrompterUIKeyboardInteractive.javawagon-1.0.0/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/intera0000644000175000017500000000560411015033162033445 0ustar twernertwernerpackage 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. * * UIKeyboardInteractive are usefull when you don't use user with * password authentication with a server that use keyboard-interactive and * doesn't allow password method PasswordAuthentication no. * * @author Juan F. Codagnone * @since Sep 22, 2005 * * @plexus.component role="com.jcraft.jsch.UIKeyboardInteractive" */ public class PrompterUIKeyboardInteractive implements UIKeyboardInteractive { /** * @plexus.requirement role-hint="default" */ private 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; } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagon.javawagon-1.0.0/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWag0000644000175000017500000003211211053643144033352 0ustar twernertwernerpackage 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.EOFException; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; 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 com.jcraft.jsch.ChannelExec; import com.jcraft.jsch.JSchException; /** * SCP protocol wagon. * * Note that this implementation is not thread-safe, and multiple channels can not be used on the session at * the same time. * * See * http://blogs.sun.com/janp/entry/how_the_scp_protocol_works * for information on how the SCP protocol works. * * @version $Id: ScpWagon.java 688222 2008-08-22 23:06:12Z hboutemy $ * @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() ) ); } } 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(); } } 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 String readLine( InputStream in ) throws IOException { StringBuffer sb = new StringBuffer(); 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; 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.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().indexOf( "set mode: Operation not permitted" ) >= 0 ) { 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; } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/SftpWagon.javawagon-1.0.0/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/SftpWa0000644000175000017500000004330211313466011033370 0ustar twernertwernerpackage 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.Iterator; import java.util.List; import java.util.Vector; 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 Brett Porter * @version $Id: SftpWagon.java 892636 2009-12-20 18:25:13Z bentmann $ * @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 ( int i = 0; i < dirs.length; i++ ) { 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 ( int i = 0; i < dirs.length; i++ ) { mkdir( dirs[i], mode ); channel.cd( dirs[i] ); } } 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().indexOf( "Can't change directory" ) != -1 ) { 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() ) { if ( !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 ( int i = 0; i < files.length; i++ ) { if ( files[i].isDirectory() ) { ftpRecursivePut( files[i], prefix, files[i].getName(), directoryMode ); } } for ( int i = 0; i < files.length; i++ ) { if ( !files[i].isDirectory() ) { ftpRecursivePut( files[i], prefix, files[i].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 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 ); } Vector fileList = channel.ls( filename ); List files = new ArrayList( fileList.size() ); for ( Iterator i = fileList.iterator(); i.hasNext(); ) { ChannelSftp.LsEntry entry = (ChannelSftp.LsEntry) i.next(); 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 -1 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; } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpCommandExecutor.javawagon-1.0.0/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/ScpCom0000644000175000017500000000253411015033162033346 0ustar twernertwernerpackage 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 Joakim Erdfelt * @version $Id: ScpCommandExecutor.java 658720 2008-05-21 14:49:22Z bentmann $ * * @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(); } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/WagonUserInfo.javawagon-1.0.0/wagon-providers/wagon-ssh/src/main/java/org/apache/maven/wagon/providers/ssh/jsch/WagonU0000644000175000017500000000457111015033162033365 0ustar twernertwernerpackage 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 * * @version $Id: WagonUserInfo.java 658720 2008-05-21 14:49:22Z bentmann $ */ 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 ); } } } wagon-1.0.0/wagon-providers/wagon-ssh/src/site/0000755000175000017500000000000011630374112021346 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/site/xdoc/0000755000175000017500000000000011630374112022303 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/site/xdoc/configuration.xml0000644000175000017500000002132611015033162025672 0ustar twernertwerner Wagon SSH provider configuration Michal Maczka

This wagon can be configured in some ways:
What? / Interface Default Value Why?
Known Hosts Provider FileKnownHostsProvider with fallback to NullKnownHostProvider provides known hosts keys, needed to check the hosts identity. This is an important thing!

Some implementations:

Host Checking Ask (type safe enum) The policy with the hosts keys:
  • Yes: Check host keys. If the incoming key is not available in the Known Hosts Provider fails
  • Ask: If the incoming key is not available in the Known Hosts Provider it ask the user if the fingerprint is trusted
  • No: don't check host keys at all. pretty unsafe!!
Interactive User Info ConsoleInteractiveUserInfo If the user choose Ask as Host Checking , this bean is used to interact with the user

Some implementations:

This wagon can be configured in some ways:
What? / Interface Default Value Why?
Known Hosts Provider FileKnownHostsProvider with fallback to NullKnownHostProvider provides known hosts keys, needed to check the hosts identity. This is an important thing!

Some implementations:

Host Checking Ask (type safe enum) The policy with the hosts keys:
  • Yes: Check host keys. If the incoming key is not available in the Known Hosts Provider fails
  • Ask: If the incoming key is not available in the Known Hosts Provider it ask the user if the fingerprint is trusted
  • No: don't check host keys at all. pretty unsafe!!
Interactive User Info ConsoleInteractiveUserInfo If the user choose Ask as Host Checking, this bean is used to interact with the user

Some implementations:

TODO Autogenerate some of this information with a xdoclet2 plugin?

wagon-1.0.0/wagon-providers/wagon-ssh/src/site/site.xml0000644000175000017500000000013211045135116023027 0ustar twernertwerner wagon-1.0.0/wagon-providers/wagon-ssh/src/site/apt/0000755000175000017500000000000011630374112022132 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/site/apt/index.apt0000644000175000017500000000067311045136112023751 0ustar twernertwerner ------ Maven Wagon HTTP ------ Carlos Sanchez ------ 2006-06-04 ------ Maven Wagon SSH This project 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 wagon-1.0.0/wagon-providers/wagon-ssh/src/test/0000755000175000017500000000000011630374112021361 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/test/resources/0000755000175000017500000000000011630374112023373 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/test/resources/org/0000755000175000017500000000000011630374112024162 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/test/resources/org/apache/0000755000175000017500000000000011630374112025403 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/0000755000175000017500000000000011630374112026511 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/0000755000175000017500000000000011630374112027624 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/0000755000175000017500000000000011630374112031641 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/0000755000175000017500000000000011630374112032436 5ustar twernertwerner././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/ScpWagonTest.xmlwagon-1.0.0/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/ScpWag0000644000175000017500000000304711015033162033543 0ustar twernertwerner org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo org.apache.maven.wagon.providers.ssh.interactive.NullInteractiveUserInfo per-lookup org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider org.apache.maven.wagon.providers.ssh.knownhost.NullKnownHostProvider per-lookup no ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/SshCommandExecutorTest.xmlwagon-1.0.0/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/SshCom0000644000175000017500000000304711015033162033553 0ustar twernertwerner org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo org.apache.maven.wagon.providers.ssh.interactive.NullInteractiveUserInfo per-lookup org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider org.apache.maven.wagon.providers.ssh.knownhost.NullKnownHostProvider per-lookup no ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/SftpWagonTest.xmlwagon-1.0.0/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/SftpWa0000644000175000017500000000304711015033162033563 0ustar twernertwerner org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo org.apache.maven.wagon.providers.ssh.interactive.NullInteractiveUserInfo per-lookup org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider org.apache.maven.wagon.providers.ssh.knownhost.NullKnownHostProvider per-lookup no ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/ScpWagonWithSshPrivateKeySearchTest.xmlwagon-1.0.0/wagon-providers/wagon-ssh/src/test/resources/org/apache/maven/wagon/providers/ssh/ScpWag0000644000175000017500000000304711015033162033543 0ustar twernertwerner org.apache.maven.wagon.providers.ssh.interactive.InteractiveUserInfo org.apache.maven.wagon.providers.ssh.interactive.NullInteractiveUserInfo per-lookup org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider org.apache.maven.wagon.providers.ssh.knownhost.NullKnownHostProvider per-lookup no wagon-1.0.0/wagon-providers/wagon-ssh/src/test/java/0000755000175000017500000000000011630374112022302 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/test/java/org/0000755000175000017500000000000011630374112023071 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/test/java/org/apache/0000755000175000017500000000000011630374112024312 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/0000755000175000017500000000000011630374112025420 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/0000755000175000017500000000000011630374112026533 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/0000755000175000017500000000000011630374112030550 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/0000755000175000017500000000000011630374112031345 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/0000755000175000017500000000000011630374112032274 5ustar twernertwerner././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/SftpWagonTest.javawagon-1.0.0/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/SftpWa0000644000175000017500000000361511020767712033435 0ustar twernertwernerpackage 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 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; /** * @author Brett Porter * @version $Id: SftpWagonTest.java 662418 2008-06-02 13:04:10Z brett $ */ public class SftpWagonTest extends StreamingWagonTestCase { protected String getProtocol() { return "sftp"; } public String getTestRepositoryUrl() { return TestData.getTestRepositoryUrl(); } 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(); } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonTest.javawagon-1.0.0/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWag0000644000175000017500000000415311020774357033416 0ustar twernertwernerpackage 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 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; /** * @author Michal Maczka * @version $Id: ScpWagonTest.java 662431 2008-06-02 13:43:11Z brett $ */ public class ScpWagonTest extends StreamingWagonTestCase { protected String getProtocol() { return "scp"; } public String getTestRepositoryUrl() { return TestData.getTestRepositoryUrl(); } 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(); } } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/KnownHostsProviderTest.javawagon-1.0.0/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/KnownH0000644000175000017500000000230211015033162033412 0ustar twernertwernerpackage 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 KnownHostsProvider * * @author Juan F. Codagnone * @see org.apache.maven.wagon.providers.ssh.knownhost.KnownHostsProvider * @since Sep 12, 2005 */ public class KnownHostsProviderTest extends KnownHostsProviderTestCase { } ././@LongLink0000000000000000000000000000017200000000000011565 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/SshCommandExecutorTest.javawagon-1.0.0/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/SshCom0000644000175000017500000000251011015033162033403 0ustar twernertwernerpackage 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 Brett Porter * @version $Id: SshCommandExecutorTest.java 658720 2008-05-21 14:49:22Z bentmann $ */ public class SshCommandExecutorTest extends CommandExecutorTestCase { protected Repository getTestRepository() { return new Repository( "test", "scp://localhost/" ); } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonWithProxyTest.javawagon-1.0.0/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWag0000644000175000017500000001331511044154044033405 0ustar twernertwernerpackage 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 ) { } } } } } } ././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWagonWithSshPrivateKeySearchTest.javawagon-1.0.0/wagon-providers/wagon-ssh/src/test/java/org/apache/maven/wagon/providers/ssh/jsch/ScpWag0000644000175000017500000000622511044055303033405 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: ScpWagonWithSshPrivateKeySearchTest.java 680995 2008-07-30 12:12:51Z brett $ */ public class ScpWagonWithSshPrivateKeySearchTest extends StreamingWagonTestCase { protected String getProtocol() { return "scp"; } public String getTestRepositoryUrl() { return TestData.getTestRepositoryUrl(); } 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(); } } } wagon-1.0.0/wagon-providers/wagon-ssh/pom.xml0000644000175000017500000000545311605164037021144 0ustar twernertwerner 4.0.0 org.apache.maven.wagon wagon-providers 1.0 ../pom.xml wagon-ssh Maven Wagon SSH Provider com.jcraft jsch 0.1.44-1 org.codehaus.plexus plexus-utils org.apache.maven.wagon wagon-ssh-common org.apache.maven.wagon wagon-ssh-common-test test org.mortbay.jetty jetty 6.1.11 test no-ssh-tests !ssh-tests maven-surefire-plugin **/SftpWagonTest.* **/SshCommandExecutorTest.* **/KnownHostsProviderTest.* **/ScpWagon*Test.* wagon-1.0.0/wagon-providers/wagon-file/0000755000175000017500000000000011630374113017736 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-file/src/0000755000175000017500000000000011630374113020525 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-file/src/main/0000755000175000017500000000000011630374113021451 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-file/src/main/resources/0000755000175000017500000000000011630374113023463 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-file/src/main/java/0000755000175000017500000000000011630374112022371 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-file/src/main/java/org/0000755000175000017500000000000011630374112023160 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-file/src/main/java/org/apache/0000755000175000017500000000000011630374112024401 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-file/src/main/java/org/apache/maven/0000755000175000017500000000000011630374112025507 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-file/src/main/java/org/apache/maven/wagon/0000755000175000017500000000000011630374112026622 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-file/src/main/java/org/apache/maven/wagon/providers/0000755000175000017500000000000011630374112030637 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-file/src/main/java/org/apache/maven/wagon/providers/file/0000755000175000017500000000000011630374113031557 5ustar twernertwerner././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-file/src/main/java/org/apache/maven/wagon/providers/file/FileWagon.javawagon-1.0.0/wagon-providers/wagon-file/src/main/java/org/apache/maven/wagon/providers/file/FileWagon0000644000175000017500000002152011147165407033364 0ustar twernertwernerpackage 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.Arrays; 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; import org.codehaus.plexus.util.StringUtils; /** * Wagon Provider for Local File System * * @author Michal Maczka * @version $Id: FileWagon.java 745730 2009-02-19 05:15:51Z brett $ * @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 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 list = new ArrayList( files.length ); for ( int i = 0; i < files.length; i++ ) { String name = files[i].getName(); if ( files[i].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(); } } wagon-1.0.0/wagon-providers/wagon-file/src/site/0000755000175000017500000000000011630374113021471 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-file/src/site/site.xml0000644000175000017500000000013211045135116023151 0ustar twernertwerner wagon-1.0.0/wagon-providers/wagon-file/src/site/apt/0000755000175000017500000000000011630374113022255 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-file/src/site/apt/index.apt0000644000175000017500000000060511045136112024066 0ustar twernertwerner ------ Maven Wagon File ------ Carlos Sanchez ------ 2006-04-16 ------ Maven Wagon File This project 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 wagon-1.0.0/wagon-providers/wagon-file/src/test/0000755000175000017500000000000011630374112021503 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-file/src/test/java/0000755000175000017500000000000011630374112022424 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-file/src/test/java/org/0000755000175000017500000000000011630374112023213 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-file/src/test/java/org/apache/0000755000175000017500000000000011630374112024434 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-file/src/test/java/org/apache/maven/0000755000175000017500000000000011630374112025542 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-file/src/test/java/org/apache/maven/wagon/0000755000175000017500000000000011630374112026655 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-file/src/test/java/org/apache/maven/wagon/providers/0000755000175000017500000000000011630374112030672 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-file/src/test/java/org/apache/maven/wagon/providers/file/0000755000175000017500000000000011630374112031611 5ustar twernertwerner././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-file/src/test/java/org/apache/maven/wagon/providers/file/FileWagonTest.javawagon-1.0.0/wagon-providers/wagon-file/src/test/java/org/apache/maven/wagon/providers/file/FileWagon0000644000175000017500000000575611117073271033426 0ustar twernertwernerpackage 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.File; import java.io.IOException; 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; /** * @author Michal Maczka * @version $Id: FileWagonTest.java 724228 2008-12-08 01:22:01Z dantran $ */ 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(); } /** * 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(); } } wagon-1.0.0/wagon-providers/wagon-file/pom.xml0000644000175000017500000000261511605164037021263 0ustar twernertwerner 4.0.0 org.apache.maven.wagon wagon-providers 1.0 ../pom.xml wagon-file Maven Wagon File Provider Wagon that gets and puts artifacts using file system protocol wagon-1.0.0/wagon-providers/wagon-http-shared/0000755000175000017500000000000011630374114021243 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-shared/src/0000755000175000017500000000000011630374113022031 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-shared/src/main/0000755000175000017500000000000011630374113022755 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-shared/src/main/java/0000755000175000017500000000000011630374113023676 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-shared/src/main/java/org/0000755000175000017500000000000011630374113024465 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-shared/src/main/java/org/apache/0000755000175000017500000000000011630374113025706 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/0000755000175000017500000000000011630374113027014 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/0000755000175000017500000000000011630374113030127 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/0000755000175000017500000000000011630374113031375 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/0000755000175000017500000000000011630374113032354 5ustar twernertwerner././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagon.javawagon-1.0.0/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/Abstr0000644000175000017500000005610111217013657033361 0ustar twernertwernerpackage 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.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.HttpException; 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.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.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.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.StringUtils; 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.net.URLEncoder; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Iterator; import java.util.Locale; import java.util.Properties; import java.util.TimeZone; import java.util.zip.GZIPInputStream; /** * @author Michal Maczka * @author James William Dumay */ public abstract class AbstractHttpClientWagon extends StreamWagon { private final class RequestEntityImplementation implements RequestEntity { private final Resource resource; private final Wagon wagon; private final File source; private RequestEntityImplementation( final InputStream stream, final Resource resource, final Wagon wagon, final File source ) throws TransferFailedException { if ( source != null ) { this.source = source; } else { FileOutputStream fos = null; try { this.source = File.createTempFile( "http-wagon.", ".tmp" ); this.source.deleteOnExit(); fos = new FileOutputStream( this.source ); IOUtil.copy( stream, fos ); } catch ( IOException e ) { fireTransferError( resource, e, TransferEvent.REQUEST_PUT ); throw new TransferFailedException( "Failed to buffer stream contents to temp file for upload.", e ); } finally { IOUtil.close( fos ); } } 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() ); FileInputStream fin = null; try { fin = new FileInputStream( source ); 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 { IOUtil.close( 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 ); String username = null; String password = null; if ( authenticationInfo != null ) { username = authenticationInfo.getUserName(); password = authenticationInfo.getPassword(); } String host = getRepository().getHost(); if ( StringUtils.isNotEmpty( username ) && StringUtils.isNotEmpty( password ) ) { Credentials 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 { String url = getRepository().getUrl(); String[] parts = StringUtils.split( resource.getName(), "/" ); for ( int i = 0; i < parts.length; i++ ) { // TODO: Fix encoding... // url += "/" + URLEncoder.encode( parts[i], System.getProperty("file.encoding") ); url += "/" + URLEncoder.encode( parts[i] ); } //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( new RequestEntityImplementation( stream, resource, this, source ) ); 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. 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; 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; } } firePutCompleted( resource, source ); } finally { putMethod.releaseConnection(); } } protected void mkdirs( String dirname ) throws HttpException, IOException { } public boolean resourceExists( String resourceName ) throws TransferFailedException, AuthorizationException { String url = getRepository().getUrl() + "/" + resourceName; HeadMethod headMethod = new HeadMethod( url ); 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 HttpException, IOException { int statusCode = SC_NULL; 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" ); } if ( httpHeaders != null ) { for ( Iterator i = httpHeaders.keySet().iterator(); i.hasNext(); ) { String header = (String) i.next(); method.addRequestHeader( header, httpHeaders.getProperty( header ) ); } } Header[] headers = config == null ? null : config.asRequestHeaders(); if ( headers != null ) { for ( int i = 0; i < headers.length; i++ ) { method.addRequestHeader( headers[i] ); } } } /** * 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(); String url = getRepository().getUrl() + "/" + resource.getName(); getMethod = new GetMethod( 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 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 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; } } 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 ? false : "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(); } } public void fillOutputData( OutputData outputData ) throws TransferFailedException { throw new IllegalStateException( "Should not be using the streaming wagon for HTTP PUT" ); } } ././@LongLink0000000000000000000000000000016700000000000011571 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/HtmlFileListParser.javawagon-1.0.0/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/HtmlF0000644000175000017500000001220411604644463033321 0ustar twernertwernerpackage 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.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; import org.apache.commons.io.IOUtils; import org.apache.maven.wagon.TransferFailedException; import org.codehaus.plexus.util.StringUtils; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; /** * 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 is the input stream. * @return the file list. * @throws TransferFailedException if there was a problem fetching the raw html. */ public static List/* */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.getElementsByTag( "a" ); Set results = new HashSet(); for ( int lx = 0; lx < links.size(); lx++ ) { Element link = links.get( lx ); /* * 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 ); } } } ArrayList resultsAsList = new ArrayList(); resultsAsList.addAll( results ); return resultsAsList; } catch ( URISyntaxException e ) { throw new TransferFailedException( "Unable to parse as base URI: " + baseurl ); } 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 ) { } catch ( UnsupportedEncodingException e ) { } return ret; } private static boolean isAcceptableLink( String link ) { if ( StringUtils.isEmpty( link ) ) { return false; } for ( int i = 0; i < SKIPS.length; i++ ) { if ( SKIPS[i].matcher( link ).find() ) { return false; } } return true; } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/HttpMethodConfiguration.javawagon-1.0.0/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/HttpM0000644000175000017500000002256311221774502033345 0ustar twernertwernerpackage 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.httpclient.Header; import org.apache.commons.httpclient.params.HttpMethodParams; import java.util.ArrayList; import java.util.Iterator; 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 ( Iterator it = params.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = (Map.Entry) it.next(); 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 ); 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 collection = new ArrayList(); for ( int i = 0; i < entries.length; i++ ) { collection.add( entries[i].trim() ); } p.setParameter( key, collection ); break; } case 'm': { String[] entries = value.split( "," ); Map map = new LinkedHashMap(); for ( int i = 0; i < entries.length; i++ ) { int idx = entries[i].indexOf( "=>" ); if ( idx < 1 ) { break; } String mapKey = entries[i].substring( 0, idx ); String mapVal = entries[i].substring( idx + 1, entries[i].length() ); map.put( mapKey.trim(), mapVal.trim() ); } p.setParameter( key, map ); break; } } } else { p.setParameter( key, value ); } } } } public Header[] asRequestHeaders() { if ( headers == null ) { return null; } Header[] result = new Header[headers.size()]; int index = 0; for ( Iterator it = headers.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = (Map.Entry) it.next(); 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; } } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/HttpConfiguration.javawagon-1.0.0/wagon-providers/wagon-http-shared/src/main/java/org/apache/maven/wagon/shared/http/HttpC0000644000175000017500000000546211221774502033332 0ustar twernertwernerpackage 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.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; } } wagon-1.0.0/wagon-providers/wagon-http-shared/src/site/0000755000175000017500000000000011630374114022776 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-shared/src/site/site.xml0000644000175000017500000000013211045135116024455 0ustar twernertwerner wagon-1.0.0/wagon-providers/wagon-http-shared/src/test/0000755000175000017500000000000011630374113023010 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-shared/src/test/resources/0000755000175000017500000000000011630374113025022 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-shared/src/test/resources/filelistings/0000755000175000017500000000000011630374113027516 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-shared/src/test/resources/filelistings/net_sf.html0000644000175000017500000001653411020327466031675 0ustar twernertwerner Index of /maven2/net/sf

Index of /maven2/net/sf

Icon  Name                    Last modified      Size  Description
[DIR] Parent Directory - [DIR] a2j/ 28-Nov-2005 11:32 - [DIR] aislib/ 10-Feb-2008 06:40 - [DIR] alchim/ 22-Nov-2007 08:27 - [DIR] antenna/ 09-Jul-2007 11:45 - [DIR] apt-jelly/ 02-Apr-2007 15:48 - [DIR] beanlib/ 20-Apr-2006 07:32 - [DIR] bluecove/ 25-Jan-2007 01:03 - [DIR] buildbox/ 13-Jan-2008 20:07 - [DIR] click/ 10-Dec-2005 19:31 - [DIR] clirr/ 11-Feb-2006 20:41 - [DIR] datavision/ 26-Jan-2008 18:46 - [DIR] dozer/ 09-Feb-2006 23:31 - [DIR] dtddoc/ 03-Feb-2007 07:32 - [DIR] dynpageplus/ 03-Jan-2006 11:36 - [DIR] ehcache/ 04-May-2007 20:14 - [DIR] ezmorph/ 17-Aug-2006 11:57 - [DIR] falcon/ 31-Jan-2007 11:35 - [DIR] grester/ 22-Oct-2007 18:25 - [DIR] gwt-widget/ 17-Sep-2007 12:58 - [DIR] hermesftp/ 14-Jun-2006 17:06 - [DIR] hibernate/ 31-Oct-2005 23:08 - [DIR] jcharts/ 16-May-2007 17:26 - [DIR] jdatabaseimport/ 20-Oct-2006 10:45 - [DIR] jeceira/ 26-Jun-2007 16:50 - [DIR] jfcunit/ 07-Feb-2006 00:49 - [DIR] jfig/ 25-Jan-2007 01:03 - [DIR] jguard/ 31-Jul-2007 18:36 - [DIR] jipcam/ 02-Mar-2006 15:32 - [DIR] jlynx/ 02-Aug-2007 22:04 - [DIR] jour/ 27-Aug-2007 20:09 - [DIR] jpf/ 26-Apr-2007 10:45 - [DIR] json-lib/ 11-Feb-2007 19:12 - [DIR] jsptest/ 07-Aug-2007 16:17 - [DIR] jsr107cache/ 25-Jan-2007 00:45 - [DIR] jt400/ 11-Nov-2005 15:31 - [DIR] jxls/ 29-Jul-2007 17:54 - [DIR] kxml/ 19-Mar-2007 20:25 - [DIR] ldaptemplate/ 27-Feb-2006 19:41 - [DIR] locale4j/ 31-Aug-2007 07:23 - [DIR] mapasuta/ 12-Nov-2006 12:05 - [DIR] maven-har/ 24-Aug-2007 07:09 - [DIR] maven-sar/ 28-Aug-2007 18:28 - [DIR] opencsv/ 14-Mar-2007 12:55 - [DIR] oval/ 15-Jan-2007 15:30 - [DIR] proguard/ 19-Jan-2006 15:41 - [DIR] qdwizard/ 19-Dec-2007 16:02 - [DIR] resultsetmapper/ 18-Mar-2007 16:23 - [DIR] retrotranslator/ 26-Apr-2006 15:31 - [DIR] saxon/ 04-Apr-2006 23:32 - [DIR] shadesdb/ 19-Oct-2006 14:58 - [DIR] smc/ 30-May-2006 01:13 - [DIR] speculoos/ 20-Nov-2006 17:04 - [DIR] springlayout/ 26-Mar-2007 15:24 - [DIR] stat-scm/ 25-Apr-2007 10:56 - [DIR] statsvn/ 29-Nov-2006 13:55 - [DIR] stax/ 31-Oct-2005 23:08 - [DIR] struts/ 28-Nov-2005 11:32 - [DIR] tacos/ 19-Dec-2007 04:16 - [DIR] testextensions/ 21-May-2007 12:54 - [DIR] webdav-servlet/ 30-Jan-2006 19:36 -
Apache/2.0.52 (Red Hat) Server at repo1.maven.org Port 80
wagon-1.0.0/wagon-providers/wagon-http-shared/src/test/resources/filelistings/org.codehaus.html0000644000175000017500000002103611020327466032771 0ustar twernertwerner Index of /org/codehaus

Index of /org/codehaus

Icon  Name                    Last modified      Size  Description
[DIR] Parent Directory - [DIR] agilifier/ 05-Oct-2006 16:06 - [DIR] benji/ 26-Jan-2008 20:04 - [DIR] bruce/ 26-Jun-2007 07:31 - [DIR] btm/ 10-Apr-2007 07:08 - [DIR] cargo/ 15-Mar-2007 15:41 - [DIR] castor-spring/ 17-Jan-2007 21:49 - [DIR] castor/ 04-Feb-2008 16:28 - [DIR] cozmos/ 18-Dec-2006 12:51 - [DIR] dataforge/ 12-Jun-2006 21:38 - [DIR] dimple/ 13-Dec-2006 04:59 - [DIR] droolsdotnet/ 21-Feb-2007 22:50 - [DIR] enunciate/ 07-Jan-2008 09:37 - [DIR] fabric3/ 25-Jan-2008 04:55 - [DIR] gant/ 08-Dec-2007 03:41 - [DIR] grails-plugins/ 17-Jan-2007 21:43 - [DIR] groovy/ 15-Dec-2007 12:15 - [DIR] gsoc/ 16-Feb-2007 15:48 - [DIR] guessencoding/ 22-Jul-2007 16:13 - [DIR] gumtree/ 18-Jan-2007 17:54 - [DIR] gwt-openlayers/ 14-Sep-2007 17:04 - [DIR] haus/ 16-Mar-2007 15:46 - [DIR] izpack/ 04-Feb-2008 05:42 - [DIR] javasim/ 22-Sep-2007 22:02 - [DIR] jedi/ 01-Jun-2007 07:10 - [DIR] jequel/ 09-Nov-2007 08:18 - [DIR] jet/ 22-Aug-2006 13:25 - [DIR] jettison/ 09-Nov-2006 04:13 - [DIR] jfdi/ 15-Sep-2006 21:24 - [DIR] jikesrvm/ 19-Jan-2007 23:07 - [DIR] jra/ 23-Oct-2006 13:13 - [DIR] jremoting/ 08-Jan-2008 10:47 - [DIR] jtestme/ 01-Sep-2007 17:20 - [DIR] jtestr/ 07-Dec-2007 18:05 - [DIR] labs-ng/ 20-Dec-2007 09:46 - [DIR] logicabyss/ 02-Dec-2007 15:57 - [DIR] marionette/ 08-Oct-2007 15:31 - [DIR] mevenide/ 18-Dec-2007 12:01 - [DIR] modello/ 22-Mar-2007 23:52 - [DIR] mojo/ 06-Feb-2008 16:17 - [DIR] mvel/ 05-Feb-2008 08:37 - [DIR] mvflex/ 29-Dec-2006 20:33 - [DIR] native-mojo/ 12-Feb-2007 18:35 - [DIR] openim/ 30-Apr-2007 15:47 - [DIR] plexus/ 06-Dec-2007 15:34 - [DIR] polymap/ 02-Dec-2007 15:32 - [DIR] prometheus/ 28-Mar-2007 10:05 - [DIR] prophit/ 30-Apr-2007 15:44 - [DIR] quaere/ 19-Sep-2007 07:08 - [DIR] redback/ 07-Sep-2007 18:57 - [DIR] rulessandpit/ 02-May-2007 16:03 - [DIR] rvm/ 19-Jan-2007 23:13 - [DIR] savana/ 09-Nov-2007 07:56 - [DIR] scala-ide/ 26-Jun-2007 07:38 - [DIR] senro/ 27-Sep-2006 16:22 - [DIR] sonar/ 24-Jan-2008 08:17 - [DIR] staxmate/ 27-Nov-2007 00:46 - [DIR] stomp/ 02-Mar-2007 10:29 - [DIR] svn4j/ 17-Nov-2006 12:17 - [DIR] swiby/ 19-Sep-2007 06:09 - [DIR] swizzle/ 04-Jan-2008 21:04 - [DIR] sxc/ 16-Feb-2007 15:46 - [DIR] testdox/ 12-Jul-2007 07:38 - [DIR] wadi/ 21-Jul-2007 02:03 - [DIR] waffle/ 06-Jan-2008 23:53 - [DIR] woodstox/ 03-Sep-2006 19:14 - [DIR] xdoclet/ 15-Jun-2006 05:04 - [DIR] xfire/ 19-Jun-2006 10:15 - [DIR] xharness/ 24-Oct-2006 15:49 - [DIR] xsite/ 11-Nov-2006 06:08 - [DIR] xstream/ 28-Jul-2006 04:30 - [DIR] xwire/ 26-Jul-2006 14:20 -
Apache/2.0.52 (Red Hat) Server at repository.codehaus.org Port 80
wagon-1.0.0/wagon-providers/wagon-http-shared/src/test/resources/filelistings/ibiblio-wagon.html0000644000175000017500000002563610670157111033142 0ustar twernertwerner Index of /maven2/org/apache/maven/wagon

Index of /maven2/org/apache/maven/wagon

      Name                                                   Last modified       Size  Description


[DIR] Parent Directory 09-May-2006 10:57 - [   ] wagon-1.0-alpha-2.pom 07-May-2006 18:31 3k [TXT] wagon-1.0-alpha-2.pom.asc 07-May-2006 18:31 1k [   ] wagon-1.0-alpha-2.pom.md5 07-May-2006 18:31 1k [   ] wagon-1.0-alpha-2.pom.sha1 07-May-2006 18:31 1k [   ] wagon-1.0-alpha-3-20050413.021234-4.pom 08-Nov-2005 17:25 3k [   ] wagon-1.0-alpha-3-20050413.021234-4.pom.md5 10-May-2006 00:11 1k [   ] wagon-1.0-alpha-3-20050413.021234-4.pom.sha1 10-May-2006 00:11 1k [   ] wagon-1.0-alpha-3-20050419.043745-5.pom 08-Nov-2005 17:25 3k [   ] wagon-1.0-alpha-3-20050419.043745-5.pom.md5 10-May-2006 00:11 1k [   ] wagon-1.0-alpha-3-20050419.043745-5.pom.sha1 10-May-2006 00:11 1k [   ] wagon-1.0-alpha-3-20050419.044035-6.pom 08-Nov-2005 17:25 3k [   ] wagon-1.0-alpha-3-20050419.044035-6.pom.md5 10-May-2006 00:11 1k [   ] wagon-1.0-alpha-3-20050419.044035-6.pom.sha1 10-May-2006 00:11 1k [   ] wagon-1.0-alpha-3-20050421.162738-7.pom 08-Nov-2005 17:25 3k [   ] wagon-1.0-alpha-3-20050421.162738-7.pom.md5 10-May-2006 00:11 1k [   ] wagon-1.0-alpha-3-20050421.162738-7.pom.sha1 10-May-2006 00:11 1k [   ] wagon-1.0-alpha-3-20050422.075233-8.pom 08-Nov-2005 17:25 3k [   ] wagon-1.0-alpha-3-20050422.075233-8.pom.md5 10-May-2006 00:11 1k [   ] wagon-1.0-alpha-3-20050422.075233-8.pom.sha1 10-May-2006 00:11 1k [   ] wagon-1.0-alpha-3-20050429.051847-9.pom 08-Nov-2005 17:25 3k [   ] wagon-1.0-alpha-3-20050429.051847-9.pom.md5 10-May-2006 00:11 1k [   ] wagon-1.0-alpha-3-20050429.051847-9.pom.sha1 10-May-2006 00:11 1k [DIR] wagon-file/ 19-Jun-2006 08:27 - [DIR] wagon-ftp/ 19-Jun-2006 08:28 - [DIR] wagon-http-lightweight/ 19-Jun-2006 08:30 - [DIR] wagon-http/ 19-Jun-2006 08:32 - [DIR] wagon-lightweight-http/ 07-May-2006 18:31 - [DIR] wagon-provider-api/ 19-Jun-2006 08:20 - [DIR] wagon-provider-test/ 19-Jun-2006 08:25 - [DIR] wagon-provider/ 13-May-2006 04:11 - [   ] wagon-providers-1.0-alpha-2.pom 07-May-2006 18:31 1k [TXT] wagon-providers-1.0-alpha-2.pom.asc 07-May-2006 18:31 1k [   ] wagon-providers-1.0-alpha-2.pom.md5 07-May-2006 18:31 1k [   ] wagon-providers-1.0-alpha-2.pom.sha1 07-May-2006 18:31 1k [   ] wagon-providers-1.0-alpha-3-20050407.202848-1.pom 08-Nov-2005 17:25 1k [   ] wagon-providers-1.0-alpha-3-20050407.202848-1.pom.md5 10-May-2006 00:11 1k [   ] wagon-providers-1.0-alpha-3-20050407.202848-1.pom.sha1 10-May-2006 00:11 1k [   ] wagon-providers-1.0-alpha-3-20050419.044035-2.pom 08-Nov-2005 17:25 1k [   ] wagon-providers-1.0-alpha-3-20050419.044035-2.pom.md5 10-May-2006 00:11 1k [   ] wagon-providers-1.0-alpha-3-20050419.044035-2.pom.sha1 10-May-2006 00:11 1k [   ] wagon-providers-1.0-alpha-3-20050421.162738-3.pom 08-Nov-2005 17:25 1k [   ] wagon-providers-1.0-alpha-3-20050421.162738-3.pom.md5 10-May-2006 00:11 1k [   ] wagon-providers-1.0-alpha-3-20050421.162738-3.pom.sha1 10-May-2006 00:11 1k [   ] wagon-providers-1.0-alpha-3-20050422.075233-4.pom 08-Nov-2005 17:25 1k [   ] wagon-providers-1.0-alpha-3-20050422.075233-4.pom.md5 10-May-2006 00:11 1k [   ] wagon-providers-1.0-alpha-3-20050422.075233-4.pom.sha1 10-May-2006 00:11 1k [   ] wagon-providers-1.0-alpha-3-20050429.051847-5.pom 08-Nov-2005 17:25 1k [   ] wagon-providers-1.0-alpha-3-20050429.051847-5.pom.md5 10-May-2006 00:11 1k [   ] wagon-providers-1.0-alpha-3-20050429.051847-5.pom.sha1 10-May-2006 00:11 1k [DIR] wagon-providers/ 19-Jun-2006 08:26 - [DIR] wagon-scm/ 07-May-2006 19:40 - [DIR] wagon-ssh-external/ 19-Jun-2006 08:34 - [DIR] wagon-ssh/ 19-Jun-2006 08:35 - [DIR] wagon-webdav/ 19-Jun-2006 08:38 - [DIR] wagon/ 19-Jun-2006 08:17 -

Apache/1.3.33 Server at www.ibiblio.org Port 80
wagon-1.0.0/wagon-providers/wagon-http-shared/src/test/resources/filelistings/mirror-wagon.html0000644000175000017500000003151210670157111033031 0ustar twernertwerner Index of /maven2/org/apache/maven/wagon/

Index of /maven2/org/apache/maven/wagon/

NameLast ModifiedSizeType
Parent Directory/ -  Directory
wagon/2006-Aug-04 20:01:55-  Directory
wagon-file/2006-Aug-04 21:01:11-  Directory
wagon-ftp/2006-Aug-04 21:01:11-  Directory
wagon-http/2006-Aug-04 21:01:11-  Directory
wagon-http-lightweight/2006-Aug-04 21:01:11-  Directory
wagon-lightweight-http/2005-Nov-01 05:17:24-  Directory
wagon-provider/2006-Aug-04 20:01:55-  Directory
wagon-provider-api/2006-Aug-04 21:01:11-  Directory
wagon-provider-test/2006-Aug-04 21:01:11-  Directory
wagon-providers/2006-Aug-04 20:01:55-  Directory
wagon-scm/2006-Aug-04 20:01:55-  Directory
wagon-ssh/2006-Aug-04 20:01:55-  Directory
wagon-ssh-external/2006-Aug-04 20:01:55-  Directory
wagon-webdav/2006-Aug-04 20:01:55-  Directory
wagon-1.0-alpha-2.pom2006-Aug-04 21:01:113.1Ktext/xml
wagon-1.0-alpha-2.pom.asc2006-Aug-04 21:01:110.1Ktext/plain
wagon-1.0-alpha-2.pom.md52006-Aug-04 21:01:110.1Ktext/plain
wagon-1.0-alpha-2.pom.sha12006-Aug-04 21:01:110.1Ktext/plain
wagon-1.0-alpha-3-20050413.021234-4.pom2005-Nov-08 22:25:323.1Ktext/xml
wagon-1.0-alpha-3-20050413.021234-4.pom.md52006-Aug-04 21:01:110.1Ktext/plain
wagon-1.0-alpha-3-20050413.021234-4.pom.sha12006-Aug-04 21:01:110.1Ktext/plain
wagon-1.0-alpha-3-20050419.043745-5.pom2005-Nov-08 22:25:323.1Ktext/xml
wagon-1.0-alpha-3-20050419.043745-5.pom.md52006-Aug-04 21:01:110.1Ktext/plain
wagon-1.0-alpha-3-20050419.043745-5.pom.sha12006-Aug-04 21:01:110.1Ktext/plain
wagon-1.0-alpha-3-20050419.044035-6.pom2005-Nov-08 22:25:323.1Ktext/xml
wagon-1.0-alpha-3-20050419.044035-6.pom.md52006-Aug-04 21:01:110.1Ktext/plain
wagon-1.0-alpha-3-20050419.044035-6.pom.sha12006-Aug-04 21:01:110.1Ktext/plain
wagon-1.0-alpha-3-20050421.162738-7.pom2005-Nov-08 22:25:323.1Ktext/xml
wagon-1.0-alpha-3-20050421.162738-7.pom.md52006-Aug-04 21:01:110.1Ktext/plain
wagon-1.0-alpha-3-20050421.162738-7.pom.sha12006-Aug-04 21:01:110.1Ktext/plain
wagon-1.0-alpha-3-20050422.075233-8.pom2005-Nov-08 22:25:323.1Ktext/xml
wagon-1.0-alpha-3-20050422.075233-8.pom.md52006-Aug-04 21:01:110.1Ktext/plain
wagon-1.0-alpha-3-20050422.075233-8.pom.sha12006-Aug-04 21:01:110.1Ktext/plain
wagon-1.0-alpha-3-20050429.051847-9.pom2005-Nov-08 22:25:323.1Ktext/xml
wagon-1.0-alpha-3-20050429.051847-9.pom.md52006-Aug-04 21:01:110.1Ktext/plain
wagon-1.0-alpha-3-20050429.051847-9.pom.sha12006-Aug-04 21:01:110.1Ktext/plain
wagon-providers-1.0-alpha-2.pom2006-Aug-04 21:01:110.9Ktext/xml
wagon-providers-1.0-alpha-2.pom.asc2006-Aug-04 21:01:110.1Ktext/plain
wagon-providers-1.0-alpha-2.pom.md52006-Aug-04 21:01:110.1Ktext/plain
wagon-providers-1.0-alpha-2.pom.sha12006-Aug-04 21:01:110.1Ktext/plain
wagon-providers-1.0-alpha-3-20050407.202848-1.pom2005-Nov-08 22:25:320.9Ktext/xml
wagon-providers-1.0-alpha-3-20050407.202848-1.pom.md52006-Aug-04 21:01:110.1Ktext/plain
wagon-providers-1.0-alpha-3-20050407.202848-1.pom.sha12006-Aug-04 21:01:110.1Ktext/plain
wagon-providers-1.0-alpha-3-20050419.044035-2.pom2005-Nov-08 22:25:320.9Ktext/xml
wagon-providers-1.0-alpha-3-20050419.044035-2.pom.md52006-Aug-04 21:01:110.1Ktext/plain
wagon-providers-1.0-alpha-3-20050419.044035-2.pom.sha12006-Aug-04 21:01:110.1Ktext/plain
wagon-providers-1.0-alpha-3-20050421.162738-3.pom2005-Nov-08 22:25:320.9Ktext/xml
wagon-providers-1.0-alpha-3-20050421.162738-3.pom.md52006-Aug-04 21:01:110.1Ktext/plain
wagon-providers-1.0-alpha-3-20050421.162738-3.pom.sha12006-Aug-04 21:01:110.1Ktext/plain
wagon-providers-1.0-alpha-3-20050422.075233-4.pom2005-Nov-08 22:25:320.9Ktext/xml
wagon-providers-1.0-alpha-3-20050422.075233-4.pom.md52006-Aug-04 21:01:110.1Ktext/plain
wagon-providers-1.0-alpha-3-20050422.075233-4.pom.sha12006-Aug-04 21:01:110.1Ktext/plain
wagon-providers-1.0-alpha-3-20050429.051847-5.pom2005-Nov-08 22:25:321.0Ktext/xml
wagon-providers-1.0-alpha-3-20050429.051847-5.pom.md52006-Aug-04 21:01:110.1Ktext/plain
wagon-providers-1.0-alpha-3-20050429.051847-5.pom.sha12006-Aug-04 21:01:110.1Ktext/plain

ibiblio.org - Mirror Site
Mirror Admin
wagon-1.0.0/wagon-providers/wagon-http-shared/src/test/resources/filelistings/nekohtml.html0000644000175000017500000000443311020327466032233 0ustar twernertwerner Index of /maven2/nekohtml/nekohtml/1.9.6

Index of /maven2/nekohtml/nekohtml/1.9.6

Icon  Name                            Last modified      Size  Description
[DIR] Parent Directory - [   ] nekohtml-1.9.6-javadoc.jar 02-Jan-2008 15:07 235K [   ] nekohtml-1.9.6-javadoc.jar.md5 17-Jan-2008 21:35 134 [   ] nekohtml-1.9.6-javadoc.jar.sha1 17-Jan-2008 21:35 142 [   ] nekohtml-1.9.6-sources.jar 17-Jan-2008 21:35 88K [   ] nekohtml-1.9.6-sources.jar.md5 17-Jan-2008 21:35 134 [   ] nekohtml-1.9.6-sources.jar.sha1 17-Jan-2008 21:35 142 [   ] nekohtml-1.9.6.jar 02-Jan-2008 15:07 108K [   ] nekohtml-1.9.6.jar.md5 17-Jan-2008 21:35 126 [   ] nekohtml-1.9.6.jar.sha1 17-Jan-2008 21:35 134 [TXT] nekohtml-1.9.6.pom 02-Jan-2008 15:07 702 [TXT] nekohtml-1.9.6.pom.md5 17-Jan-2008 21:35 126 [TXT] nekohtml-1.9.6.pom.sha1 17-Jan-2008 21:35 134
Apache/2.0.52 (Red Hat) Server at repo1.maven.org Port 80
wagon-1.0.0/wagon-providers/wagon-http-shared/src/test/resources/filelistings/mevenide.html0000644000175000017500000001057111020327466032206 0ustar twernertwerner Index of /org/codehaus/mevenide

Index of /org/codehaus/mevenide

Icon  Name                       Last modified      Size  Description
[DIR] Parent Directory - [DIR] apisupport/ 22-Jan-2008 03:01 - [DIR] autoupdate/ 22-Jan-2008 02:57 - [DIR] continuum-rpc/ 09-Aug-2006 12:41 - [DIR] continuum/ 09-Aug-2006 12:41 - [DIR] debugger-bridge/ 22-Jan-2008 02:53 - [DIR] deployment-bridge/ 22-Jan-2008 02:55 - [DIR] feature/ 22-Jan-2008 03:01 - [DIR] grammar/ 22-Jan-2008 02:55 - [DIR] ide-mojos/ 31-Aug-2007 06:04 - [DIR] indexer/ 22-Jan-2008 02:54 - [DIR] j2ee/ 22-Jan-2008 02:56 - [DIR] junit/ 22-Jan-2008 03:02 - [TXT] maven-metadata.xml 22-Jan-2008 02:59 780 [TXT] maven-metadata.xml.md5 22-Jan-2008 02:59 32 [TXT] maven-metadata.xml.sha1 22-Jan-2008 02:59 40 [DIR] mevenide2-parent/ 18-Dec-2007 11:47 - [DIR] nb-mvn-embedder/ 22-Jan-2008 02:52 - [DIR] nb-project/ 22-Jan-2008 02:54 - [DIR] nb-repo-browser/ 24-Oct-2006 13:06 - [DIR] netbeans-debugger-plugin/ 31-Aug-2007 06:35 - [DIR] netbeans-deploy-plugin/ 31-Aug-2007 06:36 - [DIR] netbeans-libs/ 22-Jan-2008 02:52 - [DIR] netbeans-nbmreload-plugin/ 31-Aug-2007 06:37 - [DIR] netbeans-repository/ 22-Jan-2008 03:00 - [DIR] netbeans-run-plugin/ 31-Aug-2007 06:36 - [DIR] netbeans/ 22-Jan-2008 02:52 - [DIR] persistence/ 22-Jan-2008 02:57 - [DIR] plugin-bridges/ 22-Jan-2008 02:53 - [DIR] plugins/ 17-May-2006 17:24 - [DIR] reload-nbm-bridge/ 22-Jan-2008 02:59 - [DIR] run-jar-bridge/ 22-Jan-2008 02:53 -
Apache/2.0.52 (Red Hat) Server at repository.codehaus.org Port 80
wagon-1.0.0/wagon-providers/wagon-http-shared/src/test/resources/filelistings/jetty-wagon.html0000644000175000017500000002666710670157111032675 0ustar twernertwerner Directory: /maven2/

Directory: /maven2/

Parent Directory
wagon-1.0-alpha-2.pom 3k 07-May-2006 18:31
wagon-1.0-alpha-2.pom.asc 1k 07-May-2006 18:31
wagon-1.0-alpha-2.pom.md5 1k 07-May-2006 18:31
wagon-1.0-alpha-2.pom.sha1 1k 07-May-2006 18:31
wagon-1.0-alpha-3-20050413.021234-4.pom 3k 08-Nov-2005 17:25
wagon-1.0-alpha-3-20050413.021234-4.pom.md5 1k 10-May-2006 00:11
wagon-1.0-alpha-3-20050413.021234-4.pom.sha1 1k 10-May-2006 00:11
wagon-1.0-alpha-3-20050419.043745-5.pom 3k 08-Nov-2005 17:25
wagon-1.0-alpha-3-20050419.043745-5.pom.md5 1k 10-May-2006 00:11
wagon-1.0-alpha-3-20050419.043745-5.pom.sha1 1k 10-May-2006 00:11
wagon-1.0-alpha-3-20050419.044035-6.pom 3k 08-Nov-2005 17:25
wagon-1.0-alpha-3-20050419.044035-6.pom.md5 1k 10-May-2006 00:11
wagon-1.0-alpha-3-20050419.044035-6.pom.sha1 1k 10-May-2006 00:11
wagon-1.0-alpha-3-20050421.162738-7.pom 3k 08-Nov-2005 17:25
wagon-1.0-alpha-3-20050421.162738-7.pom.md5 1k 10-May-2006 00:11
wagon-1.0-alpha-3-20050421.162738-7.pom.sha1 1k 10-May-2006 00:11
wagon-1.0-alpha-3-20050422.075233-8.pom 3k 08-Nov-2005 17:25
wagon-1.0-alpha-3-20050422.075233-8.pom.md5 1k 10-May-2006 00:11
wagon-1.0-alpha-3-20050422.075233-8.pom.sha1 1k 10-May-2006 00:11
wagon-1.0-alpha-3-20050429.051847-9.pom 3k 08-Nov-2005 17:25
wagon-1.0-alpha-3-20050429.051847-9.pom.md5 1k 10-May-2006 00:11
wagon-1.0-alpha-3-20050429.051847-9.pom.sha1 1k 10-May-2006 00:11
wagon-file/ 19-Jun-2006 08:27
wagon-ftp/ 19-Jun-2006 08:28
wagon-http-lightweight/ 19-Jun-2006 08:30
wagon-http/ 19-Jun-2006 08:32
wagon-lightweight-http/ 07-May-2006 18:31
wagon-provider-api/ 19-Jun-2006 08:20
wagon-provider-test/ 19-Jun-2006 08:25
wagon-provider/ 13-May-2006 04:11
wagon-providers-1.0-alpha-2.pom 1k 07-May-2006 18:31
wagon-providers-1.0-alpha-2.pom.asc 1k 07-May-2006 18:31
wagon-providers-1.0-alpha-2.pom.md5 1k 07-May-2006 18:31
wagon-providers-1.0-alpha-2.pom.sha1 1k 07-May-2006 18:31
wagon-providers-1.0-alpha-3-20050407.202848-1.pom 1k 08-Nov-2005 17:25
wagon-providers-1.0-alpha-3-20050407.202848-1.pom.md5 1k 10-May-2006 00:11
wagon-providers-1.0-alpha-3-20050407.202848-1.pom.sha1 1k 10-May-2006 00:11
wagon-providers-1.0-alpha-3-20050419.044035-2.pom 1k 08-Nov-2005 17:25
wagon-providers-1.0-alpha-3-20050419.044035-2.pom.md5 1k 10-May-2006 00:11
wagon-providers-1.0-alpha-3-20050419.044035-2.pom.sha1 1k 10-May-2006 00:11
wagon-providers-1.0-alpha-3-20050421.162738-3.pom 1k 08-Nov-2005 17:25
wagon-providers-1.0-alpha-3-20050421.162738-3.pom.md5 1k 10-May-2006 00:11
wagon-providers-1.0-alpha-3-20050421.162738-3.pom.sha1 1k 10-May-2006 00:11
wagon-providers-1.0-alpha-3-20050422.075233-4.pom 1k 08-Nov-2005 17:25
wagon-providers-1.0-alpha-3-20050422.075233-4.pom.md5 1k 10-May-2006 00:11
wagon-providers-1.0-alpha-3-20050422.075233-4.pom.sha1 1k 10-May-2006 00:11
wagon-providers-1.0-alpha-3-20050429.051847-5.pom 1k 08-Nov-2005 17:25
wagon-providers-1.0-alpha-3-20050429.051847-5.pom.md5 1k 10-May-2006 00:11
wagon-providers-1.0-alpha-3-20050429.051847-5.pom.sha1 1k 10-May-2006 00:11
wagon-providers/ 19-Jun-2006 08:26
wagon-scm/ 07-May-2006 19:40
wagon-ssh-external/ 19-Jun-2006 08:34
wagon-ssh/ 19-Jun-2006 08:35
wagon-webdav/ 19-Jun-2006 08:38
wagon/ 19-Jun-2006 08:17
wagon-1.0.0/wagon-providers/wagon-http-shared/src/test/resources/filelistings/org.apache.maven.html0000644000175000017500000001617011020327466033527 0ustar twernertwerner Index of /repo/m2-ibiblio-rsync-repository/org/apache/maven/archiva/archiva-plexus-runtime/1.0.1

Index of /repo/m2-ibiblio-rsync-repository/org/apache/maven/archiva/archiva-plexus-runtime/1.0.1

Icon  Name                                                                               Last modified      Size  Description
[DIR] Parent Directory - [   ] archiva-plexus-runtime-1.0.1-bin.tar.gz 04-Feb-2008 03:40 22M [TXT] archiva-plexus-runtime-1.0.1-bin.tar.gz.asc 04-Feb-2008 03:40 189 [TXT] archiva-plexus-runtime-1.0.1-bin.tar.gz.asc.md5 04-Feb-2008 03:40 32 [TXT] archiva-plexus-runtime-1.0.1-bin.tar.gz.asc.sha1 04-Feb-2008 03:40 40 [TXT] archiva-plexus-runtime-1.0.1-bin.tar.gz.md5 04-Feb-2008 03:40 32 [TXT] archiva-plexus-runtime-1.0.1-bin.tar.gz.sha1 04-Feb-2008 03:40 40 [   ] archiva-plexus-runtime-1.0.1-bin.zip 04-Feb-2008 03:40 23M [TXT] archiva-plexus-runtime-1.0.1-bin.zip.asc 04-Feb-2008 03:40 189 [TXT] archiva-plexus-runtime-1.0.1-bin.zip.asc.md5 04-Feb-2008 03:40 32 [TXT] archiva-plexus-runtime-1.0.1-bin.zip.asc.sha1 04-Feb-2008 03:40 40 [TXT] archiva-plexus-runtime-1.0.1-bin.zip.md5 04-Feb-2008 03:40 32 [TXT] archiva-plexus-runtime-1.0.1-bin.zip.sha1 04-Feb-2008 03:40 40 [   ] archiva-plexus-runtime-1.0.1-sources.jar 04-Feb-2008 03:40 5.4K [TXT] archiva-plexus-runtime-1.0.1-sources.jar.asc 04-Feb-2008 03:40 189 [TXT] archiva-plexus-runtime-1.0.1-sources.jar.asc.md5 04-Feb-2008 03:40 32 [TXT] archiva-plexus-runtime-1.0.1-sources.jar.asc.sha1 04-Feb-2008 03:40 40 [TXT] archiva-plexus-runtime-1.0.1-sources.jar.md5 04-Feb-2008 03:40 32 [TXT] archiva-plexus-runtime-1.0.1-sources.jar.sha1 04-Feb-2008 03:40 40 [   ] archiva-plexus-runtime-1.0.1.jar 04-Feb-2008 03:40 8.0K [TXT] archiva-plexus-runtime-1.0.1.jar.asc 04-Feb-2008 03:40 189 [TXT] archiva-plexus-runtime-1.0.1.jar.asc.md5 04-Feb-2008 03:40 32 [TXT] archiva-plexus-runtime-1.0.1.jar.asc.sha1 04-Feb-2008 03:40 40 [TXT] archiva-plexus-runtime-1.0.1.jar.md5 04-Feb-2008 03:40 32 [TXT] archiva-plexus-runtime-1.0.1.jar.sha1 04-Feb-2008 03:40 40 [   ] archiva-plexus-runtime-1.0.1.pom 04-Feb-2008 03:40 6.6K [TXT] archiva-plexus-runtime-1.0.1.pom.asc 04-Feb-2008 03:40 189 [TXT] archiva-plexus-runtime-1.0.1.pom.asc.md5 04-Feb-2008 03:40 32 [TXT] archiva-plexus-runtime-1.0.1.pom.asc.sha1 04-Feb-2008 03:40 40 [TXT] archiva-plexus-runtime-1.0.1.pom.md5 04-Feb-2008 03:40 32 [TXT] archiva-plexus-runtime-1.0.1.pom.sha1 04-Feb-2008 03:40 40 [TXT] readme artifacts.txt 04-Feb-2008 03:40 40
Apache/2.2.6 (Unix) DAV/2 mod_ssl/2.2.6 OpenSSL/0.9.7e-p1 Server at people.apache.org Port 80
wagon-1.0.0/wagon-providers/wagon-http-shared/src/test/resources/filelistings/commons-lang.html0000644000175000017500000000311711020327466033002 0ustar twernertwerner Collection: /commons-lang/commons-lang/2.3/

Collection: /commons-lang/commons-lang/2.3/

wagon-1.0.0/wagon-providers/wagon-http-shared/src/test/java/0000755000175000017500000000000011630374113023731 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-shared/src/test/java/org/0000755000175000017500000000000011630374113024520 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-shared/src/test/java/org/apache/0000755000175000017500000000000011630374113025741 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-shared/src/test/java/org/apache/maven/0000755000175000017500000000000011630374113027047 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-shared/src/test/java/org/apache/maven/wagon/0000755000175000017500000000000011630374113030162 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-shared/src/test/java/org/apache/maven/wagon/shared/0000755000175000017500000000000011630374113031430 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-shared/src/test/java/org/apache/maven/wagon/shared/http/0000755000175000017500000000000011630374113032407 5ustar twernertwerner././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-http-shared/src/test/java/org/apache/maven/wagon/shared/http/AbstractHttpClientWagonTest.javawagon-1.0.0/wagon-providers/wagon-http-shared/src/test/java/org/apache/maven/wagon/shared/http/Abstr0000644000175000017500000001230011221774502033403 0ustar twernertwernerpackage 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.httpclient.Header; import org.apache.commons.httpclient.methods.HeadMethod; import org.apache.commons.httpclient.params.HttpClientParams; import org.apache.commons.httpclient.params.HttpMethodParams; import junit.framework.TestCase; public class AbstractHttpClientWagonTest 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() ); } 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 ); } private static final class TestWagon extends AbstractHttpClientWagon { } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-http-shared/src/test/java/org/apache/maven/wagon/shared/http/HtmlFileListParserTest.javawagon-1.0.0/wagon-providers/wagon-http-shared/src/test/java/org/apache/maven/wagon/shared/http/HtmlF0000644000175000017500000006632111147167346033367 0ustar twernertwernerpackage 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.Iterator; import java.util.List; import junit.framework.TestCase; import org.apache.maven.wagon.TransferFailedException; /** * Unit Tests for the HtmlFileListParser */ public class HtmlFileListParserTest extends TestCase { private void assertContainsExpected( List/**/links, String[] expected ) { if ( expected.length != links.size() ) { Collections.sort( links ); for ( Iterator iterator = links.iterator(); iterator.hasNext(); ) { String link = (String) iterator.next(); System.out.println( " \"" + link + "\", " ); } assertEquals( "Links to Expected size", expected.length, links.size() ); } for ( int i = 0; i < expected.length; i++ ) { assertTrue( "Should find [" + expected[i] + "] in link list", links.contains( expected[i] ) ); } } private void assertNotContainingAvoided( List/**/links, String[] avoided ) { for ( int i = 0; i < avoided.length; i++ ) { assertFalse( "Should not find [" + avoided[i] + "] in link list", links.contains( avoided[i] ) ); } } private List/**/parseLinks( String url, String filename ) throws TransferFailedException { InputStream is = this.getClass().getResourceAsStream( "/filelistings/" + filename ); List 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 ) { Iterator it = files.iterator(); while ( it.hasNext() ) { System.out.println( "File: '" + it.next() + "'" ); } } return files; } /** * Example showing jetty directory browsing of commons-lang * * @throws TransferFailedException */ public void testParseCommonsLang() throws TransferFailedException { List/**/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/**/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/**/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/**/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/**/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/**/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@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/**/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/**/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/**/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/**/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 ); } } wagon-1.0.0/wagon-providers/wagon-http-shared/pom.xml0000644000175000017500000000505511605164037022570 0ustar twernertwerner 4.0.0 org.apache.maven.wagon wagon-providers 1.0 ../pom.xml wagon-http-shared Maven Wagon HTTP Shared Library Shared Library for the wagon-http, and wagon-http-lightweight wagon providers. commons-httpclient commons-httpclient 3.1 commons-logging commons-logging commons-logging commons-logging 1.1.1 commons-io commons-io 2.0.1 org.jsoup jsoup 1.6.1 wagon-1.0.0/wagon-providers/wagon-scm/0000755000175000017500000000000011630374113017601 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/0000755000175000017500000000000011630374113020370 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/main/0000755000175000017500000000000011630374113021314 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/main/resources/0000755000175000017500000000000011630374113023326 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/main/java/0000755000175000017500000000000011630374113022235 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/main/java/org/0000755000175000017500000000000011630374113023024 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/main/java/org/apache/0000755000175000017500000000000011630374113024245 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/main/java/org/apache/maven/0000755000175000017500000000000011630374113025353 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/main/java/org/apache/maven/wagon/0000755000175000017500000000000011630374113026466 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/main/java/org/apache/maven/wagon/providers/0000755000175000017500000000000011630374113030503 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/main/java/org/apache/maven/wagon/providers/scm/0000755000175000017500000000000011630374113031265 5ustar twernertwerner././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-scm/src/main/java/org/apache/maven/wagon/providers/scm/ScmWagon.javawagon-1.0.0/wagon-providers/wagon-scm/src/main/java/org/apache/maven/wagon/providers/scm/ScmWagon.ja0000644000175000017500000005546011316430216033327 0ustar twernertwernerpackage 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.ScmException; import org.apache.maven.scm.ScmFile; import org.apache.maven.scm.ScmFileSet; import org.apache.maven.scm.ScmResult; 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.Iterator; 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. *

* 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. * * @plexus.component role="org.apache.maven.wagon.Wagon" role-hint="scm" instantiation-strategy="per-lookup" * * @author Brett Porter * @author Emmanuel Venisse * @author Carlos Sanchez * @author Jason van Zyl * @version $Id: ScmWagon.java 894435 2009-12-29 16:38:38Z bentmann $ */ public class ScmWagon extends AbstractWagon { /** * @plexus.requirement */ private ScmManager scmManager; 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 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. svn, cvs * @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 ); } } 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 ), (ScmVersion) null, 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 stack = new Stack(); 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, (ScmVersion) null ) .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 { scmRepository = getScmRepository( getRepository().getUrl() + "/" + target.replace( '\\', '/' ) ); CheckOutScmResult ret = scmProvider.checkOut( scmRepository, new ScmFileSet( new File( checkoutDirectory, "" ) ), (ScmVersion) null, 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 = (String) 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. *

* 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() ) { File[] files = scmFile.listFiles(); for ( int i = 0; i < files.length; i++ ) { if ( reservedScmFile != null && !reservedScmFile.equals( files[i].getName() ) ) { addedFiles += addFiles( scmProvider, scmRepository, basedir, ( scmFilePath.length() == 0 ? "" : scmFilePath + "/" ) + files[i].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 ), (ScmVersion) null ); } else { // TODO: this should be checking out a full hierarchy (requires the -d equiv) basedir.mkdirs(); scmProvider.checkOut( scmRepository, new ScmFileSet( basedir ), (ScmVersion) null ); } 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 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, (ScmVersion) null ); if ( !result.isSuccess() ) { throw new ResourceDoesNotExistException( result.getProviderMessage() ); } // List List files = new ArrayList(); for ( Iterator it = result.getFiles().iterator(); it.hasNext(); ) { ScmFile f = (ScmFile) it.next(); files.add( f.getPath() ); System.out.println( "LIST FILE: " + f + " (path=" + 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 ); } } wagon-1.0.0/wagon-providers/wagon-scm/src/site/0000755000175000017500000000000011630374113021334 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/site/site.xml0000644000175000017500000000041711045135116023022 0ustar twernertwerner

wagon-1.0.0/wagon-providers/wagon-scm/src/site/apt/0000755000175000017500000000000011630374113022120 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/site/apt/usage.apt0000644000175000017500000000446111045136112023732 0ustar twernertwerner ------ Maven Wagon SCM ------ Carlos Sanchez ------ 2006-03-07 ------ Maven Wagon SCM Usage You need to add some extensions (wagon-scm, maven-scm-manager-plexus and the maven-scm-provider for your SCM system, see examples below) to your pom and use URLs in the {{{http://maven.apache.org/scm/scm-url-format.html}SCM format}}. Deploying your Maven site to Subversion Add the following extensions to your pom and use a wagon-scm url in the distributionManagement site url. ------ org.apache.maven.wagon wagon-scm 1.0-alpha-7-SNAPSHOT org.apache.maven.scm maven-scm-manager-plexus 1.0-beta-3-SNAPSHOT org.apache.maven.scm maven-scm-provider-svnexe 1.0-beta-3-SNAPSHOT my.svn.server scm:svn:https://username@svn.apache.org/svn/root/module ------ Deploying your Maven site to CVS Same as before, but changing svnexe to cvsexe and using a CVS svn url. ------ org.apache.maven.wagon wagon-scm 1.0-alpha-7-SNAPSHOT org.apache.maven.scm maven-scm-manager-plexus 1.0-beta-3-SNAPSHOT org.apache.maven.scm maven-scm-provider-cvsexe 1.0-beta-3-SNAPSHOT my.cvs.server scm:cvs:ext:username@cvs.apache.org:/cvs/root:module ------ Using a Subversion based remote repository in Maven 2 Not tested yet Using a CVS based remote repository in Maven 2 Not tested yet wagon-1.0.0/wagon-providers/wagon-scm/src/site/apt/index.apt0000644000175000017500000000136211045136112023732 0ustar twernertwerner ------ Introduction ------ Carlos Sanchez ------ 2006-03-07 ------ Maven Wagon SCM This project 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 wagon-1.0.0/wagon-providers/wagon-scm/src/test/0000755000175000017500000000000011630374113021347 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/0000755000175000017500000000000011630374113023361 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/0000755000175000017500000000000011630374113026107 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/README.txt0000644000175000017500000000057311015033162027603 0ustar twernertwernerThis is a Subversion repository; use the 'svnadmin' tool to examine it. Do not add, delete, or modify files here unless you know how to avoid corrupting the repository. If the directory "db" contains a Berkeley DB environment, you may need to tweak the values in "db/DB_CONFIG" to match the requirements of your site. Visit http://subversion.tigris.org/ for more information. wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/hooks/0000755000175000017500000000000011630374113027232 5ustar twernertwerner././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/hooks/pre-revprop-change.tmplwagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/hooks/pre-revprop-change.tmpl0000644000175000017500000000541410401652050033632 0ustar twernertwerner#!/bin/sh # PRE-REVPROP-CHANGE HOOK # # The pre-revprop-change hook is invoked before a revision property # is added, modified or deleted. Subversion runs this hook by invoking # a program (script, executable, binary, etc.) named 'pre-revprop-change' # (for which this file is a template), with the following ordered # arguments: # # [1] REPOS-PATH (the path to this repository) # [2] REVISION (the revision being tweaked) # [3] USER (the username of the person tweaking the property) # [4] PROPNAME (the property being set on the revision) # [5] ACTION (the property is being 'A'dded, 'M'odified, or 'D'eleted) # # [STDIN] PROPVAL ** the new property value is passed via STDIN. # # If the hook program exits with success, the propchange happens; but # if it exits with failure (non-zero), the propchange doesn't happen. # The hook program can use the 'svnlook' utility to examine the # existing value of the revision property. # # WARNING: unlike other hooks, this hook MUST exist for revision # properties to be changed. If the hook does not exist, Subversion # will behave as if the hook were present, but failed. The reason # for this is that revision properties are UNVERSIONED, meaning that # a successful propchange is destructive; the old value is gone # forever. We recommend the hook back up the old value somewhere. # # On a Unix system, the normal procedure is to have 'pre-revprop-change' # invoke other programs to do the real work, though it may do the # work itself too. # # Note that 'pre-revprop-change' must be executable by the user(s) who will # invoke it (typically the user httpd runs as), and that user must # have filesystem-level permission to access the repository. # # On a Windows system, you should name the hook program # 'pre-revprop-change.bat' or 'pre-revprop-change.exe', # but the basic idea is the same. # # The hook program typically does not inherit the environment of # its parent process. For example, a common problem is for the # PATH environment variable to not be set to its usual value, so # that subprograms fail to launch unless invoked via absolute path. # If you're having unexpected problems with a hook program, the # culprit may be unusual (or missing) environment variables. # # Here is an example hook script, for a Unix /bin/sh interpreter.# For more examples and pre-written hooks, see those in # the Subversion repository at # http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and # http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/ REPOS="$1" REV="$2" USER="$3" PROPNAME="$4" ACTION="$5" if [ "$ACTION" = "M" -a "$PROPNAME" = "svn:log" ]; then exit 0; fi echo "Changing revision properties other than svn:log is prohibited" >&2 exit 1 wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/hooks/start-commit.tmpl0000644000175000017500000000421510401652050032547 0ustar twernertwerner#!/bin/sh # START-COMMIT HOOK # # The start-commit hook is invoked before a Subversion txn is created # in the process of doing a commit. Subversion runs this hook # by invoking a program (script, executable, binary, etc.) named # 'start-commit' (for which this file is a template) # with the following ordered arguments: # # [1] REPOS-PATH (the path to this repository) # [2] USER (the authenticated user attempting to commit) # # The default working directory for the invocation is undefined, so # the program should set one explicitly if it cares. # # If the hook program exits with success, the commit continues; but # if it exits with failure (non-zero), the commit is stopped before # a Subversion txn is created, and STDERR is returned to the client. # # On a Unix system, the normal procedure is to have 'start-commit' # invoke other programs to do the real work, though it may do the # work itself too. # # Note that 'start-commit' must be executable by the user(s) who will # invoke it (typically the user httpd runs as), and that user must # have filesystem-level permission to access the repository. # # On a Windows system, you should name the hook program # 'start-commit.bat' or 'start-commit.exe', # but the basic idea is the same. # # The hook program typically does not inherit the environment of # its parent process. For example, a common problem is for the # PATH environment variable to not be set to its usual value, so # that subprograms fail to launch unless invoked via absolute path. # If you're having unexpected problems with a hook program, the # culprit may be unusual (or missing) environment variables. # # Here is an example hook script, for a Unix /bin/sh interpreter.# For more examples and pre-written hooks, see those in # the Subversion repository at # http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and # http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/ REPOS="$1" USER="$2" commit-allower.pl --repository "$REPOS" --user "$USER" || exit 1 special-auth-check.py --user "$USER" --auth-level 3 || exit 1 # All checks passed, so allow the commit. exit 0 wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/hooks/pre-unlock.tmpl0000644000175000017500000000400610401652050032201 0ustar twernertwerner#!/bin/sh # PRE-UNLOCK HOOK # # The pre-unlock hook is invoked before an exclusive lock is # destroyed. Subversion runs this hook by invoking a program # (script, executable, binary, etc.) named 'pre-unlock' (for which # this file is a template), with the following ordered arguments: # # [1] REPOS-PATH (the path to this repository) # [2] PATH (the path in the repository about to be unlocked) # [3] USER (the user destroying the lock) # # The default working directory for the invocation is undefined, so # the program should set one explicitly if it cares. # # If the hook program exits with success, the lock is destroyed; but # if it exits with failure (non-zero), the unlock action is aborted # and STDERR is returned to the client. # On a Unix system, the normal procedure is to have 'pre-unlock' # invoke other programs to do the real work, though it may do the # work itself too. # # Note that 'pre-unlock' must be executable by the user(s) who will # invoke it (typically the user httpd runs as), and that user must # have filesystem-level permission to access the repository. # # On a Windows system, you should name the hook program # 'pre-unlock.bat' or 'pre-unlock.exe', # but the basic idea is the same. # # Here is an example hook script, for a Unix /bin/sh interpreter: REPOS="$1" PATH="$2" USER="$3" # If a lock is owned by a different person, don't allow it be broken. # (Maybe this script could send email to the to the lock owner?) SVNLOOK=/usr/local/bin/svnlook GREP=/bin/grep SED=/bin/sed LOCK_OWNER=`$SVNLOOK lock "$REPOS" "$PATH" | \ $GREP '^Owner: ' | $SED 's/Owner: //'` # If we get no result from svnlook, there's no lock, return success: if [ "$LOCK_OWNER" == "" ]; then exit 0 fi # If the person unlocking matches the lock's owner, return success: if [ "$LOCK_OWNER" == "$USER" ]; then exit 0 fi # Otherwise, we've got an owner mismatch, so return failure: echo "Error: $PATH locked by ${LOCK_OWNER}." 1>&2 exit 1 wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/hooks/pre-lock.tmpl0000644000175000017500000000404010401652050031634 0ustar twernertwerner#!/bin/sh # PRE-LOCK HOOK # # The pre-lock hook is invoked before an exclusive lock is # created. Subversion runs this hook by invoking a program # (script, executable, binary, etc.) named 'pre-lock' (for which # this file is a template), with the following ordered arguments: # # [1] REPOS-PATH (the path to this repository) # [2] PATH (the path in the repository about to be locked) # [3] USER (the user creating the lock) # # The default working directory for the invocation is undefined, so # the program should set one explicitly if it cares. # # If the hook program exits with success, the lock is created; but # if it exits with failure (non-zero), the lock action is aborted # and STDERR is returned to the client. # On a Unix system, the normal procedure is to have 'pre-lock' # invoke other programs to do the real work, though it may do the # work itself too. # # Note that 'pre-lock' must be executable by the user(s) who will # invoke it (typically the user httpd runs as), and that user must # have filesystem-level permission to access the repository. # # On a Windows system, you should name the hook program # 'pre-lock.bat' or 'pre-lock.exe', # but the basic idea is the same. # # Here is an example hook script, for a Unix /bin/sh interpreter: REPOS="$1" PATH="$2" USER="$3" # If a lock exists and is owned by a different person, don't allow it # to be broken. # (Maybe this script could send email to the to the lock owner?) SVNLOOK=/usr/local/bin/svnlook GREP=/bin/grep SED=/bin/sed LOCK_OWNER=`$SVNLOOK lock "$REPOS" "$PATH" | \ $GREP '^Owner:' | $SED 's/Owner: //'` # If we get no result from svnlook, there's no lock, allow the lock to # happen: if [ "$LOCK_OWNER" == "" ]; then exit 0 fi # If the person locking matches the lock's owner, allow the lock to # happen: if [ "$LOCK_OWNER" == "$USER" ]; then exit 0 fi # Otherwise, we've got an owner mismatch, so return failure: echo "Error: $PATH already locked by ${LOCK_OWNER}." 1>&2 exit 1 wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/hooks/post-lock.tmpl0000644000175000017500000000317310401652050032041 0ustar twernertwerner#!/bin/sh # POST-LOCK HOOK # # The post-lock hook is run after a path is locked. Subversion runs # this hook by invoking a program (script, executable, binary, etc.) # named 'post-lock' (for which this file is a template) with the # following ordered arguments: # # [1] REPOS-PATH (the path to this repository) # [2] USER (the user who created the lock) # # The paths that were just locked are passed to the hook via STDIN (As # of Subversion 1.2, only one path is passed per invocation, but the # plan is to pass all locked paths at once in Subversion 1.3 and # later). # # The default working directory for the invocation is undefined, so # the program should set one explicitly if it cares. # # Because the lock has already been created and cannot be undone, # the exit code of the hook program is ignored. The hook program # can use the 'svnlook' utility to help it examine the # newly-created lock. # # On a Unix system, the normal procedure is to have 'post-lock' # invoke other programs to do the real work, though it may do the # work itself too. # # Note that 'post-lock' must be executable by the user(s) who will # invoke it (typically the user httpd runs as), and that user must # have filesystem-level permission to access the repository. # # On a Windows system, you should name the hook program # 'post-lock.bat' or 'post-lock.exe', # but the basic idea is the same. # # Here is an example hook script, for a Unix /bin/sh interpreter: REPOS="$1" USER="$2" # Send email to interested parties, let them know a lock was created: mailer.py lock "$REPOS" "$USER" /path/to/mailer.conf ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/hooks/post-revprop-change.tmplwagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/hooks/post-revprop-change.tmp0000644000175000017500000000440510401652050033654 0ustar twernertwerner#!/bin/sh # POST-REVPROP-CHANGE HOOK # # The post-revprop-change hook is invoked after a revision property # has been added, modified or deleted. Subversion runs this hook by # invoking a program (script, executable, binary, etc.) named # 'post-revprop-change' (for which this file is a template), with the # following ordered arguments: # # [1] REPOS-PATH (the path to this repository) # [2] REV (the revision that was tweaked) # [3] USER (the username of the person tweaking the property) # [4] PROPNAME (the property that was changed) # [5] ACTION (the property was 'A'dded, 'M'odified, or 'D'eleted) # # [STDIN] PROPVAL ** the old property value is passed via STDIN. # # Because the propchange has already completed and cannot be undone, # the exit code of the hook program is ignored. The hook program # can use the 'svnlook' utility to help it examine the # new property value. # # On a Unix system, the normal procedure is to have 'post-revprop-change' # invoke other programs to do the real work, though it may do the # work itself too. # # Note that 'post-revprop-change' must be executable by the user(s) who will # invoke it (typically the user httpd runs as), and that user must # have filesystem-level permission to access the repository. # # On a Windows system, you should name the hook program # 'post-revprop-change.bat' or 'post-revprop-change.exe', # but the basic idea is the same. # # The hook program typically does not inherit the environment of # its parent process. For example, a common problem is for the # PATH environment variable to not be set to its usual value, so # that subprograms fail to launch unless invoked via absolute path. # If you're having unexpected problems with a hook program, the # culprit may be unusual (or missing) environment variables. # # Here is an example hook script, for a Unix /bin/sh interpreter.# For more examples and pre-written hooks, see those in # the Subversion repository at # http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and # http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/ REPOS="$1" REV="$2" USER="$3" PROPNAME="$4" ACTION="$5" propchange-email.pl "$REPOS" "$REV" "$USER" "$PROPNAME" watchers@example.org wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/hooks/post-unlock.tmpl0000644000175000017500000000306010401652050032377 0ustar twernertwerner#!/bin/sh # POST-UNLOCK HOOK # # The post-unlock hook runs after a path is unlocked. Subversion runs # this hook by invoking a program (script, executable, binary, etc.) # named 'post-unlock' (for which this file is a template) with the # following ordered arguments: # # [1] REPOS-PATH (the path to this repository) # [2] USER (the user who destroyed the lock) # # The paths that were just unlocked are passed to the hook via STDIN # (As of Subversion 1.2, only one path is passed per invocation, but # the plan is to pass all locked paths at once in Subversion 1.3 and # later). # # The default working directory for the invocation is undefined, so # the program should set one explicitly if it cares. # # Because the lock has already been destroyed and cannot be undone, # the exit code of the hook program is ignored. # # On a Unix system, the normal procedure is to have 'post-unlock' # invoke other programs to do the real work, though it may do the # work itself too. # # Note that 'post-unlock' must be executable by the user(s) who will # invoke it (typically the user httpd runs as), and that user must # have filesystem-level permission to access the repository. # # On a Windows system, you should name the hook program # 'post-unlock.bat' or 'post-unlock.exe', # but the basic idea is the same. # # Here is an example hook script, for a Unix /bin/sh interpreter: REPOS="$1" USER="$2" # Send email to interested parties, let them know a lock was removed: mailer.py unlock "$REPOS" "$USER" /path/to/mailer.conf wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/hooks/post-commit.tmpl0000644000175000017500000000402010401652050032371 0ustar twernertwerner#!/bin/sh # POST-COMMIT HOOK # # The post-commit hook is invoked after a commit. Subversion runs # this hook by invoking a program (script, executable, binary, etc.) # named 'post-commit' (for which this file is a template) with the # following ordered arguments: # # [1] REPOS-PATH (the path to this repository) # [2] REV (the number of the revision just committed) # # The default working directory for the invocation is undefined, so # the program should set one explicitly if it cares. # # Because the commit has already completed and cannot be undone, # the exit code of the hook program is ignored. The hook program # can use the 'svnlook' utility to help it examine the # newly-committed tree. # # On a Unix system, the normal procedure is to have 'post-commit' # invoke other programs to do the real work, though it may do the # work itself too. # # Note that 'post-commit' must be executable by the user(s) who will # invoke it (typically the user httpd runs as), and that user must # have filesystem-level permission to access the repository. # # On a Windows system, you should name the hook program # 'post-commit.bat' or 'post-commit.exe', # but the basic idea is the same. # # The hook program typically does not inherit the environment of # its parent process. For example, a common problem is for the # PATH environment variable to not be set to its usual value, so # that subprograms fail to launch unless invoked via absolute path. # If you're having unexpected problems with a hook program, the # culprit may be unusual (or missing) environment variables. # # Here is an example hook script, for a Unix /bin/sh interpreter.# For more examples and pre-written hooks, see those in # the Subversion repository at # http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and # http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/ REPOS="$1" REV="$2" commit-email.pl "$REPOS" "$REV" commit-watchers@example.org log-commit.py --repository "$REPOS" --revision "$REV" wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/hooks/pre-commit.tmpl0000644000175000017500000000570010401652050032200 0ustar twernertwerner#!/bin/sh # PRE-COMMIT HOOK # # The pre-commit hook is invoked before a Subversion txn is # committed. Subversion runs this hook by invoking a program # (script, executable, binary, etc.) named 'pre-commit' (for which # this file is a template), with the following ordered arguments: # # [1] REPOS-PATH (the path to this repository) # [2] TXN-NAME (the name of the txn about to be committed) # # The default working directory for the invocation is undefined, so # the program should set one explicitly if it cares. # # If the hook program exits with success, the txn is committed; but # if it exits with failure (non-zero), the txn is aborted, no commit # takes place, and STDERR is returned to the client. The hook # program can use the 'svnlook' utility to help it examine the txn. # # On a Unix system, the normal procedure is to have 'pre-commit' # invoke other programs to do the real work, though it may do the # work itself too. # # *** NOTE: THE HOOK PROGRAM MUST NOT MODIFY THE TXN, EXCEPT *** # *** FOR REVISION PROPERTIES (like svn:log or svn:author). *** # # This is why we recommend using the read-only 'svnlook' utility. # In the future, Subversion may enforce the rule that pre-commit # hooks should not modify the versioned data in txns, or else come # up with a mechanism to make it safe to do so (by informing the # committing client of the changes). However, right now neither # mechanism is implemented, so hook writers just have to be careful. # # Note that 'pre-commit' must be executable by the user(s) who will # invoke it (typically the user httpd runs as), and that user must # have filesystem-level permission to access the repository. # # On a Windows system, you should name the hook program # 'pre-commit.bat' or 'pre-commit.exe', # but the basic idea is the same. # # The hook program typically does not inherit the environment of # its parent process. For example, a common problem is for the # PATH environment variable to not be set to its usual value, so # that subprograms fail to launch unless invoked via absolute path. # If you're having unexpected problems with a hook program, the # culprit may be unusual (or missing) environment variables. # # Here is an example hook script, for a Unix /bin/sh interpreter.# For more examples and pre-written hooks, see those in # the Subversion repository at # http://svn.collab.net/repos/svn/trunk/tools/hook-scripts/ and # http://svn.collab.net/repos/svn/trunk/contrib/hook-scripts/ REPOS="$1" TXN="$2" # Make sure that the log message contains some text. SVNLOOK=/usr/local/bin/svnlook $SVNLOOK log -t "$TXN" "$REPOS" | \ grep "[a-zA-Z0-9]" > /dev/null || exit 1 # Check that the author of this commit has the rights to perform # the commit on the files and directories being modified. commit-access-control.pl "$REPOS" "$TXN" commit-access-control.cfg || exit 1 # All checks passed, so allow the commit. exit 0 wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/db/0000755000175000017500000000000011630374113026474 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/db/revs/0000755000175000017500000000000011630374113027453 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/db/revs/00000644000175000017500000000016310401652050027527 0ustar twernertwernerPLAIN END ENDREP id: 0.0.r0/17 type: dir count: 0 text: 0 0 4 4 2d2977d1c96f487abe4a1e202dd03b4e cpath: / 17 107 wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/db/revs/10000644000175000017500000000052510401652050027532 0ustar twernertwernerDELTA SVNENDREP id: 1.0.r1/17 type: file count: 0 text: 1 0 4 0 d41d8cd98f00b204e9800998ecf8427e cpath: /dummy copyroot: 0 / PLAIN K 5 dummy V 14 file 1.0.r1/17 END ENDREP id: 0.0.r1/174 type: dir pred: 0.0.r0/17 count: 1 text: 1 127 34 34 23813f82a26f6a67845220c645224804 cpath: / copyroot: 0 / _0.0.t0-1 add true false /dummy 174 299 wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/db/uuid0000644000175000017500000000004510401652050027356 0ustar twernertwernerfe5fe0df-68a9-3845-91cb-06e0404f9739 wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/db/revprops/0000755000175000017500000000000011630374113030354 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/db/revprops/00000644000175000017500000000006210401652050030426 0ustar twernertwernerK 8 svn:date V 27 2006-03-02T20:00:40.203125Z END wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/db/revprops/10000644000175000017500000000016110401652050030427 0ustar twernertwernerK 10 svn:author V 8 csanchez K 8 svn:date V 27 2006-03-02T20:17:31.906250Z K 7 svn:log V 16 Added dummy file END wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/db/current0000644000175000017500000000000610401652050030067 0ustar twernertwerner1 2 1 wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/db/transactions/0000755000175000017500000000000011630374113031204 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/db/transactions/README.txt0000644000175000017500000000013411015033162032671 0ustar twernertwernerFile required to get the folder copied to target/test-classes (empty folders are not copied)wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/db/write-lock0000644000175000017500000000000010401652050030457 0ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/db/fs-type0000644000175000017500000000000510401652050027773 0ustar twernertwernerfsfs wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/db/format0000644000175000017500000000000210401652050027671 0ustar twernertwerner1 wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/conf/0000755000175000017500000000000011630374113027034 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/conf/svnserve.conf0000644000175000017500000000211510401652050031547 0ustar twernertwerner### This file controls the configuration of the svnserve daemon, if you ### use it to allow access to this repository. (If you only allow ### access through http: and/or file: URLs, then this file is ### irrelevant.) ### Visit http://subversion.tigris.org/ for more information. # [general] ### These options control access to the repository for unauthenticated ### and authenticated users. Valid values are "write", "read", ### and "none". The sample settings below are the defaults. # anon-access = read # auth-access = write ### The password-db option controls the location of the password ### database file. Unless you specify a path starting with a /, ### the file's location is relative to the conf directory. ### Uncomment the line below to use the default password file. # password-db = passwd ### This option specifies the authentication realm of the repository. ### If two repositories have the same authentication realm, they should ### have the same password database, and vice versa. The default realm ### is repository's uuid. # realm = My First Repository wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/conf/passwd0000644000175000017500000000047710401652050030262 0ustar twernertwerner### This file is an example password file for svnserve. ### Its format is similar to that of svnserve.conf. As shown in the ### example below it contains one section labelled [users]. ### The name and password for each user follow, one account per line. # [users] # harry = harryssecret # sally = sallyssecret wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/locks/0000755000175000017500000000000011630374113027222 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/locks/db-logs.lock0000644000175000017500000000044710401652050031422 0ustar twernertwernerDB logs lock file, representing locks on the versioned filesystem logs. All log manipulators of the repository's Berkeley DB environment take out exclusive locks on this file to ensure that only one accessor manupulates the logs at the time. You should never have to edit or remove this file. wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/locks/db.lock0000644000175000017500000000071410401652050030455 0ustar twernertwernerDB lock file, representing locks on the versioned filesystem. All accessors -- both readers and writers -- of the repository's Berkeley DB environment take out shared locks on this file, and each accessor removes its lock when done. If and when the DB recovery procedure is run, the recovery code takes out an exclusive lock on this file, so we can be sure no one else is using the DB during the recovery. You should never have to edit or remove this file. wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/dav/0000755000175000017500000000000011630374113026661 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-svn/format0000644000175000017500000000000210401652050027304 0ustar twernertwerner3 wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/0000755000175000017500000000000011630374113026074 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/CVSROOT/0000755000175000017500000000000011630374113027233 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/CVSROOT/commitinfo,v0000644000175000017500000000170110234336416031566 0ustar twernertwernerhead 1.1; access ; symbols ; locks ; strict; comment @# @; 1.1 date 2005.04.29.04.12.38; author Brett; state Exp; branches; next ; desc @@ 1.1 log @initial checkin@ text @# The "commitinfo" file is used to control pre-commit checks. # The filter on the right is invoked with the repository and a list # of files to check. A non-zero exit of the filter program will # cause the commit to be aborted. # # The first entry on a line is a regular expression which is tested # against the directory that the change is being committed to, relative # to the $CVSROOT. For the first match that is found, then the remainder # of the line is the name of the filter to run. # # If the repository name does not match any of the regular expressions in this # file, the "DEFAULT" line is used, if it is specified. # # If the name "ALL" appears as a regular expression it is always used # in addition to the first matching regex or "DEFAULT". @ wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/CVSROOT/modules0000644000175000017500000000217710234336416030640 0ustar twernertwerner# Three different line formats are valid: # key -a aliases... # key [options] directory # key [options] directory files... # # Where "options" are composed of: # -i prog Run "prog" on "cvs commit" from top-level of module. # -o prog Run "prog" on "cvs checkout" of module. # -e prog Run "prog" on "cvs export" of module. # -t prog Run "prog" on "cvs rtag" of module. # -u prog Run "prog" on "cvs update" of module. # -d dir Place module in directory "dir" instead of module name. # -l Top-level directory only -- do not recurse. # # NOTE: If you change any of the "Run" options above, you'll have to # release and re-checkout any working directories of these modules. # # And "directory" is a path to a directory relative to $CVSROOT. # # The "-a" option specifies an alias. An alias is interpreted as if # everything on the right of the "-a" had been typed on the command line. # # You can encode a module within a module by using the special '&' # character to interpose another module into the current module. This # can be useful for creating a module that consists of many directories # spread out over the entire source repository. wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/CVSROOT/verifymsg,v0000644000175000017500000000231310234336416031435 0ustar twernertwernerhead 1.1; access ; symbols ; locks ; strict; comment @# @; 1.1 date 2005.04.29.04.12.38; author Brett; state Exp; branches; next ; desc @@ 1.1 log @initial checkin@ text @# The "verifymsg" file is used to allow verification of logging # information. It works best when a template (as specified in the # rcsinfo file) is provided for the logging procedure. Given a # template with locations for, a bug-id number, a list of people who # reviewed the code before it can be checked in, and an external # process to catalog the differences that were code reviewed, the # following test can be applied to the code: # # Making sure that the entered bug-id number is correct. # Validating that the code that was reviewed is indeed the code being # checked in (using the bug-id number or a seperate review # number to identify this particular code set.). # # If any of the above test failed, then the commit would be aborted. # # Actions such as mailing a copy of the report to each reviewer are # better handled by an entry in the loginfo file. # # One thing that should be noted is the the ALL keyword is not # supported. There can be only one entry that matches a given # repository. @ wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/CVSROOT/modules,v0000644000175000017500000000251010234336416031071 0ustar twernertwernerhead 1.1; access ; symbols ; locks ; strict; comment @# @; 1.1 date 2005.04.29.04.12.38; author Brett; state Exp; branches; next ; desc @@ 1.1 log @initial checkin@ text @# Three different line formats are valid: # key -a aliases... # key [options] directory # key [options] directory files... # # Where "options" are composed of: # -i prog Run "prog" on "cvs commit" from top-level of module. # -o prog Run "prog" on "cvs checkout" of module. # -e prog Run "prog" on "cvs export" of module. # -t prog Run "prog" on "cvs rtag" of module. # -u prog Run "prog" on "cvs update" of module. # -d dir Place module in directory "dir" instead of module name. # -l Top-level directory only -- do not recurse. # # NOTE: If you change any of the "Run" options above, you'll have to # release and re-checkout any working directories of these modules. # # And "directory" is a path to a directory relative to $CVSROOT. # # The "-a" option specifies an alias. An alias is interpreted as if # everything on the right of the "-a" had been typed on the command line. # # You can encode a module within a module by using the special '&' # character to interpose another module into the current module. This # can be useful for creating a module that consists of many directories # spread out over the entire source repository. @ wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/CVSROOT/taginfo,v0000644000175000017500000000207010234336416031051 0ustar twernertwernerhead 1.1; access ; symbols ; locks ; strict; comment @# @; 1.1 date 2005.04.29.04.12.38; author Brett; state Exp; branches; next ; desc @@ 1.1 log @initial checkin@ text @# The "taginfo" file is used to control pre-tag checks. # The filter on the right is invoked with the following arguments: # # $1 -- tagname # $2 -- operation "add" for tag, "mov" for tag -F, and "del" for tag -d # $3 -- repository # $4-> file revision [file revision ...] # # A non-zero exit of the filter program will cause the tag to be aborted. # # The first entry on a line is a regular expression which is tested # against the directory that the change is being committed to, relative # to the $CVSROOT. For the first match that is found, then the remainder # of the line is the name of the filter to run. # # If the repository name does not match any of the regular expressions in this # file, the "DEFAULT" line is used, if it is specified. # # If the name "ALL" appears as a regular expression it is always used # in addition to the first matching regex or "DEFAULT". @ wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/CVSROOT/Emptydir/0000755000175000017500000000000011630374113031030 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/CVSROOT/cvswrappers0000644000175000017500000000113210234336416031535 0ustar twernertwerner# This file affects handling of files based on their names. # # The -m option specifies whether CVS attempts to merge files. # # The -k option specifies keyword expansion (e.g. -kb for binary). # # Format of wrapper file ($CVSROOT/CVSROOT/cvswrappers or .cvswrappers) # # wildcard [option value][option value]... # # where option is one of # -f from cvs filter value: path to filter # -t to cvs filter value: path to filter # -m update methodology value: MERGE or COPY # -k expansion mode value: b, o, kkv, &c # # and value is a single-quote delimited value. # For example: #*.gif -k 'b' wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/CVSROOT/editinfo0000644000175000017500000000200110234336416030753 0ustar twernertwerner# The "editinfo" file is used to allow verification of logging # information. It works best when a template (as specified in the # rcsinfo file) is provided for the logging procedure. Given a # template with locations for, a bug-id number, a list of people who # reviewed the code before it can be checked in, and an external # process to catalog the differences that were code reviewed, the # following test can be applied to the code: # # Making sure that the entered bug-id number is correct. # Validating that the code that was reviewed is indeed the code being # checked in (using the bug-id number or a seperate review # number to identify this particular code set.). # # If any of the above test failed, then the commit would be aborted. # # Actions such as mailing a copy of the report to each reviewer are # better handled by an entry in the loginfo file. # # One thing that should be noted is the the ALL keyword is not # supported. There can be only one entry that matches a given # repository. wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/CVSROOT/checkoutlist,v0000644000175000017500000000127010234336416032124 0ustar twernertwernerhead 1.1; access ; symbols ; locks ; strict; comment @# @; 1.1 date 2005.04.29.04.12.38; author Brett; state Exp; branches; next ; desc @@ 1.1 log @initial checkin@ text @# The "checkoutlist" file is used to support additional version controlled # administrative files in $CVSROOT/CVSROOT, such as template files. # # The first entry on a line is a filename which will be checked out from # the corresponding RCS file in the $CVSROOT/CVSROOT directory. # The remainder of the line is an error message to use if the file cannot # be checked out. # # File format: # # [][] # # comment lines begin with '#' @ wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/CVSROOT/config0000644000175000017500000000173710234336416030436 0ustar twernertwerner# Set this to "no" if pserver shouldn't check system users/passwords #SystemAuth=no # Put CVS lock files in this directory rather than directly in the repository. #LockDir=/var/lock/cvs # Set `TopLevelAdmin' to `yes' to create a CVS directory at the top # level of the new working directory when using the `cvs checkout' # command. #TopLevelAdmin=no # Set `LogHistory' to `all' or `TOEFWUPCGMAR' to log all transactions to the # history file, or a subset as needed (ie `TMAR' logs all write operations) #LogHistory=TOEFWUPCGMAR # Set `RereadLogAfterVerify' to `always' (the default) to allow the verifymsg # script to change the log message. Set it to `stat' to force CVS to verify# that the file has changed before reading it (this can take up to an extra # second per directory being committed, so it is not recommended for large # repositories. Set it to `never' (the previous CVS behavior) to prevent # verifymsg scripts from changing the log message. #RereadLogAfterVerify=always wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/CVSROOT/notify0000644000175000017500000000106410234336416030472 0ustar twernertwerner# The "notify" file controls where notifications from watches set by # "cvs watch add" or "cvs edit" are sent. The first entry on a line is # a regular expression which is tested against the directory that the # change is being made to, relative to the $CVSROOT. If it matches, # then the remainder of the line is a filter program that should contain # one occurrence of %s for the user to notify, and information on its # standard input. # # "ALL" or "DEFAULT" can be used in place of the regular expression. # # For example: #ALL mail -s "CVS notification" %s wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/CVSROOT/verifymsg0000644000175000017500000000200210234336416031166 0ustar twernertwerner# The "verifymsg" file is used to allow verification of logging # information. It works best when a template (as specified in the # rcsinfo file) is provided for the logging procedure. Given a # template with locations for, a bug-id number, a list of people who # reviewed the code before it can be checked in, and an external # process to catalog the differences that were code reviewed, the # following test can be applied to the code: # # Making sure that the entered bug-id number is correct. # Validating that the code that was reviewed is indeed the code being # checked in (using the bug-id number or a seperate review # number to identify this particular code set.). # # If any of the above test failed, then the commit would be aborted. # # Actions such as mailing a copy of the report to each reviewer are # better handled by an entry in the loginfo file. # # One thing that should be noted is the the ALL keyword is not # supported. There can be only one entry that matches a given # repository. wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/CVSROOT/commitinfo0000644000175000017500000000137010234336416031326 0ustar twernertwerner# The "commitinfo" file is used to control pre-commit checks. # The filter on the right is invoked with the repository and a list # of files to check. A non-zero exit of the filter program will # cause the commit to be aborted. # # The first entry on a line is a regular expression which is tested # against the directory that the change is being committed to, relative # to the $CVSROOT. For the first match that is found, then the remainder # of the line is the name of the filter to run. # # If the repository name does not match any of the regular expressions in this # file, the "DEFAULT" line is used, if it is specified. # # If the name "ALL" appears as a regular expression it is always used # in addition to the first matching regex or "DEFAULT". wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/CVSROOT/val-tags.db0000644000175000017500000000000010234336416031251 0ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/CVSROOT/rcsinfo,v0000644000175000017500000000152210234336416031066 0ustar twernertwernerhead 1.1; access ; symbols ; locks ; strict; comment @# @; 1.1 date 2005.04.29.04.12.38; author Brett; state Exp; branches; next ; desc @@ 1.1 log @initial checkin@ text @# The "rcsinfo" file is used to control templates with which the editor # is invoked on commit and import. # # The first entry on a line is a regular expression which is tested # against the directory that the change is being made to, relative to the # $CVSROOT. For the first match that is found, then the remainder of the # line is the name of the file that contains the template. # # If the repository name does not match any of the regular expressions in this # file, the "DEFAULT" line is used, if it is specified. # # If the name "ALL" appears as a regular expression it is always used # in addition to the first matching regex or "DEFAULT". @ wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/CVSROOT/modules.db0000644000175000017500000000600010234336416031211 0ustar twernertwernerΚW&<Íy—[Úêí*¼ îÍy—[Úêí*¼ d$ŸÍy—[Úêí*¼ î$ŸÍy—[Úêí*¼ ‰É Ù ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿwagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/CVSROOT/rcsinfo0000644000175000017500000000121110234336416030617 0ustar twernertwerner# The "rcsinfo" file is used to control templates with which the editor # is invoked on commit and import. # # The first entry on a line is a regular expression which is tested # against the directory that the change is being made to, relative to the # $CVSROOT. For the first match that is found, then the remainder of the # line is the name of the file that contains the template. # # If the repository name does not match any of the regular expressions in this # file, the "DEFAULT" line is used, if it is specified. # # If the name "ALL" appears as a regular expression it is always used # in addition to the first matching regex or "DEFAULT". wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/CVSROOT/loginfo0000644000175000017500000000216510234336416030622 0ustar twernertwerner# The "loginfo" file controls where "cvs commit" log information # is sent. The first entry on a line is a regular expression which must match # the directory that the change is being made to, relative to the # $CVSROOT. If a match is found, then the remainder of the line is a filter # program that should expect log information on its standard input. # # If the repository name does not match any of the regular expressions in this # file, the "DEFAULT" line is used, if it is specified. # # If the name ALL appears as a regular expression it is always used # in addition to the first matching regex or DEFAULT. # # You may specify a format string as part of the # filter. The string is composed of a `%' followed # by a single format character, or followed by a set of format # characters surrounded by `{' and `}' as separators. The format # characters are: # # s = file name # V = old version number (pre-checkin) # v = new version number (post-checkin) # # For example: #DEFAULT (echo ""; id; echo %s; date; cat) >> $CVSROOT/CVSROOT/commitlog # or #DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/CVSROOT/checkoutlist0000644000175000017500000000075710234336416031673 0ustar twernertwerner# The "checkoutlist" file is used to support additional version controlled # administrative files in $CVSROOT/CVSROOT, such as template files. # # The first entry on a line is a filename which will be checked out from # the corresponding RCS file in the $CVSROOT/CVSROOT directory. # The remainder of the line is an error message to use if the file cannot # be checked out. # # File format: # # [][] # # comment lines begin with '#' wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/CVSROOT/config,v0000644000175000017500000000225010234336416030667 0ustar twernertwernerhead 1.1; access ; symbols ; locks ; strict; comment @# @; 1.1 date 2005.04.29.04.12.38; author Brett; state Exp; branches; next ; desc @@ 1.1 log @initial checkin@ text @# Set this to "no" if pserver shouldn't check system users/passwords #SystemAuth=no # Put CVS lock files in this directory rather than directly in the repository. #LockDir=/var/lock/cvs # Set `TopLevelAdmin' to `yes' to create a CVS directory at the top # level of the new working directory when using the `cvs checkout' # command. #TopLevelAdmin=no # Set `LogHistory' to `all' or `TOEFWUPCGMAR' to log all transactions to the # history file, or a subset as needed (ie `TMAR' logs all write operations) #LogHistory=TOEFWUPCGMAR # Set `RereadLogAfterVerify' to `always' (the default) to allow the verifymsg # script to change the log message. Set it to `stat' to force CVS to verify# that the file has changed before reading it (this can take up to an extra # second per directory being committed, so it is not recommended for large # repositories. Set it to `never' (the previous CVS behavior) to prevent # verifymsg scripts from changing the log message. #RereadLogAfterVerify=always @ wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/CVSROOT/cvswrappers,v0000644000175000017500000000144310234336416032004 0ustar twernertwernerhead 1.1; access ; symbols ; locks ; strict; comment @# @; 1.1 date 2005.04.29.04.12.38; author Brett; state Exp; branches; next ; desc @@ 1.1 log @initial checkin@ text @# This file affects handling of files based on their names. # # The -m option specifies whether CVS attempts to merge files. # # The -k option specifies keyword expansion (e.g. -kb for binary). # # Format of wrapper file ($CVSROOT/CVSROOT/cvswrappers or .cvswrappers) # # wildcard [option value][option value]... # # where option is one of # -f from cvs filter value: path to filter # -t to cvs filter value: path to filter # -m update methodology value: MERGE or COPY # -k expansion mode value: b, o, kkv, &c # # and value is a single-quote delimited value. # For example: #*.gif -k 'b' @ wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/CVSROOT/notify,v0000644000175000017500000000137510234336416030741 0ustar twernertwernerhead 1.1; access ; symbols ; locks ; strict; comment @# @; 1.1 date 2005.04.29.04.12.38; author Brett; state Exp; branches; next ; desc @@ 1.1 log @initial checkin@ text @# The "notify" file controls where notifications from watches set by # "cvs watch add" or "cvs edit" are sent. The first entry on a line is # a regular expression which is tested against the directory that the # change is being made to, relative to the $CVSROOT. If it matches, # then the remainder of the line is a filter program that should contain # one occurrence of %s for the user to notify, and information on its # standard input. # # "ALL" or "DEFAULT" can be used in place of the regular expression. # # For example: #ALL mail -s "CVS notification" %s @ wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/CVSROOT/history0000644000175000017500000000025610234336416030665 0ustar twernertwernerO4271ba0d|Brett|~/cvs/maven-2/wagon/wagon-providers/wagon-scm/*0|repository||repository A4271ba20|Brett|~/cvs/maven-2/wagon/wagon-providers/wagon-scm/*0|repository|1.1|dummy wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/CVSROOT/loginfo,v0000644000175000017500000000247610234336416031071 0ustar twernertwernerhead 1.1; access ; symbols ; locks ; strict; comment @# @; 1.1 date 2005.04.29.04.12.38; author Brett; state Exp; branches; next ; desc @@ 1.1 log @initial checkin@ text @# The "loginfo" file controls where "cvs commit" log information # is sent. The first entry on a line is a regular expression which must match # the directory that the change is being made to, relative to the # $CVSROOT. If a match is found, then the remainder of the line is a filter # program that should expect log information on its standard input. # # If the repository name does not match any of the regular expressions in this # file, the "DEFAULT" line is used, if it is specified. # # If the name ALL appears as a regular expression it is always used # in addition to the first matching regex or DEFAULT. # # You may specify a format string as part of the # filter. The string is composed of a `%' followed # by a single format character, or followed by a set of format # characters surrounded by `{' and `}' as separators. The format # characters are: # # s = file name # V = old version number (pre-checkin) # v = new version number (post-checkin) # # For example: #DEFAULT (echo ""; id; echo %s; date; cat) >> $CVSROOT/CVSROOT/commitlog # or #DEFAULT (echo ""; id; echo %{sVv}; date; cat) >> $CVSROOT/CVSROOT/commitlog @ wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/CVSROOT/editinfo,v0000644000175000017500000000231210234336416031222 0ustar twernertwernerhead 1.1; access ; symbols ; locks ; strict; comment @# @; 1.1 date 2005.04.29.04.12.38; author Brett; state Exp; branches; next ; desc @@ 1.1 log @initial checkin@ text @# The "editinfo" file is used to allow verification of logging # information. It works best when a template (as specified in the # rcsinfo file) is provided for the logging procedure. Given a # template with locations for, a bug-id number, a list of people who # reviewed the code before it can be checked in, and an external # process to catalog the differences that were code reviewed, the # following test can be applied to the code: # # Making sure that the entered bug-id number is correct. # Validating that the code that was reviewed is indeed the code being # checked in (using the bug-id number or a seperate review # number to identify this particular code set.). # # If any of the above test failed, then the commit would be aborted. # # Actions such as mailing a copy of the report to each reviewer are # better handled by an entry in the loginfo file. # # One thing that should be noted is the the ALL keyword is not # supported. There can be only one entry that matches a given # repository. @ wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/CVSROOT/taginfo0000644000175000017500000000155710234336416030620 0ustar twernertwerner# The "taginfo" file is used to control pre-tag checks. # The filter on the right is invoked with the following arguments: # # $1 -- tagname # $2 -- operation "add" for tag, "mov" for tag -F, and "del" for tag -d # $3 -- repository # $4-> file revision [file revision ...] # # A non-zero exit of the filter program will cause the tag to be aborted. # # The first entry on a line is a regular expression which is tested # against the directory that the change is being committed to, relative # to the $CVSROOT. For the first match that is found, then the remainder # of the line is the name of the filter to run. # # If the repository name does not match any of the regular expressions in this # file, the "DEFAULT" line is used, if it is specified. # # If the name "ALL" appears as a regular expression it is always used # in addition to the first matching regex or "DEFAULT". wagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/repository/0000755000175000017500000000000011630374113030313 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/test/resources/test-repo-cvs/repository/dummy,v0000644000175000017500000000025410234336416031637 0ustar twernertwernerhead 1.1; access; symbols; locks; strict; comment @# @; 1.1 date 2005.04.29.04.37.52; author Brett; state Exp; branches; next ; desc @@ 1.1 log @add a file @ text @@ wagon-1.0.0/wagon-providers/wagon-scm/src/test/java/0000755000175000017500000000000011630374113022270 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/test/java/org/0000755000175000017500000000000011630374113023057 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/test/java/org/apache/0000755000175000017500000000000011630374113024300 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/test/java/org/apache/maven/0000755000175000017500000000000011630374113025406 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/0000755000175000017500000000000011630374113026521 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/0000755000175000017500000000000011630374113030536 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/0000755000175000017500000000000011630374113031320 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmWagonTest.javawagon-1.0.0/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScm0000644000175000017500000001054111015222713033445 0ustar twernertwernerpackage 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 java.io.IOException; import java.util.List; 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; /** * Test for {@link ScmWagon}. You need a subclass for each SCM provider you want to test. * * @author Carlos Sanchez * @version $Id: AbstractScmWagonTest.java 659032 2008-05-22 07:50:35Z brett $ */ 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 null {@link ScmWagon} will use the default {@link ScmProvider}. * * @return the {@link ScmProvider} to use in the {@link ScmWagon} */ protected ScmProvider getScmProvider() { return null; } 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. svn, cvs * * @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 resourceNames ) throws IOException, TransferFailedException, ResourceDoesNotExistException, AuthorizationException { FileUtils.deleteDirectory( getCheckoutDirectory() ); super.assertResourcesAreInRemoteSide( wagon, resourceNames ); } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmSvnWagonTest.javawagon-1.0.0/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScm0000644000175000017500000000425111020675550033455 0ustar twernertwernerpackage 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 Brett Porter * @version $Id: AbstractScmSvnWagonTest.java 662318 2008-06-02 04:47:36Z brett $ */ 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.indexOf( ":" ) >= 0 ) { 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; } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/ScmCvsExeWagonTest.javawagon-1.0.0/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/ScmCvsExeWa0000644000175000017500000000334611015033162033372 0ustar twernertwernerpackage 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 Carlos Sanchez * @version $Id: ScmCvsExeWagonTest.java 658720 2008-05-21 14:49:22Z bentmann $ */ 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 } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/ScmSvnExeWagonTest.javawagon-1.0.0/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/ScmSvnExeWa0000644000175000017500000000250211015033162033376 0ustar twernertwernerpackage 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 Carlos Sanchez * @version $Id: ScmSvnExeWagonTest.java 658720 2008-05-21 14:49:22Z bentmann $ */ public class ScmSvnExeWagonTest extends AbstractScmSvnWagonTest { protected ScmProvider getScmProvider() { return new SvnExeScmProvider(); } } ././@LongLink0000000000000000000000000000016600000000000011570 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScmCvsWagonTest.javawagon-1.0.0/wagon-providers/wagon-scm/src/test/java/org/apache/maven/wagon/providers/scm/AbstractScm0000644000175000017500000000272011015222713033445 0ustar twernertwernerpackage 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 Brett Porter * @version $Id: AbstractScmCvsWagonTest.java 659032 2008-05-22 07:50:35Z brett $ */ 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"; } } wagon-1.0.0/wagon-providers/wagon-scm/pom.xml0000644000175000017500000000524711605164037021132 0ustar twernertwerner 4.0.0 org.apache.maven.wagon wagon-providers 1.0 ../pom.xml wagon-scm Maven Wagon SCM Provider Wagon that gets and puts artifacts using a Source Control Management system org.apache.maven.scm maven-scm-api 1.0 org.apache.maven.scm maven-scm-manager-plexus 1.0 runtime org.apache.maven.scm maven-scm-test 1.0 test org.apache.maven.scm maven-scm-provider-cvsexe 1.0 test org.apache.maven.scm maven-scm-provider-svnexe 1.0 test maven-surefire-plugin **/*Cvs*.java wagon-1.0.0/wagon-providers/wagon-ftp/0000755000175000017500000000000011630374112017607 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ftp/src/0000755000175000017500000000000011630374112020376 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ftp/src/main/0000755000175000017500000000000011630374112021322 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ftp/src/main/resources/0000755000175000017500000000000011630374112023334 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ftp/src/main/java/0000755000175000017500000000000011630374112022243 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ftp/src/main/java/org/0000755000175000017500000000000011630374112023032 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ftp/src/main/java/org/apache/0000755000175000017500000000000011630374112024253 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ftp/src/main/java/org/apache/maven/0000755000175000017500000000000011630374112025361 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ftp/src/main/java/org/apache/maven/wagon/0000755000175000017500000000000011630374112026474 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ftp/src/main/java/org/apache/maven/wagon/providers/0000755000175000017500000000000011630374112030511 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ftp/src/main/java/org/apache/maven/wagon/providers/ftp/0000755000175000017500000000000011630374112031302 5ustar twernertwerner././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ftp/src/main/java/org/apache/maven/wagon/providers/ftp/FtpWagon.javawagon-1.0.0/wagon-providers/wagon-ftp/src/main/java/org/apache/maven/wagon/providers/ftp/FtpWagon.ja0000644000175000017500000005563511147166273033373 0ustar twernertwernerpackage 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 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; 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 org.codehaus.plexus.util.IOUtil; /** * FtpWagon * * @version $Id: FtpWagon.java 745732 2009-02-19 05:23:07Z brett $ * * @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; 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.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 ( int i = 0; i < dirs.length; i++ ) { boolean dirChanged = ftp.changeWorkingDirectory( dirs[i] ); if ( !dirChanged ) { // first, try to create it boolean success = ftp.makeDirectory( dirs[i] ); if ( success ) { if ( permissions != null && permissions.getGroup() != null ) { // ignore failures ftp.sendSiteCommand( "CHGRP " + permissions.getGroup() + " " + dirs[i] ); } if ( permissions != null && permissions.getDirectoryMode() != null ) { // ignore failures ftp.sendSiteCommand( "CHMOD " + permissions.getDirectoryMode() + " " + dirs[i] ); } dirChanged = ftp.changeWorkingDirectory( dirs[i] ); } } if ( !dirChanged ) { throw new TransferFailedException( "Unable to create directory " + dirs[i] ); } } // 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 ( int i = 0; i < dirs.length; i++ ) { boolean dirChanged = ftp.changeWorkingDirectory( dirs[i] ); if ( !dirChanged ) { String msg = "Resource " + resource + " not found. Directory " + dirs[i] + " 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 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 ret = new ArrayList(); for( int i=0; i < ftpFiles.length; i++ ) { String name = ftpFiles[i].getName(); if ( ftpFiles[i].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.FILE_STATUS_OK ) || ( 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() ) ) { throw new TransferFailedException( "Required directory: '" + getRepository().getBasedir() + "' " + "is missing" ); } } catch ( IOException e ) { throw new TransferFailedException( "Cannot change to root path " + getRepository().getBasedir() ); } 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 ( ftp.makeDirectory( fileName ) ) { 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 ) { } } String mode = permissions.getDirectoryMode(); if ( mode != null ) { try { ftp.sendSiteCommand( "CHMOD " + permissions.getDirectoryMode() ); } catch ( IOException e ) { } } } 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 ( int i = 0; i < files.length; i++ ) { if ( files[i].isDirectory() ) { ftpRecursivePut( files[i], files[i].getName() ); } } for ( int i = 0; i < files.length; i++ ) { if ( !files[i].isDirectory() ) { ftpRecursivePut( files[i], files[i].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 ) { } String mode = permissions.getFileMode(); if ( mode != null ) try { ftp.sendSiteCommand( "CHMOD " + permissions.getDirectoryMode() ); } catch ( IOException e ) { } } } 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 { IOUtil.close( sourceFileStream ); } } fireTransferDebug( "completed = " + sourceFile.getAbsolutePath() ); } } wagon-1.0.0/wagon-providers/wagon-ftp/src/site/0000755000175000017500000000000011630374112021342 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ftp/src/site/site.xml0000644000175000017500000000013211045135116023023 0ustar twernertwerner wagon-1.0.0/wagon-providers/wagon-ftp/src/site/apt/0000755000175000017500000000000011630374112022126 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ftp/src/site/apt/index.apt0000644000175000017500000000066311045136112023744 0ustar twernertwerner ------ Maven Wagon FTP ------ Carlos Sanchez ------ 2006-06-04 ------ Maven Wagon FTP This project 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 serverwagon-1.0.0/wagon-providers/wagon-ftp/src/test/0000755000175000017500000000000011630374112021355 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ftp/src/test/resources/0000755000175000017500000000000011630374112023367 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ftp/src/test/resources/org/0000755000175000017500000000000011630374112024156 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ftp/src/test/resources/org/apache/0000755000175000017500000000000011630374112025377 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ftp/src/test/resources/org/apache/maven/0000755000175000017500000000000011630374112026505 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ftp/src/test/resources/org/apache/maven/wagon/0000755000175000017500000000000011630374112027620 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ftp/src/test/resources/org/apache/maven/wagon/providers/0000755000175000017500000000000011630374112031635 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ftp/src/test/resources/org/apache/maven/wagon/providers/ftp/0000755000175000017500000000000011630374112032426 5ustar twernertwerner././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ftp/src/test/resources/org/apache/maven/wagon/providers/ftp/FtpWagonTest.xmlwagon-1.0.0/wagon-providers/wagon-ftp/src/test/resources/org/apache/maven/wagon/providers/ftp/FtpWag0000644000175000017500000001432410670157111033546 0ustar twernertwerner avalon avalon Avalon Lifecycle Handler org.apache.avalon.cornerstone.services.threads.ThreadManager org.apache.avalon.cornerstone.blocks.threads.DefaultThreadManager default 5 false 40 20 20 org.apache.avalon.cornerstone.services.connection.ConnectionManager org.apache.avalon.cornerstone.blocks.connection.DefaultConnectionManager org.apache.avalon.cornerstone.services.sockets.SocketManager org.apache.avalon.cornerstone.blocks.sockets.DefaultSocketManager org.apache.ftpserver.usermanager.UserManagerInterface org.apache.ftpserver.usermanager.PropertiesUserManager ${basedir}/target/test-output/ org.apache.ftpserver.ip.IpRestrictorInterface org.apache.ftpserver.ip.FileIpRestrictor ${basedir}/target/test-output/local-repository org.apache.ftpserver.interfaces.FtpServerInterface org.apache.ftpserver.FtpServerImpl localhost localhost false 10023 ${basedir}/target/test-output/local-repository wagon-1.0.0/wagon-providers/wagon-ftp/src/test/java/0000755000175000017500000000000011630374112022276 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ftp/src/test/java/org/0000755000175000017500000000000011630374112023065 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ftp/src/test/java/org/apache/0000755000175000017500000000000011630374112024306 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ftp/src/test/java/org/apache/maven/0000755000175000017500000000000011630374112025414 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ftp/src/test/java/org/apache/maven/wagon/0000755000175000017500000000000011630374112026527 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ftp/src/test/java/org/apache/maven/wagon/providers/0000755000175000017500000000000011630374112030544 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ftp/src/test/java/org/apache/maven/wagon/providers/ftp/0000755000175000017500000000000011630374112031335 5ustar twernertwerner././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ftp/src/test/java/org/apache/maven/wagon/providers/ftp/FtpWagonTest.javawagon-1.0.0/wagon-providers/wagon-ftp/src/test/java/org/apache/maven/wagon/providers/ftp/FtpWagonTes0000644000175000017500000000745011044055471033472 0ustar twernertwernerpackage 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 java.io.File; import org.apache.ftpserver.interfaces.FtpServerInterface; 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 org.codehaus.plexus.util.FileUtils; /** * @author Michal Maczka * @version $Id: FtpWagonTest.java 680997 2008-07-30 12:14:49Z brett $ */ public class FtpWagonTest extends StreamingWagonTestCase { private FtpServerInterface server; protected String getProtocol() { return "ftp"; } protected void setupWagonTestingFixtures() throws Exception { server = (FtpServerInterface) lookup( FtpServerInterface.ROLE ); } protected void createDirectory( Wagon wagon, String resourceToCreate, String dirName ) throws Exception { super.createDirectory( wagon, resourceToCreate, dirName ); getRepositoryDirectory().mkdirs(); } protected void tearDownWagonTestingFixtures() throws Exception { release( server ); } protected String getTestRepositoryUrl() { return "ftp://localhost:10023"; } 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() ); } } } wagon-1.0.0/wagon-providers/wagon-ftp/pom.xml0000644000175000017500000000503011605164037021127 0ustar twernertwerner 4.0.0 org.apache.maven.wagon wagon-providers 1.0 ../pom.xml wagon-ftp Maven Wagon FTP Provider Wagon that gets and puts artifacts from and to remote server using FTP protocol commons-net commons-net 2.0 org.codehaus.plexus plexus-ftpd 1.0-alpha-1 test plexus plexus-container-default org.apache.maven.plugins maven-enforcer-plugin 1.0.1 enforce 1.5.0 wagon-1.0.0/wagon-providers/wagon-http-lightweight/0000755000175000017500000000000011630374112022312 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-lightweight/src/0000755000175000017500000000000011630374112023101 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-lightweight/src/main/0000755000175000017500000000000011630374112024025 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-lightweight/src/main/resources/0000755000175000017500000000000011630374112026037 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-lightweight/src/main/java/0000755000175000017500000000000011630374112024746 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-lightweight/src/main/java/org/0000755000175000017500000000000011630374112025535 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/0000755000175000017500000000000011630374112026756 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/0000755000175000017500000000000011630374112030064 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/0000755000175000017500000000000011630374112031177 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/0000755000175000017500000000000011630374112033214 5ustar twernertwerner././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/wagon-1.0.0/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/ht0000755000175000017500000000000011630374112033550 5ustar twernertwerner././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpsWagon.javawagon-1.0.0/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/ht0000644000175000017500000000550611276106646033573 0ustar twernertwernerpackage 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 * * @author Joakim Erdfelt * @version $Id: LightweightHttpsWagon.java 834247 2009-11-09 21:46:14Z bentmann $ * * @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 ); } } ././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/http/LightweightHttpWagon.javawagon-1.0.0/wagon-providers/wagon-http-lightweight/src/main/java/org/apache/maven/wagon/providers/ht0000644000175000017500000003264511276106646033577 0ustar twernertwernerpackage 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.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.Authenticator; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.PasswordAuthentication; import java.net.URL; import java.net.URLConnection; import java.util.Iterator; import java.util.List; import java.util.Properties; import java.util.zip.GZIPInputStream; 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.HtmlFileListParser; /** * LightweightHttpWagon * * @author Michal Maczka * @version $Id: LightweightHttpWagon.java 834247 2009-11-09 21:46:14Z bentmann $ * @plexus.component role="org.apache.maven.wagon.Wagon" role-hint="http" instantiation-strategy="per-lookup" */ public class LightweightHttpWagon extends StreamWagon { private String previousProxyExclusions; private String previousHttpProxyHost; private String previousHttpProxyPort; private HttpURLConnection putConnection; /** * Whether to use any proxy cache or not. * * @plexus.configuration default="false" */ private boolean useCache; /** @plexus.configuration */ private Properties httpHeaders; /** * Builds a complete URL string from the repository URL and the relative path passed. * * @param path the relative path * @return the complete URL */ private String buildUrl( String path ) { final String repoUrl = getRepository().getUrl(); path = path.replace( ' ', '+' ); if ( repoUrl.charAt( repoUrl.length() - 1 ) != '/' ) { return repoUrl + '/' + path; } return repoUrl + path; } public void fillInputData( InputData inputData ) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { Resource resource = inputData.getResource(); try { URL url = new URL( buildUrl( resource.getName() ) ); HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); 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.getName() ) ); } InputStream is = urlConnection.getInputStream(); String contentEncoding = urlConnection.getHeaderField( "Content-Encoding" ); boolean isGZipped = contentEncoding == null ? false : "gzip".equalsIgnoreCase( contentEncoding ); if ( isGZipped ) { is = new GZIPInputStream( is ); } inputData.setInputStream( is ); resource.setLastModified( urlConnection.getLastModified() ); resource.setContentLength( urlConnection.getContentLength() ); } 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 ) { throw new TransferFailedException( "Error transferring file: " + e.getMessage(), e ); } } private void addHeaders( URLConnection urlConnection ) { if ( httpHeaders != null ) { for ( Iterator i = httpHeaders.keySet().iterator(); i.hasNext(); ) { String header = (String) i.next(); urlConnection.setRequestProperty( header, httpHeaders.getProperty( header ) ); } } } public void fillOutputData( OutputData outputData ) throws TransferFailedException { Resource resource = outputData.getResource(); try { URL url = new URL( buildUrl( resource.getName() ) ); putConnection = (HttpURLConnection) url.openConnection(); 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.getName() ) ); case HttpURLConnection.HTTP_NOT_FOUND: throw new ResourceDoesNotExistException( "File: " + buildUrl( resource.getName() ) + " does not exist" ); // add more entries here default: throw new TransferFailedException( "Failed to transfer file: " + buildUrl( resource.getName() ) + ". 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 { previousHttpProxyHost = System.getProperty( "http.proxyHost" ); previousHttpProxyPort = System.getProperty( "http.proxyPort" ); previousProxyExclusions = System.getProperty( "http.nonProxyHosts" ); final ProxyInfo proxyInfo = getProxyInfo( "http", getRepository().getHost() ); if ( proxyInfo != null ) { setSystemProperty( "http.proxyHost", proxyInfo.getHost() ); setSystemProperty( "http.proxyPort", String.valueOf( proxyInfo.getPort() ) ); setSystemProperty( "http.nonProxyHosts", proxyInfo.getNonProxyHosts() ); } else { setSystemProperty( "http.proxyHost", null ); setSystemProperty( "http.proxyPort", null ); } final boolean hasProxy = ( proxyInfo != null && proxyInfo.getUserName() != null ); final boolean hasAuthentication = ( authenticationInfo != null && authenticationInfo.getUserName() != null ); if ( hasProxy || hasAuthentication ) { Authenticator.setDefault( new Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { // TODO: ideally use getRequestorType() from JDK1.5 here... if ( hasProxy && getRequestingHost().equals( proxyInfo.getHost() ) && getRequestingPort() == proxyInfo.getPort() ) { String password = ""; if ( proxyInfo.getPassword() != null ) { password = proxyInfo.getPassword(); } return new PasswordAuthentication( proxyInfo.getUserName(), password.toCharArray() ); } if ( hasAuthentication ) { String password = ""; if ( authenticationInfo.getPassword() != null ) { password = authenticationInfo.getPassword(); } return new PasswordAuthentication( authenticationInfo.getUserName(), password.toCharArray() ); } return super.getPasswordAuthentication(); } } ); } else { Authenticator.setDefault( null ); } } public void closeConnection() throws ConnectionException { if ( putConnection != null ) { putConnection.disconnect(); } setSystemProperty( "http.proxyHost", previousHttpProxyHost ); setSystemProperty( "http.proxyPort", previousHttpProxyPort ); setSystemProperty( "http.nonProxyHosts", previousProxyExclusions ); } public List getFileList( String destinationDirectory ) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { InputData inputData = new InputData(); if ( destinationDirectory.length() > 0 && !destinationDirectory.endsWith( "/" ) ) { destinationDirectory += "/"; } String url = buildUrl( destinationDirectory ); Resource resource = new Resource( destinationDirectory ); inputData.setResource( resource ); fillInputData( inputData ); InputStream is = inputData.getInputStream(); if ( is == null ) { throw new TransferFailedException( url + " - Could not open input stream for resource: '" + resource + "'" ); } return HtmlFileListParser.parseFileList( url, is ); } public boolean resourceExists( String resourceName ) throws TransferFailedException, AuthorizationException { HttpURLConnection headConnection; try { URL url = new URL( buildUrl( new Resource( resourceName ).getName() ) ); headConnection = (HttpURLConnection) url.openConnection(); 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( resourceName ) + ". 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 ); } } } wagon-1.0.0/wagon-providers/wagon-http-lightweight/src/site/0000755000175000017500000000000011630374112024045 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-lightweight/src/site/site.xml0000644000175000017500000000013211045135116025526 0ustar twernertwerner wagon-1.0.0/wagon-providers/wagon-http-lightweight/src/site/apt/0000755000175000017500000000000011630374112024631 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-lightweight/src/site/apt/index.apt0000644000175000017500000000060111045136112026437 0ustar twernertwerner ------ Maven Wagon HTTP lightweight ------ Carlos Sanchez ------ 2006-04-16 ------ Maven Wagon HTTP lightweight This project 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. It doesn't allow deployment. Features * Get files from HTTP Server wagon-1.0.0/wagon-providers/wagon-http-lightweight/src/test/0000755000175000017500000000000011630374112024060 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-lightweight/src/test/resources/0000755000175000017500000000000011630374112026072 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-lightweight/src/test/resources/ssl/0000755000175000017500000000000011630374112026673 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-lightweight/src/test/resources/ssl/keystore0000644000175000017500000000252311044154044030464 0ustar twernertwernerþíþíjettyuQþ•»0‚·0 +*‚£m¦³8d$oOÀþ˜Î.Ë3]g®ò •d–<àÔÆzp”p¼„1ÖÉv@ˆuþðé'¥#ÖB»S»çô/s…-ÃŒÎ:V˜ƒÏŽ˜ÑÁto‚‚hlI¨,DnMŽãi 5ªß×;Š@w$uŸë*¼ÂÚH¥õÜ(³“Ö¥a€‡L5ZÅï{·´öaÈöPj‡2Ù$#­ gú-Ü.DÅéÚò¡p<ÚnvðÎÜÓ@G*·ÙCy+E#À}á”×׈îÀ¢ëæÊX˜G(F`hÿ–¾ÑßZ¶ö³ju•‘?fŠ:SÊD¦‰$µ YêJSC¡É/fÐú†zÑÆ<à^ÂRvæ•Vdc*øw‚HR$‰¶²«m+öÉÏ(LÁW‘_Œñpéy¦"0UEæÆÅ£º6ÄÝMâñÔxkE^R†yÅ5™:šÙPÍõ9Ñ«S±Ð{eþ²üÜ [ËéË @'Êëwçšz²+ÄO_ýúÝ90EçB›8î¬ «LúÂg$hßÑÞúIÀ)ËP ¡51P]Hè›&HäYb}÷Éøó5Ž8\öž Þ È„®RŠÊ­Î÷̉¬o,ÍTEIwÝØ-àd΋!)ÿµjÏ«p)V¨h6`j¸Öíùzƒÿ¥»Ëú5ºÌê.õãÈ0¶éâ ¯;Ÿ¶“@9:OX.509R0‚N0‚·H¸È0  *†H†÷ 0n10UUnknown10UUnknown10UUnknown10U Unknown10U Unknown10U localhost0 080730185400Z 081028185400Z0n10UUnknown10UUnknown10UUnknown10U Unknown10U Unknown10U localhost0Ÿ0  *†H†÷ 0‰ÐÅ.Y¥E^äákOð,J.¿§ƒ—A”#¡AôxñBÚ¿áÎè®õ.XtÆ_4ƒ Ú_‘ʤ„CÛôk‘Á-°’in‘ɳÄaHÉB€2†ŽSZ£ FNx:/}Lº)ö!pO" I¶?È¡   ¨wàÓX“%'ÉØ4Ùwy0  *†H†÷ /ÔÝÞÂLOuMšð,_ž˜2·9†µÙÞBu÷sß“>ì}u*În9Açš7ÆÐ!u7gâ/F±×2–.õøO¨¿ÏzpžèøÎL Æiä ß+'4¨ªè@¦)|ÿÜe…á½PÙØ·,âžaèó,Iô§ó;‚”Ïóò)¾ðZiu+qò»+{1'TKëÔ«pwagon-1.0.0/wagon-providers/wagon-http-lightweight/src/test/java/0000755000175000017500000000000011630374112025001 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-lightweight/src/test/java/org/0000755000175000017500000000000011630374112025570 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/0000755000175000017500000000000011630374112027011 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/0000755000175000017500000000000011630374112030117 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/0000755000175000017500000000000011630374112031232 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/0000755000175000017500000000000011630374112033247 5ustar twernertwerner././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/wagon-1.0.0/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/ht0000755000175000017500000000000011630374112033603 5ustar twernertwerner././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpsWagonTest.javawagon-1.0.0/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/ht0000644000175000017500000001156011276106646033623 0ustar twernertwernerpackage 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.apache.maven.wagon.proxy.ProxyInfo; import org.apache.maven.wagon.repository.Repository; 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 } ); } public void testHttpsProxyReset() throws Exception { ProxyInfo proxyInfo = new ProxyInfo(); proxyInfo.setType( "https" ); proxyInfo.setHost( "proxyhost" ); proxyInfo.setPort( 1234 ); proxyInfo.setNonProxyHosts( "non" ); Repository repository = new Repository(); String proxyHost = System.getProperty( "https.proxyHost" ); String proxyPort = System.getProperty( "https.proxyPort" ); String nonProxyHosts = System.getProperty( "https.nonProxyHosts" ); System.getProperties().remove( "https.proxyHost" ); System.getProperties().remove( "https.proxyPort" ); Wagon wagon = getWagon(); wagon.connect( repository, proxyInfo ); assertEquals( "proxyhost", System.getProperty( "https.proxyHost" ) ); assertEquals( "1234", System.getProperty( "https.proxyPort" ) ); assertEquals( "non", System.getProperty( "https.nonProxyHosts" ) ); wagon.disconnect(); assertNull( System.getProperty( "https.proxyHost" ) ); assertNull( System.getProperty( "https.proxyPort" ) ); System.setProperty( "https.proxyHost", "host" ); System.setProperty( "https.proxyPort", "port" ); System.setProperty( "https.nonProxyHosts", "hosts" ); wagon = getWagon(); wagon.connect( repository, proxyInfo ); assertEquals( "proxyhost", System.getProperty( "https.proxyHost" ) ); assertEquals( "1234", System.getProperty( "https.proxyPort" ) ); assertEquals( "non", System.getProperty( "https.nonProxyHosts" ) ); wagon.disconnect(); assertEquals( "host", System.getProperty( "https.proxyHost" ) ); assertEquals( "port", System.getProperty( "https.proxyPort" ) ); assertEquals( "hosts", System.getProperty( "https.nonProxyHosts" ) ); wagon = getWagon(); wagon.connect( repository ); assertNull( System.getProperty( "https.proxyHost" ) ); assertNull( System.getProperty( "https.proxyPort" ) ); wagon.disconnect(); assertEquals( "host", System.getProperty( "https.proxyHost" ) ); assertEquals( "port", System.getProperty( "https.proxyPort" ) ); assertEquals( "hosts", System.getProperty( "https.nonProxyHosts" ) ); if ( proxyHost != null ) { System.setProperty( "https.proxyHost", proxyHost ); } else { System.getProperties().remove( "https.proxyHost" ); } if ( proxyPort != null ) { System.setProperty( "https.proxyPort", proxyPort ); } else { System.getProperties().remove( "https.proxyPort" ); } if ( nonProxyHosts != null ) { System.setProperty( "https.nonProxyHosts", nonProxyHosts ); } else { System.getProperties().remove( "https.nonProxyHosts" ); } } } ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/http/LightweightHttpWagonTest.javawagon-1.0.0/wagon-providers/wagon-http-lightweight/src/test/java/org/apache/maven/wagon/providers/ht0000644000175000017500000001104411044154044033604 0ustar twernertwernerpackage 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.Wagon; import org.apache.maven.wagon.http.HttpWagonTestCase; import org.apache.maven.wagon.proxy.ProxyInfo; import org.apache.maven.wagon.repository.Repository; /** * @author Michal Maczka * @version $Id: LightweightHttpWagonTest.java 681203 2008-07-30 21:07:48Z brett $ */ public class LightweightHttpWagonTest extends HttpWagonTestCase { protected String getProtocol() { return "http"; } protected String getTestRepositoryUrl() { return getProtocol() + "://localhost:10007/"; } protected void setHttpHeaders( StreamingWagon wagon, Properties properties ) { ( (LightweightHttpWagon) wagon ).setHttpHeaders( properties ); } public void testProxyReset() throws Exception { ProxyInfo proxyInfo = new ProxyInfo(); proxyInfo.setType( "http" ); proxyInfo.setHost( "proxyhost" ); proxyInfo.setPort( 1234 ); proxyInfo.setNonProxyHosts( "non" ); Repository repository = new Repository(); String proxyHost = System.getProperty( "http.proxyHost" ); String proxyPort = System.getProperty( "http.proxyPort" ); String nonProxyHosts = System.getProperty( "http.nonProxyHosts" ); System.getProperties().remove( "http.proxyHost" ); System.getProperties().remove( "http.proxyPort" ); Wagon wagon = getWagon(); wagon.connect( repository, proxyInfo ); assertEquals( "proxyhost", System.getProperty( "http.proxyHost" ) ); assertEquals( "1234", System.getProperty( "http.proxyPort" ) ); assertEquals( "non", System.getProperty( "http.nonProxyHosts" ) ); wagon.disconnect(); assertNull( System.getProperty( "http.proxyHost" ) ); assertNull( System.getProperty( "http.proxyPort" ) ); System.setProperty( "http.proxyHost", "host" ); System.setProperty( "http.proxyPort", "port" ); System.setProperty( "http.nonProxyHosts", "hosts" ); wagon = getWagon(); wagon.connect( repository, proxyInfo ); assertEquals( "proxyhost", System.getProperty( "http.proxyHost" ) ); assertEquals( "1234", System.getProperty( "http.proxyPort" ) ); assertEquals( "non", System.getProperty( "http.nonProxyHosts" ) ); wagon.disconnect(); assertEquals( "host", System.getProperty( "http.proxyHost" ) ); assertEquals( "port", System.getProperty( "http.proxyPort" ) ); assertEquals( "hosts", System.getProperty( "http.nonProxyHosts" ) ); wagon = getWagon(); wagon.connect( repository ); assertNull( System.getProperty( "http.proxyHost" ) ); assertNull( System.getProperty( "http.proxyPort" ) ); wagon.disconnect(); assertEquals( "host", System.getProperty( "http.proxyHost" ) ); assertEquals( "port", System.getProperty( "http.proxyPort" ) ); assertEquals( "hosts", System.getProperty( "http.nonProxyHosts" ) ); if ( proxyHost != null ) { System.setProperty( "http.proxyHost", proxyHost ); } else { System.getProperties().remove( "http.proxyHost" ); } if ( proxyPort != null ) { System.setProperty( "http.proxyPort", proxyPort ); } else { System.getProperties().remove( "http.proxyPort" ); } if ( nonProxyHosts != null ) { System.setProperty( "http.nonProxyHosts", nonProxyHosts ); } else { System.getProperties().remove( "http.nonProxyHosts" ); } } } wagon-1.0.0/wagon-providers/wagon-http-lightweight/pom.xml0000644000175000017500000000370211605164037023636 0ustar twernertwerner 4.0.0 org.apache.maven.wagon wagon-providers 1.0 ../pom.xml wagon-http-lightweight Maven Wagon Lightweight HTTP Provider Wagon that gets and puts artifacts through http using standard Java library ${project.groupId} wagon-http-shared ${project.version} commons-httpclient commons-httpclient commons-logging commons-logging wagon-1.0.0/wagon-providers/wagon-ssh-common/0000755000175000017500000000000011630374114021103 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common/src/0000755000175000017500000000000011630374114021672 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/0000755000175000017500000000000011630374114022616 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/resources/0000755000175000017500000000000011630374114024630 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/0000755000175000017500000000000011630374114023537 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/0000755000175000017500000000000011630374114024326 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/0000755000175000017500000000000011630374114025547 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/0000755000175000017500000000000011630374114026655 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/0000755000175000017500000000000011630374114027770 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/0000755000175000017500000000000011630374114032005 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/0000755000175000017500000000000011630374114032602 5ustar twernertwerner././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/CommandExecutorStreamProcessor.javawagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/Comm0000644000175000017500000000544311045156772033436 0ustar twernertwernerpackage 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.Streams; import java.io.BufferedReader; import java.io.IOException; /** * CommandExecutorStreamProcessor * * @author Joakim Erdfelt * @version $Id: CommandExecutorStreamProcessor.java 682071 2008-08-02 22:21:46Z hboutemy $ */ public class CommandExecutorStreamProcessor { private CommandExecutorStreamProcessor() { // shoo! } public static Streams processStreams( BufferedReader stderrReader, BufferedReader stdoutReader ) throws IOException, CommandExecutionException { Streams streams = new Streams(); 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" ); } } 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 ); // } return streams; } } ././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/wagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/inte0000755000175000017500000000000011630374114033462 5ustar twernertwerner././@LongLink0000000000000000000000000000021400000000000011562 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/ConsoleInteractiveUserInfo.javawagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/inte0000644000175000017500000000517611015033162033465 0ustar twernertwernerpackage 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 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( new String[]{"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 ); } } ././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/NullInteractiveUserInfo.javawagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/inte0000644000175000017500000000424611015033162033462 0ustar twernertwernerpackage 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 InteractiveUserInfo, 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 NullInteractiveUserInfo 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; } } ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/interactive/InteractiveUserInfo.javawagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/inte0000644000175000017500000000240511015033162033455 0ustar twernertwernerpackage 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 UserInfo * * @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 ); } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/ScpHelper.javawagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/ScpH0000644000175000017500000002511111147165407033370 0ustar twernertwernerpackage 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 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; 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; 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 files, File zipName, File basedir ) throws IOException { ZipOutputStream zos = new ZipOutputStream( new FileOutputStream( zipName ) ); try { for ( int i = 0; i < files.size(); i++ ) { String file = (String) files.get( i ); 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; } 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; 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 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() ); zipFile.delete(); RepositoryPermissions permissions = repository.getPermissions(); if ( permissions != null && permissions.getGroup() != null ) { executor.executeCommand( "chgrp -Rf " + permissions.getGroup() + " " + path ); } if ( permissions != null && permissions.getFileMode() != null ) { executor.executeCommand( "chmod -Rf " + permissions.getFileMode() + " " + path ); } } catch ( CommandExecutionException e ) { throw new TransferFailedException( "Error performing commands for file transfer", e ); } } public List getFileList( String destinationDirectory, Repository repository ) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { try { String path = getPath( repository.getBasedir(), destinationDirectory ); 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() ); } else if ( e.getMessage().trim().endsWith( "Not a directory" ) ) { throw new ResourceDoesNotExistException( e.getMessage().trim() ); } 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 ); // 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; if ( umaskCmd != null ) { mkdirCmd = umaskCmd + "; " + mkdirCmd; } executor.executeCommand( mkdirCmd ); } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/LSParser.javawagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/LSPa0000644000175000017500000000501111045156772033331 0ustar twernertwernerpackage 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 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; import org.apache.maven.wagon.TransferFailedException; /** * LSParser * * @author Joakim Erdfelt * @version $Id: LSParser.java 682071 2008-08-02 22:21:46Z hboutemy $ */ public class LSParser { private final static Pattern PATTERN = Pattern.compile( ".+\\s+[0-9]+\\s+.+\\s+.+\\s+[0-9]+\\s+" + "([0-9]{4}-[0-9]{2}-[0-9]{2}|.+\\s+[0-9]+)\\s+[0-9:]+\\s+(.+?)" ); /** * Parse a raw "ls -la", and obtain the list of files. * * @todo use ls -1a and do away with the method all together * * @param rawLS the raw LS to parse. * @return the list of files found. * @throws TransferFailedException */ public List parseFiles( String rawLS ) throws TransferFailedException { List ret = new ArrayList(); 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; } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/SshWagon.javawagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/SshW0000644000175000017500000000254211015033162033404 0ustar twernertwernerpackage 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 Joakim Erdfelt * @version $Id: SshWagon.java 658720 2008-05-21 14:49:22Z bentmann $ */ public interface SshWagon extends Wagon { void setKnownHostsProvider( KnownHostsProvider knownHostsProvider ); } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/wagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/know0000755000175000017500000000000011630374114033501 5ustar twernertwerner././@LongLink0000000000000000000000000000020200000000000011557 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/KnownHostsProvider.javawagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/know0000644000175000017500000000244211015033162033475 0ustar twernertwernerpackage 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(); } ././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/UnknownHostException.javawagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/know0000644000175000017500000000233711015033162033500 0ustar twernertwernerpackage 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 ); } } ././@LongLink0000000000000000000000000000020500000000000011562 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/NullKnownHostProvider.javawagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/know0000644000175000017500000000230111015033162033467 0ustar twernertwernerpackage 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 KnownHostsProvider * * @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 { } ././@LongLink0000000000000000000000000000020700000000000011564 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/SingleKnownHostProvider.javawagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/know0000644000175000017500000000273011016706646033514 0ustar twernertwernerpackage 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 KnownHostsProvider 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"; } } ././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/AbstractKnownHostsProvider.javawagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/know0000644000175000017500000000357111127522327033513 0ustar twernertwernerpackage 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 Brett Porter * @version $Id: AbstractKnownHostsProvider.java 730869 2009-01-02 23:35:51Z dantran $ */ 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 knownHosts = new HashSet(); 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 { } } ././@LongLink0000000000000000000000000000021000000000000011556 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/StreamKnownHostsProvider.javawagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/know0000644000175000017500000000472111127522327033511 0ustar twernertwernerpackage 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 loadKnownHosts( String contents ) throws IOException { Set hosts = new HashSet(); BufferedReader br = new BufferedReader( new StringReader( contents ) ); String line = null; 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; } } ././@LongLink0000000000000000000000000000021100000000000011557 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/KnownHostChangedException.javawagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/know0000644000175000017500000000236511015033162033501 0ustar twernertwernerpackage 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 ); } } ././@LongLink0000000000000000000000000000020600000000000011563 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/FileKnownHostsProvider.javawagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/know0000644000175000017500000000506211127522327033510 0ustar twernertwernerpackage 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 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; } } ././@LongLink0000000000000000000000000000017600000000000011571 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/KnownHostEntry.javawagon-1.0.0/wagon-providers/wagon-ssh-common/src/main/java/org/apache/maven/wagon/providers/ssh/know0000644000175000017500000000566011134346757033525 0ustar twernertwernerpackage 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; } } wagon-1.0.0/wagon-providers/wagon-ssh-common/src/site/0000755000175000017500000000000011630374114022636 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common/src/site/site.xml0000644000175000017500000000013211045135116024315 0ustar twernertwerner wagon-1.0.0/wagon-providers/wagon-ssh-common/src/test/0000755000175000017500000000000011630374114022651 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common/src/test/resources/0000755000175000017500000000000011630374114024663 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common/src/test/resources/known_hosts_same0000644000175000017500000000143311127522327030172 0ustar twernertwerner192.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== wagon-1.0.0/wagon-providers/wagon-ssh-common/src/test/resources/known_hosts0000644000175000017500000000143311127522327027165 0ustar twernertwernerserver,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== wagon-1.0.0/wagon-providers/wagon-ssh-common/src/test/java/0000755000175000017500000000000011630374114023572 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common/src/test/java/org/0000755000175000017500000000000011630374114024361 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common/src/test/java/org/apache/0000755000175000017500000000000011630374114025602 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common/src/test/java/org/apache/maven/0000755000175000017500000000000011630374114026710 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common/src/test/java/org/apache/maven/wagon/0000755000175000017500000000000011630374114030023 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common/src/test/java/org/apache/maven/wagon/providers/0000755000175000017500000000000011630374114032040 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common/src/test/java/org/apache/maven/wagon/providers/ssh/0000755000175000017500000000000011630374114032635 5ustar twernertwerner././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-common/src/test/java/org/apache/maven/wagon/providers/ssh/LSParserTest.javawagon-1.0.0/wagon-providers/wagon-ssh-common/src/test/java/org/apache/maven/wagon/providers/ssh/LSPa0000644000175000017500000001160411016742647033371 0ustar twernertwernerpackage 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 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 files = parser.parseFiles( rawLS ); assertNotNull( files ); assertEquals( 9, files.size() ); assertTrue( files.contains( "pom.xml" ) ); assertTrue( files.contains( "spaced out" ) ); } 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 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 files = parser.parseFiles( rawLS ); assertNotNull( files ); assertEquals( 4, files.size() ); assertTrue( files.contains( "org" ) ); assertTrue( files.contains( "spaced out" ) ); } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-common/src/test/java/org/apache/maven/wagon/providers/ssh/knownhost/wagon-1.0.0/wagon-providers/wagon-ssh-common/src/test/java/org/apache/maven/wagon/providers/ssh/know0000755000175000017500000000000011630374114033534 5ustar twernertwerner././@LongLink0000000000000000000000000000021200000000000011560 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-common/src/test/java/org/apache/maven/wagon/providers/ssh/knownhost/FileKnownHostsProviderTest.javawagon-1.0.0/wagon-providers/wagon-ssh-common/src/test/java/org/apache/maven/wagon/providers/ssh/know0000644000175000017500000000531211134347320033535 0ustar twernertwernerpackage 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() ); } } wagon-1.0.0/wagon-providers/wagon-ssh-common/pom.xml0000644000175000017500000000342611605164037022430 0ustar twernertwerner 4.0.0 org.apache.maven.wagon wagon-providers 1.0 ../pom.xml wagon-ssh-common Maven Wagon SSH Common Library org.codehaus.plexus plexus-utils org.codehaus.plexus plexus-interactivity-api org.codehaus.plexus plexus-component-api wagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/0000755000175000017500000000000011630374113022361 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/0000755000175000017500000000000011630374113023150 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/0000755000175000017500000000000011630374113024074 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/resources/0000755000175000017500000000000011630374113026106 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/resources/META-INF/0000755000175000017500000000000011630374113027246 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/resources/META-INF/plexus/0000755000175000017500000000000011630374113030566 5ustar twernertwerner././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/resources/META-INF/plexus/components.xmlwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/resources/META-INF/plexus/components.xm0000644000175000017500000000371411020344026033317 0ustar twernertwerner org.apache.maven.wagon.Wagon dav org.apache.maven.wagon.providers.webdav.WebDavWagon per-lookup <p>WebDavWagon</p> <p/> <p>Allows using a webdav remote repository for downloads and deployments</p> false org.apache.maven.wagon.Wagon davs org.apache.maven.wagon.providers.webdav.WebDavWagon per-lookup <p>WebDavWagon</p> <p/> <p>Allows using a webdav remote repository for downloads and deployments</p> false org.apache.maven.wagon.Wagon dav+http org.apache.maven.wagon.providers.webdav.WebDavWagon per-lookup <p>WebDavWagon</p> <p/> <p>Allows using a webdav remote repository for downloads and deployments</p> false org.apache.maven.wagon.Wagon dav+https org.apache.maven.wagon.providers.webdav.WebDavWagon per-lookup <p>WebDavWagon</p> <p/> <p>Allows using a webdav remote repository for downloads and deployments</p> false wagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/java/0000755000175000017500000000000011630374113025015 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/0000755000175000017500000000000011630374113025604 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/0000755000175000017500000000000011630374113027025 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/jackrabbit/0000755000175000017500000000000011630374113031121 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/jackrabbit/webdav/0000755000175000017500000000000011630374113032371 5ustar twernertwerner././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/jackrabbit/webdav/client/wagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/jackrabbit/webdav/clien0000755000175000017500000000000011630374113033404 5ustar twernertwerner././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/jackrabbit/webdav/client/methods/wagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/jackrabbit/webdav/clien0000755000175000017500000000000011630374113033404 5ustar twernertwerner././@LongLink0000000000000000000000000000020400000000000011561 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/jackrabbit/webdav/client/methods/XmlRequestEntity.javawagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/jackrabbit/webdav/clien0000644000175000017500000000575411045156772033432 0ustar twernertwerner/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.jackrabbit.webdav.client.methods; 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; /** * XmlRequestEntity... */ 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(); } }././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/jackrabbit/webdav/MultiStatus.javawagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/jackrabbit/webdav/Multi0000644000175000017500000001655611132150562033420 0ustar twernertwerner/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.jackrabbit.webdav; 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.Iterator; 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 occure one single time. */ private Map responses = new LinkedHashMap(); /** * 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 MultiStatusResponse element to this MultiStatus * * @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 MultiStatus. * * @return Xml document * @param document */ public Element toXml( Document document ) { Element multistatus = DomUtil.createElement( document, XML_MULTISTATUS, NAMESPACE ); Iterator it = responses.values().iterator(); while ( it.hasNext() ) { multistatus.appendChild( ( (MultiStatusResponse) it.next() ).toXml( document ) ); } if ( responseDescription != null ) { Element respDesc = DomUtil.createElement( document, XML_RESPONSEDESCRIPTION, NAMESPACE, responseDescription ); multistatus.appendChild( respDesc ); } return multistatus; } /** * Build a MultiStatus from the specified xml element. * * @param multistatusElement * @return new MultiStatus instance. * @throws IllegalArgumentException if the given document is null * 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; } } wagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/0000755000175000017500000000000011630374113030133 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/0000755000175000017500000000000011630374113031246 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/0000755000175000017500000000000011630374113033263 5ustar twernertwerner././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/wagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/w0000755000175000017500000000000011630374113033452 5ustar twernertwerner././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/WebDavWagon.javawagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/w0000644000175000017500000002717611147155215033474 0ustar twernertwernerpackage 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 java.io.File; import java.io.IOException; import java.net.URLDecoder; import java.util.ArrayList; import java.util.List; import org.apache.commons.httpclient.HttpException; 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.apache.maven.wagon.shared.http.AbstractHttpClientWagon; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.StringUtils; import org.w3c.dom.Node; /** *

WebDavWagon

*

*

Allows using a webdav remote repository for downloads and deployments

* * @author Henry Isidro * @author Joakim Erdfelt * @author Carlos Sanchez * @author James William Dumay * * @plexus.component role="org.apache.maven.wagon.Wagon" * role-hint="dav" * instantiation-strategy="per-lookup" */ public class WebDavWagon extends AbstractHttpClientWagon { /** * Defines the protocol mapping to use. * * First string is the user definition way to define a webdav url, * the second string is the internal representation of that url. * * NOTE: The order of the mapping becomes the search order. */ private static final String[][] protocolMap = 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 true 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 HttpException * @throws TransferFailedException */ protected void mkdirs( String dir ) throws HttpException, 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 HttpException, 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 { File[] listFiles = sourceDirectory.listFiles(); for ( int i = 0; i < listFiles.length; i++ ) { if ( listFiles[i].isDirectory() ) { putDirectory( listFiles[i], destinationDirectory + "/" + listFiles[i].getName() ); } else { String target = destinationDirectory + "/" + listFiles[i].getName(); put( listFiles[i], 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 getFileList( String destinationDirectory ) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { String url = getRepository().getUrl() + '/' + 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 dirs = new ArrayList(); 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 ( int i = 0; i < protocolMap.length; i++ ) { String protocol = protocolMap[i][0]; if ( url.startsWith( protocol ) ) { return protocolMap[i][1] + url.substring( protocol.length() ); } } // No mapping trigger? then just return as-is. return url; } } ././@LongLink0000000000000000000000000000017500000000000011570 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/webdav/PathNavigator.javawagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/main/java/org/apache/maven/wagon/providers/w0000644000175000017500000000370211147155215033461 0ustar twernertwernerpackage 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 James William Dumay */ public class PathNavigator { final private List list; private int currentPosition; public PathNavigator( String path ) { list = Arrays.asList( StringUtils.split( path, "/" ) ); currentPosition = list.size(); } public String getPath() { List currentPathList = list.subList( 0, currentPosition ); StringBuffer sb = new StringBuffer(); for ( int i = 0; i < currentPathList.size(); i++ ) { sb.append( currentPathList.get( i ) ); 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; } } wagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/site/0000755000175000017500000000000011630374113024114 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/site/site.xml0000644000175000017500000000013211045135116025574 0ustar twernertwerner wagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/site/apt/0000755000175000017500000000000011630374113024700 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/site/apt/index.apt0000644000175000017500000000057611045136112026520 0ustar twernertwerner ------ Maven Wagon WebDAV ------ Carlos Sanchez ------ 2006-10-16 ------ Maven Wagon WebDAV This project is an implementation of Wagon provider for WebDAV server access. 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 wagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/test/0000755000175000017500000000000011630374113024127 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/test/resources/0000755000175000017500000000000011630374113026141 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/test/resources/ssl/0000755000175000017500000000000011630374113026742 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/test/resources/ssl/keystore0000644000175000017500000000252311044154044030532 0ustar twernertwernerþíþíjettyuQþ•»0‚·0 +*‚£m¦³8d$oOÀþ˜Î.Ë3]g®ò •d–<àÔÆzp”p¼„1ÖÉv@ˆuþðé'¥#ÖB»S»çô/s…-ÃŒÎ:V˜ƒÏŽ˜ÑÁto‚‚hlI¨,DnMŽãi 5ªß×;Š@w$uŸë*¼ÂÚH¥õÜ(³“Ö¥a€‡L5ZÅï{·´öaÈöPj‡2Ù$#­ gú-Ü.DÅéÚò¡p<ÚnvðÎÜÓ@G*·ÙCy+E#À}á”×׈îÀ¢ëæÊX˜G(F`hÿ–¾ÑßZ¶ö³ju•‘?fŠ:SÊD¦‰$µ YêJSC¡É/fÐú†zÑÆ<à^ÂRvæ•Vdc*øw‚HR$‰¶²«m+öÉÏ(LÁW‘_Œñpéy¦"0UEæÆÅ£º6ÄÝMâñÔxkE^R†yÅ5™:šÙPÍõ9Ñ«S±Ð{eþ²üÜ [ËéË @'Êëwçšz²+ÄO_ýúÝ90EçB›8î¬ «LúÂg$hßÑÞúIÀ)ËP ¡51P]Hè›&HäYb}÷Éøó5Ž8\öž Þ È„®RŠÊ­Î÷̉¬o,ÍTEIwÝØ-àd΋!)ÿµjÏ«p)V¨h6`j¸Öíùzƒÿ¥»Ëú5ºÌê.õãÈ0¶éâ ¯;Ÿ¶“@9:OX.509R0‚N0‚·H¸È0  *†H†÷ 0n10UUnknown10UUnknown10UUnknown10U Unknown10U Unknown10U localhost0 080730185400Z 081028185400Z0n10UUnknown10UUnknown10UUnknown10U Unknown10U Unknown10U localhost0Ÿ0  *†H†÷ 0‰ÐÅ.Y¥E^äákOð,J.¿§ƒ—A”#¡AôxñBÚ¿áÎè®õ.XtÆ_4ƒ Ú_‘ʤ„CÛôk‘Á-°’in‘ɳÄaHÉB€2†ŽSZ£ FNx:/}Lº)ö!pO" I¶?È¡   ¨wàÓX“%'ÉØ4Ùwy0  *†H†÷ /ÔÝÞÂLOuMšð,_ž˜2·9†µÙÞBu÷sß“>ì}u*În9Açš7ÆÐ!u7gâ/F±×2–.õøO¨¿ÏzpžèøÎL Æiä ß+'4¨ªè@¦)|ÿÜe…á½PÙØ·,âžaèó,Iô§ó;‚”Ïóò)¾ðZiu+qò»+{1'TKëÔ«pwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/test/java/0000755000175000017500000000000011630374113025050 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/0000755000175000017500000000000011630374113025637 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/0000755000175000017500000000000011630374113027060 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/0000755000175000017500000000000011630374113030166 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/0000755000175000017500000000000011630374113031301 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/0000755000175000017500000000000011630374113033316 5ustar twernertwerner././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/wagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/w0000755000175000017500000000000011630374113033505 5ustar twernertwerner././@LongLink0000000000000000000000000000020100000000000011556 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/PathNavigatorTest.javawagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/w0000644000175000017500000000411311147155215033511 0ustar twernertwernerpackage 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 James William Dumay */ 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() ); } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavWagonTest.javawagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/w0000644000175000017500000002265211147155215033521 0ustar twernertwernerpackage 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 java.io.File; import java.io.IOException; import java.util.List; import java.util.Properties; import org.apache.maven.wagon.ResourceDoesNotExistException; import org.apache.maven.wagon.StreamingWagon; 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; /* * WebDAV Wagon Test * * @author Joakim Erdfelt * * @author Carlos Sanchez */ public class WebDavWagonTest extends HttpWagonTestCase { protected String getTestRepositoryUrl() throws IOException { return getProtocol() + "://localhost:10007/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:10007/dav/", "http://localhost:10007/dav/" ); } /** * Tests the maven 2.0.x way to define a webdav URL with SSL. */ public void testGetURLDavHttps() { assertURL( "dav:https://localhost:10007/dav/", "https://localhost:10007/dav/" ); } /** * Tests the URI spec way of defining a webdav URL without SSL. */ public void testGetURLDavUri() { assertURL( "dav://localhost:10007/dav/", "http://localhost:10007/dav/" ); } /** * Tests the URI spec way of defining a webdav URL with SSL. */ public void testGetURLDavUriWithSsl() { assertURL( "davs://localhost:10007/dav/", "https://localhost:10007/dav/" ); } /** * Tests the URI spec way of defining a webdav URL without SSL. */ public void testGetURLDavPlusHttp() { assertURL( "dav+https://localhost:10007/dav/", "https://localhost:10007/dav/" ); } /** * Tests the URI spec way of defining a webdav URL with SSL. */ public void testGetURLDavPlusHttps() { assertURL( "dav+https://localhost:10007/dav/", "https://localhost:10007/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 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(); } } ././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/webdav/WebDavsWagonTest.javawagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/src/test/java/org/apache/maven/wagon/providers/w0000644000175000017500000000372611044154044033515 0ustar twernertwernerpackage 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 Joakim Erdfelt * @author Carlos Sanchez */ 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 } ); } } wagon-1.0.0/wagon-providers/wagon-webdav-jackrabbit/pom.xml0000644000175000017500000000734611605164037023714 0ustar twernertwerner 4.0.0 org.apache.maven.wagon wagon-providers 1.0 ../pom.xml wagon-webdav-jackrabbit Maven Wagon WebDav Provider Wagon that gets and puts artifacts through webdav protocol Henry Isidro hisidro@exist.com James William Dumay james@atlassian.com ${project.groupId} wagon-http-shared 1.0 org.apache.jackrabbit jackrabbit-webdav 1.5.0 commons-logging commons-logging org.slf4j slf4j-nop 1.5.3 runtime javax.servlet servlet-api 2.3 test it.could webdav 0.4 test org.codehaus.plexus plexus-maven-plugin merge-descriptors ${basedir}/src/main/resources/META-INF/plexus/components.xml ${project.build.directory}/generated-resources/plexus/META-INF/plexus/components.xml merge-descriptors ${project.groupId} wagon-http-shared ${project.version} wagon-1.0.0/wagon-providers/pom.xml0000644000175000017500000000406711605164037017236 0ustar twernertwerner 4.0.0 org.apache.maven.wagon wagon 1.0 ../pom.xml wagon-providers pom Maven Wagon Providers wagon-file wagon-ftp wagon-http-lightweight wagon-http wagon-http-shared wagon-scm wagon-ssh-external wagon-ssh-common wagon-ssh-common-test wagon-ssh wagon-webdav-jackrabbit org.apache.maven.wagon wagon-provider-api org.apache.maven.wagon wagon-provider-test test wagon-1.0.0/wagon-providers/wagon-ssh-common-test/0000755000175000017500000000000011630374113022057 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common-test/src/0000755000175000017500000000000011630374113022646 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common-test/src/main/0000755000175000017500000000000011630374113023572 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common-test/src/main/java/0000755000175000017500000000000011630374113024513 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common-test/src/main/java/org/0000755000175000017500000000000011630374113025302 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/0000755000175000017500000000000011630374113026523 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/0000755000175000017500000000000011630374113027631 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/0000755000175000017500000000000011630374113030744 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/0000755000175000017500000000000011630374113032761 5ustar twernertwerner././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/wagon-1.0.0/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh0000755000175000017500000000000011630374113033477 5ustar twernertwerner././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/TestData.javawagon-1.0.0/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh0000644000175000017500000000377410670157111033514 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: TestData.java 573459 2007-09-07 05:14:49Z brett $ */ public class TestData { public static String getTempDirectory() { return System.getProperty( "java.io.tmpdir", "/tmp" ); } public static String getTestRepositoryUrl() { return "scp://" + getHostname() + getTempDirectory() + "/wagon-ssh-test/" + getUserName(); } public static String getUserName() { return System.getProperty( "test.user", System.getProperty( "user.name" ) ); } public static File getPrivateKey() { return new File( System.getProperty( "user.home" ), "/.ssh/id_dsa" ); } public static String getHostname() { return System.getProperty( "test.host", "localhost" ); } public static String getHostKey() { try { return FileUtils.fileRead( "/etc/ssh_host_rsa_key.pub" ).substring( "ssh-rsa".length() ).trim(); } catch ( IOException e ) { return null; } } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/wagon-1.0.0/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh0000755000175000017500000000000011630374113033477 5ustar twernertwerner././@LongLink0000000000000000000000000000021700000000000011565 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh/knownhost/KnownHostsProviderTestCase.javawagon-1.0.0/wagon-providers/wagon-ssh-common-test/src/main/java/org/apache/maven/wagon/providers/ssh0000644000175000017500000000746411045156772033525 0ustar twernertwernerpackage 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 ); } } wagon-1.0.0/wagon-providers/wagon-ssh-common-test/src/site/0000755000175000017500000000000011630374113023612 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-ssh-common-test/src/site/site.xml0000644000175000017500000000013211045135116025272 0ustar twernertwerner wagon-1.0.0/wagon-providers/wagon-ssh-common-test/pom.xml0000644000175000017500000000364311605164037023406 0ustar twernertwerner 4.0.0 org.apache.maven.wagon wagon-providers 1.0 ../pom.xml wagon-ssh-common-test Maven Wagon SSH Common Tests org.codehaus.plexus plexus-container-default compile org.codehaus.plexus plexus-utils org.apache.maven.wagon wagon-ssh-common junit junit 3.8.1 compile wagon-1.0.0/wagon-providers/wagon-http/0000755000175000017500000000000011630374113017776 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http/src/0000755000175000017500000000000011630374113020565 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http/src/main/0000755000175000017500000000000011630374113021511 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http/src/main/resources/0000755000175000017500000000000011630374113023523 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http/src/main/resources/META-INF/0000755000175000017500000000000011630374113024663 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http/src/main/resources/META-INF/plexus/0000755000175000017500000000000011630374113026203 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http/src/main/resources/META-INF/plexus/components.xml0000644000175000017500000000266211014455675031131 0ustar twernertwerner org.apache.maven.wagon.Wagon http org.apache.maven.wagon.providers.http.HttpWagon per-lookup org.apache.maven.wagon.Wagon https org.apache.maven.wagon.providers.http.HttpWagon per-lookup wagon-1.0.0/wagon-providers/wagon-http/src/main/java/0000755000175000017500000000000011630374113022432 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http/src/main/java/org/0000755000175000017500000000000011630374113023221 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http/src/main/java/org/apache/0000755000175000017500000000000011630374113024442 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http/src/main/java/org/apache/maven/0000755000175000017500000000000011630374113025550 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/0000755000175000017500000000000011630374113026663 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/0000755000175000017500000000000011630374113030700 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/0000755000175000017500000000000011630374113031657 5ustar twernertwerner././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpWagon.javawagon-1.0.0/wagon-providers/wagon-http/src/main/java/org/apache/maven/wagon/providers/http/HttpWagon0000644000175000017500000000716211147165407033532 0ustar twernertwernerpackage 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.io.IOException; import java.io.InputStream; import java.util.List; import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.methods.GetMethod; 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.AbstractHttpClientWagon; import org.apache.maven.wagon.shared.http.HtmlFileListParser; /** * @author Michal Maczka * @version $Id: HttpWagon.java 745730 2009-02-19 05:15:51Z brett $ */ public class HttpWagon extends AbstractHttpClientWagon { public List getFileList( String destinationDirectory ) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { if ( destinationDirectory.length() > 0 && !destinationDirectory.endsWith( "/" ) ) { destinationDirectory += "/"; } String url = getRepository().getUrl() + "/" + destinationDirectory; GetMethod getMethod = new GetMethod( url ); try { int statusCode = execute( getMethod ); fireTransferDebug( url + " - Status code: " + statusCode ); // TODO [BP]: according to httpclient docs, really should swallow the output on error. verify if that is required switch ( statusCode ) { case HttpStatus.SC_OK: break; case SC_NULL: throw new TransferFailedException( "Failed to transfer file: " ); 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" ); //add more entries here default : throw new TransferFailedException( "Failed to transfer file: " + url + ". Return code is: " + statusCode ); } InputStream is = null; is = getMethod.getResponseBodyAsStream(); return HtmlFileListParser.parseFileList( url, is ); } catch ( IOException e ) { throw new TransferFailedException( "Could not read response body.", e ); } finally { getMethod.releaseConnection(); } } } wagon-1.0.0/wagon-providers/wagon-http/src/site/0000755000175000017500000000000011630374113021531 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http/src/site/site.xml0000644000175000017500000000013211045135116023211 0ustar twernertwerner wagon-1.0.0/wagon-providers/wagon-http/src/site/apt/0000755000175000017500000000000011630374113022315 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http/src/site/apt/index.apt0000644000175000017500000000063211045136112024126 0ustar twernertwerner ------ Maven Wagon HTTP ------ Carlos Sanchez ------ 2006-04-16 ------ Maven Wagon HTTP This project is an implementation of Wagon provider for HTTP access. It uses {{{http://jakarta.apache.org/commons/httpclient/}commons-httpclient}} as lower lever layer. It enables Maven to use remote repositories stored in HTTP servers. It doesn't allow deployment. Features * Get files from HTTP Server wagon-1.0.0/wagon-providers/wagon-http/src/test/0000755000175000017500000000000011630374113021544 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http/src/test/resources/0000755000175000017500000000000011630374113023556 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http/src/test/resources/ssl/0000755000175000017500000000000011630374113024357 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http/src/test/resources/ssl/keystore0000644000175000017500000000252311044154044026147 0ustar twernertwernerþíþíjettyuQþ•»0‚·0 +*‚£m¦³8d$oOÀþ˜Î.Ë3]g®ò •d–<àÔÆzp”p¼„1ÖÉv@ˆuþðé'¥#ÖB»S»çô/s…-ÃŒÎ:V˜ƒÏŽ˜ÑÁto‚‚hlI¨,DnMŽãi 5ªß×;Š@w$uŸë*¼ÂÚH¥õÜ(³“Ö¥a€‡L5ZÅï{·´öaÈöPj‡2Ù$#­ gú-Ü.DÅéÚò¡p<ÚnvðÎÜÓ@G*·ÙCy+E#À}á”×׈îÀ¢ëæÊX˜G(F`hÿ–¾ÑßZ¶ö³ju•‘?fŠ:SÊD¦‰$µ YêJSC¡É/fÐú†zÑÆ<à^ÂRvæ•Vdc*øw‚HR$‰¶²«m+öÉÏ(LÁW‘_Œñpéy¦"0UEæÆÅ£º6ÄÝMâñÔxkE^R†yÅ5™:šÙPÍõ9Ñ«S±Ð{eþ²üÜ [ËéË @'Êëwçšz²+ÄO_ýúÝ90EçB›8î¬ «LúÂg$hßÑÞúIÀ)ËP ¡51P]Hè›&HäYb}÷Éøó5Ž8\öž Þ È„®RŠÊ­Î÷̉¬o,ÍTEIwÝØ-àd΋!)ÿµjÏ«p)V¨h6`j¸Öíùzƒÿ¥»Ëú5ºÌê.õãÈ0¶éâ ¯;Ÿ¶“@9:OX.509R0‚N0‚·H¸È0  *†H†÷ 0n10UUnknown10UUnknown10UUnknown10U Unknown10U Unknown10U localhost0 080730185400Z 081028185400Z0n10UUnknown10UUnknown10UUnknown10U Unknown10U Unknown10U localhost0Ÿ0  *†H†÷ 0‰ÐÅ.Y¥E^äákOð,J.¿§ƒ—A”#¡AôxñBÚ¿áÎè®õ.XtÆ_4ƒ Ú_‘ʤ„CÛôk‘Á-°’in‘ɳÄaHÉB€2†ŽSZ£ FNx:/}Lº)ö!pO" I¶?È¡   ¨wàÓX“%'ÉØ4Ùwy0  *†H†÷ /ÔÝÞÂLOuMšð,_ž˜2·9†µÙÞBu÷sß“>ì}u*În9Açš7ÆÐ!u7gâ/F±×2–.õøO¨¿ÏzpžèøÎL Æiä ß+'4¨ªè@¦)|ÿÜe…á½PÙØ·,âžaèó,Iô§ó;‚”Ïóò)¾ðZiu+qò»+{1'TKëÔ«pwagon-1.0.0/wagon-providers/wagon-http/src/test/java/0000755000175000017500000000000011630374113022465 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http/src/test/java/org/0000755000175000017500000000000011630374113023254 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http/src/test/java/org/apache/0000755000175000017500000000000011630374113024475 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http/src/test/java/org/apache/maven/0000755000175000017500000000000011630374113025603 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/0000755000175000017500000000000011630374113026716 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/0000755000175000017500000000000011630374113030733 5ustar twernertwernerwagon-1.0.0/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/0000755000175000017500000000000011630374113031712 5ustar twernertwerner././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWagonTest.javawagon-1.0.0/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpsWago0000644000175000017500000000345411044154044033561 0ustar twernertwernerpackage 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 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 } ); } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTest.javawagon-1.0.0/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagon0000644000175000017500000000277111044154044033555 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: HttpWagonTest.java 681203 2008-07-30 21:07:48Z brett $ */ public class HttpWagonTest extends HttpWagonTestCase { protected String getProtocol() { return "http"; } protected String getTestRepositoryUrl() { return getProtocol() + "://localhost:10007"; } protected void setHttpHeaders( StreamingWagon wagon, Properties properties ) { ( (HttpWagon) wagon ).setHttpHeaders( properties ); } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/WaitForeverServlet.javawagon-1.0.0/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/WaitForev0000644000175000017500000000275611015033162033546 0ustar twernertwernerpackage 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.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.ServletException; import java.io.IOException; /** * User: jdumay * Date: 24/01/2008 * Time: 17:25:27 */ public class WaitForeverServlet extends HttpServlet { public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { System.out.println( "Calling WaitForeverServlet" ); try { Thread.sleep( 2000 ); } catch (InterruptedException e) { //eat } } } ././@LongLink0000000000000000000000000000017400000000000011567 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonHttpServerTestCase.javawagon-1.0.0/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagon0000644000175000017500000000364611044154044033557 0ustar twernertwernerpackage 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(); } } ././@LongLink0000000000000000000000000000016500000000000011567 Lustar rootrootwagon-1.0.0/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagonTimeoutTest.javawagon-1.0.0/wagon-providers/wagon-http/src/test/java/org/apache/maven/wagon/providers/http/HttpWagon0000644000175000017500000001077611044154044033561 0ustar twernertwernerpackage 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.io.File; 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; /** * 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.setTimeout( 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.setTimeout( 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.setTimeout( 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.setTimeout( 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() ); } } wagon-1.0.0/wagon-providers/wagon-http/pom.xml0000644000175000017500000000642211605164037021323 0ustar twernertwerner 4.0.0 org.apache.maven.wagon wagon-providers 1.0 ../pom.xml wagon-http Maven Wagon HTTP Provider Wagon that gets and puts artifacts through http using Apache commons-httpclient ${project.groupId} wagon-http-shared ${project.version} wagon-1.0.0/wagon-tcks/0000755000175000017500000000000011630374114014636 5ustar twernertwernerwagon-1.0.0/wagon-tcks/wagon-tck-http/0000755000175000017500000000000011630374114017505 5ustar twernertwernerwagon-1.0.0/wagon-tcks/wagon-tck-http/src/0000755000175000017500000000000011630374114020274 5ustar twernertwernerwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/0000755000175000017500000000000011630374114021220 5ustar twernertwernerwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/resources/0000755000175000017500000000000011630374114023232 5ustar twernertwernerwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/resources/default-server-root/0000755000175000017500000000000011630374114027143 5ustar twernertwernerwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/resources/default-server-root/protected/0000755000175000017500000000000011630374114031134 5ustar twernertwernerwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/resources/default-server-root/protected/base.txt0000644000175000017500000000003211267126213032603 0ustar twernertwernerThis is just a basic file.wagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/resources/default-server-root/large.txt0000644000175000017500000000067411267126213031006 0ustar twernertwernera;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 wagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/resources/default-server-root/base.txt0000644000175000017500000000003211267126213030612 0ustar twernertwernerThis is just a basic file.wagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/resources/ssl/0000755000175000017500000000000011630374114024033 5ustar twernertwernerwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/resources/ssl/keystore0000644000175000017500000000223711267126213025630 0ustar twernertwernerþíþíjetty$^'A;»0‚·0 +*‚£vR¹ 2Œã¤ßŒƒ5·+ÔN7š.ùüUXaÈÅ+Ra3ÍQ:©‚9g#spì&HE„û`('v–yuEØ/.&·9ŒK–ê'±j –ôŽ>?Ž”®&£Í¡±ý’úÌÛ¾‰2‹‰êíZö“©rNH§ ÁŸg<†O™968=Wïæ¿œÖÔS†[©\ ½È> º1{¤ ÷ÄGF‰†•³ÏæK…˜ ŽÌç1)HH‡9"ÅV6¨»8ÊlR¤sI¿0´|à®z«°M:»ó¹Ø&Av¢Þ‚@*‚ƒóÍv¬§F9±hRåÒZ„0šôà„«’Ut¸£ÝF›« ÄJ)ç,¿ŒÍ:%’E5üZk‘û©<éS…^oTÞ3d°[ï)b “†ÑOÆ©Ä'u{S›¯$à†£ë úM(÷p”DI:Sõ.]ÿ@A5gµ¸»~&)*ÛPöé…¼¥#Øe\X‚›®€Fô¾H^[|%O ÷<ÊÍ¢ÂÔÙkèñÕ—3Ñ(KGÕ`\=ff¿~úØöÏZ“Å!/¸ÍsµíÌÿà«´®þÄÃ'ÌÓ¿vN¹jHÖ¡Þ98v+u˜™º#ì ý”j×ÿ“°±¦†¹FÅ›~!•déãÏÕ«Úݪi *æx÷¸ç0›$ ЪE PPôÇå:¯¾y ÛPŠqáqf÷R`¶ÿAYgûEBëO£W?¸.ÁX?g&8/¤,‡Ð0£­í²=±››R8p×™”).v²~ŽR„÷âo…œÉÜXHÅ;ür¡•îví îòì•?s™¾WÈÛ۵ץj4Móãì›2ü4(ßÃèo†wfã ÿe_¥zt5Ëÿ©jÇÏr=úeX.509ž0‚š0‚JØ0  *†H†÷ 010U localhost0 091016162119Z 100114162119Z010U localhost0Ÿ0  *†H†÷ 0‰ê(J)b8y|ÖÉÆFeß»ÏÊaÏß4«èv×Ú+®„*as«(JŠ>í÷å³ï˜~"S$n-Ò‘5"øk‚/Q?×MAÔìÞ¿¥D#è?"c8ÒFDa·@8¦¶w1xK°!7(b]—Ý/¢q‡? }þá¢è‘³æÆŸ×vÀvý0  *†H†÷ Ê»qa|Àvºï¶Ü¡n©ðÔ ü8É=@¡™Ss-wuÝ6.fíWN=ÊÓˆb&œ²ÊHC8ÜÙ‚«¶S»G߀ú¨Ùy¶v³t–ÐÇÊv`1¤ fêŒc`è·hŠJÛåt¸&»œsükŸ=âo(h 1Ó„_X¹—®Gù¿M~D]0{²û¯dZ¸(ï=óA·îÃwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/0000755000175000017500000000000011630374114022141 5ustar twernertwernerwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/0000755000175000017500000000000011630374114022730 5ustar twernertwernerwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/0000755000175000017500000000000011630374114024151 5ustar twernertwernerwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/0000755000175000017500000000000011630374114025257 5ustar twernertwernerwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/0000755000175000017500000000000011630374114026372 5ustar twernertwernerwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/0000755000175000017500000000000011630374114027153 5ustar twernertwernerwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/0000755000175000017500000000000011630374114030132 5ustar twernertwernerwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/util/0000755000175000017500000000000011630374114031107 5ustar twernertwerner././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/util/ValueHolder.javawagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/util/ValueHolder0000644000175000017500000000222611300752054033243 0ustar twernertwernerpackage 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. */ public class ValueHolder { 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; } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/util/TestUtil.javawagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/util/TestUtil.ja0000644000175000017500000001032711300752054033200 0ustar twernertwernerpackage 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 org.codehaus.plexus.util.IOUtil; 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; public final class TestUtil { private static final Map bases = new HashMap(); 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(); System.out.println( "unpacking test resources in jar: " + url ); JarFile jf = null; try { jf = new JarFile( urlFile ); InputStream in = null; OutputStream out = null; for ( Enumeration 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 ) { } } } } return new File( base, path ); } else { return new File( resource.toURI().normalize() ); } } } wagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/Assertions.java0000644000175000017500000000403111300752054033122 0ustar twernertwernerpackage 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 ); } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/HttpWagonTests.javawagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/HttpWagonTests.j0000644000175000017500000002146511300752054033250 0ustar twernertwernerpackage 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 org.apache.maven.wagon.tck.http.util.TestUtil.getResource; 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 java.io.File; import java.io.IOException; import java.util.HashSet; import java.util.Set; public abstract class HttpWagonTests { private ServerFixture serverFixture; private static PlexusContainer container; private Wagon wagon; private static WagonTestCaseConfigurator configurator; private String baseUrl; private final static Set tmpFiles = new HashSet(); private Repository repo; private final Set notificationTargets = new HashSet(); @Before public void beforeEach() throws Exception { serverFixture = new ServerFixture( getPort(), isSsl() ); 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 : tmpFiles ) { 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 ) ) { System.out.println( "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 ) ) { System.out.println( "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() { int port = getPortPropertyValue(); if ( port < 1 ) { port = getDefaultPort(); } return port; } protected int getDefaultPort() { return 9080; } 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 getTmpfiles() { return tmpFiles; } protected Repository getRepo() { return repo; } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/GetWagonTests.javawagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/GetWagonTests.ja0000644000175000017500000004640711300752054033214 0ustar twernertwernerpackage 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.assertTrue; import static junit.framework.Assert.fail; import static org.apache.maven.wagon.tck.http.Assertions.assertFileContentsFromResource; 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 java.io.File; import java.io.IOException; import javax.servlet.Servlet; import javax.servlet.http.HttpServletResponse; public class GetWagonTests extends HttpWagonTests { @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( 2000 ) ); testSuccessfulGet( "slow/large.txt", "large.txt" ); } @Test public void highLatencyLowTimeout() throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException, TransferFailedException, ResourceDoesNotExistException, AuthorizationException { Servlet servlet = new LatencyServlet( 2000 ); 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 holder = new ValueHolder( 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 ) { System.out.println( "Connection timeout is: " + ( (StreamWagon) 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 { System.out.println( "Waiting 60 seconds for wagon timeout." ); t.join( 30000 ); } catch ( InterruptedException e ) { e.printStackTrace(); } System.out.println( "Interrupting thread." ); t.interrupt(); assertTrue( "TransferFailedException should have been thrown.", holder.getValue() ); } @Test public void nonExistentHost() throws ConnectionException, AuthenticationException, ComponentConfigurationException, IOException, ResourceDoesNotExistException, AuthorizationException { if ( !initTest( "http://dummy-host", 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 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 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 ) { System.out.println( "Connection timeout is: " + ( (StreamWagon) 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 } } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/HttpsGetWagonTests.javawagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/HttpsGetWagonTes0000644000175000017500000000206311300752054033265 0ustar twernertwernerpackage 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; } @Override protected int getDefaultPort() { return 9443; } } ././@LongLink0000000000000000000000000000016300000000000011565 Lustar rootrootwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/WagonTestCaseConfigurator.javawagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/WagonTestCaseCon0000644000175000017500000001052111300752054033220 0ustar twernertwernerpackage 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.classworlds.ClassRealm; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; 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; public boolean isSupported( final String useCaseId ) { if ( useCaseConfigs != null ) { PlexusConfiguration config = useCaseConfigs.getChild( useCaseId, false ); if ( config != null && config.getChild( UNSUPPORTED_ELEMENT, false ) != null ) { System.out.println( "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 ) { System.out.println( "Test case '" + useCaseId + "' is marked as unsupported by this wagon." ); return false; } else { System.out.println( "Configuring wagon for test case: " + useCaseId + " with:\n\n" + config ); configurator.configureComponent( wagon, useCaseConfigs.getChild( useCaseId, false ), realm ); } } else { System.out.println( "No wagon configuration found for test case: " + useCaseId ); } } else { System.out.println( "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; } } wagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/0000755000175000017500000000000011630374114031620 5ustar twernertwerner././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/RedirectionServlet.javawagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/Redirect0000644000175000017500000000512111300752054033300 0ustar twernertwernerpackage 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 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 path ) { this.code = code; this.targetPath = path; 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 ); } else { resp.setStatus( code ); resp.setHeader( "Location", targetPath ); } } } ././@LongLink0000000000000000000000000000016100000000000011563 Lustar rootrootwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/AuthSnoopFilter.javawagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/AuthSnoo0000644000175000017500000000412011300752054033275 0ustar twernertwernerpackage 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; public class AuthSnoopFilter implements Filter { 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 ) { System.out.println( "Authorization: " + authHeader ); String data = authHeader.substring( "BASIC ".length() ); String decoded = new String( Base64.decodeBase64( data ) ); System.out.println( decoded ); String[] creds = decoded.split( ":" ); System.out.println( "User: " + creds[0] + "\nPassword: " + creds[1] ); } } public void init( final FilterConfig filterConfig ) throws ServletException { } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/LatencyServlet.javawagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/LatencyS0000644000175000017500000000700411300752054033263 0ustar twernertwernerpackage 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.codehaus.plexus.util.IOUtil; 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; public class LatencyServlet extends HttpServlet { 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 ) { System.out.println( "Starting infinite wait." ); synchronized ( this ) { try { wait(); } catch ( InterruptedException e ) { } } 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(); System.out.println( "Starting high-latency transfer. This should take about " + ( ( f.length() / BUFFER_SIZE * latencyMs / 1000 ) + ( latencyMs / 1000 ) ) + " seconds." ); int read = -1; byte[] buf = new byte[BUFFER_SIZE]; while ( ( read = in.read( buf ) ) > -1 ) { try { Thread.sleep( latencyMs ); } catch ( InterruptedException e ) { e.printStackTrace(); } System.out.println( "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 ); } System.out.println( "High-latency transfer done in " + ( System.currentTimeMillis() - start ) + "ms" ); } } ././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ServerFixture.javawagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ServerFi0000644000175000017500000001366611300752054033301 0ustar twernertwernerpackage 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 static org.apache.maven.wagon.tck.http.util.TestUtil.getResource; 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 java.io.File; import java.io.IOException; import java.net.URISyntaxException; import javax.servlet.Filter; import javax.servlet.Servlet; public class ServerFixture { public static final String SERVER_ROOT_RESOURCE_PATH = "default-server-root"; public static final String SERVER_SSL_KEYSTORE_RESOURCE_PATH = "ssl/keystore"; public static final String SERVER_SSL_KEYSTORE_PASSWORD = "password"; 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;; public ServerFixture( final int port, final boolean ssl ) throws URISyntaxException, IOException { server = new Server(); if ( ssl ) { SslSocketConnector connector = new SslSocketConnector(); String keystore = getResource( SERVER_SSL_KEYSTORE_RESOURCE_PATH ).getAbsolutePath(); // 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 ); System.out.println( "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 { server.start(); int total = 0; while ( total < 3000 && !server.isStarted() ) { server.wait( 10 ); total += 10; } if ( !server.isStarted() ) { throw new IllegalStateException( "Server didn't start in: " + total + "ms." ); } } } ././@LongLink0000000000000000000000000000017300000000000011566 Lustar rootrootwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ProxyAuthenticationFilter.javawagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ProxyAut0000644000175000017500000000526711300752054033345 0ustar twernertwernerpackage 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 { } } ././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ErrorCodeServlet.javawagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ErrorCod0000644000175000017500000000305411300752054033261 0ustar twernertwernerpackage 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 ); } } ././@LongLink0000000000000000000000000000017100000000000011564 Lustar rootrootwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ServletExceptionServlet.javawagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ServletE0000644000175000017500000000300111300752054033263 0ustar twernertwernerpackage 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 ); } } ././@LongLink0000000000000000000000000000017700000000000011572 Lustar rootrootwagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ProxyConnectionVerifierFilter.javawagon-1.0.0/wagon-tcks/wagon-tck-http/src/main/java/org/apache/maven/wagon/tck/http/fixture/ProxyCon0000644000175000017500000000436211300752054033326 0ustar twernertwernerpackage 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; public class ProxyConnectionVerifierFilter implements Filter { 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 kEn = request.getHeaderNames(); for ( String key : Collections.list( kEn ) ) { if ( key == null ) { continue; } Enumeration vEn = request.getHeaders( key ); if ( vEn != null ) { for ( String val : Collections.list( vEn ) ) { System.out.println( key + ": " + val ); } } } chain.doFilter( req, resp ); } public void init( final FilterConfig filterConfig ) throws ServletException { } } wagon-1.0.0/wagon-tcks/wagon-tck-http/sample-tck-consumer/0000755000175000017500000000000011630374114023376 5ustar twernertwernerwagon-1.0.0/wagon-tcks/wagon-tck-http/sample-tck-consumer/src/0000755000175000017500000000000011630374114024165 5ustar twernertwernerwagon-1.0.0/wagon-tcks/wagon-tck-http/sample-tck-consumer/src/test/0000755000175000017500000000000011630374114025144 5ustar twernertwernerwagon-1.0.0/wagon-tcks/wagon-tck-http/sample-tck-consumer/src/test/resources/0000755000175000017500000000000011630374114027156 5ustar twernertwernerwagon-1.0.0/wagon-tcks/wagon-tck-http/sample-tck-consumer/src/test/resources/META-INF/0000755000175000017500000000000011630374114030316 5ustar twernertwernerwagon-1.0.0/wagon-tcks/wagon-tck-http/sample-tck-consumer/src/test/resources/META-INF/plexus/0000755000175000017500000000000011630374114031636 5ustar twernertwerner././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootwagon-1.0.0/wagon-tcks/wagon-tck-http/sample-tck-consumer/src/test/resources/META-INF/plexus/components.xmlwagon-1.0.0/wagon-tcks/wagon-tck-http/sample-tck-consumer/src/test/resources/META-INF/plexus/compone0000644000175000017500000000125411267133575033235 0ustar twernertwerner org.apache.maven.wagon.tck.http.WagonTestCaseConfigurator org.apache.maven.wagon.tck.http.WagonTestCaseConfigurator http wagon-1.0.0/wagon-tcks/wagon-tck-http/sample-tck-consumer/src/test/java/0000755000175000017500000000000011630374114026065 5ustar twernertwernerwagon-1.0.0/wagon-tcks/wagon-tck-http/sample-tck-consumer/src/test/java/org/0000755000175000017500000000000011630374114026654 5ustar twernertwernerwagon-1.0.0/wagon-tcks/wagon-tck-http/sample-tck-consumer/src/test/java/org/apache/0000755000175000017500000000000011630374114030075 5ustar twernertwernerwagon-1.0.0/wagon-tcks/wagon-tck-http/sample-tck-consumer/src/test/java/org/apache/maven/0000755000175000017500000000000011630374114031203 5ustar twernertwernerwagon-1.0.0/wagon-tcks/wagon-tck-http/sample-tck-consumer/src/test/java/org/apache/maven/wagon/0000755000175000017500000000000011630374114032316 5ustar twernertwernerwagon-1.0.0/wagon-tcks/wagon-tck-http/sample-tck-consumer/src/test/java/org/apache/maven/wagon/tck/0000755000175000017500000000000011630374114033077 5ustar twernertwerner././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootwagon-1.0.0/wagon-tcks/wagon-tck-http/sample-tck-consumer/src/test/java/org/apache/maven/wagon/tck/http/wagon-1.0.0/wagon-tcks/wagon-tck-http/sample-tck-consumer/src/test/java/org/apache/maven/wagon/tck/h0000755000175000017500000000000011630374114033247 5ustar twernertwerner././@LongLink0000000000000000000000000000016200000000000011564 Lustar rootrootwagon-1.0.0/wagon-tcks/wagon-tck-http/sample-tck-consumer/src/test/java/org/apache/maven/wagon/tck/http/consumer/wagon-1.0.0/wagon-tcks/wagon-tck-http/sample-tck-consumer/src/test/java/org/apache/maven/wagon/tck/h0000755000175000017500000000000011630374114033247 5ustar twernertwerner././@LongLink0000000000000000000000000000020000000000000011555 Lustar rootrootwagon-1.0.0/wagon-tcks/wagon-tck-http/sample-tck-consumer/src/test/java/org/apache/maven/wagon/tck/http/consumer/TestSuite.javawagon-1.0.0/wagon-tcks/wagon-tck-http/sample-tck-consumer/src/test/java/org/apache/maven/wagon/tck/h0000644000175000017500000000054311267133575033265 0ustar twernertwernerpackage org.apache.maven.wagon.tck.http.consumer; 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; @RunWith( Suite.class ) @Suite.SuiteClasses( { GetWagonTests.class, HttpsGetWagonTests.class } ) public class TestSuite { } wagon-1.0.0/wagon-tcks/wagon-tck-http/sample-tck-consumer/pom.xml0000644000175000017500000000266511605160467024732 0ustar twernertwerner 4.0.0 org.apache.maven.wagon sample-tck-consumer 1.0-SNAPSHOT sample-tck-consumer org.apache.maven.wagon wagon-http-lightweight 1.0-SNAPSHOT test org.apache.maven.wagon wagon-tck-http ${project.version} test junit junit 4.5 test maven-compiler-plugin 2.0.2 1.5 1.5 wagon-1.0.0/wagon-tcks/wagon-tck-http/Test Plan.oo3/0000755000175000017500000000000011630374114021776 5ustar twernertwernerwagon-1.0.0/wagon-tcks/wagon-tck-http/Test Plan.oo3/contents.xml0000644000175000017500000000400011267133575024361 0ustar twernertwerner‹­X[Wêº~ß¿"§gì3ƪ-E÷QöX ŠŠ€.ñe´MÛ@šÔ6å¶Çùïg¶E@°]Ëi“&ß7¿yÉlÏÿžy MHRÁ/”‘® ÂMaQî\(‘´ÕS…s 3ÁÉ…Â…òwõó]vêýa·D$åuµÖM)ª¦ S'‘d OÓ.û—¨3è·nÚ T:Ò5­ÑVâJéÿ¥iÓéôèãó{$ô±I´ŒwÒí h.¡ÔIéÈ’–,Và0ÉËÌ{NJJõ<”sFT,e@H5  e0ßšYSIAc2¿PlÁ¥jSÆ”`¥# Šáà&)˜d2Áô®zžü¢é…¢+Zõ\ÛÚƒ¬¯#S‰5wb¯¦–¸†L©r‘*¤ ²(XÂðÈ3ØW(æšê¸r'Ôjjì8–$3©ØÇ8ÜR—nZ¢Æ³+Ô÷‡ûáì]Å ï\ÞÆW„~sDmã'~Ž¿œ^âpÀÇ?j<¯Jl0‚,bãˆIu‚YDbR[¨„p‰ÞYîÏ¡ÌÄ6x¾ðÜa_YQ\­.5Ç_Xp¶Z`‰ÈH!´%»¤ÞY«(ñB+8üp‡¨å+Òqí¾÷äwÆ+ä&„º>$RBÜ•ˆK<½ê¹MƒPªÉ¨K0 UlJ:’lÒ Ä„™èU–Ƶð<ö?ìY="^=gnLÇÐ4Ž× ¥Óé3^Õ§’‘§åø;P›Â&±êÉB-ÙCƒÍ´t[-Å…‹m’ñƒ–ø%â¶X¿VA½¥â@ÅÄŒ\ 3ŠWôÅ•]Øäµ¤« 9÷IztÌÁÍADäÃFÕõXú7Y‰E%Ä” ^"ËóëBù§¢¾¡Š^üŸ‹ú és kTÂc!¬•ÆV€§ ±¥ŒÍŒ³¢ò¤+B©0%84Sp•pìF½Óç§ú÷§ç´R$ ’àŽ<®.’ð³ú~»t;ú5¾²3=s¦±é€QéQN=(6ëCx¶9”$<™ù"oÉq\È$ÁreÒ'Aœ40ëIxT*¥y˜\Ë‹ÝÙøil>“4 ÕBa+Od‡o‘«½GÛrBKø ßèêµ9¸¶~^:…úœo XÚPOþvªX)&2®zÎJ~ä¼–m#–9šbGpØ4” ÿ4Ÿ6-ÔÞb%B~ê°e#T=ûRyLÏÇ-Ù©$^‹-µ¨–ëäåçwhýg>´ú«,ˆ·qŽè¸S p—åýÄÚ@HF„Ÿš¼ÚÀt)³Â׈`R4NëNkTœfBnöû݃xZ ³6.œšþ Ý6.3ƒõ¾Š¦½[¹‰ïßÍÔF-lÞðÇMÕªìé +—Æì: TWW´¹çºÑÏ,)¾|ÅX*{÷î²ïMºng>{.ö÷»§ñýi (4\‡:ì&çʼn"^xã×Ï’ƒÂ¾Pmàv/¹AH‰C’Ës£ÓçáŒc{0 2쀹˜räŠPfwéy§ü0š/å_7ÿ{$ݸËH›–<ÈëO"Ãî>fÒ ™& C;b‰Ì2ŒÚ­ië¦ósÐͨ}ø‹Èþà™Þ‹ú“Sû¹?§B
jetty wagon test plan
VX Test protocols
*X HTTP
*X HTTPS
V Test methods
* GET
* PUT
* HEAD / exists
V- Use cases
*X Unknown host
V- Authentication
*X Successful auth
*X Unsuccessful auth
* Preemptive auth
V Non-preemptive auth
* Should not send payload twice, if it can be helped
VX Connection latency
*X High latency, high timeout
*X High latency, low timeout
*X No response
VX Common errors
*X 404
*X 500
*X 503
*X 403
VX Redirection: 301 / 302
*X Redirection within max count
*X Redirection over max count
*X Infinite redirection
V Proxies
* No authentication
* Authorization failure
* Authentication success
V Headers
* User Agent
* no-cache (Pragma, etc.)
V Authorization
* long (something that will line-wrap Sun's header impl)
V File listing
* Missing directory
* normal listing
* Forbidden directory listing
wagon-1.0.0/wagon-tcks/wagon-tck-http/Test Plan.html/outliner.js0000644000175000017500000000534511267126213024451 0ustar twernertwernervar img_expanded = 'Expanded.png'; var img_collapsed = 'Collapsed.png'; var img_blank = 'blank.png'; var img_leaf = 'LeafRowHandle.png'; new Image(9,9),src = img_expanded; // caching new Image(9,9),src = img_collapsed; // caching new Image(9,9),src = img_blank; // caching new Image(9,9),src = img_leaf; // caching function hover(iNode, over) { if (over) { t = document.getElementById(iNode).alt; if (t == '*') { document.getElementById(iNode).src=img_leaf; } else if (t == 'V') { document.getElementById(iNode).src=img_expanded; } else { document.getElementById(iNode).src=img_collapsed; } } else { document.getElementById(iNode).src=img_blank; } } function expand(ioNode) { ioWedge = "i" + ioNode.substr(1); if (document.getElementById && document.getElementById(ioNode) != null) { document.getElementById(ioNode).className='expanded'; if (document.getElementById(ioWedge) != null) { document.getElementById(ioWedge).src=img_expanded; document.getElementById(ioWedge).title='collapse'; document.getElementById(ioWedge).alt='V'; } } } function collapse(ioNode) { ioWedge = "i" + ioNode.substr(1); if (document.getElementById && document.getElementById(ioNode) != null) { document.getElementById(ioNode).className='collapsed'; if (document.getElementById(ioWedge) != null) { document.getElementById(ioWedge).src=img_collapsed; document.getElementById(ioWedge).title='expand'; document.getElementById(ioWedge).alt='>'; } } } function ioSwitch(ioNode,fully) { if (document.getElementById && document.getElementById(ioNode) != null) { nodeState = document.getElementById(ioNode).className; } if (nodeState == 'collapsed') { if (fully) { expandAll(); } else { expand(ioNode); } } else { if (fully) { collapseAll(); } else { collapse(ioNode); } } } function expandAll() { if (document.getElementsByTagName) { nodeList = document.getElementsByTagName('div'); for (var i = 0; i < nodeList.length; i++) { if (nodeList.item(i).className == 'expanded' || nodeList.item(i).className == 'collapsed') { expand(nodeList.item(i).id); } } } else { alert ("Sorry, don't know how to make this run in your browser."); } } function collapseAll() { if (document.getElementsByTagName) { nodeList = document.getElementsByTagName('div'); for (var i = 0; i < nodeList.length; i++) { if (nodeList.item(i).className == 'expanded' || nodeList.item(i).className == 'collapsed') { collapse(nodeList.item(i).id); } } } else { alert ("Sorry, don't know how to make this run in your browser."); } } wagon-1.0.0/wagon-tcks/wagon-tck-http/Test Plan.html/Mixed.png0000644000175000017500000000032511267126213024017 0ustar twernertwerner‰PNG  IHDR à‘ pHYs  šœgAMA±Ž|ûQ“ cHRMz%€ƒùÿ€éu0ê`:˜o’_ÅFKIDATxÚbd``øÏ@#H0âTÀÈø €ˆR@D) ¨"¨Ûбˆ ¢L ¢QŠˆ‘˜p0ye*7”$©§IEND®B`‚wagon-1.0.0/wagon-tcks/wagon-tck-http/Test Plan.html/LeafRowHandle.png0000644000175000017500000000032211267126213025421 0ustar twernertwerner‰PNG  IHDR à‘gAMAÖØÔOX2tEXtSoftwareAdobe ImageReadyqÉe<dIDATxÚbüÿÿ?!@L D€b™5-ˆßñ(“ ˜$ÿ‘ €äfT!2€Š3²Iÿq™@D¹ €àŠLt€™ÃÄHL8"€Mëzo&‰IEND®B`‚wagon-1.0.0/wagon-tcks/wagon-tck-http/Test Plan.html/Checked.png0000644000175000017500000000042511267126213024300 0ustar twernertwerner‰PNG  IHDR ft¾ pHYs  šœgAMA±Ž|ûQ“ cHRMz%€ƒùÿ€éu0ê`:˜o’_ÅF‹IDATxÚbøÿÿ?.  @ü €@Œÿèª@ª`?@1À±˜²ªÉ €t±”íUÐâÌ:(½*xjÈJ€B6©¦J@Åÿ²"i÷¡‚ç‘Üö €PŽäd>@1Bh¬€‘‘ñ?@1Έ ”.qõYÏÖ>IEND®B`‚wagon-1.0.0/wagon-tcks/wagon-tck-http/Test Plan.html/blank.png0000644000175000017500000000025011267126213024035 0ustar twernertwerner‰PNG  IHDR à‘gAMAÖØÔOX2tEXtSoftwareAdobe ImageReadyqÉe<:IDATxÚbüÿÿ?!@L D€"J@¥ €ˆR@D) ¢QŠˆ(EêNY×çPIEND®B`‚wagon-1.0.0/wagon-tcks/wagon-tck-http/Test Plan.html/Unchecked.png0000644000175000017500000000031511267133575024652 0ustar twernertwerner‰PNG  IHDR à‘ pHYs  šœgAMA±Ž|ûQ“ cHRMz%€ƒùÿ€éu0ê`:˜o’_ÅFCIDATxÚbd``øÏ@#H0âTÀÈø €ˆR@D) ¢QŠˆ(ED”"€b$&œ `%׃R$IEND®B`‚wagon-1.0.0/wagon-tcks/wagon-tck-http/Test Plan.html/Collapsed.png0000644000175000017500000000030111267126213024651 0ustar twernertwerner‰PNG  IHDR à‘gAMAÖØÔOX2tEXtSoftwareAdobe ImageReadyqÉe<SIDATxÚbøÿÿ?Üb ¨¢ÿPÜÄèŠ]Ñl¦6E¦ €ˆ² €ˆr8@1ÄU„+Â}å]‚IEND®B`‚wagon-1.0.0/wagon-tcks/wagon-tck-http/Test Plan.html/Expanded.png0000644000175000017500000000032211267126213024476 0ustar twernertwerner‰PNG  IHDR à‘gAMAÖØÔOX2tEXtSoftwareAdobe ImageReadyqÉe<dIDATxÚbüÿÿ?!@ tˆÿãÀ 9€)2À£Èd@1@­kÀ¢ $ÂÄg00œG·&@ÈŠ Эa€b@á@¬íGa€b$&ˆ‰˜00¿í\9éÛIEND®B`‚wagon-1.0.0/wagon-tcks/wagon-tck-http/pom.xml0000644000175000017500000000377011605164037021034 0ustar twernertwerner 4.0.0 org.apache.maven.wagon wagon-tcks 1.0 ../pom.xml wagon-tck-http Wagon HTTP Test Compatibility Kit org.apache.maven.wagon wagon-http-lightweight ${project.version} org.codehaus.plexus plexus-container-default 1.0-alpha-9-stable-1 compile junit junit 4.8.1 org.mortbay.jetty jetty 6.1.21 org.apache.maven.wagon wagon-provider-api 1.0-beta-6 commons-codec commons-codec 1.4 maven-compiler-plugin 2.3.1 1.5 1.5 wagon-1.0.0/wagon-tcks/pom.xml0000644000175000017500000000305011605164037016154 0ustar twernertwerner 4.0.0 org.apache.maven.wagon wagon 1.0 ../pom.xml wagon-tcks pom Maven Test Compatibility Kits wagon-tck-http org.apache.maven.wagon wagon-provider-api wagon-1.0.0/wagon-provider-api/0000755000175000017500000000000011630374114016273 5ustar twernertwernerwagon-1.0.0/wagon-provider-api/src/0000755000175000017500000000000011630374114017062 5ustar twernertwernerwagon-1.0.0/wagon-provider-api/src/main/0000755000175000017500000000000011630374114020006 5ustar twernertwernerwagon-1.0.0/wagon-provider-api/src/main/java/0000755000175000017500000000000011630374114020727 5ustar twernertwernerwagon-1.0.0/wagon-provider-api/src/main/java/org/0000755000175000017500000000000011630374114021516 5ustar twernertwernerwagon-1.0.0/wagon-provider-api/src/main/java/org/apache/0000755000175000017500000000000011630374114022737 5ustar twernertwernerwagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/0000755000175000017500000000000011630374114024045 5ustar twernertwernerwagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/0000755000175000017500000000000011630374114025160 5ustar twernertwernerwagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/0000755000175000017500000000000011630374114026464 5ustar twernertwernerwagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferListener.java0000644000175000017500000000316110670157111032621 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: TransferListener.java 573459 2007-09-07 05:14:49Z brett $ */ 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 ); } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEvent.java0000644000175000017500000001771111045150702032117 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: TransferEvent.java 682051 2008-08-02 21:29:38Z hboutemy $ */ 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 * TransferEvent.REQUEST_GET or TransferEvent.REQUEST_PUT */ public int getRequestType() { return requestType; } /** * Sets the request type * * @param requestType The requestType to set. * The Request type value should be either * TransferEvent.REQUEST_GET or TransferEvent.REQUEST_PUT. * @throws IllegalArgumentException when */ public void setRequestType( final int requestType ) { switch ( requestType ) { case REQUEST_PUT: break; 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: break; case TRANSFER_STARTED: break; case TRANSFER_COMPLETED: break; case TRANSFER_PROGRESS: break; 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() { StringBuffer sb = new StringBuffer(); 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; } } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionListener.java0000644000175000017500000000722011045150702032454 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: SessionListener.java 682051 2008-08-02 21:29:38Z hboutemy $ */ 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. *

* 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. *

* 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. *

* 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 ); }wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionEvent.java0000644000175000017500000001503711045150702031755 0ustar twernertwernerpackage 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. *

* The session event is emitted by Wagon objects when *

*

    *
  • Before connection to the repository will be opened
  • *
  • After connection to the repository was opened
  • *
  • After wagon has logged-in to the repository
  • *
  • After wagon has logged-off from the repository
  • *
  • Before connection to the repository will be closed
  • *
  • After connection to the repository was closed
  • *
* * @author Michal Maczka * @version $Id: SessionEvent.java 682051 2008-08-02 21:29:38Z hboutemy $ */ 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 Wagon 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 SESSION_ERROR_OCCURRED * * @param wagon Wagon 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: break; case SessionEvent.SESSION_DISCONNECTED: break; case SessionEvent.SESSION_DISCONNECTING: break; case SessionEvent.SESSION_ERROR_OCCURRED: break; case SessionEvent.SESSION_LOGGED_IN: break; case SessionEvent.SESSION_LOGGED_OFF: break; case SessionEvent.SESSION_OPENED: break; case SessionEvent.SESSION_OPENING: break; 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() { StringBuffer sb = new StringBuffer(); 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(); } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootwagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEventSupport.javawagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/TransferEventSupport.java0000644000175000017500000001646111045150702033515 0ustar twernertwernerpackage 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.Iterator; 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 Michal Maczka * @version $Id: TransferEventSupport.java 682051 2008-08-02 21:29:38Z hboutemy $ */ public final class TransferEventSupport { /** * registered listeners */ private final List listeners = new ArrayList(); /** * Adds the listener to the collection of listeners * who will be notified when any transfer event occurs * in this Wagon object. *
* If listener is null, 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. *
* If listener is null or specified listener was not added * to this TransferEventSupport 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 true * if given listener was added to the collection of listeners * false 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 TransferEvent * 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 ( Iterator iter = listeners.iterator(); iter.hasNext(); ) { final TransferListener listener = (TransferListener) iter.next(); listener.transferStarted( transferEvent ); } } /** * Dispatches the given TransferEvent * 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 ( Iterator iter = listeners.iterator(); iter.hasNext(); ) { final TransferListener listener = (TransferListener) iter.next(); listener.transferProgress( transferEvent, buffer, length ); } } /** * Dispatches the given TransferEvent * 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 ( Iterator iter = listeners.iterator(); iter.hasNext(); ) { final TransferListener listener = (TransferListener) iter.next(); listener.transferCompleted( transferEvent ); } } /** * Dispatches the given TransferEvent * 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 ( Iterator iter = listeners.iterator(); iter.hasNext(); ) { final TransferListener listener = (TransferListener) iter.next(); 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 ( Iterator iter = listeners.iterator(); iter.hasNext(); ) { final TransferListener listener = (TransferListener) iter.next(); listener.debug( message ); } } /** * Dispatches the given TransferEvent * 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 ( Iterator iter = listeners.iterator(); iter.hasNext(); ) { final TransferListener listener = (TransferListener) iter.next(); listener.transferInitiated( transferEvent ); } } } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/SessionEventSupport.java0000644000175000017500000002155311045150702033352 0ustar twernertwernerpackage 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.Iterator; import java.util.List; /** * The class allows registration and deregistration of session listeners * * @author Michal Maczka * @version $Id: SessionEventSupport.java 682051 2008-08-02 21:29:38Z hboutemy $ */ public final class SessionEventSupport { /** * registered listeners */ private final List listeners = new ArrayList(); /** * Adds the listener to the collection of listeners * who will be notified when any session event occurs * in this Wagon object. *
* If listener is null, 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. *
* If listener is null or specified listener was not added * to this SessionEventSupport 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 true * if given listener was added to the collection of listeners * false 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 SessionEvent * 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 ( Iterator iter = listeners.iterator(); iter.hasNext(); ) { final SessionListener listener = (SessionListener) iter.next(); listener.sessionDisconnected( sessionEvent ); } } /** * Dispatches the given SessionEvent * 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 ( Iterator iter = listeners.iterator(); iter.hasNext(); ) { final SessionListener listener = (SessionListener) iter.next(); listener.sessionDisconnecting( sessionEvent ); } } /** * Dispatches the given SessionEvent * 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 ( Iterator iter = listeners.iterator(); iter.hasNext(); ) { final SessionListener listener = (SessionListener) iter.next(); listener.sessionLoggedIn( sessionEvent ); } } /** * Dispatches the given SessionEvent * 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 ( Iterator iter = listeners.iterator(); iter.hasNext(); ) { final SessionListener listener = (SessionListener) iter.next(); listener.sessionLoggedOff( sessionEvent ); } } /** * Dispatches the given SessionEvent * 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 ( Iterator iter = listeners.iterator(); iter.hasNext(); ) { final SessionListener listener = (SessionListener) iter.next(); listener.sessionOpened( sessionEvent ); } } /** * Dispatches the given SessionEvent * 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 ( Iterator iter = listeners.iterator(); iter.hasNext(); ) { final SessionListener listener = (SessionListener) iter.next(); listener.sessionOpening( sessionEvent ); } } /** * Dispatches the given SessionEvent * 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 ( Iterator iter = listeners.iterator(); iter.hasNext(); ) { final SessionListener listener = (SessionListener) iter.next(); 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 ( Iterator iter = listeners.iterator(); iter.hasNext(); ) { final SessionListener listener = (SessionListener) iter.next(); listener.debug( message ); } } /** * Dispatches the given SessionEvent * 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 ( Iterator iter = listeners.iterator(); iter.hasNext(); ) { final SessionListener listener = (SessionListener) iter.next(); listener.sessionError( sessionEvent ); } } } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/events/WagonEvent.java0000644000175000017500000000416411045150702031404 0ustar twernertwernerpackage 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 Wagon objects. * * @author Michal Maczka * @version $Id: WagonEvent.java 682051 2008-08-02 21:29:38Z hboutemy $ */ 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; } } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/TransferFailedException.java0000644000175000017500000000276711045150702032602 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: TransferFailedException.java 682051 2008-08-02 21:29:38Z hboutemy $ */ 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 ); } } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/ConnectionException.java0000644000175000017500000000300111045150702031766 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: ConnectionException.java 682051 2008-08-02 21:29:38Z hboutemy $ */ 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 ); } } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/0000755000175000017500000000000011630374114027172 5ustar twernertwernerwagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/Debug.java0000644000175000017500000001314311045146232031063 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: Debug.java 682047 2008-08-02 21:07:38Z hboutemy $ */ 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; } } ././@LongLink0000000000000000000000000000015400000000000011565 Lustar rootrootwagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/AbstractTransferListener.javawagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/AbstractTransferListen0000644000175000017500000000376410670157111033555 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: AbstractTransferListener.java 573459 2007-09-07 05:14:49Z brett $ */ 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 ) { } } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/observers/ChecksumObserver.java0000644000175000017500000000753311043224661033316 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: ChecksumObserver.java 680225 2008-07-28 02:06:41Z brett $ */ 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 */ 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" ); } String retValue = ""; for ( int i = 0; i < binaryData.length; i++ ) { String t = Integer.toHexString( binaryData[i] & 0xff ); if ( t.length() == 1 ) { retValue += ( "0" + t ); } else { retValue += t; } } return retValue.trim(); } } ././@LongLink0000000000000000000000000000014600000000000011566 Lustar rootrootwagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/UnsupportedProtocolException.javawagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/UnsupportedProtocolException.jav0000644000175000017500000000274210670157111033617 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: UnsupportedProtocolException.java 573459 2007-09-07 05:14:49Z brett $ */ 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 ); } } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/PermissionModeUtils.java0000644000175000017500000000414311045150702031776 0ustar twernertwernerpackage 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 Juan F. Codagnone * @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; ret = Integer.toOctalString( 0777 - mode ); } 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; } } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/CommandExecutionException.java0000644000175000017500000000273111015033162033137 0ustar twernertwernerpackage 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 Brett Porter * @version $Id: CommandExecutionException.java 658720 2008-05-21 14:49:22Z bentmann $ */ 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 ); } } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/WagonException.java0000644000175000017500000000757211045150702030763 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: WagonException.java 682051 2008-08-02 21:29:38Z hboutemy $ */ 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; } } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/proxy/0000755000175000017500000000000011630374114026341 5ustar twernertwernerwagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/proxy/ProxyUtils.java0000644000175000017500000000414011044035101031332 0ustar twernertwernerpackage 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 Thomas Champagne */ 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; } } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/proxy/ProxyInfoProvider.java0000644000175000017500000000227311016671400032654 0ustar twernertwernerpackage 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 ); } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/proxy/ProxyInfo.java0000644000175000017500000001110711045150702031134 0ustar twernertwernerpackage 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 Wagon objects * while connection to the repository must go thru a proxy server. * * @author Michal Maczka * @version $Id: ProxyInfo.java 682051 2008-08-02 21:29:38Z hboutemy $ * @todo Propose standard types of proxy servers (e.g. SOCKSv4), * 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: *.foo.com|localhost. */ 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 SOCKSv4 */ 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; } } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamWagon.java0000644000175000017500000002132111217013636030251 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: StreamWagon.java 786702 2009-06-19 22:56:30Z jdcasey $ */ 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 ); } private 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 ); } } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/StreamingWagon.java0000644000175000017500000000630311021021030030726 0ustar twernertwernerpackage 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 destination * @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 destination * @param timestamp * @return true if newer resource has been downloaded, false 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; /** * Copy from a local input stream to remote. * * @param source the local file * @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 source the local file * @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; } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/repository/0000755000175000017500000000000011630374114027377 5ustar twernertwerner././@LongLink0000000000000000000000000000015200000000000011563 Lustar rootrootwagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/repository/RepositoryPermissions.javawagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/repository/RepositoryPermissions0000644000175000017500000000577311045150702033744 0ustar twernertwernerpackage 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. */ /** * Describes the permissions to set on files uploaded to the repository. * * @author Brett Porter * @version $Id: RepositoryPermissions.java 682051 2008-08-02 21:29:38Z hboutemy $ */ public class RepositoryPermissions { /** * 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; } } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/repository/Repository.java0000644000175000017500000001531511045146232032424 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: Repository.java 682047 2008-08-02 21:07:38Z hboutemy $ * @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" ); } setId( id ); if ( url == null ) { throw new NullPointerException( "url can not 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; } StringBuffer sb = new StringBuffer(); sb.append( protocol ); sb.append( "://" ); sb.append( host ); if ( port != WagonConstants.UNKNOWN_PORT ) { sb.append( ":" ); sb.append( port ); } sb.append( basedir ); return sb.toString(); } public String getHost() { if ( host == null ) { return "localhost"; } return host; } public String getName() { if ( name == null ) { return getId(); } return name; } public String toString() { StringBuffer sb = new StringBuffer(); 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; } } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/resource/0000755000175000017500000000000011630374114027007 5ustar twernertwernerwagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/resource/Resource.java0000644000175000017500000000706211045146232031444 0ustar twernertwernerpackage 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. *

* This class contains minimal set of informations, which * are needed to reuse wagon in maven 1. * * @author Michal Maczka * @version $Id: Resource.java 682047 2008-08-02 21:07:38Z hboutemy $ */ 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; } } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/authorization/0000755000175000017500000000000011630374114030060 5ustar twernertwerner././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootwagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/authorization/AuthorizationException.javawagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/authorization/AuthorizationExcep0000644000175000017500000000311611045150702033624 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: AuthorizationException.java 682051 2008-08-02 21:29:38Z hboutemy $ */ 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 ); } } ././@LongLink0000000000000000000000000000014700000000000011567 Lustar rootrootwagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/ResourceDoesNotExistException.javawagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/ResourceDoesNotExistException.ja0000644000175000017500000000260510670157111033455 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: ResourceDoesNotExistException.java 573459 2007-09-07 05:14:49Z brett $ */ 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 ); } } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/AbstractWagon.java0000644000175000017500000006460211045150702030565 0ustar twernertwernerpackage 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.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.List; 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; /** * Implementation of common facilities for Wagon providers. * * @author Michal Maczka * @version $Id: AbstractWagon.java 682051 2008-08-02 21:29:38Z hboutemy $ */ 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 = 60000; 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; } } } ); this.proxyInfo = proxyInfo; } 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, Integer.MAX_VALUE ); } protected void getTransfer( Resource resource, OutputStream output, InputStream input ) throws TransferFailedException { getTransfer( resource, output, input, true, Integer.MAX_VALUE ); } protected void getTransfer( Resource resource, File destination, InputStream input, boolean closeInput, int 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 ); } protected void getTransfer( Resource resource, OutputStream output, InputStream input, boolean closeInput, int 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} * * @since 1.0-beta-1 * * @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 */ 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 ); 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, Integer.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 */ protected void transfer( Resource resource, InputStream input, OutputStream output, int requestType, int maxSize ) throws IOException { byte[] buffer = new byte[DEFAULT_BUFFER_SIZE]; TransferEvent transferEvent = new TransferEvent( this, resource, TransferEvent.TRANSFER_PROGRESS, requestType ); transferEvent.setTimestamp( System.currentTimeMillis() ); int remaining = maxSize; while ( remaining > 0 ) { int n = input.read( buffer, 0, 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 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; } } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/Streams.java0000644000175000017500000000225211015033162027432 0ustar twernertwernerpackage 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; } } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/Wagon.java0000644000175000017500000002646311045150702027104 0ustar twernertwernerpackage 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(); // ---------------------------------------------------------------------- // 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 true if newer resource has been downloaded, false 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; /** *

* Returns a {@link List} of strings naming the files and directories in the directory denoted by * this abstract pathname. *

*

* 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. *

*

* 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. *

* * @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 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(); // ---------------------------------------------------------------------- // 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 ); } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/CommandExecutor.java0000644000175000017500000000241110670157111031115 0ustar twernertwernerpackage 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 Brett Porter * @version $Id: CommandExecutor.java 573459 2007-09-07 05:14:49Z brett $ */ public interface CommandExecutor extends Wagon { String ROLE = CommandExecutor.class.getName(); void executeCommand( String command ) throws CommandExecutionException; Streams executeCommand( String command, boolean ignoreFailures ) throws CommandExecutionException; } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/authentication/0000755000175000017500000000000011630374114030177 5ustar twernertwerner././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootwagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/authentication/AuthenticationInfo.javawagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/authentication/AuthenticationInf0000644000175000017500000000667711045150702033551 0ustar twernertwernerpackage 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 Wagon * will use during login operation. * * @author Michal Maczka * @version $Id: AuthenticationInfo.java 682051 2008-08-02 21:29:38Z hboutemy $ */ 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; } } ././@LongLink0000000000000000000000000000016000000000000011562 Lustar rootrootwagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/authentication/AuthenticationException.javawagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/authentication/AuthenticationExc0000644000175000017500000000325110670157111033541 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: AuthenticationException.java 573459 2007-09-07 05:14:49Z brett $ */ 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 ); } } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/InputData.java0000644000175000017500000000276010670157111027720 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: InputData.java 573459 2007-09-07 05:14:49Z brett $ */ 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; } } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/PathUtils.java0000644000175000017500000003340711373210752027750 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: PathUtils.java 944160 2010-05-14 09:03:38Z bentmann $ */ 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 * http://www.codehause.org this method will return www.apache.org * * @param url the url * @return the host name */ public static String host( final String url ) { String authorization = authorization( url ); int index = authorization.indexOf( '@' ); if ( index >= 0 ) { return authorization.substring( index + 1 ); } else { return authorization; } } /** * 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( '@' ); if ( pos > 0 ) { pos = host.indexOf( ':', pos ); } else { pos = host.indexOf( ":" ); } if ( pos > 0 ) { host = host.substring( 0, pos ); } return host; } /** * /** * Return the protocol name. *
* E.g: for input * http://www.codehause.org this method will return http * * @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. Note: This decoder assumes that ISO-8859-1 is used to * convert URL-encoded octets to characters. * * @param url The URL to decode, may be null. * @return The decoded URL or null if the input was null. */ 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; } } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/LazyFileOutputStream.java0000644000175000017500000000622511025500520032132 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: LazyFileOutputStream.java 668181 2008-06-16 15:05:52Z brett $ */ 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 ); } } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/WagonConstants.java0000644000175000017500000000243211045146232030772 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: WagonConstants.java 682047 2008-08-02 21:07:38Z hboutemy $ */ 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; } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/WagonUtils.java0000644000175000017500000000616311044035101030112 0ustar twernertwernerpackage 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.util.LinkedList; import org.apache.maven.wagon.authorization.AuthorizationException; import org.codehaus.plexus.util.FileUtils; /** * @author Michal Maczka * @version $Id: WagonUtils.java 680954 2008-07-30 09:54:09Z brett $ * @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 ); String retValue = FileUtils.fileRead( file ); return retValue; } 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 ); } } } } } wagon-1.0.0/wagon-provider-api/src/main/java/org/apache/maven/wagon/OutputData.java0000644000175000017500000000277410670157111030126 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: OutputData.java 573459 2007-09-07 05:14:49Z brett $ */ 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; } } wagon-1.0.0/wagon-provider-api/src/site/0000755000175000017500000000000011630374114020026 5ustar twernertwernerwagon-1.0.0/wagon-provider-api/src/site/site.xml0000644000175000017500000000013211045135116021505 0ustar twernertwerner wagon-1.0.0/wagon-provider-api/src/site/apt/0000755000175000017500000000000011630374114020612 5ustar twernertwernerwagon-1.0.0/wagon-provider-api/src/site/apt/index.apt0000644000175000017500000000101711045361236022427 0ustar twernertwerner ------ Maven Wagon API ------ Carlos Sanchez ------ 2006-04-16 ------ Maven Wagon API The Wagon API project defines 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. wagon-1.0.0/wagon-provider-api/src/test/0000755000175000017500000000000011630374114020041 5ustar twernertwernerwagon-1.0.0/wagon-provider-api/src/test/resources/0000755000175000017500000000000011630374114022053 5ustar twernertwernerwagon-1.0.0/wagon-provider-api/src/test/resources/org/0000755000175000017500000000000011630374114022642 5ustar twernertwernerwagon-1.0.0/wagon-provider-api/src/test/resources/org/apache/0000755000175000017500000000000011630374114024063 5ustar twernertwernerwagon-1.0.0/wagon-provider-api/src/test/resources/org/apache/maven/0000755000175000017500000000000011630374114025171 5ustar twernertwernerwagon-1.0.0/wagon-provider-api/src/test/resources/org/apache/maven/wagon/0000755000175000017500000000000011630374114026304 5ustar twernertwernerwagon-1.0.0/wagon-provider-api/src/test/resources/org/apache/maven/wagon/manager/0000755000175000017500000000000011630374114027716 5ustar twernertwerner././@LongLink0000000000000000000000000000015500000000000011566 Lustar rootrootwagon-1.0.0/wagon-provider-api/src/test/resources/org/apache/maven/wagon/manager/DefaultWagonManagerTest.xmlwagon-1.0.0/wagon-provider-api/src/test/resources/org/apache/maven/wagon/manager/DefaultWagonManager0000644000175000017500000000314410670157111033515 0ustar twernertwerner org.apache.maven.wagon.Wagon a org.apache.maven.wagon.manager.WagonA org.apache.maven.wagon.Wagon b1 org.apache.maven.wagon.manager.WagonB org.apache.maven.wagon.Wagon b2 org.apache.maven.wagon.manager.WagonB org.apache.maven.wagon.Wagon c org.apache.maven.wagon.manager.WagonC wagon-1.0.0/wagon-provider-api/src/test/java/0000755000175000017500000000000011630374114020762 5ustar twernertwernerwagon-1.0.0/wagon-provider-api/src/test/java/org/0000755000175000017500000000000011630374114021551 5ustar twernertwernerwagon-1.0.0/wagon-provider-api/src/test/java/org/apache/0000755000175000017500000000000011630374114022772 5ustar twernertwernerwagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/0000755000175000017500000000000011630374114024100 5ustar twernertwernerwagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/0000755000175000017500000000000011630374114025213 5ustar twernertwernerwagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/0000755000175000017500000000000011630374114026517 5ustar twernertwerner././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootwagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/TransferListenerMock.javawagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/TransferListenerMock.java0000644000175000017500000001045010670157111033465 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: TransferListenerMock.java 573459 2007-09-07 05:14:49Z brett $ */ public class TransferListenerMock implements TransferListener { private String debugMessage; private boolean debugCalled; private TransferEvent transferEvent; private boolean transferCompletedCalled; private boolean transferProgressCalled; private boolean transferStartedCalled; private int numberOfProgressCalls; private boolean transferErrorCalled; private boolean transferInitiatedCalled; public boolean isTransferInitiatedCalled() { return transferInitiatedCalled; } /** * @return Returns the debugCalled. */ public boolean isDebugCalled() { return debugCalled; } /** * @return Returns the transferCompletedCalled. */ public boolean isTransferCompletedCalled() { return transferCompletedCalled; } /** * @return Returns the transferEvent. */ public TransferEvent getTransferEvent() { return transferEvent; } /** * @return Returns the transferProgressCalled. */ public boolean isTransferProgressCalled() { return transferProgressCalled; } /** * @return Returns the transferStartedCalled. */ public boolean isTransferStartedCalled() { return transferStartedCalled; } public void transferInitiated( TransferEvent transferEvent ) { this.transferEvent = transferEvent; transferInitiatedCalled = true; } /** * @see org.apache.maven.wagon.events.TransferListener#transferStarted(org.apache.maven.wagon.events.TransferEvent) */ public void transferStarted( final TransferEvent transferEvent ) { this.transferEvent = transferEvent; transferStartedCalled = true; } /** * @see org.apache.maven.wagon.events.TransferListener#transferProgress(org.apache.maven.wagon.events.TransferEvent) */ public void transferProgress( final TransferEvent transferEvent, byte[] buffer, int length ) { this.transferEvent = transferEvent; transferProgressCalled = true; numberOfProgressCalls++; } /** * @see org.apache.maven.wagon.events.TransferListener#transferCompleted(org.apache.maven.wagon.events.TransferEvent) */ public void transferCompleted( final TransferEvent transferEvent ) { this.transferEvent = transferEvent; transferCompletedCalled = true; } /** * @see org.apache.maven.wagon.events.TransferListener#debug(java.lang.String) */ public void debug( final String message ) { debugMessage = message; debugCalled = true; } /** * @return */ public String getDebugMessage() { return debugMessage; } /** * @return Returns the numberOfprogressCalls. */ public int getNumberOfProgressCalls() { return numberOfProgressCalls; } /** * @see org.apache.maven.wagon.events.TransferListener#transferError(org.apache.maven.wagon.events.TransferEvent) */ public void transferError( final TransferEvent transferEvent ) { this.transferEvent = transferEvent; transferErrorCalled = true; } /** * @return Returns the transferErrorCalled. */ public boolean isTransferErrorCalled() { return transferErrorCalled; } } ././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootwagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/SessionEventSupportTest.javawagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/SessionEventSupportTest.j0000644000175000017500000001667011020527671033567 0ustar twernertwernerpackage 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.easymock.MockControl; /** * @author Michal Maczka * @version $Id: SessionEventSupportTest.java 662218 2008-06-01 14:18:33Z brett $ */ public class SessionEventSupportTest extends TestCase { private SessionEventSupport eventSupport; private MockControl wagonMockControl; private Wagon wagon; /** * @see junit.framework.TestCase#setUp() */ protected void setUp() throws Exception { super.setUp(); eventSupport = new SessionEventSupport(); // TODO: actually test it gets called? wagonMockControl = MockControl.createControl( Wagon.class ); wagon = (Wagon) wagonMockControl.getMock(); } public void testSessionListenerRegistration() { final SessionListenerMock mock1 = new SessionListenerMock(); eventSupport.addSessionListener( mock1 ); assertTrue( eventSupport.hasSessionListener( mock1 ) ); final SessionListenerMock mock2 = new SessionListenerMock(); 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() { final SessionListenerMock mock1 = new SessionListenerMock(); eventSupport.addSessionListener( mock1 ); final SessionListenerMock mock2 = new SessionListenerMock(); eventSupport.addSessionListener( mock2 ); final SessionEvent event = new SessionEvent( wagon, 1 ); eventSupport.fireSessionDisconnected( event ); assertTrue( mock1.isSessionDisconnectedCalled() ); assertTrue( mock2.isSessionDisconnectedCalled() ); assertEquals( event, mock1.getSessionEvent() ); assertEquals( event, mock2.getSessionEvent() ); } public void testFireSessionDisconneting() { final SessionListenerMock mock1 = new SessionListenerMock(); eventSupport.addSessionListener( mock1 ); final SessionListenerMock mock2 = new SessionListenerMock(); eventSupport.addSessionListener( mock2 ); final SessionEvent event = new SessionEvent( wagon, 1 ); eventSupport.fireSessionDisconnecting( event ); assertTrue( mock1.isSessionDisconnectingCalled() ); assertTrue( mock2.isSessionDisconnectingCalled() ); assertEquals( event, mock1.getSessionEvent() ); assertEquals( event, mock2.getSessionEvent() ); } public void testFireSessionLoggedIn() { final SessionListenerMock mock1 = new SessionListenerMock(); eventSupport.addSessionListener( mock1 ); final SessionListenerMock mock2 = new SessionListenerMock(); eventSupport.addSessionListener( mock2 ); final SessionEvent event = new SessionEvent( wagon, 1 ); eventSupport.fireSessionLoggedIn( event ); assertTrue( mock1.isSessionLoggedInCalled() ); assertTrue( mock2.isSessionLoggedInCalled() ); assertEquals( event, mock1.getSessionEvent() ); assertEquals( event, mock2.getSessionEvent() ); } public void testFireSessionLoggedOff() { final SessionListenerMock mock1 = new SessionListenerMock(); eventSupport.addSessionListener( mock1 ); final SessionListenerMock mock2 = new SessionListenerMock(); eventSupport.addSessionListener( mock2 ); final SessionEvent event = new SessionEvent( wagon, 1 ); eventSupport.fireSessionLoggedOff( event ); assertTrue( mock1.isSessionLoggedOffCalled() ); assertTrue( mock2.isSessionLoggedOffCalled() ); assertEquals( event, mock1.getSessionEvent() ); assertEquals( event, mock2.getSessionEvent() ); } public void testFireSessionOpened() { final SessionListenerMock mock1 = new SessionListenerMock(); eventSupport.addSessionListener( mock1 ); final SessionListenerMock mock2 = new SessionListenerMock(); eventSupport.addSessionListener( mock2 ); final SessionEvent event = new SessionEvent( wagon, 1 ); eventSupport.fireSessionOpened( event ); assertTrue( mock1.isSessionOpenedCalled() ); assertTrue( mock2.isSessionOpenedCalled() ); assertEquals( event, mock1.getSessionEvent() ); assertEquals( event, mock2.getSessionEvent() ); } public void testFireSessionOpenning() { final SessionListenerMock mock1 = new SessionListenerMock(); eventSupport.addSessionListener( mock1 ); final SessionListenerMock mock2 = new SessionListenerMock(); eventSupport.addSessionListener( mock2 ); final SessionEvent event = new SessionEvent( wagon, 1 ); eventSupport.fireSessionOpening( event ); assertTrue( mock1.isSessionOpenningCalled() ); assertTrue( mock2.isSessionOpenningCalled() ); assertEquals( event, mock1.getSessionEvent() ); assertEquals( event, mock2.getSessionEvent() ); } public void testFireSessionRefused() { final SessionListenerMock mock1 = new SessionListenerMock(); eventSupport.addSessionListener( mock1 ); final SessionListenerMock mock2 = new SessionListenerMock(); eventSupport.addSessionListener( mock2 ); final SessionEvent event = new SessionEvent( wagon, 1 ); eventSupport.fireSessionConnectionRefused( event ); assertTrue( mock1.isSessionRefusedCalled() ); assertTrue( mock2.isSessionRefusedCalled() ); assertEquals( event, mock1.getSessionEvent() ); assertEquals( event, mock2.getSessionEvent() ); } public void testFireDebug() { final SessionListenerMock mock1 = new SessionListenerMock(); eventSupport.addSessionListener( mock1 ); final SessionListenerMock mock2 = new SessionListenerMock(); eventSupport.addSessionListener( mock2 ); eventSupport.fireDebug( "mm" ); assertTrue( mock1.isDebugCalled() ); assertTrue( mock2.isDebugCalled() ); assertEquals( "mm", mock1.getDebugMessage() ); assertEquals( "mm", mock2.getDebugMessage() ); } } wagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/SessionListenerMock.java0000644000175000017500000001046011012241534033317 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: SessionListenerMock.java 655761 2008-05-13 07:29:32Z brett $ */ public class SessionListenerMock implements SessionListener { private boolean connectionOpenningCalled = false; private boolean debugCalled = false; private boolean connectionLoggedOffCalled = false; private boolean connectionLoggedInCalled = false; private boolean connectionRefusedCalled = false; private boolean connectionDisconnectedCalled = false; private boolean connectionDisconnectingCalled = false; private boolean connectionOpenedCalled = false; private SessionEvent sessionEvent; private String message; public boolean isSessionDisconnectedCalled() { return connectionDisconnectedCalled; } public boolean isSessionDisconnectingCalled() { return connectionDisconnectingCalled; } public boolean isSessionLoggedInCalled() { return connectionLoggedInCalled; } public boolean isSessionLoggedOffCalled() { return connectionLoggedOffCalled; } public boolean isSessionOpenedCalled() { return connectionOpenedCalled; } public boolean isSessionOpenningCalled() { return connectionOpenningCalled; } public boolean isSessionRefusedCalled() { return connectionRefusedCalled; } public boolean isDebugCalled() { return debugCalled; } public void reset() { connectionOpenningCalled = false; debugCalled = false; connectionLoggedOffCalled = false; connectionLoggedInCalled = false; connectionRefusedCalled = false; connectionDisconnectedCalled = false; connectionDisconnectingCalled = false; connectionOpenedCalled = false; sessionEvent = null; message = null; } public void sessionOpening( final SessionEvent connectionEvent ) { connectionOpenningCalled = true; this.sessionEvent = connectionEvent; } public void sessionOpened( final SessionEvent connectionEvent ) { connectionOpenedCalled = true; this.sessionEvent = connectionEvent; } public void sessionDisconnecting( final SessionEvent connectionEvent ) { connectionDisconnectingCalled = true; this.sessionEvent = connectionEvent; } public void sessionDisconnected( final SessionEvent connectionEvent ) { connectionDisconnectedCalled = true; this.sessionEvent = connectionEvent; } public void sessionConnectionRefused( final SessionEvent connectionEvent ) { connectionRefusedCalled = true; this.sessionEvent = connectionEvent; } public void sessionLoggedIn( final SessionEvent connectionEvent ) { connectionLoggedInCalled = true; this.sessionEvent = connectionEvent; } public void sessionLoggedOff( final SessionEvent connectionEvent ) { connectionLoggedOffCalled = true; this.sessionEvent = connectionEvent; } public void sessionError( final SessionEvent connectionEvent ) { this.sessionEvent = connectionEvent; } public void debug( final String message ) { debugCalled = true; this.message = message; } public SessionEvent getSessionEvent() { return sessionEvent; } public String getDebugMessage() { return message; } } wagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/TransferEventTest.java0000644000175000017500000001203311020527671033010 0ustar twernertwernerpackage 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.MockControl; /** * @author Michal Maczka * @version $Id: TransferEventTest.java 662218 2008-06-01 14:18:33Z brett $ */ 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 = (Wagon) MockControl.createControl( Wagon.class ).getMock(); 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] ); } } } } wagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/SessionEventTest.java0000644000175000017500000001146011020527671032652 0ustar twernertwernerpackage 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.MockControl; /** * @author Michal Maczka * @version $Id: SessionEventTest.java 662218 2008-06-01 14:18:33Z brett $ */ 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 = (Wagon) MockControl.createControl( Wagon.class ).getMock(); 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] ); } } } } ././@LongLink0000000000000000000000000000015100000000000011562 Lustar rootrootwagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/TransferEventSupportTest.javawagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/events/TransferEventSupportTest.0000644000175000017500000001357111020527671033553 0ustar twernertwernerpackage 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.easymock.MockControl; /** * @author Michal Maczka * @version $Id: TransferEventSupportTest.java,v 1.2 2003/11/16 12:41:02 michal * Exp $ */ public class TransferEventSupportTest extends TestCase { private TransferEventSupport eventSupport; private MockControl wagonMockControl; private Wagon wagon; /** * @see junit.framework.TestCase#setUp() */ protected void setUp() throws Exception { super.setUp(); eventSupport = new TransferEventSupport(); // TODO: actually test it gets called? wagonMockControl = MockControl.createControl( Wagon.class ); wagon = (Wagon) wagonMockControl.getMock(); } public void testTransferListenerRegistration() { final TransferListenerMock mock1 = new TransferListenerMock(); eventSupport.addTransferListener( mock1 ); assertTrue( eventSupport.hasTransferListener( mock1 ) ); final TransferListenerMock mock2 = new TransferListenerMock(); 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() { final TransferListenerMock mock1 = new TransferListenerMock(); eventSupport.addTransferListener( mock1 ); final TransferListenerMock mock2 = new TransferListenerMock(); eventSupport.addTransferListener( mock2 ); final TransferEvent event = getEvent( wagon ); eventSupport.fireTransferStarted( event ); assertTrue( mock1.isTransferStartedCalled() ); assertTrue( mock2.isTransferStartedCalled() ); assertEquals( event, mock1.getTransferEvent() ); assertEquals( event, mock2.getTransferEvent() ); } public void testFireTransferProgress() { final TransferListenerMock mock1 = new TransferListenerMock(); eventSupport.addTransferListener( mock1 ); final TransferListenerMock mock2 = new TransferListenerMock(); eventSupport.addTransferListener( mock2 ); final TransferEvent event = getEvent( wagon ); // TODO: should be testing the buffer eventSupport.fireTransferProgress( event, null, 0 ); assertTrue( mock1.isTransferProgressCalled() ); assertTrue( mock2.isTransferProgressCalled() ); assertEquals( event, mock1.getTransferEvent() ); assertEquals( event, mock2.getTransferEvent() ); } public void testFireTransferCompleted() { final TransferListenerMock mock1 = new TransferListenerMock(); eventSupport.addTransferListener( mock1 ); final TransferListenerMock mock2 = new TransferListenerMock(); eventSupport.addTransferListener( mock2 ); final TransferEvent event = getEvent( wagon ); eventSupport.fireTransferCompleted( event ); assertTrue( mock1.isTransferCompletedCalled() ); assertTrue( mock2.isTransferCompletedCalled() ); assertEquals( event, mock1.getTransferEvent() ); assertEquals( event, mock2.getTransferEvent() ); } public void testFireTransferError() { final TransferListenerMock mock1 = new TransferListenerMock(); eventSupport.addTransferListener( mock1 ); final TransferListenerMock mock2 = new TransferListenerMock(); eventSupport.addTransferListener( mock2 ); final TransferEvent event = getEvent( wagon ); eventSupport.fireTransferError( event ); assertTrue( mock1.isTransferErrorCalled() ); assertTrue( mock2.isTransferErrorCalled() ); assertEquals( event, mock1.getTransferEvent() ); assertEquals( event, mock2.getTransferEvent() ); } public void testFireDebug() { final TransferListenerMock mock1 = new TransferListenerMock(); eventSupport.addTransferListener( mock1 ); final TransferListenerMock mock2 = new TransferListenerMock(); eventSupport.addTransferListener( mock2 ); eventSupport.fireDebug( "mm" ); assertTrue( mock1.isDebugCalled() ); assertTrue( mock2.isDebugCalled() ); assertEquals( "mm", mock1.getDebugMessage() ); assertEquals( "mm", mock2.getDebugMessage() ); } private TransferEvent getEvent( final Wagon wagon ) { final TransferEvent event = new TransferEvent( wagon, null, TransferEvent.TRANSFER_COMPLETED, TransferEvent.REQUEST_GET ); return event; } } wagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/PathUtilsTest.java0000644000175000017500000003232111373172316030640 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: PathUtilsTest.java 944139 2010-05-14 06:59:26Z dennisl $ */ 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@www.codehaus.org:/root" ) ); assertEquals( "www.codehaus.org", PathUtils.host( "SCM:CVS:pserver:anoncvs@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@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@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@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@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@localhost:/temp:module" ) ); assertEquals( 2402, PathUtils.port( "scm:cvs:pserver:anoncvs@localhost:2402/temp:module" ) ); assertEquals( 2402, PathUtils.port( "SCM:CVS:pserver:anoncvs@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@www.codehause.org:80/maven" ) ); assertEquals( "/maven", PathUtils.basedir( "scm:cvs:pserver:anoncvs@www.codehause.org:/maven" ) ); assertEquals( "/maven/module", PathUtils.basedir( "scm:cvs:pserver:anoncvs@www.codehause.org:80/maven:module" ) ); assertEquals( "/maven/module", PathUtils.basedir( "scm:cvs:pserver:anoncvs@www.codehause.org:/maven:module" ) ); assertEquals( "/maven/module", PathUtils.basedir( "SCM:CVS:pserver:anoncvs@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 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() ) ); } } wagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/LazyFileOutputStreamTest.java0000644000175000017500000000326010670157111033032 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: LazyFileOutputStreamTest.java 573459 2007-09-07 05:14:49Z brett $ */ 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 ); } } wagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/observers/0000755000175000017500000000000011630374114027225 5ustar twernertwerner././@LongLink0000000000000000000000000000015000000000000011561 Lustar rootrootwagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/observers/ChecksumObserverTest.javawagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/observers/ChecksumObserverTest.j0000644000175000017500000000734211044035101033505 0ustar twernertwernerpackage 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() ); } } wagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/InputStreamMock.java0000644000175000017500000000355610670157111031153 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: InputStreamMock.java 573459 2007-09-07 05:14:49Z brett $ */ 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; } } wagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/proxy/0000755000175000017500000000000011630374114026374 5ustar twernertwernerwagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/proxy/ProxyInfoTest.java0000644000175000017500000000366010670157111032040 0ustar twernertwernerpackage 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 Jason van Zyl * @version $Id: ProxyInfoTest.java 573459 2007-09-07 05:14:49Z brett $ */ 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() ); } } wagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/proxy/ProxyInfoUtilsTest.java0000644000175000017500000000621111015033162033045 0ustar twernertwernerpackage 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 Thomas Champagne */ 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" ) ); } } ././@LongLink0000000000000000000000000000014500000000000011565 Lustar rootrootwagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/TransferFailedExceptionTest.javawagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/TransferFailedExceptionTest.java0000644000175000017500000000273310670157111033472 0ustar twernertwernerpackage 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 Jason van Zyl * @version $Id: TransferFailedExceptionTest.java 573459 2007-09-07 05:14:49Z brett $ */ 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() ); } } wagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/CannotConnectExceptionTest.java0000644000175000017500000000271410670157111033334 0ustar twernertwernerpackage 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 Jason van Zyl * @version $Id: CannotConnectExceptionTest.java 573459 2007-09-07 05:14:49Z brett $ */ 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() ); } } wagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/NotAuthorizedExceptionTest.java0000644000175000017500000000303110670157111033370 0ustar twernertwernerpackage 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 Jason van Zyl * @version $Id: NotAuthorizedExceptionTest.java 573459 2007-09-07 05:14:49Z brett $ */ 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() ); } } wagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/repository/0000755000175000017500000000000011630374114027432 5ustar twernertwernerwagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/repository/RepositoryTest.java0000644000175000017500000000602111012241534033304 0ustar twernertwernerpackage 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 Jason van Zyl * @version $Id: RepositoryTest.java 655761 2008-05-13 07:29:32Z brett $ */ 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() ); } } ././@LongLink0000000000000000000000000000015600000000000011567 Lustar rootrootwagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/repository/RepositoryPermissionsTest.javawagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/repository/RepositoryPermissions0000644000175000017500000000364310670157111033775 0ustar twernertwernerpackage 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 Brett Porter * @version $Id: RepositoryPermissionsTest.java 573459 2007-09-07 05:14:49Z brett $ * @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() ); } } wagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/PermissionModeUtilsTest.java0000644000175000017500000000365611021021030032662 0ustar twernertwernerpackage 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 Juan F. Codagnone * @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 ( int i = 0; i < tests.length; i++ ) { String umask = null; try { umask = PermissionModeUtils.getUserMaskFor( tests[ i ][ 0 ] ); } catch ( IllegalArgumentException e ) { // nothing to do } assertEquals( tests[ i ][ 1 ], umask ); } } } ././@LongLink0000000000000000000000000000015300000000000011564 Lustar rootrootwagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/ResourceDoesNotExistExceptionTest.javawagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/ResourceDoesNotExistExceptionTes0000644000175000017500000000277710670157111033605 0ustar twernertwernerpackage 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 Jason van Zyl * @version $Id: ResourceDoesNotExistExceptionTest.java 573459 2007-09-07 05:14:49Z brett $ */ 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() ); } } wagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/WagonMock.java0000644000175000017500000000576511021021030027734 0ustar twernertwernerpackage 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 Jason van Zyl * @version $Id: WagonMock.java 662483 2008-06-02 16:38:48Z brett $ */ 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 getFileList( String destinationDirectory ) throws TransferFailedException, AuthorizationException { return Collections.EMPTY_LIST; } public boolean resourceExists( String resourceName ) throws AuthorizationException { return false; } } wagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/authentication/0000755000175000017500000000000011630374114030232 5ustar twernertwerner././@LongLink0000000000000000000000000000015700000000000011570 Lustar rootrootwagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/authentication/AuthenticationInfoTest.javawagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/authentication/AuthenticationInf0000644000175000017500000000401210670157111033565 0ustar twernertwernerpackage 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 Jason van Zyl * @version $Id: AuthenticationInfoTest.java 573459 2007-09-07 05:14:49Z brett $ * @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() ); } } ././@LongLink0000000000000000000000000000016400000000000011566 Lustar rootrootwagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/authentication/AuthenticationExceptionTest.javawagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/authentication/AuthenticationExc0000644000175000017500000000275210670157111033601 0ustar twernertwernerpackage 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 Jason van Zyl * @version $Id: AuthenticationExceptionTest.java 573459 2007-09-07 05:14:49Z brett $ */ 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() ); } } wagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/OutputStreamMock.java0000644000175000017500000000357510670157111031355 0ustar twernertwernerpackage 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 Michal Maczka * @version $Id: OutputStreamMock.java 573459 2007-09-07 05:14:49Z brett $ */ 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; } } wagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/AbstractWagonTest.java0000644000175000017500000004744211046407077031476 0ustar twernertwernerpackage 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.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; 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.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.AbstractMatcher; import org.easymock.MockControl; /** * @author Michal Maczka * @version $Id: AbstractWagonTest.java 630808 2008-02-25 11:01:41Z brett $ */ 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; private MockControl transferListenerControl; private MockControl sessionListenerControl; 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(); sessionListenerControl = MockControl.createControl( SessionListener.class ); sessionListener = (SessionListener) sessionListenerControl.getMock(); wagon.addSessionListener( sessionListener ); transferListenerControl = MockControl.createControl( TransferListener.class ); transferListener = (TransferListener) transferListenerControl.getMock(); 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(); sessionListenerControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER ); sessionListener.sessionOpening( null ); sessionListener.sessionOpened( null ); sessionListenerControl.replay(); wagon.connect( repository ); sessionListenerControl.verify(); 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(); sessionListenerControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER ); sessionListener.sessionOpening( null ); sessionListener.sessionConnectionRefused( null ); sessionListenerControl.replay(); 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 { sessionListenerControl.verify(); assertEquals( repository, wagon.getRepository() ); } } public void testSessionCloseEvents() throws Exception { sessionListenerControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER ); sessionListener.sessionDisconnecting( null ); sessionListener.sessionDisconnected( null ); sessionListenerControl.replay(); wagon.disconnect(); sessionListenerControl.verify(); } public void testSessionCloseRefusedEventConnectionException() throws Exception { Repository repository = new Repository(); sessionListenerControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER ); sessionListener.sessionDisconnecting( null ); sessionListener.sessionError( null ); sessionListenerControl.replay(); 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 { sessionListenerControl.verify(); } } public void testGetTransferEvents() throws Exception { transferListener.debug( "fetch debug message" ); transferListenerControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER ); transferListener.transferInitiated( null ); transferListener.transferStarted( null ); transferListener.debug( null ); transferListenerControl.setVoidCallable( MockControl.ZERO_OR_MORE ); transferListener.transferProgress( null, null, 0 ); transferListenerControl.setVoidCallable( 5 ); transferListener.transferCompleted( null ); transferListenerControl.replay(); wagon.fireTransferDebug( "fetch debug message" ); Repository repository = new Repository(); wagon.connect( repository ); wagon.get( artifact, destination ); transferListenerControl.verify(); } public void testGetError() throws Exception { transferListenerControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER ); transferListener.transferInitiated( null ); transferListener.transferStarted( null ); transferListener.debug( null ); transferListenerControl.setVoidCallable( MockControl.ZERO_OR_MORE ); transferListener.transferError( null ); transferListenerControl.replay(); 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 ); } transferListenerControl.verify(); } public void testPutTransferEvents() throws ConnectionException, AuthenticationException, ResourceDoesNotExistException, TransferFailedException, AuthorizationException { transferListener.debug( "deploy debug message" ); transferListenerControl.setDefaultMatcher( MockControl.ALWAYS_MATCHER ); transferListener.transferInitiated( null ); transferListener.transferStarted( null ); transferListener.transferProgress( null, null, 0 ); transferListener.transferCompleted( null ); transferListenerControl.replay(); wagon.fireTransferDebug( "deploy debug message" ); Repository repository = new Repository(); wagon.connect( repository ); wagon.put( source, artifact ); transferListenerControl.verify(); } 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( null ); transferListenerControl.setMatcher( MockControl.ALWAYS_MATCHER ); transferListener.transferStarted( null ); transferListenerControl.setMatcher( MockControl.ALWAYS_MATCHER ); TransferEvent event = new TransferEvent( wagon, resource, TransferEvent.TRANSFER_PROGRESS, TransferEvent.REQUEST_PUT ); event.setLocalFile( tempFile ); transferListener.transferProgress( event, content.getBytes(), content.length() ); ProgressArgumentMatcher matcher = new ProgressArgumentMatcher(); transferListenerControl.setMatcher( matcher ); transferListener.transferCompleted( null ); transferListenerControl.setMatcher( MockControl.ALWAYS_MATCHER ); transferListenerControl.replay(); wagon.postProcessListeners( resource, tempFile, TransferEvent.REQUEST_PUT ); assertEquals( content.length(), matcher.getSize() ); assertEquals( new String( content.getBytes() ), new String( matcher.getBytes() ) ); tempFile.delete(); } static final class ProgressArgumentMatcher extends AbstractMatcher { private ByteArrayOutputStream baos = new ByteArrayOutputStream(); private int size; private byte[] lastArray; protected boolean argumentMatches( Object expected, Object actual ) { if ( actual instanceof byte[] ) { lastArray = (byte[]) actual; return true; } if ( actual instanceof Integer ) { int length = ( (Integer) actual ).intValue(); baos.write( lastArray, 0, length ); size += length; return true; } return super.argumentMatches( expected, actual ); } public int getSize() { return size; } public byte[] getBytes() { return baos.toByteArray(); } } } wagon-1.0.0/wagon-provider-api/src/test/java/org/apache/maven/wagon/StreamWagonTest.java0000644000175000017500000004250211044035101031135 0ustar twernertwernerpackage 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.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.IOUtil; import org.codehaus.plexus.util.StringInputStream; import org.codehaus.plexus.util.StringOutputStream; import org.easymock.MockControl; 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 ); } }; MockControl control = MockControl.createControl( TransferListener.class ); TransferListener listener = (TransferListener) control.getMock(); listener.transferInitiated( null ); control.setMatcher( MockControl.ALWAYS_MATCHER ); TransferEvent transferEvent = new TransferEvent( wagon, new Resource( "resource" ), new TransferFailedException( "" ), TransferEvent.REQUEST_GET ); listener.transferError( transferEvent ); control.replay(); wagon.connect( repository ); wagon.addTransferListener( listener ); try { wagon.getToStream( "resource", new StringOutputStream() ); fail(); } catch ( TransferFailedException e ) { assertTrue( true ); } finally { wagon.disconnect(); } control.verify(); } public void testNullOutputStream() throws Exception { StreamingWagon wagon = new TestWagon() { public void fillOutputData( OutputData inputData ) { inputData.setOutputStream( null ); } }; MockControl control = MockControl.createControl( TransferListener.class ); TransferListener listener = (TransferListener) control.getMock(); listener.transferInitiated( null ); control.setMatcher( MockControl.ALWAYS_MATCHER ); TransferEvent transferEvent = new TransferEvent( wagon, new Resource( "resource" ), new TransferFailedException( "" ), TransferEvent.REQUEST_PUT ); listener.transferError( transferEvent ); control.replay(); wagon.connect( repository ); wagon.addTransferListener( listener ); try { wagon.putFromStream( new StringInputStream( "" ), "resource" ); fail(); } catch ( TransferFailedException e ) { assertTrue( true ); } finally { wagon.disconnect(); } control.verify(); } 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( "" ); } }; MockControl control = MockControl.createControl( TransferListener.class ); TransferListener listener = (TransferListener) control.getMock(); listener.transferInitiated( null ); control.setMatcher( MockControl.ALWAYS_MATCHER ); TransferEvent transferEvent = new TransferEvent( wagon, new Resource( "resource" ), new TransferFailedException( "" ), TransferEvent.REQUEST_PUT ); listener.transferError( transferEvent ); control.replay(); wagon.connect( repository ); wagon.addTransferListener( listener ); try { wagon.putFromStream( new StringInputStream( "" ), "resource" ); fail(); } catch ( TransferFailedException e ) { assertTrue( true ); } finally { wagon.disconnect(); control.verify(); } } 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; } } }; MockControl control = MockControl.createControl( TransferListener.class ); TransferListener listener = (TransferListener) control.getMock(); listener.transferInitiated( null ); control.setMatcher( MockControl.ALWAYS_MATCHER ); TransferEvent transferEvent = new TransferEvent( wagon, new Resource( "resource" ), exception, TransferEvent.REQUEST_GET ); listener.transferError( transferEvent ); control.replay(); wagon.connect( repository ); wagon.addTransferListener( listener ); try { wagon.getToStream( "resource", new StringOutputStream() ); fail(); } finally { wagon.disconnect(); control.verify(); } } 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(); } } } wagon-1.0.0/wagon-provider-api/pom.xml0000644000175000017500000000333111605164037017613 0ustar twernertwerner 4.0.0 org.apache.maven.wagon wagon 1.0 ../pom.xml wagon-provider-api Maven Wagon API Maven Wagon API that defines the contract between different Wagon implementations org.codehaus.plexus plexus-utils easymock easymock 1.2_Java1.3 test wagon-1.0.0/pom.xml0000644000175000017500000002315311605164037014105 0ustar twernertwerner 4.0.0 maven-parent org.apache.maven 20 ../pom/maven/pom.xml org.apache.maven.wagon wagon 1.0 pom Maven Wagon Tools to manage artifacts and deployment http://maven.apache.org/wagon 2003 michal Michal Maczka michal@codehaus.org Codehaus Developer James William Dumay Nathan Beyer Gregory Block Thomas Recloux Trustin Lee John Wells Marcel Schutte David Hawkins Juan F. Codagnone ysoonleo Thomas Champagne M. van der Plas Jason Dillon Jochen Wiedmann Gilles Scokart Wolfgang Glas Kohsuke Kawaguchi Antti Virtanen Thorsten Heit Benson Margulies bimargulies@apache.org Committer America/Boston scm:svn:http://svn.apache.org/repos/asf/maven/wagon/tags/wagon-1.0 scm:svn:https://svn.apache.org/repos/asf/maven/wagon/tags/wagon-1.0 http://svn.apache.org/viewvc/maven/wagon/tags/wagon-1.0 jira http://jira.codehaus.org/browse/WAGON Jenkins https://builds.apache.org/hudson/job/maven-wagon/ wagon-provider-api wagon-providers wagon-provider-test wagon-tcks true junit junit test org.apache.maven.wagon wagon-provider-api ${project.version} org.apache.maven.wagon wagon-provider-test ${project.version} org.apache.maven.wagon wagon-ssh-common-test ${project.version} org.apache.maven.wagon wagon-ssh-common ${project.version} junit junit 3.8.1 org.codehaus.plexus plexus-interactivity-api 1.0-alpha-6 plexus plexus-utils org.codehaus.plexus plexus-container-default classworlds classworlds org.codehaus.plexus plexus-container-default 1.0-alpha-9 test org.codehaus.plexus plexus-utils 1.4.2 maven-release-plugin https://svn.apache.org/repos/asf/maven/wagon/tags true maven-site-plugin scp://people.apache.org/www/maven.apache.org/wagon-${project.version} org.codehaus.plexus plexus-maven-plugin 1.3.5 org.codehaus.plexus plexus-maven-plugin generate descriptor maven-javadoc-plugin http://java.sun.com/j2ee/1.4/docs/api http://commons.apache.org/collections/apidocs-COLLECTIONS_3_0/ http://commons.apache.org/dbcp/apidocs/ http://commons.apache.org/fileupload/apidocs/ http://commons.apache.org/httpclient/apidocs/ http://commons.apache.org/logging/apidocs/ http://commons.apache.org/pool/apidocs/ http://junit.sourceforge.net/javadoc/ http://logging.apache.org/log4j/1.2/apidocs/ http://jakarta.apache.org/regexp/apidocs/ http://velocity.apache.org/engine/releases/velocity-1.5/apidocs/ http://maven.apache.org/ref/current/maven-artifact/apidocs/ http://maven.apache.org/ref/current/maven-artifact-manager/apidocs/ http://maven.apache.org/ref/current/maven-model/apidocs/ http://maven.apache.org/ref/current/maven-plugin-api/apidocs/ http://maven.apache.org/ref/current/maven-project/apidocs/ http://maven.apache.org/ref/current/maven-reporting/maven-reporting-api/apidocs/ http://maven.apache.org/ref/current/maven-settings/apidocs/ wagon-1.0.0/wagon-provider-test/0000755000175000017500000000000011630374112016477 5ustar twernertwernerwagon-1.0.0/wagon-provider-test/src/0000755000175000017500000000000011630374112017266 5ustar twernertwernerwagon-1.0.0/wagon-provider-test/src/main/0000755000175000017500000000000011630374111020211 5ustar twernertwernerwagon-1.0.0/wagon-provider-test/src/main/java/0000755000175000017500000000000011630374111021132 5ustar twernertwernerwagon-1.0.0/wagon-provider-test/src/main/java/org/0000755000175000017500000000000011630374111021721 5ustar twernertwernerwagon-1.0.0/wagon-provider-test/src/main/java/org/apache/0000755000175000017500000000000011630374111023142 5ustar twernertwernerwagon-1.0.0/wagon-provider-test/src/main/java/org/apache/maven/0000755000175000017500000000000011630374111024250 5ustar twernertwernerwagon-1.0.0/wagon-provider-test/src/main/java/org/apache/maven/wagon/0000755000175000017500000000000011630374112025364 5ustar twernertwernerwagon-1.0.0/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/0000755000175000017500000000000011630374111026342 5ustar twernertwernerwagon-1.0.0/wagon-provider-test/src/main/java/org/apache/maven/wagon/http/HttpWagonTestCase.java0000644000175000017500000006440611147155215032573 0ustar twernertwernerpackage 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 java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.net.URLDecoder; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; import java.util.Properties; import java.util.zip.GZIPOutputStream; import javax.servlet.ServletException; import javax.servlet.ServletInputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.maven.wagon.ConnectionException; 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.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.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.StringOutputStream; import org.mortbay.jetty.Handler; import org.mortbay.jetty.HttpConnection; import org.mortbay.jetty.Request; 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; /** * @version $Id: LightweightHttpWagonTest.java 680764 2008-07-29 16:45:51Z brett $ */ public abstract class HttpWagonTestCase extends StreamingWagonTestCase { 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( 10007 ); PutHandler putHandler = new PutHandler( repositoryDirectory ); server.addHandler( putHandler ); createContext( server, repositoryDirectory ); addConnectors( server ); server.start(); } 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 StringOutputStream() ); wagon.disconnect(); server.stop(); assertEquals( "Maven-Wagon/1.0", 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 testGet500() throws Exception { try { runTestGet( HttpServletResponse.SC_INTERNAL_SERVER_ERROR ); fail(); } catch ( TransferFailedException e ) { assertTrue( true ); } } private void runTestGet( int status ) throws Exception, ConnectionException, AuthenticationException, TransferFailedException, ResourceDoesNotExistException, AuthorizationException { 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 StringOutputStream() ); 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 ); } } private boolean runTestResourceExists( int status ) throws Exception, ConnectionException, AuthenticationException, TransferFailedException, ResourceDoesNotExistException, AuthorizationException { 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( 10008 ); 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" ); TestHeaderHandler handler = new AuthorizingProxyHandler(); runTestProxiedRequest( proxyInfo, handler ); assertTrue( handler.headers.containsKey( "Proxy-Authorization" ) ); } private void runTestProxiedRequest( ProxyInfo proxyInfo, TestHeaderHandler handler ) throws Exception, IOException, ConnectionException, AuthenticationException, ResourceDoesNotExistException, TransferFailedException, AuthorizationException { Server proxyServer = new Server( 10007 ); proxyServer.setHandler( handler ); proxyServer.start(); proxyInfo.setPort( 10007 ); 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 ); StringOutputStream out = new StringOutputStream(); try { wagon.getToStream( "test-proxied-resource", out ); assertTrue( handler.headers.containsKey( "Proxy-Connection" ) ); } finally { 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 ); StringOutputStream out = new StringOutputStream(); try { wagon.getToStream( "test-secured-resource", out ); } finally { wagon.disconnect(); } assertEquals( "top secret", out.toString() ); } 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; } protected SecurityHandler 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( "/*" ); SecurityHandler sh = new SecurityHandler(); HashUserRealm hashUserRealm = new HashUserRealm( "MyRealm" ); hashUserRealm.put( "user", "secret" ); hashUserRealm.addUserToRole( "user", "admin" ); sh.setUserRealm( hashUserRealm ); sh.setConstraintMappings( new ConstraintMapping[] { cm } ); return sh; } 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 ); out.write( child.getBytes() ); out.close(); file = new File( parent, child + ".gz" ); file.deleteOnExit(); out = new FileOutputStream( file ); out = new GZIPOutputStream( out ); // write out different data than non-gz file, so we can // assert the gz version was returned String content = file.getAbsolutePath(); out.write( content.getBytes() ); 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 ); } } private void runTestPut( int status ) throws Exception, ConnectionException, AuthenticationException, TransferFailedException, ResourceDoesNotExistException, AuthorizationException { 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 { String localRepositoryPath = FileTestUtils.getTestOutputDir().toString(); Server server = new Server( 0 ); SecurityHandler sh = createSecurityHandler(); PutHandler handler = new PutHandler( new File( localRepositoryPath ) ); HandlerCollection handlers = new HandlerCollection(); handlers.setHandlers( new Handler[] { sh, handler } ); server.setHandler( handlers ); addConnectors( server ); server.start(); try { StreamingWagon wagon = (StreamingWagon) getWagon(); Repository testRepository = new Repository( "id", getRepositoryUrl( server ) ); wagon.connect( testRepository, authInfo ); 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 { wagon.disconnect(); tempFile.delete(); } assertEquals( "put top secret", FileUtils.fileRead( sourceFile.getAbsolutePath() ) ); } finally { server.stop(); } } 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 PutHandler extends AbstractHandler { private final File resourceBase; public PutHandler( File repositoryDirectory ) { this.resourceBase = repositoryDirectory; } public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch ) throws IOException, ServletException { Request base_request = request instanceof Request ? (Request) request : HttpConnection.getCurrentConnection().getRequest(); if ( base_request.isHandled() || !"PUT".equals( base_request.getMethod() ) ) { return; } base_request.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(); } response.setStatus( HttpServletResponse.SC_CREATED ); } } private static class AuthorizingProxyHandler extends TestHeaderHandler { public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch ) throws IOException, ServletException { if ( request.getHeader( "Proxy-Authorization" ) == null ) { response.setStatus( 407 ); response.addHeader( "Proxy-Authenticate", "Basic realm=\"Squid proxy-caching web server\"" ); ( (Request) request ).setHandled( true ); return; } super.handle( target, request, response, dispatch ); } } private static class TestHeaderHandler extends AbstractHandler { private Map headers; public TestHeaderHandler() { } public void handle( String target, HttpServletRequest request, HttpServletResponse response, int dispatch ) throws IOException, ServletException { headers = new HashMap(); for ( Enumeration e = request.getHeaderNames(); e.hasMoreElements(); ) { String name = (String) e.nextElement(); headers.put( name, request.getHeader( name ) ); } response.setContentType( "text/plain" ); response.setStatus( HttpServletResponse.SC_OK ); response.getWriter().println( "Hello, World!" ); ( (Request) request ).setHandled( true ); } } } wagon-1.0.0/wagon-provider-test/src/main/java/org/apache/maven/wagon/FileTestUtils.java0000644000175000017500000000565211435306130030775 0ustar twernertwernerpackage 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.FileWriter; import java.io.IOException; import java.io.Writer; import org.codehaus.plexus.util.FileUtils; /** * @author Brett Porter * @version $Id: CommandExecutorTestCase.java 658720 2008-05-21 14:49:22Z bentmann $ */ 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(); } wagon-1.0.0/wagon-provider-test/src/main/java/org/apache/maven/wagon/WagonTestCase.java0000644000175000017500000010404411147165407030751 0ustar twernertwernerpackage 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.security.NoSuchAlgorithmException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; 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.AbstractMatcher; import org.easymock.MockControl; /** * @author Jason van Zyl * @version $Id: WagonTestCase.java 745730 2009-02-19 05:15:51Z brett $ */ public abstract class WagonTestCase extends PlexusTestCase { static final class ProgressArgumentMatcher extends AbstractMatcher { private int size; protected boolean argumentMatches( Object expected, Object actual ) { if ( actual instanceof byte[] ) { return true; } if ( actual instanceof Integer ) { size += ( (Integer) actual ).intValue(); return true; } return super.argumentMatches( expected, actual ); } public int getSize() { return size; } } protected static 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; protected MockControl mockTransferListenerControl; // ---------------------------------------------------------------------- // Constructors // ---------------------------------------------------------------------- protected void setUp() throws Exception { checksumObserver = new ChecksumObserver(); mockTransferListenerControl = MockControl.createControl( TransferListener.class ); mockTransferListener = (TransferListener) mockTransferListenerControl.getMock(); 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.

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. scp, ftp * * @return the protocol id */ protected abstract String getProtocol(); // ---------------------------------------------------------------------- // 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 ) { System.out.println( message ); } // ---------------------------------------------------------------------- // // ---------------------------------------------------------------------- public void testWagon() throws Exception { setupRepositories(); setupWagonTestingFixtures(); fileRoundTripTesting(); tearDownWagonTestingFixtures(); } public void testWagonGetIfNewerIsNewer() throws Exception { if ( supportsGetIfNewer() ) { setupRepositories(); setupWagonTestingFixtures(); int expectedSize = putFile(); getIfNewer( getExpectedLastModifiedOnGet( testRepository, new Resource( resource ) ) + 30000, false, expectedSize ); } } protected boolean supportsGetIfNewer() { return true; } 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 ); } } public void testWagonGetIfNewerIsSame() throws Exception { if ( supportsGetIfNewer() ) { setupRepositories(); setupWagonTestingFixtures(); int expectedSize = putFile(); getIfNewer( getExpectedLastModifiedOnGet( testRepository, new Resource( resource ) ), false, expectedSize ); } } private void getIfNewer( long timestamp, boolean expectedResult, int expectedSize ) throws Exception, NoSuchAlgorithmException, IOException, ConnectionException, AuthenticationException, TransferFailedException, ResourceDoesNotExistException, AuthorizationException { Wagon wagon = getWagon(); ProgressArgumentMatcher progressArgumentMatcher = setupGetIfNewerTest( wagon, expectedResult, expectedSize ); connectWagon( wagon ); boolean result = wagon.getIfNewer( this.resource, destFile, timestamp ); assertEquals( expectedResult, result ); disconnectWagon( wagon ); assertGetIfNewerTest( progressArgumentMatcher, expectedResult, expectedSize ); tearDownWagonTestingFixtures(); } protected void assertGetIfNewerTest( ProgressArgumentMatcher progressArgumentMatcher, boolean expectedResult, int expectedSize ) throws IOException { if ( expectedResult == true ) { verifyMock( progressArgumentMatcher, 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 { mockTransferListenerControl.verify(); mockTransferListenerControl.reset(); assertNull( "check checksum is null", checksumObserver.getActualChecksum() ); assertFalse( destFile.exists() ); } } protected ProgressArgumentMatcher 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(); ProgressArgumentMatcher progressArgumentMatcher = null; if ( expectedResult == true ) { progressArgumentMatcher = replaceMockForGet( wagon, expectedSize ); } else { replaceMockForSkippedGetIfNewer( wagon, expectedSize ); } return progressArgumentMatcher; } 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( null ); mockTransferListenerControl.setMatcher( MockControl.ALWAYS_MATCHER ); mockTransferListenerControl.setVoidCallable( MockControl.ZERO_OR_MORE ); mockTransferListenerControl.replay(); } 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 ( int i = 0; i < resources.length; i++ ) { writeTestFile( resources[i] ); } wagon.connect( testRepository, getAuthInfo() ); wagon.putDirectory( sourceFile, dirName ); List resourceNames = new ArrayList( resources.length + 1 ); resourceNames.add( dirName + "/" + resourceToCreate ); for ( int i = 0; i < resources.length; i++ ) { resourceNames.add( dirName + "/" + resources[i] ); } 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 ( int i = 0; i < resources.length; i++ ) { writeTestFile( resources[i] ); } wagon.connect( testRepository, getAuthInfo() ); wagon.putDirectory( sourceFile, "." ); List resourceNames = new ArrayList( resources.length + 1 ); resourceNames.add( resourceToCreate ); for ( int i = 0; i < resources.length; i++ ) { resourceNames.add( resources[i] ); } 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 resourceNames ) throws IOException, TransferFailedException, ResourceDoesNotExistException, AuthorizationException { Iterator iter = resourceNames.iterator(); while ( iter.hasNext() ) { String resourceName = (String) iter.next(); 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 ( int i = 0; i < filenames.length; i++ ) { putFile( dirName + "/" + filenames[i], dirName + "/" + filenames[i], filenames[i] + "\n" ); } Wagon wagon = getWagon(); wagon.connect( testRepository, getAuthInfo() ); List 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 ( int i = 0; i < filenames.length; i++ ) { assertTrue( "Filename '" + filenames[i] + "' should be in list.", list.contains( filenames[i] ) ); } // 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(); ProgressArgumentMatcher progressArgumentMatcher = replayMockForPut( resourceName, content, wagon ); message( "Putting test artifact: " + resourceName + " into test repository " + testRepository ); connectWagon( wagon ); wagon.put( sourceFile, resourceName ); disconnectWagon( wagon ); verifyMock( progressArgumentMatcher, content.length() ); } protected ProgressArgumentMatcher 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( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_PROGRESS, TransferEvent.REQUEST_PUT, sourceFile ), new byte[] {}, 0 ); ProgressArgumentMatcher progressArgumentMatcher = new ProgressArgumentMatcher(); mockTransferListenerControl.setMatcher( progressArgumentMatcher ); mockTransferListener.debug( null ); mockTransferListenerControl.setMatcher( MockControl.ALWAYS_MATCHER ); mockTransferListenerControl.setVoidCallable( MockControl.ZERO_OR_MORE ); mockTransferListener.transferCompleted( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_COMPLETED, TransferEvent.REQUEST_PUT, sourceFile ) ); mockTransferListenerControl.replay(); return progressArgumentMatcher; } 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(); ProgressArgumentMatcher progressArgumentMatcher = replaceMockForGet( wagon, expectedSize ); message( "Getting test artifact from test repository " + testRepository ); connectWagon( wagon ); wagon.get( this.resource, destFile ); disconnectWagon( wagon ); verifyMock( progressArgumentMatcher, expectedSize ); } protected void verifyMock( ProgressArgumentMatcher progressArgumentMatcher, int length ) { mockTransferListenerControl.verify(); assertEquals( length, progressArgumentMatcher.getSize() ); mockTransferListenerControl.reset(); } 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() ); } protected ProgressArgumentMatcher 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 ) ); mockTransferListener.transferStarted( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_STARTED, TransferEvent.REQUEST_GET, destFile ) ); mockTransferListener.transferProgress( new TransferEvent( wagon, resource, TransferEvent.TRANSFER_PROGRESS, TransferEvent.REQUEST_GET ), new byte[] {}, 0 ); ProgressArgumentMatcher progressArgumentMatcher = new ProgressArgumentMatcher(); mockTransferListenerControl.setMatcher( progressArgumentMatcher ); mockTransferListener.debug( null ); mockTransferListenerControl.setMatcher( MockControl.ALWAYS_MATCHER ); mockTransferListenerControl.setVoidCallable( MockControl.ZERO_OR_MORE ); mockTransferListener.transferCompleted( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_COMPLETED, TransferEvent.REQUEST_GET, destFile ) ); mockTransferListenerControl.replay(); return progressArgumentMatcher; } 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; } } wagon-1.0.0/wagon-provider-test/src/main/java/org/apache/maven/wagon/StreamingWagonTestCase.java0000644000175000017500000002233211020773461032615 0ustar twernertwernerpackage 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.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.security.NoSuchAlgorithmException; import java.text.SimpleDateFormat; import org.apache.maven.wagon.authentication.AuthenticationException; import org.apache.maven.wagon.authorization.AuthorizationException; 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; /** * @author Brett Porter * @version $Id: WagonTestCase.java 660462 2008-05-27 10:52:46Z brett $ */ public abstract class StreamingWagonTestCase extends WagonTestCase { public void testStreamingWagon() throws Exception { 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(); getIfNewerToStream( getExpectedLastModifiedOnGet( testRepository, new Resource( resource ) ) + 30000, false, expectedSize ); } } 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, NoSuchAlgorithmException, IOException, ConnectionException, AuthenticationException, TransferFailedException, ResourceDoesNotExistException, AuthorizationException { StreamingWagon wagon = (StreamingWagon) getWagon(); ProgressArgumentMatcher progressArgumentMatcher = 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( progressArgumentMatcher, 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(); ProgressArgumentMatcher progressArgumentMatcher = 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() ); } finally { IOUtil.close( stream ); } disconnectWagon( wagon ); verifyMock( progressArgumentMatcher, content.length() ); return content.length(); } private void getStream( int expectedSize ) throws Exception { destFile = FileTestUtils.createUniqueFile( getName(), getName() ); destFile.deleteOnExit(); StreamingWagon wagon = (StreamingWagon) getWagon(); ProgressArgumentMatcher progressArgumentMatcher = 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 ); } finally { IOUtil.close( stream ); } disconnectWagon( wagon ); verifyMock( progressArgumentMatcher, expectedSize ); } } wagon-1.0.0/wagon-provider-test/src/site/0000755000175000017500000000000011630374112020232 5ustar twernertwernerwagon-1.0.0/wagon-provider-test/src/site/site.xml0000644000175000017500000000013211045135116021713 0ustar twernertwerner

wagon-1.0.0/wagon-provider-test/src/site/apt/0000755000175000017500000000000011630374112021016 5ustar twernertwernerwagon-1.0.0/wagon-provider-test/src/site/apt/index.apt0000644000175000017500000000021311045136112022623 0ustar twernertwerner ------ Maven Wagon Test ------ Carlos Sanchez ------ 2006-04-16 ------ Maven Wagon Test Suite of tests for Wagon implementations wagon-1.0.0/wagon-provider-test/pom.xml0000644000175000017500000000411111605164037020016 0ustar twernertwerner 4.0.0 org.apache.maven.wagon wagon 1.0 ../pom.xml wagon-provider-test Maven Wagon Provider Test Suite of tests for Wagon implementations junit junit org.apache.maven.wagon wagon-provider-api org.codehaus.plexus plexus-container-default compile easymock easymock 1.2_Java1.3 org.mortbay.jetty jetty 6.1.11