org.apache.maven.artifact.repository.Authentication.getPassphrase()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(4.4k)|赞(0)|评价(0)|浏览(142)

本文整理了Java中org.apache.maven.artifact.repository.Authentication.getPassphrase()方法的一些代码示例,展示了Authentication.getPassphrase()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Authentication.getPassphrase()方法的具体详情如下:
包路径:org.apache.maven.artifact.repository.Authentication
类名称:Authentication
方法名:getPassphrase

Authentication.getPassphrase介绍

[英]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.
[中]获取私钥文件的密码短语。仅当主机/协议支持通过私钥/公钥交换进行身份验证且私钥用于身份验证时,才使用密码短语。

代码示例

代码示例来源:origin: apache/maven

private static Authentication toAuthentication( org.apache.maven.artifact.repository.Authentication auth )
{
  Authentication result = null;
  if ( auth != null )
  {
    AuthenticationBuilder authBuilder = new AuthenticationBuilder();
    authBuilder.addUsername( auth.getUsername() ).addPassword( auth.getPassword() );
    authBuilder.addPrivateKey( auth.getPrivateKey(), auth.getPassphrase() );
    result = authBuilder.build();
  }
  return result;
}

代码示例来源:origin: takari/takari-lifecycle

private static Authentication toAuthentication(org.apache.maven.artifact.repository.Authentication auth) {
 Authentication result = null;
 if (auth != null) {
  AuthenticationBuilder authBuilder = new AuthenticationBuilder();
  authBuilder.addUsername(auth.getUsername()).addPassword(auth.getPassword());
  authBuilder.addPrivateKey(auth.getPrivateKey(), auth.getPassphrase());
  result = authBuilder.build();
 }
 return result;
}

代码示例来源:origin: io.takari.maven.plugins/takari-lifecycle-plugin

private static Authentication toAuthentication(org.apache.maven.artifact.repository.Authentication auth) {
 Authentication result = null;
 if (auth != null) {
  AuthenticationBuilder authBuilder = new AuthenticationBuilder();
  authBuilder.addUsername(auth.getUsername()).addPassword(auth.getPassword());
  authBuilder.addPrivateKey(auth.getPrivateKey(), auth.getPassphrase());
  result = authBuilder.build();
 }
 return result;
}

代码示例来源:origin: egineering-llc/gitflow-helper-maven-plugin

/**
 * Builds a RemoteRepository for resolving artifacts.
 *
 * @param altRepository the repository identifier or alt-syntax specification
 * @return the resolve remote repository
 * @throws MojoExecutionException if the provided repository specification defines an invalid repository layout
 * @throws MojoFailureException if the provided repository specification is invalid
 */
RemoteRepository getRepository(final String altRepository) throws MojoExecutionException, MojoFailureException {
  if (getLog().isDebugEnabled()) {
    getLog().debug("Creating remote Aether repository (to resolve remote artifacts) for: " + altRepository);
  }
  // Get an appropriate injected ArtifactRepository. (This resolves authentication in the 'normal' manner from Maven)
  ArtifactRepository remoteArtifactRepo = getDeploymentRepository(altRepository);
  if (getLog().isDebugEnabled()) {
    getLog().debug("Resolved maven deployment repository. Transcribing to Aether Repository...");
  }
  RemoteRepository.Builder remoteRepoBuilder = new RemoteRepository.Builder(remoteArtifactRepo.getId(), remoteArtifactRepo.getLayout().getId(), remoteArtifactRepo.getUrl());
  // Add authentication.
  if (remoteArtifactRepo.getAuthentication() != null) {
    if (getLog().isDebugEnabled()) {
      getLog().debug("Maven deployment repsoitory has Authentication. Transcribing to Aether Authentication...");
    }
    remoteRepoBuilder.setAuthentication(new AuthenticationBuilder().addUsername(remoteArtifactRepo.getAuthentication().getUsername())
        .addPassword(remoteArtifactRepo.getAuthentication().getPassword())
        .addPrivateKey(remoteArtifactRepo.getAuthentication().getPrivateKey(), remoteArtifactRepo.getAuthentication().getPassphrase())
        .build());
  }
  return remoteRepoBuilder.build();
}

代码示例来源:origin: org.springframework.boot.experimental/spring-boot-thin-launcher

private org.apache.maven.repository.Proxy proxy(MavenSettings settings,
    RepositorySystemSession session, RemoteRepository remote,
    ProxySelector proxy) {
  Proxy config = proxy.getProxy(remote);
  if (config == null) {
    return null;
  }
  org.apache.maven.repository.Proxy result = new org.apache.maven.repository.Proxy();
  result.setHost(config.getHost());
  if (config.getAuthentication() != null) {
    org.apache.maven.artifact.repository.Authentication auth = authentication(
        settings, session,
        new RemoteRepository.Builder(remote)
            .setAuthentication(config.getAuthentication()).build(),
        config.getAuthentication());
    result.setUserName(auth.getUsername());
    result.setPassword(auth.getPassword() != null ? auth.getPassword()
        : auth.getPassphrase());
  }
  result.setProtocol(config.getType());
  result.setPort(config.getPort());
  return result;
}

相关文章