本文整理了Java中org.apache.maven.settings.Settings.getServer()
方法的一些代码示例,展示了Settings.getServer()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Settings.getServer()
方法的具体详情如下:
包路径:org.apache.maven.settings.Settings
类名称:Settings
方法名:getServer
[英]Method getServers.
[中]方法获取服务器。
代码示例来源:origin: eirslett/frontend-maven-plugin
static Server decryptServer(String serverId, MavenSession mavenSession, SettingsDecrypter decrypter) {
if (StringUtils.isEmpty(serverId)) {
return null;
}
Server server = mavenSession.getSettings().getServer(serverId);
if (server != null) {
final DefaultSettingsDecryptionRequest decryptionRequest = new DefaultSettingsDecryptionRequest(server);
SettingsDecryptionResult decryptedResult = decrypter.decrypt(decryptionRequest);
return decryptedResult.getServer();
} else {
LOGGER.warn("Could not find server '" + serverId + "' in settings.xml");
return null;
}
}
代码示例来源:origin: spotify/dockerfile-maven
@Override
public RegistryAuth authFor(final String imageName) throws DockerException {
final ImageRef ref = new ImageRef(imageName);
Server server = settings.getServer(ref.getRegistryName());
if (server != null) {
return createRegistryAuth(server);
}
log.warn("Did not find maven server configuration for docker server " + ref.getRegistryName());
return null;
}
代码示例来源:origin: jeremylong/DependencyCheck
settings.setStringIfNotEmpty(Settings.KEYS.ANALYZER_NEXUS_URL, nexusUrl);
if (nexusServerId != null) {
final Server server = settingsXml.getServer(nexusServerId);
if (server != null) {
final String nexusUser = server.getUsername();
if (Boolean.TRUE.equals(artifactoryAnalyzerEnabled)) {
if (artifactoryAnalyzerServerId != null) {
final Server server = settingsXml.getServer(artifactoryAnalyzerServerId);
if (server != null) {
settings.setStringIfNotNull(Settings.KEYS.ANALYZER_ARTIFACTORY_API_USERNAME, server.getUsername());
settings.setStringIfNotEmpty(Settings.KEYS.DB_CONNECTION_STRING, connectionString);
if (databaseUser == null && databasePassword == null && serverId != null) {
final Server server = settingsXml.getServer(serverId);
if (server != null) {
databaseUser = server.getUsername();
代码示例来源:origin: ingenieux/beanstalker
private boolean hasServerSettings() {
if (serverId == null) {
return false;
} else {
final Server srv = settings.getServer(serverId);
return srv != null;
}
}
代码示例来源:origin: fabric8io/fabric8-maven-plugin
public Server getServer(final Settings settings, final String serverId) {
if (settings == null || StringUtils.isBlank(serverId)) {
return null;
}
return settings.getServer(serverId);
}
代码示例来源:origin: maven-gae-plugin/maven-gae-plugin
protected boolean hasServerSettings() {
if (isEmpty(serverId)) {
return false;
} else {
final Server srv = settings.getServer(serverId);
return srv != null;
}
}
代码示例来源:origin: Microsoft/azure-maven-plugins
/**
* Get server credential from Maven settings by server Id.
*
* @param settings Maven settings object.
* @param serverId Server Id.
* @return Server object if it exists in settings. Otherwise return null.
*/
public static Server getServer(final Settings settings, final String serverId) {
if (settings == null || StringUtils.isEmpty(serverId)) {
return null;
}
return settings.getServer(serverId);
}
代码示例来源:origin: com.microsoft.azure/azure-maven-plugin-lib
/**
* Get server credential from Maven settings by server Id.
*
* @param settings Maven settings object.
* @param serverId Server Id.
* @return Server object if it exists in settings. Otherwise return null.
*/
public static Server getServer(final Settings settings, final String serverId) {
if (settings == null || StringUtils.isEmpty(serverId)) {
return null;
}
return settings.getServer(serverId);
}
代码示例来源:origin: maven-gae-plugin/maven-gae-plugin
private void addEmailOption(final List<String> args) {
if (hasServerSettings() && emailAccount == null) {
addStringOption(args, "--email=", settings.getServer(serverId).getUsername());
if (settings.getServer(serverId).getPassword() != null) {
// Force GAE tools to read from System.in instead of System.console()
passIn = true;
}
} else {
addStringOption(args, "--email=", emailAccount);
}
}
代码示例来源:origin: com.github.eirslett/frontend-maven-plugin
static Server decryptServer(String serverId, MavenSession mavenSession, SettingsDecrypter decrypter) {
if (StringUtils.isEmpty(serverId)) {
return null;
}
Server server = mavenSession.getSettings().getServer(serverId);
if (server != null) {
final DefaultSettingsDecryptionRequest decryptionRequest = new DefaultSettingsDecryptionRequest(server);
SettingsDecryptionResult decryptedResult = decrypter.decrypt(decryptionRequest);
return decryptedResult.getServer();
} else {
LOGGER.warn("Could not find server '" + serverId + "' in settings.xml");
return null;
}
}
代码示例来源:origin: danielflower/multi-module-maven-release-plugin
protected final void configureJsch(final Log log) {
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 {
log.warn(format("No server configuration in Maven settings found with id %s", serverId));
}
}
JschConfigSessionFactory.setInstance(new SshAgentSessionFactory(log, knownHosts, privateKey, passphrase));
}
}
代码示例来源:origin: wouterd/docker-maven-plugin
private Optional<Credentials> getCredentialsFromSettings() {
if(settings == null) {
getLog().debug("No settings.xml");
return empty();
}
Server server = settings.getServer(serverId);
if(server == null) {
getLog().debug("Cannot find server " + serverId + " in Maven settings");
return empty();
}
getLog().debug("Using credentials from Maven settings: " + server.getUsername());
return of(new Credentials(server.getUsername(), server.getPassword(), getEmail(server), null));
}
代码示例来源:origin: danielflower/multi-module-maven-release-plugin
protected CredentialsProvider getCredentialsProvider(final Log log) throws ValidationException {
if (serverId != null) {
Server server = settings.getServer(serverId);
if (server == null) {
log.warn(format("No server configuration in Maven settings found with id %s", serverId));
}
if (server.getUsername() != null && server.getPassword() != null) {
return new UsernamePasswordCredentialsProvider(server.getUsername(), server.getPassword());
}
}
return null;
}
代码示例来源:origin: io.fabric8/fabric-maven
private Authentication getAuthentication( String repoId ) {
Server server = m_settings.getServer(repoId);
if (server != null && server.getUsername() != null) {
AuthenticationBuilder authBuilder = new AuthenticationBuilder();
authBuilder.addUsername( server.getUsername() ).addPassword( server.getPassword() );
return authBuilder.build();
}
return null;
}
代码示例来源:origin: org.apache.maven.continuum/continuum-notifier-wagon
private AuthenticationInfo getAuthenticationInfo( String repositoryId )
{
Settings settings = getSettings();
Server server = settings.getServer( repositoryId );
if ( server == null )
{
return null;
}
wagonManager.addAuthenticationInfo( repositoryId, server.getUsername(), server.getPassword(),
server.getPrivateKey(), server.getPassphrase() );
return wagonManager.getAuthenticationInfo( repositoryId );
}
}
代码示例来源:origin: org.apache.continuum/continuum-notifier-wagon
private AuthenticationInfo getAuthenticationInfo( String repositoryId )
{
Settings settings = getSettings();
Server server = settings.getServer( repositoryId );
if ( server == null )
{
return null;
}
wagonManager.addAuthenticationInfo( repositoryId, server.getUsername(), server.getPassword(),
server.getPrivateKey(), server.getPassphrase() );
return wagonManager.getAuthenticationInfo( repositoryId );
}
}
代码示例来源:origin: ingenieux/beanstalker
protected Expose exposeSettings(String serverId) throws MojoFailureException {
Server server = settings.getServer(serverId);
Expose expose = new Expose();
if (null != server) {
expose.setServerId(serverId);
expose.setAccessKey(server.getUsername());
expose.setSharedKey(getDecryptedAwsKey(server.getPassword().trim()));
} else {
getLog().warn(format("serverId['%s'] not found. Using runtime defaults", serverId));
expose.setServerId("runtime");
expose.setAccessKey(getAWSCredentials().getCredentials().getAWSAccessKeyId());
expose.setSharedKey(getAWSCredentials().getCredentials().getAWSSecretKey());
}
return expose;
}
代码示例来源:origin: org.uberfire/uberfire-maven-integration
private static RemoteRepository.Builder toRemoteRepositoryBuilder( Settings settings,
String id,
String layout,
String url ) {
RemoteRepository.Builder remoteBuilder = new RemoteRepository.Builder( id,
layout,
url );
Server server = settings.getServer( id );
if ( server != null ) {
remoteBuilder.setAuthentication( new AuthenticationBuilder().addUsername( server.getUsername() )
.addPassword( server.getPassword() )
.build() );
}
return remoteBuilder;
}
代码示例来源:origin: org.kie.soup/kie-soup-maven-integration
private static RemoteRepository.Builder toRemoteRepositoryBuilder( Settings settings,
String id,
String layout,
String url ) {
RemoteRepository.Builder remoteBuilder = new RemoteRepository.Builder( id,
layout,
url );
Server server = settings.getServer( id );
if ( server != null ) {
remoteBuilder.setAuthentication( new AuthenticationBuilder().addUsername( server.getUsername() )
.addPassword( server.getPassword() )
.build() );
}
return remoteBuilder;
}
代码示例来源:origin: org.eclipse.tycho/tycho-core
@Override
public MavenRepositorySettings.Credentials getCredentials(MavenRepositoryLocation location) {
if (location.getId() == null) {
return null;
}
Server serverSettings = context.getSession().getSettings().getServer(location.getId());
if (serverSettings != null) {
SettingsDecryptionResult result = decrypter.decryptAndLogProblems(serverSettings);
Server decryptedServer = result.getServer();
return new MavenRepositorySettings.Credentials(decryptedServer.getUsername(),
decryptedServer.getPassword());
}
return null;
}
内容来源于网络,如有侵权,请联系作者删除!