當前位置: 首頁>>代碼示例>>Java>>正文


Java Server類代碼示例

本文整理匯總了Java中org.apache.maven.settings.Server的典型用法代碼示例。如果您正苦於以下問題:Java Server類的具體用法?Java Server怎麽用?Java Server使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Server類屬於org.apache.maven.settings包,在下文中一共展示了Server類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateAppRuntime

import org.apache.maven.settings.Server; //導入依賴的package包/類
@Test
public void updateAppRuntime() throws Exception {
    final SiteInner siteInner = mock(SiteInner.class);
    doReturn("app,linux").when(siteInner).kind();
    final WithCredentials withCredentials = mock(WithCredentials.class);
    final Update update = mock(Update.class);
    doReturn(withCredentials).when(update).withPrivateRegistryImage(null, null);
    final WebApp app = mock(WebApp.class);
    doReturn(siteInner).when(app).inner();
    doReturn(update).when(app).update();

    final ContainerSetting containerSetting = new ContainerSetting();
    containerSetting.setServerId("serverId");
    doReturn(containerSetting).when(mojo).getContainerSettings();

    final Server server = mock(Server.class);
    final Settings settings = mock(Settings.class);
    doReturn(server).when(settings).getServer(anyString());
    doReturn(settings).when(mojo).getSettings();

    handler.updateAppRuntime(app);

    verify(update, times(1)).withPrivateRegistryImage(null, null);
    verify(server, times(1)).getUsername();
    verify(server, times(1)).getPassword();
}
 
開發者ID:Microsoft,項目名稱:azure-maven-plugins,代碼行數:27,代碼來源:PrivateRegistryRuntimeHandlerImplTest.java

示例2: updateAppRuntime

import org.apache.maven.settings.Server; //導入依賴的package包/類
@Test
public void updateAppRuntime() throws Exception {
    final WebApp app = mock(WebApp.class);
    final SiteInner siteInner = mock(SiteInner.class);
    doReturn("app,linux").when(siteInner).kind();
    doReturn(siteInner).when(app).inner();
    final Update update = mock(Update.class);
    final WithCredentials withCredentials = mock(WithCredentials.class);
    doReturn(withCredentials).when(update).withPrivateDockerHubImage(null);
    doReturn(update).when(app).update();

    final ContainerSetting containerSetting = new ContainerSetting();
    containerSetting.setServerId("serverId");
    doReturn(containerSetting).when(mojo).getContainerSettings();

    final Server server = mock(Server.class);
    final Settings settings = mock(Settings.class);
    doReturn(server).when(settings).getServer(anyString());
    doReturn(settings).when(mojo).getSettings();

    handler.updateAppRuntime(app);

    verify(update, times(1)).withPrivateDockerHubImage(null);
    verify(server, times(1)).getUsername();
    verify(server, times(1)).getPassword();
}
 
開發者ID:Microsoft,項目名稱:azure-maven-plugins,代碼行數:27,代碼來源:PrivateDockerHubRuntimeHandlerImplTest.java

示例3: getAuthObjFromServerId

import org.apache.maven.settings.Server; //導入依賴的package包/類
/**
 * Get Authenticated object by referencing server definition in Maven settings.xml
 *
 * @param settings Settings object
 * @param serverId Server Id to search in settings.xml
 * @return Authenticated object if configurations are correct; otherwise return null.
 */
protected Authenticated getAuthObjFromServerId(final Settings settings, final String serverId) {
    if (StringUtils.isEmpty(serverId)) {
        getLog().debug(SERVER_ID_NOT_CONFIG);
        return null;
    }

    final Server server = Utils.getServer(settings, serverId);
    if (server == null) {
        getLog().error(SERVER_ID_NOT_FOUND + serverId);
        return null;
    }

    final ApplicationTokenCredentials credential = getAppTokenCredentialsFromServer(server);
    if (credential == null) {
        getLog().error(AZURE_AUTH_INVALID + serverId);
        return null;
    }

    final Authenticated auth = azureConfigure().authenticate(credential);
    if (auth != null) {
        getLog().info(AUTH_WITH_SERVER_ID + serverId);
    }
    return auth;
}
 
開發者ID:Microsoft,項目名稱:azure-maven-plugins,代碼行數:32,代碼來源:AzureAuthHelper.java

示例4: getValueFromServerConfiguration

import org.apache.maven.settings.Server; //導入依賴的package包/類
/**
 * Get string value from server configuration section in settings.xml.
 *
 * @param server Server object.
 * @param key    Key string.
 * @return String value if key exists; otherwise, return null.
 */
public static String getValueFromServerConfiguration(final Server server, final String key) {
    if (server == null) {
        return null;
    }

    final Xpp3Dom configuration = (Xpp3Dom) server.getConfiguration();
    if (configuration == null) {
        return null;
    }

    final Xpp3Dom node = configuration.getChild(key);
    if (node == null) {
        return null;
    }

    return node.getValue();
}
 
開發者ID:Microsoft,項目名稱:azure-maven-plugins,代碼行數:25,代碼來源:Utils.java

示例5: configureJsch

import org.apache.maven.settings.Server; //導入依賴的package包/類
protected final void configureJsch() {
	if (!disableSshAgent) {
		if (serverId != null) {
			final Server server = settings.getServer(serverId);
			if (server != null) {
				privateKey = privateKey == null ? server.getPrivateKey() : privateKey;
				passphrase = passphrase == null ? server.getPassphrase() : passphrase;
			} else {
				getLog().warn(format("No server configuration in Maven settings found with id %s", serverId));
			}
		}

		JschConfigSessionFactory
				.setInstance(new SshAgentSessionFactory(getLog(), knownHosts, privateKey, passphrase));
	}
}
 
開發者ID:SourcePond,項目名稱:release-maven-plugin-parent,代碼行數:17,代碼來源:NextMojo.java

示例6: getAwsKeyPair

import org.apache.maven.settings.Server; //導入依賴的package包/類
static AwsKeyPair getAwsKeyPair(String serverId, String awsAccessKey, String awsSecretAccessKey,
        Settings settings, SettingsDecrypter decrypter) throws MojoExecutionException {
    final AwsKeyPair keys;
    if (serverId != null) {
        Server server = settings.getServer(serverId);
        if (server == null) {
            throw new MojoExecutionException("serverId not found in settings: " + serverId);
        } else {
            SettingsDecryptionRequest request = new DefaultSettingsDecryptionRequest(server);
            SettingsDecryptionResult result = decrypter.decrypt(request);
            keys = new AwsKeyPair(result.getServer().getUsername(),
                    result.getServer().getPassword());
        }
    } else {
        keys = new AwsKeyPair(awsAccessKey, awsSecretAccessKey);
    }
    return keys;
}
 
開發者ID:davidmoten,項目名稱:aws-maven-plugin,代碼行數:19,代碼來源:Util.java

示例7: test002DefaultUsernamePassword

import org.apache.maven.settings.Server; //導入依賴的package包/類
public void test002DefaultUsernamePassword()
    throws MojoExecutionException
{

    Settings settings = new Settings();
    Server server = new Server();
    settings.addServer( server );

    mojo.setSettings( settings );

    // force a lookup of username
    mojo.setUsername( null );
    mojo.setPassword( null );

    mojo.execute();

    assertEquals( "", mojo.getUsername() );
    assertEquals( "", mojo.getPassword() );

}
 
開發者ID:mojohaus,項目名稱:sql-maven-plugin,代碼行數:21,代碼來源:SqlExecMojoTest.java

示例8: test003UsernamePasswordLookup

import org.apache.maven.settings.Server; //導入依賴的package包/類
public void test003UsernamePasswordLookup()
    throws MojoExecutionException
{

    Settings settings = new Settings();
    Server server = new Server();
    server.setId( "somekey" );
    server.setUsername( "username" );
    server.setPassword( "password" );
    settings.addServer( server );

    mojo.setSettings( settings );

    // force a lookup of username
    mojo.setSettingsKey( "somekey" );
    mojo.setUsername( null );
    mojo.setPassword( null );

    mojo.execute();

    assertEquals( "username", mojo.getUsername() );
    assertEquals( "password", mojo.getPassword() );

}
 
開發者ID:mojohaus,項目名稱:sql-maven-plugin,代碼行數:25,代碼來源:SqlExecMojoTest.java

示例9: addServers

import org.apache.maven.settings.Server; //導入依賴的package包/類
/**
 * Adds a list of server configurations to the maven settings object
 *
 * @param settings Maven Settings to append to
 * @param servers  Servers to add to the settings
 */
private void addServers(Settings settings, List<MavenSettingsServer> servers) {
    for (MavenSettingsServer server : servers) {
        Server serverToAdd = new Server();
        serverToAdd.setId(server.getId());

        String username = server.getUsername();
        String password = server.getPassword();

        if (StringUtils.isNotBlank(username)) {
            serverToAdd.setUsername(username);
        }
        if (StringUtils.isNotBlank(password)) {
            serverToAdd.setPassword(password);
        }
        settings.addServer(serverToAdd);
    }
}
 
開發者ID:alancnet,項目名稱:artifactory,代碼行數:24,代碼來源:MavenServiceImpl.java

示例10: loadInfosFromSettings

import org.apache.maven.settings.Server; //導入依賴的package包/類
/**
 * Load username password from settings.
 */
private void loadInfosFromSettings( ScmProviderRepositoryWithHost repo )
{
    if ( username == null || password == null )
    {
        String host = repo.getHost();

        int port = repo.getPort();

        if ( port > 0 )
        {
            host += ":" + port;
        }

        Server server = this.settings.getServer( host );

        if ( server != null )
        {
            setPasswordIfNotEmpty( repo, decrypt( server.getPassword(), host ) );

            setUserIfNotEmpty( repo, server.getUsername() );
        }
    }
}
 
開發者ID:mojohaus,項目名稱:buildnumber-maven-plugin,代碼行數:27,代碼來源:AbstractScmMojo.java

示例11: getRemoteRepoFromDeployment

import org.apache.maven.settings.Server; //導入依賴的package包/類
private RemoteRepository getRemoteRepoFromDeployment(final DeploymentRepository repo,
                                                     final MavenEmbedder embedder) {
    RemoteRepository.Builder remoteRepoBuilder = new RemoteRepository.Builder(repo.getId(),
                                                                              repo.getLayout(),
                                                                              repo
                                                                                      .getUrl())
            .setSnapshotPolicy(new RepositoryPolicy(true,
                                                    RepositoryPolicy.UPDATE_POLICY_DAILY,
                                                    RepositoryPolicy.CHECKSUM_POLICY_WARN))
            .setReleasePolicy(new RepositoryPolicy(true,
                                                   RepositoryPolicy.UPDATE_POLICY_ALWAYS,
                                                   RepositoryPolicy.CHECKSUM_POLICY_WARN));

    Settings settings = MavenSettings.getSettings();
    Server server = settings.getServer(repo.getId());

    if (server != null) {
        Authentication authentication = embedder.getMavenSession().getRepositorySession()
                .getAuthenticationSelector()
                .getAuthentication(remoteRepoBuilder.build());
        remoteRepoBuilder.setAuthentication(authentication);
    }

    return remoteRepoBuilder.build();
}
 
開發者ID:kiegroup,項目名稱:appformer,代碼行數:26,代碼來源:DistributionManagementArtifactRepository.java

示例12: convertToArtifactRepository

import org.apache.maven.settings.Server; //導入依賴的package包/類
private RemoteRepository convertToArtifactRepository(final org.apache.maven.artifact.repository.ArtifactRepository artifactRepository) {
    final MavenEmbedder mavenEmbedder = MavenProjectLoader.newMavenEmbedder(MavenSettings.getSettings().isOffline());
    final RemoteRepository.Builder remoteRepoBuilder = new RemoteRepository.Builder(artifactRepository.getId(),
                                                                                    artifactRepository.getLayout().getId(),
                                                                                    artifactRepository.getUrl())
            .setSnapshotPolicy(new RepositoryPolicy(true,
                                                    RepositoryPolicy.UPDATE_POLICY_DAILY,
                                                    RepositoryPolicy.CHECKSUM_POLICY_WARN))
            .setReleasePolicy(new RepositoryPolicy(true,
                                                   RepositoryPolicy.UPDATE_POLICY_ALWAYS,
                                                   RepositoryPolicy.CHECKSUM_POLICY_WARN));

    final Settings settings = MavenSettings.getSettings();
    final Server server = settings.getServer(artifactRepository.getId());

    if (server != null) {
        final Authentication authentication = mavenEmbedder
                .getMavenSession()
                .getRepositorySession()
                .getAuthenticationSelector()
                .getAuthentication(remoteRepoBuilder.build());
        remoteRepoBuilder.setAuthentication(authentication);
    }

    return remoteRepoBuilder.build();
}
 
開發者ID:kiegroup,項目名稱:appformer,代碼行數:27,代碼來源:ProjectRepositoryResolverImpl.java

示例13: getRemoteRepoFromDeployment

import org.apache.maven.settings.Server; //導入依賴的package包/類
private static RemoteRepository getRemoteRepoFromDeployment(final DeploymentRepository deploymentRepository,
                                                            final RepositorySystemSession mavenSession) {
    final RemoteRepository.Builder remoteRepoBuilder = new RemoteRepository.Builder(deploymentRepository.getId(),
                                                                                    deploymentRepository.getLayout(),
                                                                                    deploymentRepository.getUrl())
            .setSnapshotPolicy(new RepositoryPolicy(true,
                                                    RepositoryPolicy.UPDATE_POLICY_DAILY,
                                                    RepositoryPolicy.CHECKSUM_POLICY_WARN))
            .setReleasePolicy(new RepositoryPolicy(true,
                                                   RepositoryPolicy.UPDATE_POLICY_DAILY,
                                                   RepositoryPolicy.CHECKSUM_POLICY_WARN));

    final Settings settings = MavenSettings.getSettings();
    final Server server = settings.getServer(deploymentRepository.getId());

    if (server != null) {
        final Authentication authentication = mavenSession
                .getAuthenticationSelector()
                .getAuthentication(remoteRepoBuilder.build());
        remoteRepoBuilder.setAuthentication(authentication);
    }

    return remoteRepoBuilder.build();
}
 
開發者ID:kiegroup,項目名稱:appformer,代碼行數:25,代碼來源:RepositoryResolverTestUtils.java

示例14: execute

import org.apache.maven.settings.Server; //導入依賴的package包/類
@Override
public void execute(FrontendPluginFactory factory) throws InstallationException {
    ProxyConfig proxyConfig = MojoUtils.getProxyConfig(this.session, this.decrypter);
    Server server = MojoUtils.decryptServer(this.serverId, this.session, this.decrypter);
    if (null != server) {
        factory.getNodeInstaller(proxyConfig).setNodeDownloadRoot(this.nodeDownloadRoot)
            .setNodeVersion(this.nodeVersion).setPassword(server.getPassword())
            .setUserName(server.getUsername()).install();
        factory.getYarnInstaller(proxyConfig).setYarnDownloadRoot(this.yarnDownloadRoot)
            .setYarnVersion(this.yarnVersion).setUserName(server.getUsername())
            .setPassword(server.getPassword()).install();
    } else {
        factory.getNodeInstaller(proxyConfig).setNodeDownloadRoot(this.nodeDownloadRoot)
            .setNodeVersion(this.nodeVersion).install();
        factory.getYarnInstaller(proxyConfig).setYarnDownloadRoot(this.yarnDownloadRoot)
            .setYarnVersion(this.yarnVersion).install();
    }
}
 
開發者ID:eirslett,項目名稱:frontend-maven-plugin,代碼行數:19,代碼來源:InstallNodeAndYarnMojo.java

示例15: testAuthenticationHandling

import org.apache.maven.settings.Server; //導入依賴的package包/類
public void testAuthenticationHandling()
    throws Exception
{
    Server server = new Server();
    server.setId( "repository" );
    server.setUsername( "jason" );
    server.setPassword( "abc123" );

    ArtifactRepository repository =
        repositorySystem.createArtifactRepository( "repository", "http://foo", null, null, null );
    repositorySystem.injectAuthentication( Arrays.asList( repository ), Arrays.asList( server ) );
    Authentication authentication = repository.getAuthentication();
    assertNotNull( authentication );
    assertEquals( "jason", authentication.getUsername() );
    assertEquals( "abc123", authentication.getPassword() );
}
 
開發者ID:gems-uff,項目名稱:oceano,代碼行數:17,代碼來源:LegacyRepositorySystemTest.java


注:本文中的org.apache.maven.settings.Server類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。