[MRM-513] Support remote repositories with passwords.

Commited patch from James William Dumay.
Updated title/h1 sections of add/edit/delete jsps to be consistent with regards to "remote" and "managed" usage.



git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@581324 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Joakim Erdfelt 2007-10-02 18:00:48 +00:00
parent f4330d5248
commit 3a88ce0ad2
9 changed files with 88 additions and 20 deletions

View File

@ -274,6 +274,22 @@
The URL for this repository.
</description>
</field>
<field>
<name>username</name>
<version>1.0.0+</version>
<type>String</type>
<description>
The Username for this repository.
</description>
</field>
<field>
<name>password</name>
<version>1.0.0+</version>
<type>String</type>
<description>
The Password for this repository.
</description>
</field>
</fields>
</class>
<class>

View File

@ -78,6 +78,16 @@ public class ArchivaRepository
return this.url;
}
public void setUsername(String username)
{
this.model.setRepositoryUsername(username);
}
public void setPassword(String password)
{
this.model.setRepositoryPassword(password);
}
public ArchivaRepositoryModel getModel()
{
return this.model;
@ -103,6 +113,16 @@ public class ArchivaRepository
return this.model.getName();
}
public String getUsername()
{
return model.getRepositoryUsername();
}
public String getPassword()
{
return model.getRepositoryPassword();
}
public String toString()
{
StringBuffer sb = new StringBuffer();

View File

@ -132,6 +132,24 @@
The URL of the repository.
</description>
</field>
<field stash.maxSize="250">
<name>repositoryUsername</name>
<identifier>false</identifier>
<version>1.0.0+</version>
<type>String</type>
<description>
The Username of the repository.
</description>
</field>
<field stash.maxSize="250">
<name>repositoryPassword</name>
<identifier>false</identifier>
<version>1.0.0+</version>
<type>String</type>
<description>
The Password of the repository.
</description>
</field>
<field stash.maxSize="20">
<name>creationSource</name>
<identifier>false</identifier>

View File

@ -45,6 +45,7 @@ import org.apache.maven.wagon.ResourceDoesNotExistException;
import org.apache.maven.wagon.Wagon;
import org.apache.maven.wagon.WagonException;
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.codehaus.plexus.logging.AbstractLogEnabled;
@ -441,6 +442,7 @@ public class DefaultRepositoryProxyConnectors
transferChecksum( wagon, remoteRepository, remotePath, localFile, ".sha1" );
transferChecksum( wagon, remoteRepository, remotePath, localFile, ".md5" );
}
}
catch ( ResourceDoesNotExistException e )
@ -691,15 +693,31 @@ public class DefaultRepositoryProxyConnectors
try
{
AuthenticationInfo authInfo = null;
String username = remoteRepository.getUsername();
String password = remoteRepository.getPassword();
if (username != null && password != null)
{
getLogger().info("Using username " + username + " to connect to remote repository "
+ remoteRepository.getUrl());
authInfo = new AuthenticationInfo();
authInfo.setUserName(username);
authInfo.setPassword(password);
}
else
{
getLogger().info("No authentication for remote repository needed");
}
Repository wagonRepository =
new Repository( remoteRepository.getId(), remoteRepository.getUrl().toString() );
if ( networkProxy != null )
{
wagon.connect( wagonRepository, networkProxy );
wagon.connect( wagonRepository, authInfo, networkProxy );
}
else
{
wagon.connect( wagonRepository );
wagon.connect( wagonRepository, authInfo );
}
connected = true;
}
@ -871,6 +889,8 @@ public class DefaultRepositoryProxyConnectors
ArchivaRepository repo = new ArchivaRepository( repoConfig.getId(), repoConfig.getName(), repoConfig.getUrl() );
repo.getModel().setLayoutName( repoConfig.getLayout() );
repo.setUsername(repoConfig.getUsername());
repo.setPassword(repoConfig.getPassword());
return repo;
}

View File

@ -21,18 +21,16 @@
<html>
<head>
<title>Admin: Add Repository</title>
<title>Admin: Add Remote Repository</title>
<ww:head/>
</head>
<body>
<h1>Admin: Add Repository</h1>
<h1>Admin: Add Remote Repository</h1>
<div id="contentArea">
<h2>Add Repository</h2>
<ww:actionmessage/>
<ww:form method="post" action="addRemoteRepository!commit" namespace="/admin" validate="true">
<ww:textfield name="repository.id" label="Identifier" size="10" required="true"/>

View File

@ -21,18 +21,16 @@
<html>
<head>
<title>Admin: Add Repository</title>
<title>Admin: Add Managed Repository</title>
<ww:head/>
</head>
<body>
<h1>Admin: Add Repository</h1>
<h1>Admin: Add Managed Repository</h1>
<div id="contentArea">
<h2>Add Repository</h2>
<ww:actionmessage/>
<ww:form method="post" action="addRepository!commit" namespace="/admin" validate="true">
<ww:textfield name="repository.id" label="Identifier" size="10" required="true"/>

View File

@ -21,20 +21,18 @@
<html>
<head>
<title>Admin: Edit Repository</title>
<title>Admin: Edit Remote Repository</title>
<ww:head/>
</head>
<body>
<h1>Admin: Edit Repository</h1>
<h1>Admin: Edit Remote Repository</h1>
<ww:actionerror/>
<div id="contentArea">
<h2>Edit Repository</h2>
<ww:actionmessage/>
<ww:form method="post" action="editRemoteRepository!commit" namespace="/admin" validate="false">
<ww:hidden name="repository.id"/>

View File

@ -21,20 +21,18 @@
<html>
<head>
<title>Admin: Edit Repository</title>
<title>Admin: Edit Managed Repository</title>
<ww:head/>
</head>
<body>
<h1>Admin: Edit Repository</h1>
<h1>Admin: Edit Managed Repository</h1>
<ww:actionerror/>
<div id="contentArea">
<h2>Edit Repository</h2>
<ww:actionmessage/>
<ww:form method="post" action="editRepository!commit" namespace="/admin" validate="false">
<ww:hidden name="repository.id"/>

View File

@ -21,5 +21,7 @@
<ww:textfield name="repository.name" label="Name" size="50" required="true"/>
<ww:textfield name="repository.url" label="URL" size="50" required="true"/>
<ww:textfield name="repository.username" label="Username" size="25" required="false"/>
<ww:password name="repository.password" label="Password" size="25" required="false"/>
<ww:select list="#@java.util.LinkedHashMap@{'default' : 'Maven 2.x Repository', 'legacy' : 'Maven 1.x Repository'}"
name="repository.layout" label="Type"/>