本文整理汇总了Java中org.apache.maven.settings.Server.getUsername方法的典型用法代码示例。如果您正苦于以下问题:Java Server.getUsername方法的具体用法?Java Server.getUsername怎么用?Java Server.getUsername使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.settings.Server
的用法示例。
在下文中一共展示了Server.getUsername方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAdminClient
import org.apache.maven.settings.Server; //导入方法依赖的package包/类
public SVNAdminClient getAdminClient() {
if (adminClient == null) {
String authenticationId = svnRepository.getAuthenticationId();
if (!StringUtils.isBlank(authenticationId)) {
}
Server serverSettings = mavenContext
.getServerSettings(authenticationId);
String username = serverSettings.getUsername();
String password = serverSettings.getPassword();
DefaultSVNOptions defaultSVNOptions = new DefaultSVNOptions();
SVNClientManager clientManager = SVNClientManager.newInstance(
defaultSVNOptions, username, password);
adminClient = clientManager.getAdminClient();
}
return adminClient;
}
示例2: getUsername
import org.apache.maven.settings.Server; //导入方法依赖的package包/类
public String getUsername() throws GoalParameterException {
String username = driverConfig.getUsername();
if (StringUtils.isBlank(username)) {
String serverId = driverConfig.getServerId();
if (StringUtils.isBlank(serverId)) {
throw new GoalParameterException(
"No username nor a serverId is configured.");
}
Server serverSettings = mavenContext.getServerSettings(serverId
.trim());
if (serverSettings == null) {
throw new GoalParameterException(
"Maven settings does not contain server configuration "
+ serverId);
}
username = serverSettings.getUsername();
if (StringUtils.isBlank(username)) {
throw new GoalParameterException(
"Maven settings server configuration " + serverId
+ " does not contain a username.");
}
}
return username.trim();
}
示例3: loadUserInfoFromSettings
import org.apache.maven.settings.Server; //导入方法依赖的package包/类
/**
* Issue 39
*
* Load username password from settings if user has not set them in JVM properties
*
* @throws MojoExecutionException
*/
protected void loadUserInfoFromSettings() throws MojoExecutionException {
if ((getUsername() == null || getPassword() == null) && (mavenSettings != null)) {
if (this.serverId == null)
throw new MojoExecutionException("SettingKey must be set! (username and/or password are not provided)");
Server server = this.mavenSettings.getServer(this.serverId);
if (server == null)
throw new MojoExecutionException(String.format("server with id [%s] not found in settings!", this.serverId));
if (getUsername() == null && server.getUsername() != null) username = server.getUsername();
if (getPassword() == null && server.getPassword() != null) {
try {
//
// FIX to resolve
// org.sonatype.plexus.components.sec.dispatcher.SecDispatcherException:
// java.io.FileNotFoundException: ~/.settings-security.xml (No such file or directory)
//
if (securityDispatcher instanceof DefaultSecDispatcher) {
//System.setProperty( DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION, sb.toString() );
((DefaultSecDispatcher) securityDispatcher).setConfigurationFile("~/.m2/settings-security.xml");
}
password = securityDispatcher.decrypt(server.getPassword());
} catch (SecDispatcherException e) {
throw new MojoExecutionException(e.getMessage());
}
}
}
}
示例4: loadUserInfoFromSettings
import org.apache.maven.settings.Server; //导入方法依赖的package包/类
/**
* Load username password from settings if user has not set them in JVM properties
*/
private void loadUserInfoFromSettings()
throws MojoExecutionException
{
if ( this.settingsKey == null )
{
this.settingsKey = url;
}
if ( ( username == null || password == null ) && ( settings != null ) )
{
Server server = this.settings.getServer( this.settingsKey );
if ( server != null )
{
if ( username == null )
{
username = server.getUsername();
}
if ( password == null )
{
password = server.getPassword();
}
}
}
if ( username == null )
{
//allow emtpy username
username = "" ;
}
if ( password == null )
{
//allow emtpy password
password = "" ;
}
}
示例5: loadUserInfoFromSettings
import org.apache.maven.settings.Server; //导入方法依赖的package包/类
/**
* Load username password from settings if user has not set them in JVM properties
*/
private void loadUserInfoFromSettings()
throws MojoExecutionException {
if (this.settingsKey == null) {
this.settingsKey = url;
}
if ((username == null || password == null) && (settings != null)) {
Server server = this.settings.getServer(this.settingsKey);
if (server != null) {
if (username == null) {
username = server.getUsername();
}
if (password == null) {
password = server.getPassword();
}
}
}
if (username == null) {
//allow emtpy username
username = "";
}
if (password == null) {
//allow emtpy password
password = "";
}
}
示例6: applyAuthenticationIfAny
import org.apache.maven.settings.Server; //导入方法依赖的package包/类
private void applyAuthenticationIfAny(SVNRepository svnKitRepository) {
String authenticationId = svnRepository.getAuthenticationId();
ISVNAuthenticationManager authManager = null;
if (StringUtils.isNotBlank(authenticationId)) {
Server serverSettings = mavenContext
.getServerSettings(authenticationId);
String username = serverSettings.getUsername();
String password = serverSettings.getPassword();
authManager = SVNWCUtil.createDefaultAuthenticationManager(
username, password);
svnKitRepository.setAuthenticationManager(authManager);
}
}
示例7: execute
import org.apache.maven.settings.Server; //导入方法依赖的package包/类
/**
* Execute the mojo.
*
* @throws MojoExecutionException
*/
@Override
public void execute() throws MojoExecutionException {
Log log = getLog();
boolean debugEnabled = log.isDebugEnabled();
for (Server server : this.settings.getServers()) {
String settingsKey = server.getId();
String username = server.getUsername();
String password = server.getPassword();
String usernameProperty = settingsKey + "."
+ DEFAULT_USERNAME_PROPERTY_SUFFIX;
String passwordProperty = settingsKey + "."
+ DEFAULT_PASSWORD_PROPERTY_SUFFIX;
if (!project.getProperties().containsKey(usernameProperty))
project.getProperties().setProperty(usernameProperty, username);
if (!project.getProperties().containsKey(passwordProperty))
project.getProperties().setProperty(passwordProperty, password);
if (useSystemProperties) {
if (System.getProperty(usernameProperty) == null)
System.setProperty(usernameProperty, username);
if (System.getProperty(passwordProperty) == null)
System.setProperty(passwordProperty, password);
}
if (debugEnabled)
log.debug(String.format("username property '%s' is '%s'",
usernameProperty, username));
if (debugEnabled)
log.debug(String.format("password property '%s' is '%s'",
passwordProperty, password));
}
}
示例8: getClientConfiguration
import org.apache.maven.settings.Server; //导入方法依赖的package包/类
/**
* Gets a client configuration used to create a new {@link ModelControllerClient}.
*
* @return the configuration to use
*/
protected synchronized MavenModelControllerClientConfiguration getClientConfiguration() {
final Log log = getLog();
String username = this.username;
String password = this.password;
if (username == null && password == null) {
if (id != null) {
if (settings != null) {
Server server = settings.getServer(id);
if (server != null) {
log.debug(DEBUG_MESSAGE_SETTINGS_HAS_ID);
password = decrypt(server);
username = server.getUsername();
if (username != null && password != null) {
log.debug(DEBUG_MESSAGE_SETTINGS_HAS_CREDS);
} else {
log.debug(DEBUG_MESSAGE_NO_CREDS);
}
} else {
log.debug(DEBUG_MESSAGE_NO_SERVER_SECTION);
}
} else {
log.debug(DEBUG_MESSAGE_NO_SETTINGS_FILE);
}
} else {
log.debug(DEBUG_MESSAGE_NO_ID);
}
} else {
log.debug(DEBUG_MESSAGE_POM_HAS_CREDS);
}
final ModelControllerClientConfiguration.Builder builder = new ModelControllerClientConfiguration.Builder()
.setProtocol(protocol)
.setHostName(hostname)
.setPort(port)
.setConnectionTimeout(timeout * 1000);
if (authenticationConfig != null) {
try {
builder.setAuthenticationConfigUri(authenticationConfig.toURI());
} catch (URISyntaxException e) {
throw new RuntimeException("Failed to create URI from " + authenticationConfig, e);
}
}
return new MavenModelControllerClientConfiguration(builder.build(), username, password);
}
示例9: AWSCredentialsImpl
import org.apache.maven.settings.Server; //导入方法依赖的package包/类
public AWSCredentialsImpl(final Server server) {
this.accessKey = server.getUsername();
this.secretKey = server.getPassword();
}