Skip to content

Commit

Permalink
[FIXED JENKINS-16432] Match root in global auth when no port specified
Browse files Browse the repository at this point in the history
  • Loading branch information
mc1arke committed Mar 17, 2013
1 parent 85adb39 commit c239e53
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/main/java/hudson/scm/AbstractCvs.java
Expand Up @@ -27,7 +27,10 @@
import hudson.EnvVars;
import hudson.FilePath;
import hudson.Launcher;
import hudson.model.*;
import hudson.model.AbstractBuild;
import hudson.model.AbstractProject;
import hudson.model.BuildListener;
import hudson.model.TaskListener;
import hudson.remoting.VirtualChannel;
import hudson.scm.cvstagging.CvsTagAction;
import hudson.util.Secret;
Expand Down Expand Up @@ -312,10 +315,15 @@ public Client getCvsClient(final CvsRepository repository, final EnvVars envVars
cvsRoot.setPassword(Secret.toString(repository.getPassword()));
}
else {
String partialRoot = cvsRoot.getHostName() + ":" + cvsRoot.getPort() + cvsRoot.getRepository();
String partialRoot = cvsRoot.getHostName() + ":" + ConnectionFactory.getConnection(cvsRoot).getPort() + cvsRoot.getRepository();
String sanitisedRoot = ":" + cvsRoot.getMethod() + ":" + partialRoot;
for (CvsAuthentication authentication : getDescriptor().getAuthentication()) {
if (authentication.getCvsRoot().equals(sanitisedRoot) && (cvsRoot.getUserName() == null || authentication.getUsername().equals(cvsRoot.getUserName()))) {
CVSRoot authenticationRoot = CVSRoot.parse(authentication.getCvsRoot());
String partialAuthenticationRoot = authenticationRoot.getHostName() + ":"
+ ConnectionFactory.getConnection(authenticationRoot).getPort() + authenticationRoot.getRepository();
String sanitisedAuthenticationRoot = ":" + cvsRoot.getMethod() + ":" + partialAuthenticationRoot;
if (sanitisedAuthenticationRoot.equals(sanitisedRoot)
&& (cvsRoot.getUserName() == null || authentication.getUsername().equals(cvsRoot.getUserName()))) {
cvsRoot = CVSRoot.parse(":" + cvsRoot.getMethod() + ":" + (authentication.getUsername() != null ? authentication.getUsername() + "@" :"") + partialRoot);
cvsRoot.setPassword(authentication.getPassword().getPlainText());
if (showAuthenticationInfo) {
Expand Down

0 comments on commit c239e53

Please sign in to comment.