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

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

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

Authentication.setPrivateKey介绍

[英]Set the absolute path to private key file.
[中]将绝对路径设置为私钥文件。

代码示例

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

authentication.setPrivateKey( server.getPrivateKey() );
authentication.setPassphrase( server.getPassphrase() );

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

private Authentication getAuthentication( RepositorySystemSession session, ArtifactRepository repository )
{
  if ( session != null )
  {
    AuthenticationSelector selector = session.getAuthenticationSelector();
    if ( selector != null )
    {
      RemoteRepository repo = RepositoryUtils.toRepo( repository );
      org.eclipse.aether.repository.Authentication auth = selector.getAuthentication( repo );
      if ( auth != null )
      {
        repo = new RemoteRepository.Builder( repo ).setAuthentication( auth ).build();
        AuthenticationContext authCtx = AuthenticationContext.forRepository( session, repo );
        Authentication result =
          new Authentication( authCtx.get( AuthenticationContext.USERNAME ),
                    authCtx.get( AuthenticationContext.PASSWORD ) );
        result.setPrivateKey( authCtx.get( AuthenticationContext.PRIVATE_KEY_PATH ) );
        result.setPassphrase( authCtx.get( AuthenticationContext.PRIVATE_KEY_PASSPHRASE ) );
        authCtx.close();
        return result;
      }
    }
  }
  return null;
}

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

private Authentication getAuthentication( RepositorySystemSession session, ArtifactRepository repository )
{
  if ( session != null )
  {
    AuthenticationSelector selector = session.getAuthenticationSelector();
    if ( selector != null )
    {
      RemoteRepository repo = RepositoryUtils.toRepo( repository );
      org.eclipse.aether.repository.Authentication auth = selector.getAuthentication( repo );
      if ( auth != null )
      {
        repo = new RemoteRepository.Builder( repo ).setAuthentication( auth ).build();
        AuthenticationContext authCtx = AuthenticationContext.forRepository( session, repo );
        Authentication result =
          new Authentication( authCtx.get( AuthenticationContext.USERNAME ),
                    authCtx.get( AuthenticationContext.PASSWORD ) );
        result.setPrivateKey( authCtx.get( AuthenticationContext.PRIVATE_KEY_PATH ) );
        result.setPassphrase( authCtx.get( AuthenticationContext.PRIVATE_KEY_PASSPHRASE ) );
        authCtx.close();
        return result;
      }
    }
  }
  return null;
}

代码示例来源:origin: shillner/unleash-maven-plugin

private Authentication createServerAuthentication(Server server) {
  Authentication authentication = new Authentication(server.getUsername(), server.getPassword());
  authentication.setPrivateKey(server.getPrivateKey());
  authentication.setPassphrase(server.getPassphrase());
  return authentication;
 }
}

代码示例来源:origin: com.itemis.maven.plugins/unleash-maven-plugin

private Authentication createServerAuthentication(Server server) {
  Authentication authentication = new Authentication(server.getUsername(), server.getPassword());
  authentication.setPrivateKey(server.getPrivateKey());
  authentication.setPassphrase(server.getPassphrase());
  return authentication;
 }
}

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

private org.apache.maven.artifact.repository.Authentication authentication(
    MavenSettings settings, RepositorySystemSession session,
    RemoteRepository remote, Authentication authentication) {
  AuthenticationContext context = AuthenticationContext.forRepository(session,
      remote);
  if (context == null) {
    return null;
  }
  authentication.fill(context, "username", Collections.<String, String>emptyMap());
  authentication.fill(context, "password", Collections.<String, String>emptyMap());
  authentication.fill(context, "passphrase",
      Collections.<String, String>emptyMap());
  authentication.fill(context, "privateKey",
      Collections.<String, String>emptyMap());
  org.apache.maven.artifact.repository.Authentication maven = new org.apache.maven.artifact.repository.Authentication(
      context.get("username"), context.get("password"));
  if (context.get("passphrase") != null) {
    maven.setPassphrase(context.get("passphrase"));
  }
  if (context.get("privateKey") != null) {
    maven.setPrivateKey(context.get("privateKey"));
  }
  return maven;
}

相关文章