Java Code Examples for org.eclipse.aether.util.repository.AuthenticationBuilder#build()

The following examples show how to use org.eclipse.aether.util.repository.AuthenticationBuilder#build() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MavenTest.java    From packagedrone with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testMvn1 () throws Exception
{
    final ChannelTester ct = ChannelTester.create ( getWebContext (), "m1" );
    ct.addAspect ( "mvn" );
    ct.addAspect ( "maven.repo" );
    ct.assignDeployGroup ( "m1" );

    final String key = ct.getDeployKeys ().iterator ().next (); // get first

    assertNotNull ( key );

    final RepositorySystem system = MavenUtil.newRepositorySystem ();
    final RepositorySystemSession session = MavenUtil.newRepositorySystemSession ( system );

    Artifact jarArtifact = new DefaultArtifact ( "org.eclipse.packagedrone.testing", "test.felix1", "", "jar", "0.0.1-SNAPSHOT" );
    jarArtifact = jarArtifact.setFile ( new File ( TEST_1_JAR ) );

    Artifact pomArtifact = new SubArtifact ( jarArtifact, "", "pom" );
    pomArtifact = pomArtifact.setFile ( new File ( TEST_1_POM ) );

    Artifact srcArtifact = new SubArtifact ( jarArtifact, "sources", "jar" );
    srcArtifact = srcArtifact.setFile ( new File ( TEST_1_SOURCES_JAR ) );

    final AuthenticationBuilder ab = new AuthenticationBuilder ();
    ab.addUsername ( "deploy" );
    ab.addPassword ( key );
    final Authentication auth = ab.build ();
    final RemoteRepository distRepo = new RemoteRepository.Builder ( "test", "default", resolve ( String.format ( "/maven/%s", ct.getId () ) ) ).setAuthentication ( auth ).build ();

    final DeployRequest deployRequest = new DeployRequest ();
    deployRequest.addArtifact ( jarArtifact ).addArtifact ( pomArtifact ).addArtifact ( srcArtifact );
    deployRequest.setRepository ( distRepo );

    system.deploy ( session, deployRequest );

    testUrl ( String.format ( "/maven/%s", ct.getId () ) ); // index page

    // FIXME: check more data
}
 
Example 2
Source File: ResolverImpl.java    From vertx-stack with Apache License 2.0 5 votes vote down vote up
private static Authentication extractAuth(URL url) {
  String userInfo = url.getUserInfo();
  if (userInfo != null) {
    AuthenticationBuilder authBuilder = new AuthenticationBuilder();
    int sep = userInfo.indexOf(':');
    if (sep != -1) {
      authBuilder.addUsername(userInfo.substring(0, sep));
      authBuilder.addPassword(userInfo.substring(sep + 1));
    } else {
      authBuilder.addUsername(userInfo);
    }
    return authBuilder.build();
  }
  return null;
}
 
Example 3
Source File: AetherUtils.java    From takari-lifecycle with Eclipse Public License 1.0 5 votes vote down vote up
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;
}