Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added code to get the username and password from the settings.xml file

if an id is provided (with null username and password values).
  • Loading branch information...
commit 0d1ec056bbaa6ec590fab9152527f7cb9f825fd3 1 parent 9b7aaf9
@smoyer64 authored
View
18 src/main/java/org/jboss/as/plugin/common/AbstractServerConnection.java
@@ -28,8 +28,11 @@
import java.net.UnknownHostException;
import javax.security.auth.callback.CallbackHandler;
+import org.apache.http.auth.Credentials;
+import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.settings.Settings;
import org.jboss.as.controller.client.ModelControllerClient;
import org.jboss.as.controller.client.helpers.domain.DomainClient;
import org.jboss.dmr.ModelNode;
@@ -66,6 +69,12 @@
*/
@Parameter(property = "jboss-as.id")
private String id;
+
+ /**
+ * Provides a reference to the settings file.
+ */
+ @Parameter(property = "${settings}", readonly = true, required = true)
+ private Settings settings;
/**
* Specifies the username to use if prompted to authenticate by the server.
@@ -176,14 +185,19 @@ public synchronized final CallbackHandler getCallbackHandler() {
CallbackHandler result = handler;
if (result == null) {
if(username == null && password == null && id != null) {
- username = getUsernameFromSettings();
- password = getPasswordFromSettings();
+ getCredentialsFromSettings();
}
result = handler = new ClientCallbackHandler(username, password);
}
return result;
}
+ private void getCredentialsFromSettings() {
+ getLog().info("AbstractServerConnection.getCredentialsFromSettings()");
+ password = settings.getServer(id).getPassword();
+ username = settings.getServer(id).getUsername();
+ }
+
private String getPasswordFromSettings() {
return "testPassword";
}
Please sign in to comment.
Something went wrong with that request. Please try again.