Author: alessio.soldano(a)jboss.com
Date: 2012-04-06 11:45:04 -0400 (Fri, 06 Apr 2012)
New Revision: 16118
Added:
container/jboss71/branches/jbossws-jboss710/src/main/resources/META-INF/services/org.jboss.wsf.spi.deployer.Deployer
Modified:
container/jboss71/branches/jbossws-jboss710/pom.xml
container/jboss71/branches/jbossws-jboss710/src/main/java/org/jboss/as/webservices/tests/RemoteDeployer.java
Log:
[JBWS-3483] Fixing/synching RemoteDeployer with version shipped in AS 7.1.0.Final + adding
missing service declaration + adding transitive dependencies for jbossws testsuite
Modified: container/jboss71/branches/jbossws-jboss710/pom.xml
===================================================================
--- container/jboss71/branches/jbossws-jboss710/pom.xml 2012-04-06 14:38:25 UTC (rev
16117)
+++ container/jboss71/branches/jbossws-jboss710/pom.xml 2012-04-06 15:45:04 UTC (rev
16118)
@@ -88,6 +88,24 @@
<version>${jboss.jaxws.api.version}</version>
<scope>provided</scope>
</dependency>
+
+ <!-- AS specific transitive dependencies for JBossWS testsuite execution -->
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-controller-client</artifactId>
+ <version>${jboss.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+ <artifactId>jboss-as-security</artifactId>
+ <version>${jboss.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.marshalling</groupId>
+ <artifactId>jboss-marshalling-river</artifactId>
+ <version>1.3.9.GA</version>
+ </dependency>
+
</dependencies>
<!-- plugins -->
Modified:
container/jboss71/branches/jbossws-jboss710/src/main/java/org/jboss/as/webservices/tests/RemoteDeployer.java
===================================================================
---
container/jboss71/branches/jbossws-jboss710/src/main/java/org/jboss/as/webservices/tests/RemoteDeployer.java 2012-04-06
14:38:25 UTC (rev 16117)
+++
container/jboss71/branches/jbossws-jboss710/src/main/java/org/jboss/as/webservices/tests/RemoteDeployer.java 2012-04-06
15:45:04 UTC (rev 16118)
@@ -22,23 +22,49 @@
package org.jboss.as.webservices.tests;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
+import static
org.jboss.as.controller.descriptions.ModelDescriptionConstants.ALLOW_RESOURCE_SERVICE_RESTART;
+import static
org.jboss.as.controller.descriptions.ModelDescriptionConstants.FAILURE_DESCRIPTION;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.NAME;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
+import static
org.jboss.as.controller.descriptions.ModelDescriptionConstants.OPERATION_HEADERS;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OUTCOME;
+import static
org.jboss.as.controller.descriptions.ModelDescriptionConstants.READ_ATTRIBUTE_OPERATION;
+import static
org.jboss.as.controller.descriptions.ModelDescriptionConstants.RELEASE_VERSION;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REMOVE;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.REQUIRED;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RESULT;
+import static
org.jboss.as.controller.descriptions.ModelDescriptionConstants.ROLLBACK_ON_RUNTIME_FAILURE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM;
+import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUCCESS;
import static org.jboss.as.security.Constants.AUTHENTICATION;
+import static org.jboss.as.security.Constants.CLASSIC;
import static org.jboss.as.security.Constants.CODE;
import static org.jboss.as.security.Constants.FLAG;
+import static org.jboss.as.security.Constants.LOGIN_MODULES;
import static org.jboss.as.security.Constants.MODULE_OPTIONS;
import static org.jboss.as.security.Constants.SECURITY_DOMAIN;
import java.io.IOException;
import java.net.InetAddress;
import java.net.URL;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import javax.security.auth.callback.Callback;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.callback.NameCallback;
+import javax.security.auth.callback.PasswordCallback;
+import javax.security.auth.callback.UnsupportedCallbackException;
+import javax.security.sasl.RealmCallback;
+import javax.security.sasl.RealmChoiceCallback;
+
import org.jboss.as.controller.client.ModelControllerClient;
+import org.jboss.as.controller.client.OperationBuilder;
import org.jboss.as.controller.client.helpers.standalone.DeploymentAction;
import org.jboss.as.controller.client.helpers.standalone.DeploymentPlan;
import org.jboss.as.controller.client.helpers.standalone.DeploymentPlanBuilder;
@@ -59,23 +85,15 @@
private static final Logger LOGGER = Logger.getLogger(RemoteDeployer.class);
private static final int PORT = 9999;
- private static final String JBWS_DEPLOYER_HOST = "jbossws.deployer.host";
- private static final String JBWS_DEPLOYER_PORT = "jbossws.deployer.port";
+ private static final String JBWS_DEPLOYER_AUTH_USER =
"jbossws.deployer.authentication.username";
+ private static final String JBWS_DEPLOYER_AUTH_PWD =
"jbossws.deployer.authentication.password";
private final Map<URL, String> url2Id = new HashMap<URL, String>();
private final InetAddress address = InetAddress.getByName("127.0.0.1");
+ private final CallbackHandler callbackHandler = getCallbackHandler();
+ private final ServerDeploymentManager deploymentManager;
- private ServerDeploymentManager deploymentManager;
-
public RemoteDeployer() throws IOException {
- final String host = System.getProperty(JBWS_DEPLOYER_HOST);
- InetAddress address;
- if (host != null) {
- address = InetAddress.getByName(host);
- } else {
- address = InetAddress.getByName("localhost");
- }
- final Integer port = Integer.getInteger(JBWS_DEPLOYER_PORT, PORT);
- deploymentManager = ServerDeploymentManager.Factory.create(address, port);
+ deploymentManager = ServerDeploymentManager.Factory.create(address, PORT,
callbackHandler);
}
@Override
@@ -88,7 +106,6 @@
url2Id.put(archiveURL, uniqueId);
}
- @Override
public void undeploy(final URL archiveURL) throws Exception {
final DeploymentPlanBuilder builder = deploymentManager.newDeploymentPlan();
final String uniqueName = url2Id.get(archiveURL);
@@ -108,8 +125,7 @@
final ServerDeploymentPlanResult planResult =
deploymentManager.execute(plan).get();
if (deployAction != null) {
- final ServerDeploymentActionResult actionResult = planResult
- .getDeploymentActionResult(deployAction.getId());
+ final ServerDeploymentActionResult actionResult =
planResult.getDeploymentActionResult(deployAction.getId());
if (actionResult != null) {
final Exception deploymentException = (Exception)
actionResult.getDeploymentException();
if (deploymentException != null)
@@ -122,54 +138,124 @@
}
}
- @Override
- public void addSecurityDomain(String name, Map<String, String>
authenticationOptions) throws Exception {
- ModelControllerClient client = ModelControllerClient.Factory.create(address,
PORT);
- ModelNode result = createSecurityDomain(client, name, authenticationOptions);
- checkResult(result);
- }
+ public String getServerVersion() throws Exception {
+ final ModelNode request = new ModelNode();
+ request.get(OP).set(READ_ATTRIBUTE_OPERATION);
+ request.get(OP_ADDR).setEmptyList();
+ request.get(NAME).set(RELEASE_VERSION);
- @Override
- public void removeSecurityDomain(String name) throws Exception {
- ModelControllerClient client = ModelControllerClient.Factory.create(address,
PORT);
- ModelNode result = removeSecurityDomain(client, name);
- checkResult(result);
+ final ModelNode response = applyUpdate(request, getModelControllerClient());
+ return response.get(RESULT).asString();
}
- private static ModelNode createSecurityDomain(ModelControllerClient client, String
name, Map<String, String> authenticationOptions) throws IOException {
+ public void addSecurityDomain(String name, Map<String, String>
authenticationOptions) throws Exception {
+ final List<ModelNode> updates = new ArrayList<ModelNode>();
+
ModelNode op = new ModelNode();
op.get(OP).set(ADD);
op.get(OP_ADDR).add(SUBSYSTEM, "security");
op.get(OP_ADDR).add(SECURITY_DOMAIN, name);
- ModelNode loginModule = op.get(AUTHENTICATION).add();
+ updates.add(op);
+
+ op = new ModelNode();
+ op.get(OP).set(ADD);
+ op.get(OP_ADDR).add(SUBSYSTEM, "security");
+ op.get(OP_ADDR).add(SECURITY_DOMAIN, name);
+ op.get(OP_ADDR).add(AUTHENTICATION, CLASSIC);
+
+ final ModelNode loginModule = op.get(LOGIN_MODULES).add();
loginModule.get(CODE).set("UsersRoles");
- loginModule.get(FLAG).set("required");
- ModelNode moduleOptions = loginModule.get(MODULE_OPTIONS);
+ loginModule.get(FLAG).set(REQUIRED);
+ op.get(OPERATION_HEADERS).get(ALLOW_RESOURCE_SERVICE_RESTART).set(true);
+ updates.add(op);
+
+ final ModelNode moduleOptions = loginModule.get(MODULE_OPTIONS);
if (authenticationOptions != null) {
- for (String k : authenticationOptions.keySet()) {
+ for (final String k : authenticationOptions.keySet()) {
moduleOptions.add(k, authenticationOptions.get(k));
}
}
- return client.execute(op);
+
+ applyUpdates(updates, getModelControllerClient());
}
- private static ModelNode removeSecurityDomain(ModelControllerClient client, String
name) throws IOException {
- ModelNode op = new ModelNode();
+ public void removeSecurityDomain(String name) throws Exception {
+ final ModelNode op = new ModelNode();
op.get(OP).set(REMOVE);
op.get(OP_ADDR).add(SUBSYSTEM, "security");
op.get(OP_ADDR).add(SECURITY_DOMAIN, name);
- return client.execute(op);
+ op.get(OPERATION_HEADERS, ROLLBACK_ON_RUNTIME_FAILURE).set(false);
+
+ applyUpdate(op, getModelControllerClient());
}
- private static void checkResult(ModelNode result) throws Exception {
- if (result.hasDefined("outcome") &&
"success".equals(result.get("outcome").asString())) {
- if (result.hasDefined("result")) {
- LOGGER.info(result.get("result"));
+ private ModelControllerClient getModelControllerClient() {
+ return ModelControllerClient.Factory.create(address, PORT, callbackHandler);
+ }
+
+ private static void applyUpdates(final List<ModelNode> updates, final
ModelControllerClient client) throws Exception {
+ for (final ModelNode update : updates) {
+ applyUpdate(update, client);
+ }
+ }
+
+ private static ModelNode applyUpdate(final ModelNode update, final
ModelControllerClient client) throws Exception {
+ final ModelNode result = client.execute(new OperationBuilder(update).build());
+ checkResult(result);
+ return result;
+ }
+
+ private static void checkResult(final ModelNode result) throws Exception {
+ if (result.hasDefined(OUTCOME) &&
SUCCESS.equals(result.get(OUTCOME).asString())) {
+ if (result.hasDefined(RESULT)) {
+ LOGGER.info(result.get(RESULT));
}
- } else if (result.hasDefined("failure-description")) {
- throw new Exception(result.get("failure-description").toString());
+ } else if (result.hasDefined(FAILURE_DESCRIPTION)) {
+ throw new Exception(result.get(FAILURE_DESCRIPTION).toString());
} else {
- throw new Exception("Operation not successful; outcome = " +
result.get("outcome"));
+ throw new Exception("Operation not successful; outcome = " +
result.get(OUTCOME));
}
}
+
+ private static CallbackHandler getCallbackHandler() {
+ final String username = getSystemProperty(JBWS_DEPLOYER_AUTH_USER, null);
+ if (username == null || ("${" + JBWS_DEPLOYER_AUTH_USER +
"}").equals(username)) {
+ return null;
+ }
+ String pwd = getSystemProperty(JBWS_DEPLOYER_AUTH_PWD, null);
+ if (("${" + JBWS_DEPLOYER_AUTH_PWD + "}").equals(pwd)) {
+ pwd = null;
+ }
+ final String password = pwd;
+ return new CallbackHandler() {
+ public void handle(Callback[] callbacks) throws IOException,
UnsupportedCallbackException {
+ for (Callback current : callbacks) {
+ if (current instanceof NameCallback) {
+ NameCallback ncb = (NameCallback) current;
+ ncb.setName(username);
+ } else if (current instanceof PasswordCallback) {
+ PasswordCallback pcb = (PasswordCallback) current;
+ pcb.setPassword(password.toCharArray());
+ } else if (current instanceof RealmCallback) {
+ RealmCallback rcb = (RealmCallback) current;
+ rcb.setText(rcb.getDefaultText());
+ } else if (current instanceof RealmChoiceCallback) {
+ // Ignored but not rejected.
+ } else {
+ throw new UnsupportedCallbackException(current);
+ }
+ }
+ }
+ };
+ }
+
+ private static String getSystemProperty(final String name, final String defaultValue)
{
+ PrivilegedAction<String> action = new PrivilegedAction<String>() {
+ public String run() {
+ return System.getProperty(name, defaultValue);
+ }
+ };
+ return AccessController.doPrivileged(action);
+ }
+
}
Added:
container/jboss71/branches/jbossws-jboss710/src/main/resources/META-INF/services/org.jboss.wsf.spi.deployer.Deployer
===================================================================
---
container/jboss71/branches/jbossws-jboss710/src/main/resources/META-INF/services/org.jboss.wsf.spi.deployer.Deployer
(rev 0)
+++
container/jboss71/branches/jbossws-jboss710/src/main/resources/META-INF/services/org.jboss.wsf.spi.deployer.Deployer 2012-04-06
15:45:04 UTC (rev 16118)
@@ -0,0 +1 @@
+org.jboss.as.webservices.tests.RemoteDeployer