Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2006-2013 smartics, Kronseder & Reiner GmbH
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT 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 com.redhat.rcm.maven.plugin.buildmetadata.scm.maven;
 
 
 
Provides the information required to connect to a SCM system.

Author(s):
Robert Reiner
Version:
$Revision:591 $
 
 public final class ScmConnectionInfo implements Serializable
 {
   // ********************************* Fields *********************************
 
   // --- constants ------------------------------------------------------------
 
  
The class version identifier.

The value of this constant is .

 
   private static final long serialVersionUID = 1L;
 
   // --- members --------------------------------------------------------------
 
  
The URL to connect to the SCM system.
 
   private String connectionUrl;

  
The user name to authenticate against the SCM system.
 
   private String userName;

  
The password to authenticate against the SCM system.
 
   private String password;

  
The private key to authenticate against the SCM system.
 
   private String privateKey;

  
The pass phrase to authenticate against the SCM system.
 
   private String passPhrase;

  
The url of tags base directory (used by svn protocol).
 
   private String tagBase;
 
   // ****************************** Initializer *******************************
 
   // ****************************** Constructors ******************************
 
   // ****************************** Inner Classes *****************************
 
   // ********************************* Methods ********************************
 
   // --- init -----------------------------------------------------------------
 
   // --- get&set --------------------------------------------------------------
 
  
Returns the URL to connect to the SCM system.

Returns:
the URL to connect to the SCM system.
 
   public String getConnectionUrl()
   {
    return ;
  }

  
Sets the URL to connect to the SCM system.

Parameters:
connectionUrl the URL to connect to the SCM system.
  public void setScmConnectionUrl(final String connectionUrl)
  {
    this. = connectionUrl;
  }

  
Returns the user name to authenticate against the SCM system.

Returns:
the user name to authenticate against the SCM system.
  public String getUserName()
  {
    return ;
  }

  
Sets the user name to authenticate against the SCM system.

Parameters:
userName the user name to authenticate against the SCM system.
  public void setUserName(final String userName)
  {
    this. = userName;
  }

  
Returns the password to authenticate against the SCM system.

Returns:
the password to authenticate against the SCM system.
  public String getPassword()
  {
    return ;
  }

  
Sets the password to authenticate against the SCM system.

Parameters:
password the password to authenticate against the SCM system.
  public void setPassword(final String password)
  {
    this. = password;
  }

  
Returns the private key to authenticate against the SCM system.

Returns:
the private key to authenticate against the SCM system.
  public String getPrivateKey()
  {
    return ;
  }

  
Sets the private key to authenticate against the SCM system.

Parameters:
privateKey the private key to authenticate against the SCM system.
  public void setPrivateKey(final String privateKey)
  {
    this. = privateKey;
  }

  
Returns the pass phrase to authenticate against the SCM system.

Returns:
the pass phrase to authenticate against the SCM system.
  public String getPassPhrase()
  {
    return ;
  }

  
Sets the pass phrase to authenticate against the SCM system.

Parameters:
passPhrase the pass phrase to authenticate against the SCM system.
  public void setPassPhrase(final String passPhrase)
  {
    this. = passPhrase;
  }

  
Returns the url of tags base directory (used by svn protocol).

Returns:
the url of tags base directory (used by svn protocol).
  public String getTagBase()
  {
    return ;
  }

  
Sets the url of tags base directory (used by svn protocol).

Parameters:
tagBase the url of tags base directory (used by svn protocol).
  public void setTagBase(final String tagBase)
  {
    this. = tagBase;
  }
  // --- business -------------------------------------------------------------

  
Creates and configures the SCM repository.

Parameters:
scmManager the manager to create the repository dependent on the connection URL.
Returns:
the repository implementation to connect to the SCM system.
Throws:
com.redhat.rcm.maven.plugin.buildmetadata.scm.ScmException if the repository implementation cannot be created or configured. This happens especially if no provider exists for the given connection URL.
  public ScmRepository createRepository(final ScmManager scmManager)
    throws ScmException
  {
    try
    {
      final ScmRepository repository =
          scmManager.makeScmRepository();
      final ScmProviderRepository providerRepository =
          repository.getProviderRepository();
      configure(providerRepository);
      if (repository.getProviderRepository() instanceof ScmProviderRepositoryWithHost)
      {
        final ScmProviderRepositoryWithHost providerRepositoryWithHost =
            (ScmProviderRepositoryWithHostrepository.getProviderRepository();
        configure(providerRepositoryWithHost);
      }
      if (!StringUtils.isEmpty()
          && repository.getProvider().equals("svn"))
      {
        final SvnScmProviderRepository svnRepository =
            (SvnScmProviderRepositoryrepository.getProviderRepository();
        configure(svnRepository);
      }
      return repository;
    }
    catch (final Exception e)
    {
      throw new ScmException("The SCM provider cannot be created."e);
    }
  }

  
Configures the repository with authentication information.

Parameters:
repository the repository instance to configure.
  protected void configure(final ScmProviderRepository repository)
  {
    if (!StringUtils.isEmpty())
    {
      repository.setUser();
    }
    if (!StringUtils.isEmpty())
    {
      repository.setPassword();
    }
  }

  
Configures the repository with private key and password information.

Parameters:
repository the repository instance to configure.
  protected void configure(final ScmProviderRepositoryWithHost repository)
  {
    if (!StringUtils.isEmpty())
    {
      repository.setPrivateKey();
    }
    if (!StringUtils.isEmpty())
    {
      repository.setPassphrase();
    }
  }

  
Configures the repository with the tag base information.

Parameters:
repository the repository instance to configure.
  protected void configure(final SvnScmProviderRepository repository)
  {
    repository.setTagBase();
  }
  // --- object basics --------------------------------------------------------

  
Returns the string representation of the object. Sensitive information is masked.

Returns:
the string representation of the object.
  public String toString()
  {
    final StringBuilder buffer = new StringBuilder();
    buffer.append("SCM connection info: url=").append();
    appendIfExists(buffer"user");
    appendSensibleDataIfExists(buffer"password");
    appendSensibleDataIfExists(buffer"privateKey");
    appendSensibleDataIfExists(buffer"passPhrase");
    appendIfExists(buffer"tagBase");
    return buffer.toString();
  }
  private static void appendIfExists(final StringBuilder buffer,
      final String labelfinal String value)
  {
    if (StringUtils.isNotBlank(value))
    {
      buffer.append(", ").append(label).append('=').append(value);
    }
  }
  private static void appendSensibleDataIfExists(final StringBuilder buffer,
      final String labelfinal String value)
  {
    if (StringUtils.isNotBlank(value))
    {
      buffer.append(", ").append(label).append('=').append(mask(value));
    }
  }
  private static String mask(final String input)
  {
    return StringUtils.repeat("*"input.length());
  }
New to GrepCode? Check out our FAQ X